:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --line: #e3e1dc;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --good: #2b8a3e;
  --bad: #c92a2a;
  --warn-bg: #fff4e0;
  --chip: #eef1fb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1e2125;
    --text: #e7e9ec;
    --muted: #a0a7b1;
    --line: #30343a;
    --accent: #7b93ff;
    --accent-text: #0e1116;
    --good: #69db7c;
    --bad: #ff8787;
    --warn-bg: #3a2f1c;
    --chip: #262b36;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  max-width: 980px; margin: 0 auto; padding: 18px 16px 6px;
}
.brand { font-weight: 700; font-size: 20px; }
.pill {
  font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: middle;
}
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.steps button {
  background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 6px 12px;
  border-radius: 99px; font-size: 14px;
}
.steps button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.steps button:disabled { opacity: .5; cursor: default; }
main { max-width: 980px; margin: 0 auto; padding: 8px 16px 48px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow); margin-top: 12px;
}
h2 { margin: 0 0 6px; font-size: 22px; }
h3 { margin: 26px 0 10px; font-size: 17px; }
h4 { margin: 0 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hint { color: var(--muted); margin: 0 0 14px; }
.sceneHeader { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
#sceneCount { color: var(--muted); font-size: 14px; }
.stageWrap { position: relative; margin-bottom: 14px; }
.stage { position: relative; width: 100%; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.actor { position: absolute; left: 0; top: 0; line-height: 1; user-select: none; will-change: transform;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
#replay { position: absolute; right: 10px; bottom: 10px; }
textarea {
  width: 100%; min-height: 140px; resize: vertical; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 10px; }
.row.right { justify-content: flex-end; }
#wordCount { color: var(--muted); font-size: 14px; }
#wordCount.ok { color: var(--good); }
#checkHint { color: var(--muted); font-size: 14px; margin-right: auto; }
.note { color: var(--muted); font-size: 14px; margin: 6px 0; }
.hidden { display: none !important; }
button {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 9px 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: color-mix(in srgb, var(--card) 85%, transparent); }
button.small { padding: 4px 10px; font-size: 13px; }
.issues { display: grid; gap: 8px; margin-top: 10px; }
.issue { border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: 8px; padding: 8px 12px; }
.issueHead { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.bad { color: var(--bad); font-weight: 600; text-decoration: underline wavy; }
.msg { color: var(--muted); font-size: 14px; }
.issueActions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fix { padding: 3px 10px; font-size: 14px; background: var(--chip); }
#summary { padding-left: 20px; margin: 10px 0; }
#summary li { margin: 4px 0; }
.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.num { background: var(--chip); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.numValue { font-size: 20px; font-weight: 700; }
.numLabel { font-size: 13px; color: var(--muted); }
code { background: var(--chip); padding: 3px 7px; border-radius: 6px; font-size: 13px; word-break: break-word; }
.reveal { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.reveal .col { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.reveal .col.tool { border-color: var(--accent); }
.reveal p { margin: 0; }
@media (max-width: 760px) { .reveal { grid-template-columns: 1fr; } }
.output { margin-top: 18px; }
.final { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.meta { color: var(--muted); font-size: 13px; margin: 6px 0 14px; word-break: break-word; }
.piece { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.piece summary { cursor: pointer; font-weight: 600; }
.labelled { margin: 10px 0; }
.labelled .label { font-size: 13px; color: var(--muted); }
.labelled p { margin: 2px 0 0; }
.warn { background: var(--warn-bg); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.userBox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.authCard { max-width: 420px; margin: 40px auto 0; }
#authForm { display: grid; gap: 14px; margin-top: 8px; }
#authForm label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
#authForm input {
  font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
#authForm input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.wide { width: 100%; }
.formError { color: var(--bad); font-size: 14px; margin: 0; }
.switchMode { text-align: center; color: var(--muted); font-size: 14px; margin: 16px 0 0; }
.linkButton { border: none; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; }
.busy {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; gap: 14px;
  align-items: center; justify-content: center; color: #fff; padding: 16px; text-align: center; z-index: 10;
  backdrop-filter: blur(3px);
}
.busy span { background: rgba(20, 22, 26, .9); padding: 12px 16px; border-radius: 12px; max-width: 440px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
