:root {
  --bg: #004AAD;
  --panel: #003B8F;
  --panel-2: #0D5FB5;
  --line: rgba(255, 255, 255, 0.16);
  --text: #FFFFFF;
  --text-dim: rgba(255, 255, 255, 0.6);
  --accent: #47BDD9;
  --accent-ink: #003B8F;
  --bubble-me: #47BDD9;
  --bubble-me-text: #003B8F;
  --bubble-other: rgba(255, 255, 255, 0.14);
  --bubble-other-text: #FFFFFF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

.hidden { display: none !important; }

/* ---------- login ---------- */
.screen {
  height: 100%;
  display: flex;
  background: #004AAD;
  overflow: hidden;
}

.auth {
  display: flex;
  width: 100%;
  height: 100%;
}

.auth-brand {
  flex: 0 0 55%;
  position: relative;
  overflow: hidden;
}

.brand-text {
  position: absolute;
  top: 7%;
  left: 0;
  font-family: "Arial Black", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 900;
  line-height: 0.85;
  color: #fff;
}

.brand-line {
  display: block;
  white-space: nowrap;
  text-shadow:
    0.04em 0.04em 0 rgba(13, 95, 181, 0.55),
    0.08em 0.08em 0 rgba(45, 147, 201, 0.45),
    0.12em 0.12em 0 rgba(71, 189, 217, 0.35),
    0.16em 0.16em 0 rgba(143, 212, 232, 0.2);
}

.brand-line.s {
  font-size: 42vh;
  margin-left: -0.14em;
}

.brand-line.chat {
  font-size: 28vh;
  margin-left: -0.11em;
}

.auth-panel {
  flex: 1;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, #47BDD9 0%, #2D93C9 34%, #0D5FB5 66%, #004AAD 100%);
  border-radius: 10vh 0 0 10vh;
}

.auth-panel-inner {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-heading {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.mode-tabs {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  overflow: hidden;
}

.mode-tab {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.66);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.mode-tab + .mode-tab {
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.mode-tab.active {
  color: #004AAD;
  background: #fff;
}

.auth-panel input {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  color: #fff;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.auth-panel input::placeholder { color: rgba(255, 255, 255, 0.55); }

.auth-panel input:focus { border-color: #fff; }

#submit-btn {
  border: 0;
  background: #fff;
  color: #004AAD;
  padding: 13px 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

#submit-btn:hover { opacity: 0.88; }

.login-error {
  min-height: 18px;
  font-size: 13px;
  color: #FFB4B4;
  text-align: center;
}

@media (max-width: 760px) {
  .auth-brand { display: none; }
  .auth-panel { border-radius: 0; }
}

/* ---------- layout ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--panel);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding: 24px 0 16px;
  border-right: 1px solid var(--line);
}

.brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--line);
}

.brand-name {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
}

.brand-me {
  margin-top: 8px;
  font-size: 12px;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color: var(--accent);
}

.sidebar-label {
  padding: 20px 24px 8px;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.user-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.user-list .empty {
  padding: 8px 24px;
  font-size: 13px;
  color: var(--text-dim);
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  border-left: 2px solid transparent;
}

.user:hover { background: var(--panel-2); }
.user.active {
  background: var(--panel-2);
  border-left-color: var(--accent);
  color: var(--accent);
}

.user .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

.user .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.8em;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 3px;
}

.user .badge {
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

.user.active .badge { background: var(--text); color: var(--bg); }

/* ---------- chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.chat-partner {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.typing-hint {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent);
}

.fingerprint {
  margin-left: auto;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.messages .placeholder {
  margin: auto;
  color: var(--text-dim);
  font-size: 14px;
}

.msg { display: flex; flex-direction: column; max-width: 70%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }

.msg .bubble {
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.45;
  border-radius: 3px;
  word-break: break-word;
}

.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-text); }
.msg.them .bubble { background: var(--bubble-other); color: var(--bubble-other-text); }

.msg .meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

.msg .meta.read { color: var(--accent); }

/* ---------- compose ---------- */
.compose {
  display: flex;
  gap: 12px;
  padding: 18px 28px;
  border-top: 1px solid var(--line);
}

#msg-input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

#msg-input::placeholder { color: var(--text-dim); }

.compose button {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  padding: 11px 22px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  transition: background 0.2s ease, color 0.2s ease;
}

.compose button:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- key management ---------- */
.sidebar-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  padding: 8px 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.key-btn:hover { border-color: var(--accent); color: var(--accent); }
