:root {
  --bg: #f5f6fb; --surface: #ffffff; --ink: #1d2050; --brand: #262a6e; --muted: #5d618c; --line: #e1e3ef;
  --teal: #0b7268; --on-teal: #ffffff; --teal-soft: #e3f5f2; /* 5:1 or more on every light background (WCAG AA) */ --red: #c23a48; --red-soft: #fbe9eb; --amber: #a86a12; --amber-soft: #fbf1df;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11132b; --surface: #1a1d3f; --ink: #e9eaf8; --brand: #e9eaf8; --muted: #a3a6cc; --line: #2c3061;
    --teal: #33c2b2; --on-teal: #0d1f1d; --teal-soft: #163a43; --red: #f07a86; --red-soft: #3d1d2b; --amber: #e5b15b; --amber-soft: #3a2d1c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11132b; --surface: #1a1d3f; --ink: #e9eaf8; --brand: #e9eaf8; --muted: #a3a6cc; --line: #2c3061;
  --teal: #33c2b2; --on-teal: #0d1f1d; --teal-soft: #163a43; --red: #f07a86; --red-soft: #3d1d2b; --amber: #e5b15b; --amber-soft: #3a2d1c; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px));
}
.wrap { max-width: 820px; margin: 0 auto; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.card > * { min-width: 0; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; color: var(--brand); margin: 0; }
.privacy { margin: 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.privacy svg { width: 16px; height: 16px; }
h1 { font-size: clamp(24px, 5vw, 32px); line-height: 1.15; letter-spacing: -0.02em; margin: 0; font-weight: 650; }
h2 { font-size: 19px; margin: 0; }
h3 { font-size: 15px; margin: 8px 0 0; }
p { margin: 0; }
a { color: var(--teal); }
.lede, .small, .empty { color: var(--muted); }
.small { font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; flex: 0 0 auto; }
/* Phones: all six tabs in view, three to a row, rather than some scrolled off the edge. */
@media (max-width: 620px) {
  .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; overflow: visible; }
  .tabs button { padding: 9px 4px; white-space: normal; text-align: center; line-height: 1.25; }
}
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--teal); }
.parts { margin-top: 12px; }
.parts button[aria-selected="true"] { color: var(--ink); border-color: var(--teal); background: var(--card, transparent); font-weight: 600; }
.drop, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; gap: 14px; }
.drop { border-style: dashed; border-width: 1.5px; }
.drop.over { border-color: var(--teal); background: var(--teal-soft); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--on-teal); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:focus-visible, label.btn:focus-visible, .link:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--teal); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 6px; }
.item .top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.item .name { font-weight: 600; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.item .words { color: var(--muted); font-size: 14px; }
.badge { flex: none; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--muted); }
.badge.ok { background: var(--teal-soft); color: var(--teal); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.stage { position: relative; align-self: center; justify-self: center; max-width: 100%; touch-action: none; user-select: none; }
.stage img { display: block; max-width: 100%; max-height: 60vh; border-radius: 8px; }
.shape { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5); cursor: move; font-size: 11px; font-weight: 700; color: #fff; padding: 2px 4px; }
.shape.box { background: #000; } /* as solid as in the copy */
.shape.blur { background: rgba(120,130,150,.6); border-style: dashed; }
.shape.crop { border-color: var(--amber); background: transparent; border-width: 3px; color: var(--amber); padding: 0; pointer-events: none; }
.shape.crop .crop-tab, .shape.crop .crop-edge, .shape.crop .corner { pointer-events: auto; }
.shape.crop .crop-tab { position: absolute; left: -3px; top: -26px; background: var(--amber); color: #fff; padding: 2px 8px; border-radius: 6px 6px 0 0; cursor: move; }
.shape.crop .crop-edge { position: absolute; cursor: move; }
.crop-edge.top, .crop-edge.bottom { left: 0; right: 0; height: 14px; }
.crop-edge.top { top: -9px; }
.crop-edge.bottom { bottom: -9px; }
.crop-edge.left, .crop-edge.right { top: 0; bottom: 0; width: 14px; }
.crop-edge.left { left: -9px; }
.crop-edge.right { right: -9px; }
.shape.sel { border-color: var(--teal); }
.shape .corner { position: absolute; right: -10px; bottom: -10px; width: 22px; height: 22px; border-radius: 50%; background: var(--teal); border: 2px solid #fff; cursor: nwse-resize; }
.redactions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.redactions li { display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); padding: 4px 0; }
.redactions li span { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; }
.result { padding: 12px; border-radius: 10px; background: var(--teal-soft); display: grid; gap: 8px; }
.result.bad { background: var(--red-soft); }
footer { color: var(--muted); font-size: 13px; text-align: center; }
.field { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; overflow-wrap: anywhere; padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); user-select: all; display: block; max-width: 100%; }
.code.long { max-height: 9.5em; overflow-y: auto; font-size: 13px; }
.code-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -2px; }
.nowrap { white-space: nowrap; }
.result.warn { background: var(--amber-soft); }
body.locked main, body.locked .tabs { display: none !important; }
.ai-log { display: grid; gap: 8px; margin-bottom: 10px; }
.ai-msg { padding: 10px 12px; border-radius: 10px; }
.ai-msg.me { background: var(--teal-soft); justify-self: end; max-width: 90%; }
.ai-msg.ai { background: var(--bg); border: 1px solid var(--line); }
.ai-msg.action { border: 1px dashed var(--teal); }
.ai-msg.note { color: var(--muted); font-size: 13px; }
.ai-msg p + p, .ai-msg ul { margin-top: 6px; }
dialog:not([open]) { display: none !important; } /* .card sets display; a closed dialog must still vanish */
dialog.card { max-width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(10, 12, 30, 0.45); }
.stack { display: grid; gap: 8px; }
.notice { background: var(--amber-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink); }
.notice summary { cursor: pointer; }
.notice .more { color: var(--teal); text-decoration: underline; }
.notice p { margin-top: 8px; }
.code.spoken { font-size: 28px; letter-spacing: 0.08em; text-align: center; }

.grow { flex: 1; }
.live-preview { width: 100%; border-radius: 12px; background: #000; }
.oauth-page { font: 16px system-ui, sans-serif; margin: 2rem; color: #222; background: #fff; }

.lang-switch { background: none; border: 1px solid var(--line, #ccc); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; color: inherit; cursor: pointer; }

.overview { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.overview li { border-top: 1px solid var(--line, #ddd); padding-top: 8px; }

/* The Create tab: Creator-plan sections are shown but locked until the plan includes them. */
[data-creator][data-locked] { opacity: 0.72; }
[data-creator][data-locked] .creator-action { cursor: not-allowed; }
ol.nb li, ol.checklist li { margin: 6px 0; }
.cite { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-word; }
.ok { color: var(--teal); }
.bad { color: var(--red); }
.muted { color: var(--muted); }

/* The signature pad: drawing with a finger mustn't scroll the page. */
.sigpad { width: 100%; max-width: 600px; aspect-ratio: 5 / 2; height: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; display: block; }
