:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262a33;
  --text: #ecedf0;
  --muted: #9097a3;
  --accent: #c8a46b;      /* warm gold */
  --accent-ink: #1a1408;
  --me: #2a2f3a;
  --error: #ff8a80;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ---------- gate ---------- */
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.monogram {
  width: 84px; height: 84px; margin: 0 auto 14px;
  border-radius: 24px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #d9b67c, #a7834b);
  color: var(--accent-ink);
  font: 600 46px/1 Georgia, "Times New Roman", serif;
}
h1 { margin: 0 0 10px; font-size: 28px; font-weight: 600; letter-spacing: 0.3px; }
.muted { color: var(--muted); margin: 0 0 18px; }
form { display: grid; gap: 12px; }
input[type="text"] {
  width: 100%; padding: 14px 16px;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  font: inherit; text-align: center; letter-spacing: 1px;
}
.primary {
  width: 100%; padding: 15px 18px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.primary:disabled { opacity: 0.6; }
.error { color: var(--error); min-height: 1.4em; margin: 14px 0 0; font-size: 15px; }

/* ---------- chat ---------- */
.chat { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(12px);
}
.title { font-weight: 600; display: flex; align-items: center; gap: 8px; justify-content: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.log {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--me); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.error { align-self: center; background: transparent; color: var(--error); font-size: 15px; text-align: center; }
.msg.typing::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; margin-left: 1px; }
.empty { margin: auto; color: var(--muted); text-align: center; padding: 0 20px; }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  grid-template-columns: none;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px;
  padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; line-height: 1.35;
}
.composer textarea:focus { outline: none; border-color: #3a404c; }
.send {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.send:disabled { opacity: 0.4; }
.send.stop { background: #e9e9ec; color: #111; }
