/* Clef Gate — Graphite & Ember. Flat ember, no gradient fills. */

:root {
  --ember: #c2410c;
  --ember-2: #e2622e;
  --font-heading: "Bricolage Grotesque", "Space Grotesk", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 10px;
  --topbar-h: 60px;
}

:root, [data-theme="dark"] {
  --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: #e8e8e4;
  --muted: #8a8a85;
  --accent-text: #e2622e;
  --ok: #5aa877;
  --danger: #d0533f;
  --warn: #d19a2a;
}

[data-theme="light"] {
  --ember: #b23a0a;
  --ember-2: #c2410c;
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f3f1eb;
  --border: rgba(23, 23, 26, 0.1);
  --border-strong: rgba(23, 23, 26, 0.18);
  --text: #3d3a34;
  --text-strong: #17171a;
  --muted: #6b675e;
  --accent-text: #b23a0a;
  --ok: #2f7d4f;
  --danger: #b43d2b;
  --warn: #a86f0a;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
h1, h2 { font-family: var(--font-heading); color: var(--text-strong); letter-spacing: -0.03em; margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
a { color: var(--text-strong); }
a:hover { color: var(--accent-text); }
button, textarea { font: inherit; color: inherit; }
: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 {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0.6rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 0.45rem; color: var(--text-strong); text-decoration: none; font-weight: 650; }
.brand__mark { color: var(--ember); }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title p { color: var(--muted); font-size: 0.85rem; }
.topbar__actions { display: flex; gap: 0.4rem; }

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--ember); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #fff8f5; }
.btn-primary:hover { background: var(--ember-2); border-color: var(--ember-2); }
.btn-ghost { background: transparent; }
.btn-icon { width: 2.2rem; padding: 0.35rem; display: grid; place-items: center; }
.icon { width: 1.1rem; height: 1.1rem; }

.strip {
  margin: 0;
  padding: 0.45rem 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.pending {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin: 0.8rem 1.1rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--ember);
  border-radius: var(--radius);
  background: var(--surface);
}
.pending[hidden] { display: none; }
.pending__actions { display: flex; gap: 0.4rem; }
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 0.2rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 1rem;
  padding: 1rem 1.1rem 1.4rem;
  align-items: start;
}

.chat, .gate { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }
.transcript {
  list-style: none;
  margin: 0;
  padding: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 220px;
  max-height: calc(100dvh - 340px);
  overflow: auto;
}
.bubble {
  max-width: 40rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble--user { align-self: flex-end; background: var(--surface-2); border-color: var(--border-strong); }
.bubble--tool { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }
.bubble__role { display: block; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.15rem; }
.empty { color: var(--muted); padding: 1.5rem 0.2rem; }

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  border: 1px solid var(--border-strong);
  background: transparent;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  color: var(--text);
}
.chip:hover { border-color: var(--ember); color: var(--text-strong); }
textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 0.6rem 0.7rem;
}
.composer__row { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.6rem; }
.turnstile { min-height: 65px; }
@media (max-width: 720px) {
  .composer__row { flex-direction: column; align-items: stretch; }
  .composer__row .btn { align-self: flex-end; }
}

.panel, .card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.85rem 0.9rem;
}
.toggle { display: flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; margin: 0.45rem 0; }
.toggle__btn {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0.45rem;
  cursor: pointer;
  color: var(--text);
}
.toggle__btn.is-on { background: var(--ember); color: #fff8f5; }
.hint { color: var(--muted); font-size: 0.82rem; }
.card__reason { margin: 0.35rem 0 0.7rem; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.bars li { display: grid; grid-template-columns: 5.5rem 1fr 2.6rem; gap: 0.45rem; align-items: center; font-family: var(--font-mono); font-size: 0.78rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar__fill { display: block; height: 100%; width: 0; }
.bar__fill--allow { background: var(--ok); }
.bar__fill--deny { background: var(--danger); }
.bar__fill--ask { background: var(--ember); }
.meta { margin-top: 0.65rem; color: var(--muted); font-size: 0.8rem; font-family: var(--font-mono); }

.audit__head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
#audit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.audit__item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: baseline;
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
  font-size: 0.86rem;
}
.audit__item strong { font-family: var(--font-mono); font-weight: 500; }
.tag { font-family: var(--font-mono); font-size: 0.75rem; white-space: nowrap; }
.tag--allow { color: var(--ok); }
.tag--deny { color: var(--danger); }
.tag--ask-human { color: var(--warn); }

.foot { padding: 0 1.1rem 1.4rem; color: var(--muted); font-size: 0.85rem; }
.foot p + p { margin-top: 0.3rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
  .topbar__title { flex: 1 1 12rem; }
  .pending { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 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;
}
