:root {
  color-scheme: dark;
  --ink: #080a0e;
  --panel: rgba(17, 21, 28, 0.88);
  --line: rgba(214, 179, 106, 0.2);
  --line-strong: rgba(214, 179, 106, 0.46);
  --gold: #d6b36a;
  --gold-pale: #f0dfb2;
  --ivory: #ece6d8;
  --muted: #989589;
  --teal: #6fa7a0;
  --red: #b55d57;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.36);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ink); }
body {
  color: var(--ivory);
  font-family: "Segoe UI", "Noto Sans SC", sans-serif;
  background-image:
    linear-gradient(rgba(214, 179, 106, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 179, 106, 0.025) 1px, transparent 1px);
  background-size: 64px 64px;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.shell {
  width: min(920px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: linear-gradient(180deg, rgba(12, 15, 20, 0.92), rgba(8, 10, 14, 0.98));
  border-inline: 1px solid rgba(214, 179, 106, 0.12);
}
.topbar {
  min-height: 84px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 14, 0.82);
  backdrop-filter: blur(18px);
}
.identity { display: flex; align-items: center; gap: 13px; min-width: 0; }
.sigil {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  color: var(--gold-pale);
  font: 600 19px/1 Georgia, serif;
  transform: rotate(45deg);
  background: rgba(214, 179, 106, 0.07);
}
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }
h1 { margin: 0; font: 600 22px/1.15 Georgia, "Noto Serif SC", serif; letter-spacing: 0.04em; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 14px rgba(111, 167, 160, 0.6); }
.actions { display: flex; gap: 8px; }
.quiet-button { border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; background: transparent; color: var(--muted); }
.quiet-button:hover, .quiet-button:focus-visible { border-color: var(--line-strong); color: var(--gold-pale); }
.conversation { overflow-y: auto; padding: 30px clamp(16px, 4vw, 48px) 120px; scroll-behavior: smooth; }
.message { width: min(720px, 92%); margin: 0 0 22px; animation: enter 220ms ease-out both; }
.message.user { margin-left: auto; }
.message-meta { margin-bottom: 7px; color: var(--muted); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.message.user .message-meta { text-align: right; }
.message-body { position: relative; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); line-height: 1.8; white-space: pre-wrap; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18); }
.message.assistant .message-body { border-left: 2px solid var(--gold); font-family: Georgia, "Noto Serif SC", serif; font-size: 16px; }
.message.user .message-body { border-color: rgba(111, 167, 160, 0.24); background: rgba(20, 29, 31, 0.8); }
.message.error .message-body { border-color: rgba(181, 93, 87, 0.45); color: #e0a29d; }
.typing .message-body::after { content: "……"; color: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px max(18px, env(safe-area-inset-left)) calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(8, 10, 14, 0.94);
  backdrop-filter: blur(18px);
}
textarea { width: 100%; min-height: 48px; max-height: 160px; resize: none; border: 1px solid var(--line); border-radius: 6px; padding: 13px 15px; background: rgba(15, 19, 25, 0.92); color: var(--ivory); line-height: 1.5; outline: none; }
textarea:focus { border-color: var(--line-strong); }
textarea::placeholder { color: #716f67; }
.send-button { min-width: 84px; border: 1px solid var(--gold); border-radius: 6px; padding: 0 18px; background: var(--gold); color: #17130b; font-weight: 700; }
.send-button:disabled { cursor: wait; opacity: 0.55; }
.login-layer { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(5, 7, 10, 0.86); backdrop-filter: blur(16px); }
.login-layer[hidden] { display: none; }
.login-panel { width: min(380px, 100%); padding: 28px; border: 1px solid var(--line-strong); border-radius: 8px; background: #10141b; box-shadow: var(--shadow); }
.login-panel h2 { margin: 0 0 20px; font: 600 27px/1.2 Georgia, "Noto Serif SC", serif; }
.login-panel label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.login-panel input { width: 100%; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 12px 13px; background: #0b0e13; color: var(--ivory); outline: none; }
.login-panel input:focus { border-color: var(--gold); }
.login-panel .send-button { width: 100%; min-height: 46px; }
.login-error { min-height: 20px; margin: 0 0 10px; color: #d98a84; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (max-width: 680px) {
  .shell { border: 0; }
  .topbar { min-height: 72px; grid-template-columns: 1fr auto; gap: 12px; padding: 11px 15px; }
  .status { display: none; }
  .sigil { width: 36px; height: 36px; font-size: 16px; }
  h1 { font-size: 19px; }
  .quiet-button { padding: 7px 9px; font-size: 12px; }
  .conversation { padding: 20px 14px 110px; }
  .message { width: 96%; margin-bottom: 18px; }
  .message-body { padding: 14px; }
  .message.assistant .message-body { font-size: 15px; }
  .composer { grid-template-columns: minmax(0, 1fr) 72px; padding-inline: 12px; }
  .send-button { min-width: 0; padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}