@import url("/static/css/tokens.css");

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--ground) var(--texture-ground) repeat;
  color: var(--ink);
  font-family: var(--font-reading);
  font-size: var(--text-lg);
  line-height: var(--leading-reading);
}

.card {
  width: min(100%, 440px);
  background: var(--card);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-8);
}

body.gate {
  display: block;
  padding: 0;
  overflow-x: clip;
}

.gate {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.gate-hero {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--ground);
  transform: translateZ(0);
  isolation: isolate;
}

.gate-hero > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.gate-hero .loop {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.gate-hero .loop-video,
.gate-hero .loop-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.gate-hero .loop-video { display: block; }
.gate-hero .loop-still { display: none; }

@media (max-width: 640px), (prefers-reduced-motion: reduce) {
  .gate-hero .loop-video { display: none; }
  .gate-hero .loop-still { display: block; }
}

.gate-stage {
  position: absolute;
  top: clamp(16px, 4vh, 48px);
  left: clamp(16px, 3vw, 64px);
  z-index: 2;
  display: flex;
  justify-content: flex-start;
  width: auto;
  max-width: calc(100% - 32px);
  padding: 0;
  box-sizing: border-box;
  transform: translateZ(0);
}

.card.plate-cream {
  position: relative;
  width: min(var(--gate-plate-width), calc(100vw - var(--space-8)));
  background: var(--cream);
  color: var(--cream-ink);
  border: 0;
  border-radius: var(--radius-md);
  padding: 56px 40px 40px;
  text-align: center;
}

.plate-frame {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  color: var(--gold-dim);
}

.plate-frame svg { width: 100%; height: 100%; display: block; }

.plate-cream h1 {
  font-size: var(--text-xl);
  line-height: var(--leading-display);
  color: var(--ink);
}

.plate-cream p,
.plate-cream .lede { color: var(--ink-muted); }

.plate-rule {
  overflow: hidden;
  height: 18px;
  margin: 0 0 var(--space-4);
  color: var(--gold-dim);
}

.plate-rule svg { width: 100%; height: auto; display: block; }

.mark {
  margin: 0 0 12px;
  color: var(--accent);
}

h1 {
  margin: 0 0 8px;
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: var(--leading-display);
}

h1, .content h1, th, .mark {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
}

p { margin: 0 0 20px; color: var(--muted); }

strong { color: var(--ink); font-weight: 600; }

.button {
  display: inline-block;
  background: var(--gold);
  color: var(--ground);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  line-height: 1;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.button:hover { background: var(--gold-2); }
a { color: var(--gold); }
:focus-visible { outline: 1px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

body.app {
  display: block;
  padding: 0;
  font-family: var(--font-reading);
  font-size: var(--text-md);
  line-height: var(--leading-reading);
}

.shell {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr;
  min-height: 100vh;
}

.nav {
  padding: 28px 18px;
  border-right: var(--border-hairline);
  background: var(--ground-2);
}

a.mark { color: var(--gold); text-decoration: none; display: inline-block; line-height: 0; }
.glyph {
  display: block;
  background-color: currentColor;
  -webkit-mask-image: var(--glyph);
  mask-image: var(--glyph);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}
.mark-horizontal .glyph { width: 320px; max-width: 100%; height: auto; aspect-ratio: 1072 / 108; }
.mark-stacked { margin: 0 0 var(--space-4); }
.mark-stacked .glyph { width: 140px; max-width: 100%; height: auto; aspect-ratio: 746 / 196; }
.nav-emblem { width: 20px; height: 20px; flex: none; display: inline-flex; color: inherit; }
.nav-emblem .glyph { width: 20px; height: 20px; }

.nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: 0;
  color: var(--ink-muted);
  font-family: var(--font-reading);
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: transparent;
  color: var(--gold);
  border-left: 1px solid var(--gold);
}
.nav .sign-out { margin-top: 28px; color: var(--ink-muted); }
.ambient-toggle {
  margin: var(--space-4) 0 0;
  background: transparent;
  color: var(--ink-muted);
  border: var(--border-hairline);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  padding: 8px 10px;
  cursor: pointer;
}
.ambient-toggle[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); }
.nav .who { margin: 18px 10px 0; font-size: var(--text-sm); }
.footer-line {
  margin: var(--space-6) 10px 0;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.content {
  padding: var(--space-8) var(--space-8) var(--space-16);
  max-width: none;
  min-width: 0;
}
.content > :not(.procession) { max-width: var(--content-max); width: 100%; }
.content h1 { font-size: var(--text-3xl); font-weight: 600; line-height: var(--leading-display); }
.content h2 { margin: 28px 0 8px; font-size: 20px; }
.lede { max-width: var(--measure); }
.hint, .muted { color: var(--muted); }
.mono, textarea, pre, code, .snippet {
  font-family: var(--font-data);
  line-height: var(--leading-data);
}
.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 8px 0 24px;
}
.panel {
  display: block;
  background: var(--ground-3);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: inherit;
  text-decoration: none;
}
.panel:hover, .q-card:hover, .run-card:hover { border: var(--border-gold-dim); }
.panel h2 { margin: 0 0 6px; }
.panel p { margin: 0; }
.banner {
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.banner.bad {
  background: var(--terracotta);
  color: var(--ink);
  font-size: var(--text-lg);
}
.secret-flash code, .snippet {
  display: block;
  white-space: pre-wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  overflow-x: auto;
}
.grid { width: 100%; border-collapse: collapse; background: var(--ground-3); }
.grid th, .grid td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.grid th {
  color: var(--hatch);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.actions button, .add-row button, .toggle button, .export button, .inline button, .q-card button {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  line-height: 1;
  color: var(--gold);
  background: transparent;
  border: var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
}
.pill {
  display: inline-block;
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: var(--text-xs);
  background: color-mix(in srgb, var(--hatch) 12%, transparent);
  color: var(--hatch);
}
.pill.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.pill.failed { background: color-mix(in srgb, var(--terracotta-2) 12%, transparent); color: var(--terracotta-2); }
.pill.untested { background: color-mix(in srgb, var(--hatch) 12%, transparent); color: var(--hatch); }
.pill.default { background: transparent; color: var(--gold); border: 1px solid var(--gold); }
.test-message { display: block; color: var(--muted); max-width: 36ch; }
.stack { display: grid; gap: 10px; max-width: 560px; }
.stack.compact { max-width: none; }
.stack label, .toolbar label, .inline label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.stack input, .inline input, .toolbar select, textarea, select {
  width: 100%;
  border: var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--ground-3);
  color: var(--ink);
  font: var(--text-sm)/var(--leading-reading) var(--font-reading);
}
.stack input:focus, .inline input:focus, .toolbar select:focus, textarea:focus, select:focus {
  border-color: var(--gold);
}
textarea { font-family: var(--font-data); font-size: var(--text-sm); line-height: var(--leading-data); }
.check { display: flex !important; align-items: center; gap: 8px; }
.check input { width: auto; }
.errors { margin: 0; color: var(--terracotta-2); }
.inline { display: flex; gap: 12px; align-items: end; margin-bottom: 18px; }
.status-list { list-style: none; padding: 0; }
.status-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin: 8px 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0; }
.toolbar label { min-width: 160px; }
.usage {
  font-family: var(--font-data);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--gold);
  padding-bottom: var(--space-1);
}
.workspace, .drawers { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.section-head, .q-head, .choice-row, .score-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.section-head h2 { margin: 12px 0; }
.toggle { display: flex; gap: 4px; }
.toggle button[aria-pressed="true"] { background: var(--gold); color: var(--ground); border-color: var(--gold); }
.add-row { display: flex; gap: 8px; margin: 8px 0 16px; }
.q-card {
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 0 0 10px;
  background: var(--ground-3);
}
.q-card label { display: grid; gap: 4px; margin: 8px 0; font-size: 13px; color: var(--muted); }
.choice-row, .score-row { margin: 6px 0; }
.choice-row input, .score-row input { flex: 1; }
.export { position: relative; }
.export summary { cursor: pointer; padding: 8px 0; }
.export button { display: block; margin: 4px 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.run-card { border: var(--border-hairline); border-radius: var(--radius-md); padding: 12px; background: var(--ground-3); }
.run-card h3 { margin: 0 0 8px; font-size: 16px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 1fr) 2fr auto; gap: 8px; align-items: center; margin: 4px 0; font-size: 13px; }
.track { display: block; height: 8px; background: var(--hatch); border-radius: var(--radius-sm); overflow: hidden; }
.fill { display: block; height: 100%; background: var(--gold); }
.bar-row.chosen .fill { background: var(--gold-2); }
.meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.example-list { list-style: none; padding: 0; margin: 0; }
.example-list li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.example-list button { background: none; border: 0; padding: 0; color: var(--gold); cursor: pointer; font: inherit; text-align: left; }
.example-list .row-actions { display: flex; gap: 10px; }

.loop-video,
.loop-still { width: 100%; height: auto; }
.loop-video { display: block; }
.loop-still { display: none; }
@media (max-width: 640px), (prefers-reduced-motion: reduce) {
  .loop-video { display: none; }
  .loop-still { display: block; }
}

.procession {
  overflow: hidden;
  width: calc(100% + 2 * var(--space-8));
  max-width: none;
  margin: 0 calc(-1 * var(--space-8)) var(--space-6);
}
.procession .loop-video,
.procession .loop-still {
  width: 110%;
  max-width: none;
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(-9%); }
}
@media (prefers-reduced-motion: reduce) {
  .procession .loop-video,
  .procession .loop-still { animation: none; }
}
.section-hero { margin: 0 0 var(--space-6); }
.section-hero img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.empty, .useless { margin: 0 0 var(--space-6); }
.empty { text-align: center; }
.empty img, .useless img { width: min(100%, 400px); height: auto; }
@media (min-width: 900px) {
  .empty img, .useless img { width: min(100%, 800px); }
}
.plate-cream .empty img { width: min(100%, 400px); }

