:root {
  /* Neutral ink and soft grays. The mascot's gradient (--brand) is kept for
     the logo-colored touches only, not for buttons or chrome. */
  --brand: linear-gradient(110deg, #2f6bff 0%, #7c5cff 38%, #ee6fc5 72%, #fdb46b 100%);
  --bg: #fafafa;
  --panel: #ffffff;
  --fg: #18181b;
  --muted: #6b6b76;
  --line: #e7e7ea;
  --accent: #18181b;
  --on-accent: #ffffff;
  --err: #c0262d;
  --err-bg: #fdecef;
  --ok: #2f8a5c;
  --c-word: #4f5bd5;
  --c-string: #2f8a5c;
  --c-number: #2f6fd6;
  --c-ticker: #b4458f;
  --c-sym: #a1a1aa;
  --c-comment: #a1a1aa;
  --viewer-bg: #f1f1f4;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Dark only when someone picks it with the ☾ button. */
:root[data-theme="dark"] {
  --bg: #111113; --panel: #18181b; --fg: #f1f1f3; --muted: #9b9ba6; --line: #2a2a30;
  --accent: #f1f1f3; --on-accent: #18181b; --err: #ff8a8f; --err-bg: #3a1a22; --ok: #8fd6a6;
  --c-word: #a4acf5; --c-string: #9fe0b5; --c-number: #8fb7f5; --c-ticker: #f0a6d6;
  --c-sym: #63636e; --c-comment: #63636e; --viewer-bg: #1c1c20; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

select, button {
  font: inherit;
  font-size: 14px;
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; padding: 8px 20px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--c-number); outline-offset: 2px; }

.studio {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 16px;
  padding: 16px 20px 20px;
}
.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pane-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.kind { font-weight: 600; color: var(--fg); text-transform: lowercase; }
.pane-head { justify-content: flex-start; gap: 10px; }
.pane-head .kind { margin-right: auto; }
.mini { font-size: 12.5px; padding: 5px 11px; font-weight: 600; }
.assets { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.asset {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 3px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg);
  font: 12px var(--mono); color: var(--fg); cursor: pointer;
}
.asset img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: #fff; }
.asset .x { border: 0; background: none; padding: 0 6px; color: var(--muted); font-size: 14px; cursor: pointer; border-radius: 999px; }
.asset .x:hover { color: var(--err); }
.drop-hint { outline: 2px dashed var(--c-word); outline-offset: -8px; }
kbd { font-family: var(--mono); font-size: 12px; padding: 0 5px; border: 1px solid var(--line); border-radius: 4px; }

.editor { position: relative; flex: 1; min-height: 0; }
.editor pre, .editor textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 16px;
  font: 15px/1.7 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  tab-size: 2;
}
.editor pre { pointer-events: none; color: var(--fg); }
.editor textarea { resize: none; border: 0; background: transparent; color: transparent; caret-color: var(--fg); outline: none; }
.editor textarea::selection { background: color-mix(in srgb, var(--c-number) 30%, transparent); color: transparent; }
.t-word { color: var(--c-word); font-weight: 600; }
.t-string { color: var(--c-string); }
.t-number { color: var(--c-number); }
.t-ticker { color: var(--c-ticker); font-weight: 600; }
.t-sym { color: var(--c-sym); }
.t-comment { color: var(--c-comment); font-style: italic; }
.t-err { text-decoration: wavy underline var(--err); text-underline-offset: 4px; }

.status { border-top: 1px solid var(--line); padding: 10px 16px; font-size: 13px; min-height: 42px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status.ok::before { content: "●"; color: var(--ok); margin-right: 8px; }
.status.err { background: var(--err-bg); color: var(--err); }
.status .where { font-weight: 600; }
.status .fix { display: block; color: var(--fg); margin-top: 2px; }

.preview-pane { position: relative; }
.preview-pane.stale > * { opacity: .35; transition: opacity .2s; }
#page { flex: 1; width: 100%; border: 0; background: #fff; }
.viewer { flex: 1; min-height: 0; background: var(--viewer-bg); position: relative; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.empty { margin: auto; color: var(--muted); padding: 24px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--accent); color: var(--on-accent);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
}

@media (max-width: 820px) {
  .ext { display: none; }
  .studio { grid-template-columns: 1fr; grid-template-rows: minmax(260px, 1fr) minmax(320px, 1fr); padding: 12px 16px 16px; gap: 12px; }
  .pane-head .hint { display: none; }
}
@media (max-width: 760px) {
  .mast-actions select { max-width: 104px; min-width: 0; }
  .mast-actions .btn { padding: 8px 12px; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
}
@media (max-width: 380px) {
  .masthead { gap: 8px; padding: 0 10px; }
  .mast-actions { gap: 6px; }
  .mast-actions select { max-width: 78px; padding-left: 10px; padding-right: 6px; }
  .mast-actions .btn { padding: 8px 10px; }
}
