:root {
  --bg: #f5f6fa; --panel: #ffffff; --text: #1c1e26; --muted: #6b7080; --line: #e3e5ee;
  --accent: #4f46e5; --accent-text: #ffffff; --me: #4f46e5; --me-text: #ffffff; --bot: #ffffff; --danger: #d92d4a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --panel: #181b24; --text: #e8eaf2; --muted: #9298ab; --line: #272b38;
    --accent: #7c75ff; --accent-text: #0f1117; --me: #5b54e6; --me-text: #ffffff; --bot: #1f2330; --danger: #ff6b82;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.hidden { display: none !important; }
.screen { height: 100%; }
button { font: inherit; cursor: pointer; }

/* вход */
#login { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box .logo { width: 84px; height: 84px; border-radius: 20px; }
.login-box h1 { margin: 12px 0 6px; font-size: 24px; }
.login-box p { color: var(--muted); margin: 8px 0 16px; }
.login-box input {
  width: 100%; padding: 14px; font-size: 22px; letter-spacing: 3px; text-align: center; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
}
.login-box button {
  width: 100%; margin-top: 12px; padding: 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.error { color: var(--danger) !important; min-height: 1.4em; }

/* каркас */
#app { display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; background: var(--bg); }
header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
header .title { display: flex; flex-direction: column; }
header small { color: var(--muted); }
.ghost { background: none; border: 0; color: var(--muted); padding: 6px 8px; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
nav { display: flex; background: var(--panel); border-top: 1px solid var(--line); }
nav button {
  flex: 1; border: 0; background: none; padding: 8px 2px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; font-size: 20px;
}
nav button span { font-size: 11px; }
nav button.active { color: var(--accent); font-weight: 600; }

/* чат */
.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--me); color: var(--me-text); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--muted); font-style: italic; }
.msg a { color: inherit; text-decoration: underline; }
.composer { display: flex; gap: 8px; padding: 10px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 18px; background: var(--bg); color: var(--text); font: inherit;
}
.composer button {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 18px;
}
.composer button:disabled { opacity: .5; }

/* списки */
.list { list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.list .main { flex: 1; overflow-wrap: anywhere; }
.list .meta { display: block; color: var(--muted); font-size: 13px; }
.list .late { color: var(--danger); }
.list .act { border: 0; background: none; font-size: 20px; padding: 4px 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; list-style: none; }
