:root {
  --ember: #c2410c;
  --bg: #0e0e11;
  --surface: #141418;
  --surface-2: #1b1b20;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #c9c9c4;
  --text-strong: #f2f1ec;
  --muted: #8d8d86;
  --ok: #8faf96;
  --danger: #e0a090;
  --font-heading: "Bricolage Grotesque", "Avenir Next", sans-serif;
  --font-body: "Hanken Grotesk", "Avenir Next", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 12px;
  --topbar: 64px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-heading); color: var(--text-strong); letter-spacing: -0.03em; margin: 0; }
h1 { font-size: 1.35rem; font-weight: 680; }
h2 { font-size: 1.55rem; font-weight: 640; }
h3 { font-size: 0.95rem; font-weight: 640; margin-bottom: 0.55rem; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--ember); text-decoration: none; font-weight: 650; }
.brand__mark { display: block; }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title p { color: var(--muted); font-size: 0.86rem; }
.topbar__actions { display: flex; gap: 0.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-strong);
  text-decoration: none;
}
.btn:hover { border-color: var(--ember); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }

.strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.strip__dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ember); flex: none; }

main { padding: 1.25rem; max-width: 1180px; margin: 0 auto; }
.eyebrow { color: var(--ember); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; margin-bottom: 0.4rem; }
.lede { max-width: 42rem; color: var(--text); margin: 0.7rem 0 1rem; }
.hint { min-height: 1.3rem; color: var(--danger); font-size: 0.9rem; margin-top: 0.45rem; }
.mono { font-family: var(--font-mono); font-size: 0.86em; }

.gate {
  max-width: 40rem;
  padding: 1.5rem 0 2rem;
}
.turnstile { min-height: 0; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
}
.chat, .memory {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.pane__head { margin-bottom: 0.8rem; }
.pane__head p { color: var(--muted); font-size: 0.9rem; }

.suggestions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.chip {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.86rem;
}
.chip:hover { border-color: var(--ember); color: var(--text-strong); }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; min-height: 16rem; max-height: 32rem; overflow: auto; }
.bubble { max-width: 92%; padding: 0.7rem 0.85rem; border-radius: 12px; }
.bubble p { white-space: pre-wrap; }
.bubble--user { align-self: flex-end; background: #2a160f; border: 1px solid rgba(194, 65, 12, 0.45); }
.bubble--assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); }
.bubble--unknown { border-style: dashed; }
.cites { list-style: none; margin: 0.55rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.cite { font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 0.35rem; }
.cite code { font-family: var(--font-mono); color: var(--ember); font-size: 0.78rem; }

.composer, .add { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.8rem; }
textarea, input, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; color: var(--muted); }
.composer__row, .token__row, .add__row { display: flex; gap: 0.6rem; align-items: flex-end; justify-content: space-between; }
.add__row label { flex: 1; }

.cards { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.card { border: 1px solid var(--border); border-left: 3px solid var(--ember); border-radius: 8px; padding: 0.65rem 0.75rem; background: var(--bg); }
.card--decision { border-left-color: var(--ok); }
.card p { color: var(--text-strong); }
.card__meta { margin-top: 0.3rem; color: var(--muted); font-size: 0.78rem; }
.card__meta code { font-family: var(--font-mono); color: var(--text); }

.token { border: 1px solid var(--border-strong); border-radius: 8px; padding: 0.75rem; margin-bottom: 1rem; background: var(--bg); }
.token__title { color: var(--text-strong); font-weight: 680; margin-bottom: 0.25rem; }
.token p { color: var(--muted); font-size: 0.86rem; margin-bottom: 0.55rem; }
.memory section + section { margin-top: 0.2rem; }

.foot { padding: 1.5rem 1.25rem 2rem; color: var(--muted); font-size: 0.88rem; text-align: center; }
.foot a { color: var(--text-strong); }

@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 0.75rem 1rem; }
  .topbar__title { order: 3; flex-basis: 100%; }
  .workspace { grid-template-columns: 1fr; }
  .log { max-height: 24rem; }
}

/* Phone layout. Graphite and Ember stay; controls grow to a finger and fields stay at 16px so iOS does not zoom. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
textarea,
select {
  font-size: 16px;
}
.turnstile { max-width: 100%; overflow: auto; }
@media (max-width: 900px) {
  .btn,
  a.btn,
  .btn-primary,
  .btn-ghost,
  .filter,
  button.chip,
  .size,
  .swatch,
  .n,
  .toggle__btn,
  .room-btn,
  .tabs a,
  .note {
    min-height: 44px;
  }
  .btn-icon,
  .swatch,
  .filter,
  .n,
  .size {
    min-width: 44px;
  }
  .btn-icon,
  .swatch {
    width: 44px;
    height: 44px;
  }
  .topbar {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .topbar__actions { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .title-input, .composer input, .join input { min-width: 0; max-width: 100%; }
}
@media (max-width: 900px) and (max-height: 520px) {
  .canvas-wrap { min-height: 42dvh; }
  .chat { min-height: 0; }
  .lobby { min-height: 0; padding-top: 0.5rem; padding-bottom: 0.5rem; }
}


.shows {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.shows--bar {
  margin: 0;
  padding: 0.7rem 1rem;
  background: rgba(194, 65, 12, 0.08);
  border-bottom: 1px solid rgba(194, 65, 12, 0.28);
}
.shows__k {
  margin-right: 0.45rem;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c2410c;
}
