:root {
  --bg: #eef2f6;
  --paper: #ffffff;
  --paper-2: #f6f8fb;
  --ink: #15202b;
  --ink-2: #566472;
  --line: #d9e0e8;
  --accent: #0d7c86;
  --accent-ink: #ffffff;
  --accent-soft: #d8f0f1;
  --coral: #ff6b57;
  --coral-deep: #d94a37;
  --good: #17734a;
  --good-soft: #dcf1e5;
  --bad: #b3361f;
  --bad-soft: #fbe2dc;
  --warn: #8a5a00;
  --warn-soft: #fbefd2;
  --focus: #1f5fbf;
  --shadow: 0 1px 0 rgba(21, 32, 43, 0.05), 0 14px 30px -20px rgba(21, 32, 43, 0.4);
  --r: 18px;
  --r-s: 10px;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121820;
    --paper: #1b232d;
    --paper-2: #212b36;
    --ink: #e8eef4;
    --ink-2: #a2b0be;
    --line: #2f3b48;
    --accent: #4fc6cf;
    --accent-ink: #0b1a1c;
    --accent-soft: #173538;
    --coral: #ff7a66;
    --coral-deep: #ff9b8a;
    --good: #6fd3a0;
    --good-soft: #17322a;
    --bad: #ff9a85;
    --bad-soft: #3b211c;
    --warn: #f3c463;
    --warn-soft: #3a2f16;
    --focus: #8ab4ff;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 30px -20px rgba(0, 0, 0, 0.85);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }
body {
  font-family: var(--body);
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 160px;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }

.top { padding: 36px 0 22px; }
.brand { font-family: var(--round); font-weight: 800; letter-spacing: 0.01em; display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px var(--accent-soft); }
h1 { font-family: var(--round); font-size: clamp(1.9rem, 6vw, 2.8rem); line-height: 1.08; margin-top: 10px; letter-spacing: -0.01em; }
h1 em { font-style: normal; color: var(--accent); }
.lede { color: var(--ink-2); margin-top: 12px; max-width: 58ch; font-size: 1.05rem; }

.steps { display: grid; gap: 16px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.panel h2 { font-family: var(--round); font-size: 1.25rem; display: flex; align-items: center; gap: 10px; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 0.95rem; flex: none; }

.kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 14px; }
.kind {
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  text-align: left; font: inherit; color: inherit; background: var(--paper-2); border: 2px solid var(--line);
  border-radius: 14px; padding: 10px 12px; cursor: pointer; min-height: 60px;
}
.kind:hover { border-color: var(--accent); }
.kind[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.kind-shape { grid-row: 1 / 3; justify-self: center; border: 2px solid var(--ink-2); border-radius: 4px; background: linear-gradient(180deg, transparent 55%, var(--line) 55%); position: relative; }
.kind-shape::after { content: ""; position: absolute; left: 50%; top: 22%; width: 38%; height: 38%; transform: translateX(-50%); border-radius: 50%; background: var(--ink-2); opacity: 0.6; }
.kind-shape.is-sign { background: none; }
.kind-shape.is-sign::after { top: 40%; width: 70%; height: 3px; border-radius: 2px; }
.kind[aria-checked="true"] .kind-shape { border-color: var(--accent); }
.kind-name { font-weight: 650; font-size: 0.95rem; line-height: 1.25; }
.kind-meta { color: var(--ink-2); font-size: 0.82rem; }
.note { margin-top: 12px; color: var(--ink-2); font-size: 0.92rem; }

.rules { margin-top: 10px; }
.rules summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.95rem; padding: 6px 0; }
.rule-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 8px; }
.rule-grid label { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; }
.unit { color: var(--ink-2); font-weight: 400; }
input:not([type]), input[inputmode], select {
  font: inherit; color: var(--ink); background: var(--paper-2); border: 1.5px solid var(--line);
  border-radius: var(--r-s); padding: 8px 10px; min-height: 42px; width: 100%;
}
input:focus-visible, select:focus-visible { border-color: var(--focus); }
.hint { color: var(--ink-2); font-size: 0.86rem; margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--accent); border-radius: 999px;
  padding: 10px 18px; min-height: 44px; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 6px 14px; min-height: 38px; font-size: 0.9rem; }
