/* The workbench's look: shadcn/ui's zinc theme, as plain CSS (no build step). */
:root {
  --bg: #ffffff; --panel: #ffffff; --sidebar: #fafafa; --ink: #09090b; --muted: #71717a;
  --line: #e4e4e7; --soft: #f4f4f5; --accent: #18181b; --accent-ink: #fafafa;
  --ring: #a1a1aa; --child: #eff6ff; --pup: #fffbeb;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --radius: 8px; --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b; --panel: #0c0c0f; --sidebar: #0c0c0f; --ink: #fafafa; --muted: #a1a1aa;
    --line: #27272a; --soft: #18181b; --accent: #fafafa; --accent-ink: #18181b;
    --ring: #52525b; --child: #172036; --pup: #2a2214;
    --ok: #4ade80; --ok-bg: #14301f; --warn: #fbbf24; --warn-bg: #33270d;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 28px 0 12px; }
.muted { color: var(--muted); }

/* Shell: a sidebar on the left, the page on the right. */
.shell { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: 240px; flex: none;
  display: flex; flex-direction: column; gap: 4px; padding: 12px;
  background: var(--sidebar); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 12px; font-weight: 600; }
.logo { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 13px; }
/* The studio switcher: the current studio, and a menu of the others */
.switcher { position: relative; }
.switcher .current { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
  font: inherit; text-align: left; }
.switcher button.current { cursor: pointer; }
.switcher button.current:hover, .switcher button.current[aria-expanded=true] { background: var(--soft); }
.switcher .logo { width: 28px; height: 28px; flex: none; text-transform: uppercase; }
.switcher .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.switcher strong, .menu .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher .grow .muted { font-size: 12px; }
.switcher .chev { color: var(--muted); }
.menu { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); }
.menu .section { padding: 6px 8px 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0;
  border-radius: 6px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--soft); outline: none; }
.menu .logo { width: 22px; height: 22px; font-size: 11px; }
.menu .grow { flex: 1; min-width: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--soft); color: var(--ink); }
.nav a.on { background: var(--soft); color: var(--ink); }
.nav .section { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 4px;
  border-top: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--soft); flex: none;
  display: grid; place-items: center; font-weight: 600; text-transform: uppercase; }
.user .email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; }
.page { flex: 1; min-width: 0; padding: 28px 32px 48px; max-width: 1180px; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.head .grow { flex: 1; min-width: 200px; }
.head p { margin: 4px 0 0; }
.topbar { display: none; }
.scrim { display: none; }

/* Controls */
.filters select { max-width: 280px; }
.range { display: inline-flex; align-items: center; gap: 6px; }
.range input { width: 72px; }
select, input[type=email], input[type=number] {
  font: inherit; height: 36px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); min-width: 0;
}
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px;
  padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button.outline { background: var(--panel); color: var(--ink); border-color: var(--line); }
.button.ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 0 8px; }
.button.ghost:hover, .button.outline:hover { background: var(--soft); color: var(--ink); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline;
  cursor: pointer; font: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Filter chips: a segmented control */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--radius); background: var(--soft); gap: 2px;
  flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 500; border: 0; background: transparent; color: var(--muted);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Tooltip: on hover or focus of the thing it explains */
.tip { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.tip .i { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--muted); font-size: 11px; cursor: help; }
.tip .bubble { position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: max-content;
  max-width: min(260px, calc(100vw - 48px)); padding: 6px 10px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; line-height: 1.4;
  font-weight: 400; display: none; }
.tip:hover .bubble, .tip:focus-within .bubble { display: block; }

