/* SpriteCut — styles */
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(fonts/pixelify-sans-600.woff2) format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(fonts/instrument-sans-var.woff2) format('woff2');
}

:root {
  --bg: #eef1ee;
  --panel: #ffffff;
  --panel-2: #f6f8f6;
  --ink: #17201c;
  --ink-2: #4d5c55;
  --line: #d3dbd6;
  --key: #c4146f;
  --key-ink: #ffffff;
  --key-soft: rgba(196, 20, 111, 0.12);
  --mat: #1d4a3a;
  --mat-ink: #d9efe4;
  --mat-2: #173d30;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --check-a: #e3e8e5;
  --check-b: #f7f9f8;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(23, 32, 28, 0.06), 0 8px 24px rgba(23, 32, 28, 0.06);
  --font-ui: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-pixel: 'Pixelify Sans', var(--font-ui);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --panel: #161e1b;
    --panel-2: #1b2521;
    --ink: #e4ebe7;
    --ink-2: #9aaba3;
    --line: #29352f;
    --key: #ff4fa3;
    --key-ink: #17201c;
    --key-soft: rgba(255, 79, 163, 0.16);
    --mat: #163a2e;
    --mat-2: #112e24;
    --ok: #5fd39a;
    --warn: #f0b45a;
    --check-a: #222c28;
    --check-b: #2b3631;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, canvas { display: block; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--key); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ── Header ─────────────────────────────────────────────── */
.site-header { border-bottom: 1px solid var(--line); background: var(--panel); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-pixel); font-weight: 600; font-size: 24px; letter-spacing: 0.01em; line-height: 1; }
.logo svg { width: 28px; height: 28px; flex: none; }
.site-nav { display: flex; align-items: center; gap: 20px; margin-left: auto; font-size: 15px; }
.site-nav a { text-decoration: none; color: var(--ink-2); }
.site-nav a:hover { color: var(--ink); }
.btn-support { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; font-weight: 550; font-size: 14px; color: var(--ink); background: var(--panel-2); }
.btn-support:hover { border-color: var(--ink-2); }

/* ── Hero ───────────────────────────────────────────────── */
.hero { padding: 28px 0 20px; }
.hero h1 { font-family: var(--font-pixel); font-weight: 600; font-size: clamp(28px, 3.4vw, 42px); line-height: 1.1; letter-spacing: 0.005em; margin: 0 0 10px; max-width: 26ch; text-wrap: balance; }
.hero p { margin: 0; color: var(--ink-2); font-size: 17px; max-width: 68ch; }

/* ── Workspace ──────────────────────────────────────────── */
.workspace { --stage-h: clamp(420px, calc(100vh - 200px), 700px); display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: 'stage panel' 'tray tray'; gap: 16px; align-items: start; }
.stage-card { grid-area: stage; }
.panel { grid-area: panel; max-height: var(--stage-h); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.tray { grid-area: tray; }
.stage-card, .panel, .tray { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); }

.stage-card { overflow: hidden; position: relative; }
.stage { position: relative; height: var(--stage-h); background: var(--mat); touch-action: none; user-select: none; -webkit-user-select: none; }
.stage canvas { width: 100%; height: 100%; }
.stage.is-empty canvas { cursor: default; }
.stage.can-pan canvas { cursor: grab; }
.stage.is-panning canvas { cursor: grabbing; }
.stage.is-picking canvas { cursor: crosshair; }
.stage.drag-over::after { content: ''; position: absolute; inset: 10px; border: 2px dashed var(--mat-ink); border-radius: var(--radius-s); pointer-events: none; }

