:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --fg: #16181d;
  --muted: #5b6270;
  --line: #dfe3ea;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --danger: #b42318;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --fg: #e8eaee;
    --muted: #a3aab8;
    --line: #2c313b;
    --accent: #5b8cff;
    --accent-fg: #0b0d12;
    --danger: #ff8a7a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

header.site { background: var(--surface); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
header.site nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
header.site nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
header.site nav a[aria-current="page"] { color: var(--fg); font-weight: 600; }

main { padding-top: 20px; padding-bottom: 40px; }
h1 { font-size: 28px; line-height: 1.25; margin: 8px 0 8px; }
h2 { font-size: 21px; margin: 36px 0 10px; }
.lede { color: var(--muted); margin: 0 0 18px; }

/* ---------- tool ---------- */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 32px 16px; text-align: center;
}
.drop.over { border-color: var(--accent); }
.drop-title { font-size: 19px; font-weight: 600; margin: 0 0 4px; }
.drop-sub, .drop-note { color: var(--muted); margin: 6px 0; font-size: 15px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 10px; }
.toolbar label { font-size: 15px; color: var(--muted); }
.toolbar input[type="range"] { width: 140px; }

/* The stage shrinks to the image so the whole picture and the buttons fit on one screen;
   #paint is stretched over #img, and app.js maps pointer positions through its rect. */
.stage {
  position: relative; width: fit-content; max-width: 100%; margin: 0 auto; line-height: 0;
  background: repeating-conic-gradient(var(--line) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
}
#img { display: block; width: auto; height: auto; max-width: 100%; max-height: 65vh; }
#paint { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0.5; touch-action: none; cursor: crosshair; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
button {
  font: inherit; font-size: 15px; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.status { min-height: 1.6em; margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.status.error { color: var(--danger); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* ---------- content ---------- */
ol.steps { padding-left: 22px; }
ol.steps li { margin: 6px 0; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--fg); }
.card span { display: block; color: var(--muted); font-size: 15px; margin-top: 4px; }

footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
footer.site .wrap { padding-top: 18px; padding-bottom: 28px; }
footer.site nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }

@media (min-width: 720px) {
  h1 { font-size: 34px; }
  .tool { padding: 20px; }
}