/* Cards and stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px;
  box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat .label { color: var(--muted); font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.cta p { margin: 4px 0 0; }

/* Badges */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.finished { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.stopped { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.internal { background: var(--soft); color: var(--ink); }

/* Tables, which stack into cards on a phone */
.table { width: 100%; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 10px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--soft); }
td.who { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
time { white-space: nowrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.skeleton { height: 14px; border-radius: 4px; background: var(--soft); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* A play as its book: the picture beside the words and the page's talk */
.bookpage { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 12px; }
.bookpage .art { margin: 0; flex: 0 1 360px; min-width: 200px; }
.bookpage .art img { width: 100%; display: block; border-radius: 10px; }
.bookpage .missing { aspect-ratio: 16 / 9; border-radius: 10px; border: 1px dashed var(--line);
  display: grid; place-items: center; }
.bookpage .words { flex: 1 1 300px; min-width: 0; }
.bookpage .words p { font-size: 15px; line-height: 1.65; margin: 6px 0 4px; }
.storypage { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; max-width: 880px; }
.talk { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }
.story-q, .story-a { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 6px 12px; border-radius: 14px; max-width: 100%; }
.story-q { background: var(--pup); }
.story-a { background: var(--child); }
.talk .play { margin-left: 8px; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 10px; cursor: pointer; }
/* A page as Lylli shows it (the console's admin.css has the same rules): the
   16:9 picture, the spread's crease, the words in a frosted box on the side the
   picture kept calm. */
.app-shot { margin: 0; container-type: inline-size; }
.app-shot figcaption { font-size: 12px; margin-top: 6px; }
.app-page { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 14px;
  background: var(--soft); }
.app-page img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.app-page::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1.2cqw;
  transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, rgba(46, 34, 56, 0), rgba(46, 34, 56, .16), rgba(46, 34, 56, 0)); }
.app-missing { position: absolute; inset: 0; display: grid; place-items: center; }
.app-words { position: absolute; z-index: 1; left: 5.5%; top: 12%; width: fit-content; max-width: 41%;
  padding: 1.4cqw 1.6cqw; border-radius: 2.2cqw; background: rgba(255, 255, 255, .32);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); color: #2E2238;
  font: 400 max(1.9cqw, 11px) / 1.4 "PT Serif Caption", Georgia, "Times New Roman", serif; }
.app-words[data-spot="right"], .app-words[data-spot="left"] { top: 0; bottom: 0; height: fit-content; margin-block: auto; }
.app-words[data-spot="right"] { left: auto; right: 11%; }
.app-words[data-spot="top"], .app-words[data-spot="bottom"] { left: 0; right: 0; margin-inline: auto; width: 72%; max-width: none; }
.app-words[data-spot="top"] { top: 9%; }
.app-words[data-spot="bottom"] { top: auto; bottom: 9%; }
/* Narrow, as the app held upright: the picture above, the words below it. */
@container (max-width: 560px) {
  .app-page { aspect-ratio: auto; }
  .app-page::after { display: none; }
  .app-page img { position: static; height: auto; aspect-ratio: 16 / 9; }
  .app-words, .app-words[data-spot] { position: static; inset: auto; margin: 0; width: auto; max-width: none;
    height: auto; border-radius: 0; background: #FDFDF5; font-size: 15px; padding: 10px 12px; }
}

/* A play with no book: its conversation */
.lines { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.line { padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.line.child { background: var(--child); border-color: transparent; }
.line.character { background: var(--pup); border-color: transparent; }
.line .speaker { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 500; color: var(--muted); }
.line audio { display: block; width: 100%; max-width: 360px; height: 32px; margin-top: 8px; }
.line.action { padding: 4px 14px; background: transparent; border: 0; color: var(--muted); font-size: 13px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); margin: -8px 0 8px; }

/* Raw events ("Include raw events", for an org whose share_org_stats is set):
   totals, a legend, one row per event */
.raw-toggle { margin-top: 12px; }
.legend { margin: 12px 0; padding: 12px 20px; }
.legend summary { cursor: pointer; font-weight: 500; }
.legend dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; }
.legend dt { font-weight: 500; }
.legend dd { margin: 0; color: var(--muted); }
.table.raw { overflow-x: auto; font-size: 13px; }
.table.raw th { cursor: help; }
.table.raw th .i { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--line); font-size: 10px; }
.table.raw td { padding: 6px 10px; white-space: nowrap; }
.table.raw td.raw-safety, .table.raw td.raw-model { white-space: normal; min-width: 120px; }
.table.raw td.raw-cost, .table.raw td.raw-start, .table.raw td.raw-ttft, .table.raw td.raw-ttfa,
.table.raw td.raw-took { text-align: right; font-variant-numeric: tabular-nums; }
.table.raw tr:not(.raw-json) td { border-bottom: 0; }
.table.raw tr.raw-json td { padding-top: 0; color: var(--muted); }
.table.raw pre { margin: 6px 0 0; padding: 10px; border-radius: 8px; background: var(--soft); color: var(--ink);
  font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.raw-error { color: var(--warn); }

/* People */
.invite { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.invite input[type=email] { flex: 1 1 240px; }
.games { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px; margin: 0; }
.games legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.notice { border: 1px solid var(--line); background: var(--soft); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 16px; }
.status { min-height: 1.5em; margin: 8px 0 0; }

/* A phone: the sidebar becomes a drawer behind a top bar; tables stack. */
@media (max-width: 800px) {
  .topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .shell { display: block; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; transform: translateX(-100%);
    transition: transform 0.2s; }
  body.drawer .side { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 0.2); }
  body.drawer .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.4); }
  .page { padding: 20px 16px 40px; }
  .table { border: 0; background: transparent; overflow: visible; }
  .table table, .table tbody { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { display: block; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
    background: var(--panel); padding: 6px 0; }
  .table td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 14px; }
  .table td::before { content: attr(data-label); color: var(--muted); flex: none; }
  .table td > * { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  td.who { max-width: none; white-space: normal; }
  .table.raw td, .table.raw td.raw-safety, .table.raw td.raw-model { white-space: normal; text-align: right; }
  .table.raw tr.raw-json td { display: block; text-align: left; }
  .table.raw tr.raw-json td::before { content: none; }
  .legend dl { grid-template-columns: 1fr; }
  .bookpage { flex-direction: column; }
  .bookpage .art, .bookpage .words { flex-basis: auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
  .skeleton { animation: none; }
}

/* Reports: one card per report, its clip played in place. */
.report { margin-bottom: 12px; }
.report .meta { margin: 0 0 8px; }
.report .note { margin: 0 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.report .actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.report .clip { display: block; width: 100%; max-width: 560px; border-radius: 8px; }
