:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --ink: #1b2120;
  --muted: #5d6865;
  --line: #d9ddd8;
  --accent: #0f6e63;
  --accent-ink: #ffffff;
  --accent-soft: #dcefeb;
  --good: #1f7a3a;
  --bad: #b3261e;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141917; --surface: #1c2220; --ink: #e8ece9; --muted: #9aa6a2; --line: #2e3633;
    --accent: #3fbfac; --accent-ink: #0b1513; --accent-soft: #19332e; --good: #5cc77a; --bad: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141917; --surface: #1c2220; --ink: #e8ece9; --muted: #9aa6a2; --line: #2e3633;
  --accent: #3fbfac; --accent-ink: #0b1513; --accent-soft: #19332e; --good: #5cc77a; --bad: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5;
}
.wrap {
  max-width: 880px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 40px 56px;
  display: grid; gap: 28px;
}
header { display: grid; gap: 6px; }
h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 6vw, 3.2rem);
  letter-spacing: -0.02em; line-height: 1; margin: 0; text-wrap: balance;
}
h1 span { color: var(--accent); }
.lede { color: var(--muted); margin: 0; max-width: 60ch; }

.controls {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px;
}
@media (max-width: 860px) { .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .controls { grid-template-columns: 1fr; } }
.ctl { display: grid; gap: 6px; min-width: 0; }
.ctl label, .ctl .lbl {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  display: flex; justify-content: space-between; gap: 8px;
}
select { width: 100%; font: 500 13px var(--font-mono); padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); }
.ctl output { font-family: var(--font-mono); font-size: 13px; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 500; }
.ctl small { color: var(--muted); font-size: 12px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--ink); font: 500 13px var(--font-mono);
  padding: 7px 4px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.drop {
  border: 2px dashed var(--line); border-radius: 12px; background: var(--surface);
  padding: 44px 20px; text-align: center; cursor: pointer; display: grid; gap: 6px; justify-items: center;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop strong { font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; }
.drop span { color: var(--muted); font-size: 13px; }
.drop svg { width: 34px; height: 34px; stroke: var(--accent); }

.bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.stats { font-family: var(--font-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--ink); font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  font: 600 14px var(--font-body); border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .seg button:focus-visible, .row button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.list { display: grid; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.list:empty { display: none; }
.row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 12px 14px;
}
.row + .row { border-top: 1px solid var(--line); }
.thumb {
  width: 64px; height: 64px; border-radius: 6px; object-fit: cover; display: block;
  background: repeating-conic-gradient(var(--line) 0% 25%, transparent 0% 50%) 50% / 12px 12px;
}
.thumb.wait { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.meta { min-width: 0; display: grid; gap: 2px; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name em { font-style: normal; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-left: 6px; }
.nums { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.save { color: var(--good); font-weight: 500; }
.worse { color: var(--bad); font-weight: 500; }
.err { color: var(--bad); font-size: 13px; }
.row .rb { display: flex; gap: 6px; }
.row button {
  border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 7px;
  padding: 6px 10px; font: 500 13px var(--font-body); cursor: pointer;
}
.row button.dl { border-color: var(--accent); color: var(--accent); }
.row button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 520px) {
  .row { grid-template-columns: 52px minmax(0, 1fr); }
  .thumb { width: 52px; height: 52px; }
  .row .rb { grid-column: 1 / -1; justify-content: flex-end; }
}

.note { display: grid; gap: 10px; color: var(--muted); font-size: 14px; max-width: 68ch; }
.note h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; color: var(--ink); margin: 0; }
.note p { margin: 0; }
.note code { font-family: var(--font-mono); font-size: 13px; color: var(--ink); }

dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  padding: 0; max-width: min(96vw, 1100px); width: 100%;
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
.cmp { display: grid; gap: 10px; padding: 14px; }
.cmp-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.cmp-head span { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.cmp-stage { position: relative; overflow: hidden; border-radius: 8px; max-height: 75vh; user-select: none; touch-action: none; }
.cmp-stage img { display: block; width: 100%; height: auto; max-height: 75vh; object-fit: contain; }
.cmp-stage .top { position: absolute; inset: 0; clip-path: inset(0 0 0 50%); }
.cmp-stage .top img { width: 100%; height: 100%; }
.cmp-line { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--accent); pointer-events: none; }
.tag { position: absolute; top: 8px; font: 500 11px var(--font-mono); background: rgb(0 0 0 / .6); color: #fff; padding: 3px 7px; border-radius: 4px; }
.tag.l { left: 8px; } .tag.r { right: 8px; }
@media (prefers-reduced-motion: reduce) { .thumb.wait { animation: none; } .drop { transition: none; } }