:root {
  --bg: #0a0a0f;
  --surface: #14141c;
  --border: #2a2a35;
  --text: #e8e8ed;
  --text-dim: #888;
  --accent: #4a9eff;
  --accent-hover: #6bb0ff;
  --danger: #e55;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
}

.hidden { display: none !important; }

#screen-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 360px;
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.auth-card .sub { color: var(--text-dim); margin: 0 0 1.5rem; font-size: 0.9rem; }
.auth-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.auth-form button {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}
.auth-form button:hover { background: var(--accent-hover); }
.toggle-auth { margin-top: 1rem; text-align: center; font-size: 0.9rem; }
.toggle-auth a { color: var(--accent); text-decoration: none; }

#screen-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100dvh;
}
.app-header, .chat-header {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.app-header { justify-content: space-between; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.icon-btn:hover { background: var(--border); }

#panel-list { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.list-header {
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.list-header input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.primary {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#user-list { flex: 1; overflow: auto; }
.user-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user-item:hover { background: var(--surface); }
.user-item .name { font-weight: 500; }
.user-item .username { font-size: 0.85rem; color: var(--text-dim); }

#panel-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.e2e-bar {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.e2e-bar input {
  flex: 1;
  min-width: 120px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.e2e-bar button { padding: 0.4rem 0.75rem; cursor: pointer; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
#messages {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.msg {
  max-width: 85%;
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  word-break: break-word;
}
.msg.sent { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.received { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.msg .time { font-size: 0.75rem; opacity: 0.8; margin-top: 0.25rem; }
.composer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  background: var(--surface);
}
.composer input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.composer button {
  padding: 0.6rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

@media (min-width: 600px) {
  #screen-app { flex-direction: row; }
  #panel-list { max-width: 320px; border-left: 1px solid var(--border); }
  #panel-chat { flex: 1; }
}