.btn.big { font-size: 1.1rem; padding: 12px 26px; min-height: 52px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[download]:not([href]) { opacity: 0.45; pointer-events: none; }
.link { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 6px 2px; min-height: 36px; }

.drop {
  margin-top: 14px; border: 2px dashed var(--line); border-radius: var(--r); padding: 26px 16px; text-align: center;
  background: var(--paper-2); display: grid; justify-items: center; gap: 6px; transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-big { font-family: var(--round); font-weight: 750; font-size: 1.15rem; }
.drop-small { color: var(--ink-2); font-size: 0.9rem; }
.drop-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.drop input:focus-visible + label, .drop-btns:focus-within .btn { outline: none; }
#file:focus-visible ~ .drop-btns label[for="file"], .drop-btns label:focus-within { outline: 3px solid var(--focus); }

.was { margin-top: 14px; }
.was-title { font-weight: 650; font-size: 0.92rem; }
.err { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-s); background: var(--bad-soft); color: var(--bad); font-weight: 600; }

.checks { list-style: none; padding: 0; display: grid; gap: 6px; margin-top: 8px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; font-size: 0.93rem; padding: 6px 10px; border-radius: var(--r-s); }
.checks .ico { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; margin-top: 1px; }
.checks .ok { background: var(--good-soft); color: var(--good); }
.checks .ok .ico { background: var(--good); color: var(--paper); }
.checks .no { background: var(--bad-soft); color: var(--bad); }
.checks .no .ico { background: var(--bad); color: var(--paper); }
.checks .warn { background: var(--warn-soft); color: var(--warn); }
.checks .warn .ico { background: var(--warn); color: var(--paper); }

.ask { margin-top: 10px; font-weight: 650; min-height: 1.5em; }
.stage-wrap { margin-top: 12px; display: flex; justify-content: center; }
.stage {
  display: block; border-radius: 6px; background: repeating-conic-gradient(var(--paper-2) 0 25%, var(--line) 0 50%) 0 0 / 18px 18px;
  box-shadow: 0 0 0 1px var(--line), 0 10px 26px -16px rgba(0, 0, 0, 0.5); touch-action: none; cursor: crosshair;
}
.editor:not(.marking) .stage { cursor: grab; }
.stage:active { cursor: grabbing; }
.tools { margin-top: 14px; display: grid; gap: 10px; }
.slide { display: grid; grid-template-columns: 92px 1fr; align-items: center; font-weight: 600; font-size: 0.9rem; }
.slide input { width: 100%; accent-color: var(--accent); min-height: 32px; }
.tool-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.keys { margin-top: 0; }

.result { display: grid; grid-template-columns: minmax(0, 200px) 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.result img { width: 100%; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); background: #fff; }
.result-side { display: grid; gap: 10px; justify-items: start; }
.sheet { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.sheet h3 { font-family: var(--round); font-size: 1.1rem; }
.sheet-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-top: 10px; }
.pick { display: grid; gap: 4px; font-size: 0.85rem; font-weight: 600; min-width: 210px; }
.sheet-view { display: block; margin-top: 12px; max-width: 100%; border-radius: 4px; box-shadow: 0 0 0 1px var(--line); background: #fff; }

.foot { margin-top: 28px; color: var(--ink-2); font-size: 0.9rem; }

.snap-dock { position: fixed; right: 16px; bottom: 16px; display: grid; justify-items: end; gap: 6px; z-index: 5; pointer-events: none; }
.snap-dock > * { pointer-events: auto; }
.bubble {
  max-width: min(300px, calc(100vw - 32px)); background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  border-radius: 16px 16px 4px 16px; padding: 10px 14px; font-size: 0.93rem; line-height: 1.4; box-shadow: var(--shadow);
}
.bubble:empty { display: none; }
.bubble.pop { animation: pop 0.25s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(0.96); opacity: 0; } }
.snap { width: 84px; height: 78px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 22px; }
.snap svg { width: 100%; height: 100%; overflow: visible; }
.s-shell { fill: var(--coral); stroke: #2a1714; stroke-width: 3.5; }
.s-top { fill: var(--coral-deep); stroke: #2a1714; stroke-width: 3.5; }
.s-strip { fill: rgba(42, 23, 20, 0.16); }
.s-bulb { fill: #fff6cf; stroke: #2a1714; stroke-width: 3; }
.s-flash { fill: none; stroke: #ffc928; stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; opacity: 0; }
.s-ring { fill: #f4f1ea; stroke: #2a1714; stroke-width: 3.5; }
.s-lens { fill: #1d2a3a; }
.s-pupil { fill: #6fd0d8; transition: transform 0.12s ease-out; }
.s-glint { fill: #fff; }
.s-eye { transition: transform 0.12s ease-out; }
.s-lid { fill: var(--coral); stroke: #2a1714; stroke-width: 2.5; opacity: 0; }
.s-mouth { fill: none; stroke: #2a1714; stroke-width: 3.5; stroke-linecap: round; display: none; }
.m-wow { fill: #2a1714; }
.s-cheek { fill: #ff9d8f; opacity: 0.8; }
.s-think { fill: var(--ink-2); display: none; }
.snap[data-mood="happy"] .m-happy, .snap[data-mood="sleepy"] .m-flat, .snap[data-mood="thinking"] .m-flat,
.snap[data-mood="worried"] .m-worry, .snap[data-mood="wow"] .m-wow { display: inline; }
.snap[data-mood="sleepy"] .s-lid { opacity: 1; }
.snap[data-mood="thinking"] .s-think { display: inline; }
.snap[data-mood="wow"] .s-flash, .snap[data-mood="happy"] .s-flash { opacity: 1; }
.snap[data-mood="wow"] .s-bulb { fill: #ffe066; }
.snap[data-mood="worried"] .s-pupil { fill: #ff9a85; }
.snap.blink .s-lid { opacity: 1; }
.snap.hop { animation: hop 0.45s ease-out; }
.snap.wiggle { animation: wiggle 0.5s ease-in-out; }
@keyframes hop { 40% { transform: translateY(-10px); } }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.snap-hide { font: inherit; font-size: 0.8rem; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; min-height: 30px; }
.snap-dock.tucked .bubble, .snap-dock.tucked .snap-hide { display: none; }
.snap-dock.tucked .snap { width: 46px; height: 44px; opacity: 0.85; }

@media (max-width: 560px) {
  .rule-grid { grid-template-columns: repeat(2, 1fr); }
  .result { grid-template-columns: 1fr; }
  .result img { max-width: 220px; }
  .panel { padding: 16px; }
  .top { padding-top: 24px; }
  .snap { width: 70px; height: 65px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (pointer: coarse) {
  .keys { display: none; }
}