.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 24px; color: var(--mat-ink); }
.empty[hidden] { display: none; }
.empty-title { font-size: 22px; font-weight: 600; margin: 0; color: #fff; }
.empty-sub { margin: 0 0 14px; font-size: 15px; opacity: 0.85; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.empty-hint { margin: 12px 0 0; font-size: 13px; opacity: 0.7; }
.empty .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.06); }
.empty .btn-ghost:hover { border-color: #fff; }

.stage-tools { position: absolute; top: 34px; right: 12px; display: flex; gap: 4px; padding: 4px; border-radius: 8px; background: rgba(10, 26, 20, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); color: #fff; }
.stage-tools[hidden] { display: none; }
.stage-tools button { min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums; }
.stage-tools button:hover { background: rgba(255, 255, 255, 0.12); }
.stage-tools .sep { width: 1px; background: rgba(255, 255, 255, 0.2); margin: 6px 2px; }
.stage-status { position: absolute; left: 34px; bottom: 12px; padding: 6px 10px; border-radius: 6px; background: rgba(10, 26, 20, 0.72); color: #fff; font-size: 13px; pointer-events: none; max-width: calc(100% - 60px); }
.stage-status[hidden] { display: none; }
.stage-status.is-warn { background: #7a4300; }

/* ── Buttons ────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid transparent; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-key { background: var(--key); color: var(--key-ink); }
.btn-key:not(:disabled):hover { filter: brightness(1.08); }
.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn-ghost:not(:disabled):hover { border-color: var(--ink-2); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ── Settings panel ─────────────────────────────────────── */
.panel { padding: 6px 0; }
.panel-section { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-section:last-child { border-bottom: 0; }
.panel h3 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field:first-of-type { margin-top: 0; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; color: var(--ink-2); }
.field-label output { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.hint { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.45; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 3px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; text-align: center; padding: 6px 8px; border-radius: 6px; font-size: 14px; font-weight: 550; color: var(--ink-2); }
.segmented input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.segmented input:focus-visible + span { outline: 2px solid var(--key); outline-offset: 1px; }

.row { display: flex; align-items: center; gap: 8px; }
.row > * { min-width: 0; }
.num { width: 100%; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); font-variant-numeric: tabular-nums; }
.num:focus { border-color: var(--key); outline: none; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
.pair .times { color: var(--ink-2); font-size: 14px; }
select.num { padding-right: 6px; }
input[type='range'] { width: 100%; accent-color: var(--key); margin: 4px 0; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; font-size: 14px; cursor: pointer; }
.check input { margin: 3px 0 0; accent-color: var(--key); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.4; margin-top: 2px; }

.bg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: var(--radius-s); border: 1px solid var(--line); position: relative; overflow: hidden; flex: none; background-image: conic-gradient(var(--check-a) 25%, var(--check-b) 0 50%, var(--check-a) 0 75%, var(--check-b) 0); background-size: 10px 10px; }
.swatch i { position: absolute; inset: 0; }
.swatch input[type='color'] { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); opacity: 0; cursor: pointer; border: 0; padding: 0; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--ink-2); }
.icon-btn[aria-pressed='true'] { border-color: var(--key); background: var(--key-soft); color: var(--key); }
.icon-btn svg { width: 18px; height: 18px; }
.bg-name { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.text-btn { background: none; border: 0; padding: 0; color: var(--key); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

[data-show-for][hidden] { display: none; }

/* ── Results tray ───────────────────────────────────────── */
.tray[hidden] { display: none; }
.tray-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.tray-title { margin: 0; font-size: 18px; font-weight: 650; }
.tray-title small { font-weight: 450; color: var(--ink-2); font-size: 14px; margin-left: 6px; }
.tray-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.tray-sel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; padding: 16px 18px 18px; max-height: 560px; overflow: auto; }
.tile { position: relative; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.tile:hover, .tile.is-hot { border-color: var(--ink-2); }
.tile.is-sel { border-color: var(--key); box-shadow: 0 0 0 1px var(--key); }
.tile-main { display: flex; flex-direction: column; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.tile-main:focus-visible { outline-offset: -3px; }
.tile-img { height: 104px; width: 100%; display: flex; align-items: center; justify-content: center; padding: 8px; background-image: conic-gradient(var(--check-a) 25%, var(--check-b) 0 50%, var(--check-a) 0 75%, var(--check-b) 0); background-size: 12px 12px; }
.tile-img canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.tile-meta { display: flex; justify-content: space-between; gap: 6px; width: 100%; padding: 6px 8px; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; border-top: 1px solid var(--line); }
.tile-meta b { color: var(--ink); font-weight: 600; }
.tile.is-sel .tile-meta { background: var(--key-soft); }
.tile-dl { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); display: none; align-items: center; justify-content: center; cursor: pointer; }
.tile-dl svg { width: 15px; height: 15px; }
.tile:hover .tile-dl, .tile:focus-within .tile-dl { display: inline-flex; }
@media (hover: none) { .tile-dl { display: inline-flex; } }

/* ── Dialogs ────────────────────────────────────────────── */
dialog { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--panel); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(10, 18, 15, 0.55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 16px 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.preview-box { display: flex; align-items: center; justify-content: center; min-height: 240px; border-radius: 8px; overflow: hidden; background-image: conic-gradient(var(--check-a) 25%, var(--check-b) 0 50%, var(--check-a) 0 75%, var(--check-b) 0); background-size: 16px 16px; }
.preview-box canvas { image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; max-height: 360px; }
.dlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.dlg-grid .field { margin-top: 0; }

/* ── Content (SEO sections) ─────────────────────────────── */
.content { padding: 64px 0 24px; }
.content section { max-width: 760px; margin: 0 0 56px; }
.content h2 { font-family: var(--font-pixel); font-weight: 600; font-size: 30px; line-height: 1.15; margin: 0 0 18px; }
.content p { margin: 0 0 14px; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 18px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 40px 1fr; gap: 14px; }
.steps li::before { content: counter(step); font-family: var(--font-pixel); font-weight: 600; font-size: 20px; width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--mat); color: #fff; }
.steps h3 { margin: 6px 0 4px; font-size: 17px; }
.steps p { margin: 0; color: var(--ink-2); }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 32px; margin: 0; }
.features dt { font-weight: 650; margin-top: 14px; }
.features dd { margin: 2px 0 0; color: var(--ink-2); }
.feature { break-inside: avoid; }
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; list-style: none; padding: 12px 28px 12px 0; font-weight: 600; font-size: 17px; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; position: absolute; right: 4px; top: 10px; font-size: 20px; color: var(--ink-2); }
.faq details[open] summary::after { content: '−'; }
.faq details p { color: var(--ink-2); margin: 0 0 14px; }

.site-footer { border-top: 1px solid var(--line); background: var(--panel); margin-top: 24px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding-top: 22px; padding-bottom: 22px; font-size: 14px; color: var(--ink-2); }
.site-footer nav { display: flex; gap: 18px; margin-left: auto; }
.site-footer a { color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); z-index: 50; }
.toast[hidden] { display: none; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 980px) {
  .workspace { --stage-h: clamp(300px, 56vh, 560px); grid-template-columns: minmax(0, 1fr); grid-template-areas: 'stage' 'tray' 'panel'; }
  .panel { max-height: none; overflow: visible; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .site-nav .nav-link { display: none; }
  .site-header .wrap { gap: 12px; }
  .hero { padding: 24px 0 16px; }
  .hero p { font-size: 16px; }
  .features { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); padding: 12px; }
  .tray-head { padding: 12px; }
  .tray-actions { margin-left: 0; width: 100%; }
  .tray-actions .btn { flex: 1; }
  .content { padding-top: 40px; }
  .content h2 { font-size: 26px; }
  .stage-status { left: 12px; }
  .dlg-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