@media (max-width: 900px) {
  .shell, .panels, .workspace, .drawers, .compare, .chat-app { grid-template-columns: 1fr; }
  .nav { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-app { height: auto; }
}

.chat-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  height: calc(100vh - 220px);
  min-height: 520px;
}
.chat-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.chat-list { list-style: none; padding: 0; margin: 0; overflow: auto; }
.chat-list li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.chat-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.chat-list button[aria-current="true"] { color: var(--gold); }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-system { flex: 1 1 100%; }
.chat-system summary { cursor: pointer; }
.thread {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 16px;
}
.bubble {
  max-width: 72ch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.bubble.self { align-self: flex-end; background: var(--paper); }
.loading-block { display: inline-flex; align-items: center; gap: var(--space-3); }
.loading-line { margin: 0; color: var(--ink-muted); font-size: var(--text-sm); }
.bubble-body p { margin: 0 0 8px; }
.bubble-body p:last-child { margin-bottom: 0; }
.bubble-body pre {
  overflow-x: auto;
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 8px;
}
.reasoning { margin-top: 8px; color: var(--muted); font-size: 13px; }
.reasoning pre { white-space: pre-wrap; }
.tool-log {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}
.tool-log li { margin: 2px 0; }
.composer { display: grid; gap: 8px; }
.composer textarea { min-height: 72px; }
