:root {
  --bg: #0b1020;
  --panel: #111827;
  --panel-2: #182238;
  --card: #1f2937;
  --text: #f8fafc;
  --muted: #a7b0c0;
  --border: rgba(255,255,255,.10);
  --accent: #d6e4ff;
  --accent-2: #7dd3fc;
  --danger: #fecaca;
  --ok: #bbf7d0;
  --shadow: 0 18px 50px rgba(0,0,0,.32);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #1f2a44 0, var(--bg) 38%, #050816 100%);
  color: var(--text);
}
button, input, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 999px;
  padding: .75rem 1rem;
  background: var(--accent);
  color: #07111f;
  font-weight: 800;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--border);
}
button.small { padding: .45rem .7rem; font-size: .88rem; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 1rem;
  padding: .85rem .95rem;
  outline: none;
}
input:focus, textarea:focus { border-color: rgba(125,211,252,.7); }
label { display: grid; gap: .35rem; color: var(--muted); font-size: .9rem; }
.app-shell {
  display: grid;
  grid-template-columns: 330px 1fr;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
.sidebar {
  background: rgba(10,16,32,.82);
  border-right: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
  backdrop-filter: blur(14px);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.app-title { font-weight: 900; font-size: 1.35rem; letter-spacing: .2px; }
.app-subtitle { color: var(--muted); font-size: .9rem; }
.auth-view, .install-card {
  background: rgba(17,24,39,.86);
  border: 1px solid var(--border);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
  padding: 1rem;
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.auth-tabs button { background: rgba(255,255,255,.07); color: var(--text); }
.auth-tabs button.active { background: var(--accent); color: #07111f; }
.auth-form { display: grid; gap: .8rem; }
.error-line { color: var(--danger); min-height: 1.2rem; }
.section-label {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin: 1rem 0 .45rem;
}
.chat-list { display: grid; gap: .45rem; }
.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  padding: .8rem .85rem;
  border-radius: 1rem;
  background: rgba(255,255,255,.055);
  border: 1px solid transparent;
  color: var(--text);
  text-align: left;
}
.chat-item.active { border-color: rgba(125,211,252,.65); background: rgba(125,211,252,.12); }
.chat-item small { color: var(--muted); display: block; margin-top: .1rem; }
.pill {
  font-size: .72rem;
  color: #07111f;
  background: var(--accent-2);
  border-radius: 999px;
  padding: .22rem .45rem;
  white-space: nowrap;
}
.chat-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 76px;
  border-bottom: 1px solid var(--border);
  padding: .8rem 1rem;
  background: rgba(15,23,42,.72);
  backdrop-filter: blur(14px);
}
.chat-header h1 { margin: 0; font-size: 1.18rem; }
.chat-header p { margin: .15rem 0 0; color: var(--muted); font-size: .9rem; }
.back { display: none; min-width: 42px; }
.empty-state {
  display: grid;
  place-content: center;
  gap: .5rem;
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}
.empty-state strong { color: var(--text); font-size: 1.2rem; }
.messages {
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.msg {
  max-width: min(720px, 82%);
  align-self: flex-start;
  background: rgba(255,255,255,.075);
  border: 1px solid var(--border);
  border-radius: 1.2rem 1.2rem 1.2rem .35rem;
  padding: .7rem .85rem;
  word-break: break-word;
}
.msg.mine {
  align-self: flex-end;
  background: rgba(214,228,255,.18);
  border-color: rgba(214,228,255,.23);
  border-radius: 1.2rem 1.2rem .35rem 1.2rem;
}
.msg-meta {
  display: flex;
  gap: .5rem;
  align-items: center;
  color: var(--muted);
  font-size: .76rem;
  margin-bottom: .28rem;
}
.msg-text { white-space: pre-wrap; line-height: 1.35; }
audio { max-width: 100%; width: 290px; }
.location-link { color: var(--accent-2); font-weight: 700; }
.composer {
  border-top: 1px solid var(--border);
  background: rgba(15,23,42,.88);
  padding: .75rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .6rem;
  align-items: end;
}
.composer textarea {
  resize: none;
  max-height: 150px;
  min-height: 46px;
}
.composer-actions { display: flex; gap: .45rem; align-items: center; }
.voice-btn.recording { background: #fecaca; color: #3b0a0a; }
.record-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .9rem;
}
.install-page { min-height: 100%; display: grid; place-items: center; padding: 1rem; }
.install-card { width: min(720px, 100%); }
.install-card h1, .install-card h2 { margin-top: 0; }
.install-form { display: grid; gap: .9rem; }
.hint { color: var(--muted); }
.ok-box, .error-box {
  border-radius: 1rem;
  padding: .85rem 1rem;
}
.ok-box { color: #052e16; background: var(--ok); }
.error-box { color: #450a0a; background: var(--danger); }
.danger-text { color: var(--danger); }
.button-link {
  display: inline-flex;
  background: var(--accent);
  color: #07111f;
  padding: .8rem 1rem;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: block; height: 100dvh; border-right: 0; }
  .chat-pane { display: none; }
  .app-shell.chat-open .sidebar { display: none; }
  .app-shell.chat-open .chat-pane { display: grid; }
  .back { display: inline-flex; align-items: center; justify-content: center; }
  .msg { max-width: 90%; }
  .composer { grid-template-columns: 1fr; }
  .composer-actions { justify-content: space-between; }
  .composer-actions button { flex: 1; }
}
.voice-btn { touch-action: none; user-select: none; }
.location-box { display: grid; gap: .25rem; }
