:root {
  --bg: #10110f;
  --sidebar: #171814;
  --panel: #1c1d18;
  --line: rgba(244, 241, 232, 0.1);
  --text: #f4f1e8;
  --muted: #9b968a;
  --faint: #6f6b61;
  --accent: #d7f06a;
  --accent-ink: #1a1c12;
  --gold: #e2b15a;
  --gold-dim: rgba(226, 177, 90, 0.18);
  --deny: #f0c2b6;
  --user: #23281c;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --sans: "Liberation Sans", "DejaVu Sans", "Segoe UI", sans-serif;
  --serif: "Liberation Serif", "Iowan Old Style", Palatino, Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--sans);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden, [hidden] { display: none !important; }

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100%;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px 12px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 4px 6px 14px;
}
.brand strong {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.03em;
}
.brand span { color: var(--muted); font-size: 12px; }
.mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--serif);
  font-size: 22px;
}
.side-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 8px 8px 6px;
}
.side-label button, .ghost, .icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
}
.side-label button:hover, .icon-btn:hover, .ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-toggle { display: none; }

.agents, .threads { display: flex; flex-direction: column; gap: 2px; }
.threads { flex: 1; overflow: auto; min-height: 80px; }
.agent, .thread-link, .destinations a {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
}
.thread-link, .destinations a { grid-template-columns: 1fr; padding: 8px 10px; color: var(--muted); }
.agent small, .thread-link { color: var(--muted); font-size: 12.5px; }
.agent strong, .thread-link { font-weight: 550; }
.agent strong { display: block; color: var(--text); font-size: 14px; font-weight: 600; }
.agent .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent.active, .thread-link.active, .destinations a.active { background: #24281e; color: var(--text); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: #22261c;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.avatar.shadow { box-shadow: inset 0 0 0 1px rgba(226, 177, 90, 0.7); color: var(--gold); }
.pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(226, 177, 90, 0.45);
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 1px;
}

.destinations {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 8px;
}
.account {
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding: 10px 8px 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.account strong { color: var(--text); font-weight: 600; display: block; }

.stage { min-width: 0; min-height: 100vh; }
.chat {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 18px;
}
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 4px 16px;
}
.chat-head h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.03em;
  margin: 0;
}
.chat-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.head-actions { display: flex; gap: 8px; }
.transcript { flex: 1; display: flex; flex-direction: column; gap: 18px; padding-bottom: 12px; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; max-width: min(520px, 88%); }
.msg.user .bubble {
  background: var(--user);
  border-radius: 18px 18px 6px 18px;
  padding: 10px 14px;
}
.msg.assistant .body { font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; }
.who { color: var(--faint); font-size: 12px; margin-bottom: 4px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file-chip, .file-link {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 12px;
}
.file-chip img, .msg img.preview {
  display: block;
  max-width: 220px;
  max-height: 160px;
  border-radius: 10px;
  margin-top: 6px;
}

.approval {
  margin-top: 12px;
  background: linear-gradient(180deg, #262216, #1b1913);
  border: 1px solid rgba(226, 177, 90, 0.38);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
.approval header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.approval h3 { margin: 0; font-size: 14px; font-weight: 650; }
.approval .risk { color: var(--gold); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.approval pre {
  white-space: pre-wrap;
  font: 13.5px/1.45 var(--sans);
  margin: 10px 0 12px;
  color: var(--text);
}
.approval .hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.actions { display: flex; gap: 8px; }
.approve, .deny, .primary, .secondary {
  border-radius: 999px;
  padding: 8px 14px;
  border: 0;
}
.approve, .primary { background: var(--text); color: #17170f; font-weight: 650; }
.deny {
  background: transparent;
  color: var(--deny);
  border: 1px solid rgba(240, 194, 182, 0.45);
}
.decided { color: var(--muted); font-size: 13px; }

.composer-wrap { position: sticky; bottom: 0; padding-top: 8px; background: linear-gradient(180deg, transparent, var(--bg) 28%); }
.pending-note { color: var(--gold); font-size: 13px; margin: 0 8px 8px; }
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border: 1px solid var(--line);
  background: #191a16;
  border-radius: 22px;
  padding: 8px;
}
.composer:focus-within { border-color: rgba(215, 240, 106, 0.55); }
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  background: transparent;
  outline: none;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 8px;
}
.send, .clip {
  width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
}
.clip { background: transparent; color: var(--muted); }
.send { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.send:disabled, .composer textarea:disabled { opacity: 0.45; cursor: default; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.suggest button, .secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
}

.page { max-width: 980px; margin: 0 auto; padding: 28px 22px 48px; }
.page h1 { font-family: var(--serif); font-weight: 500; font-size: 36px; letter-spacing: -0.03em; margin: 0 0 8px; }
.lede { color: var(--muted); max-width: 62ch; margin-top: 0; }
.banner {
  border: 1px solid var(--line);
  background: #181910;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--muted);
  margin: 16px 0 20px;
}
.group { margin: 22px 0; }
.group h2 { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); font-weight: 650; }
.routine, .event, .note {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.routine p, .event p, .note p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.switch {
  width: 44px; height: 26px; border-radius: 999px; border: 0;
  background: #2a2c26; position: relative; flex: none;
}
.switch[aria-pressed="true"] { background: #3d4a22; }
.switch i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #c8c4b8; display: block;
}
.switch[aria-pressed="true"] i { left: 21px; background: var(--accent); }

.cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr; }
}
.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #161712;
}
.card header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .summary { color: var(--muted); margin: 0; }
.badge {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.live { color: var(--accent-ink); background: var(--accent); border-color: transparent; }
.tools { color: var(--faint); font-size: 12.5px; margin: 10px 0; }
.grants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.grant {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.grant[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: transparent; }

.memory {
  position: fixed;
  top: 0; right: 0; height: 100vh; width: min(440px, 100%);
  background: #141510;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px 18px 32px;
  overflow: auto;
  z-index: 5;
}
.memory h1, .memory h2, .memory h3 { font-family: var(--serif); font-weight: 500; }
.memory h1 { font-size: 26px; }
.memory h2 { font-size: 18px; margin-top: 1.4em; }
.memory li { margin: 4px 0; }
.prose { font-size: 14px; line-height: 1.55; color: #e6e2d6; }
.notes {
  position: absolute;
  right: 0; top: 42px;
  width: min(320px, 80vw);
  background: #1b1c17;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 4;
}
.note { grid-template-columns: 1fr; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card { width: min(420px, 100%); }
.gate-card h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 48px;
  letter-spacing: -0.04em;
  margin: 12px 0 8px;
}
.gate-card p { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.stack .primary, .stack .secondary { text-align: center; padding: 12px 14px; }
.error { color: #f0b4a8; font-size: 13px; min-height: 1.2em; }
.status-line { color: var(--faint); font-size: 13px; margin: 0 8px 8px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 6;
    transform: translateX(-105%);
    transition: transform 160ms ease;
    width: min(320px, 88vw);
  }
  .sidebar.open { transform: none; }
  .nav-toggle {
    display: inline-grid;
    place-items: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 7;
    width: 64px;
    height: 36px;
    background: #171814;
    border: 1px solid var(--line);
    color: var(--text);
  }
  .chat, .page { padding-top: 56px; }
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 5; }
  .chat-head h1, .page h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
