:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #16181d;
  --muted: #545b68;
  --border: #d7dbe2;
  --accent: #1f5fd6;
  --accent-text: #ffffff;
  --accent-soft: #e4ecfb;
  --danger: #b42318;
  --focus: #1f5fd6;
  --check-a: #e9ebef;
  --check-b: #f8f9fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #23272f;
    --text: #eceef2;
    --muted: #a6adba;
    --border: #343a45;
    --accent: #7aa7ff;
    --accent-text: #0b1220;
    --accent-soft: #1d2a44;
    --danger: #ff8a80;
    --focus: #9cbcff;
    --check-a: #22262d;
    --check-b: #2a2f37;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
a { color: var(--accent); }
img, canvas { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header.top { padding-top: 28px; padding-bottom: 8px; }
header.top h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
header.top p { margin: 0; color: var(--muted); max-width: 70ch; }
.privacy { display: inline-flex; gap: 6px; align-items: center; margin-top: 10px; font-size: .9rem; color: var(--muted); }
.privacy svg { flex: none; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.tool { margin-top: 18px; margin-bottom: 28px; display: grid; gap: 16px; }

.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 6px 0; }
.drop .hint { color: var(--muted); font-size: .92rem; }

.btn {
  font: inherit;
  font-size: .95rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; min-height: 34px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.workspace { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .workspace { grid-template-columns: 320px 1fr; align-items: start; }
  .side { position: sticky; top: 12px; }
}
.side { display: grid; gap: 14px; }
.side h2 { font-size: 1rem; margin: 0 0 8px; }
.source-box { position: relative; background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 16px 16px; border-radius: 8px; overflow: hidden; cursor: crosshair; touch-action: none; }
.source-box img { width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.focal-dot {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.55), inset 0 0 0 2px rgba(0,0,0,.35);
  pointer-events: none;
}
.source-meta { font-size: .85rem; color: var(--muted); margin: 8px 0 0; overflow-wrap: anywhere; }

.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label, .field .lbl { font-size: .88rem; font-weight: 600; }
select, input[type="color"] {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-height: 38px;
}
input[type="color"] { padding: 2px; width: 56px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: .85rem; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 11px; background: var(--surface); color: var(--text); cursor: pointer; min-height: 32px;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar .count { color: var(--muted); font-size: .92rem; }
.status { min-height: 1.4em; font-size: .9rem; color: var(--muted); }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; align-content: start; box-shadow: var(--shadow); }
.card.off { opacity: .55; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.card h3 { font-size: .95rem; margin: 0; line-height: 1.3; }
.card .dims { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { font-size: .72rem; background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.stage {
  display: flex; justify-content: center; align-items: center; min-height: 140px;
  background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 14px 14px;
  border-radius: 6px; padding: 6px;
}
.stage canvas { width: auto; height: auto; max-width: 100%; max-height: 300px; cursor: grab; touch-action: none; border-radius: 2px; }
.stage canvas:active { cursor: grabbing; }
.card-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-controls .zoom { flex: 1 1 100%; display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.legend { font-size: .78rem; color: var(--muted); margin: 0; }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

.content { padding-bottom: 30px; }
.content h2 { font-size: 1.35rem; margin: 36px 0 10px; }
.content h3 { font-size: 1.05rem; margin: 22px 0 6px; }
.content p, .content li { max-width: 75ch; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 8px 0; max-width: 80ch; }
summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 2px; }

footer { border-top: 1px solid var(--border); padding: 22px 0 36px; font-size: .92rem; color: var(--muted); }
footer ul { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
