:root {
  --bg: #f6f5fb; --panel: #ffffff; --panel-2: #f1f0f8; --ink: #1c1a2e; --muted: #6b6883; --line: #dcd9ea;
  --accent: #6d5ae6; --accent-soft: #c9bfff; --accent-ink: #ffffff; --stripe: rgba(109, 90, 230, .06);
  --ok: #1f8a4c; --warn: #9a5b00;
  --check1: #e6e4f0; --check2: #ffffff; --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 40, .06), 0 8px 24px -16px rgba(20, 18, 40, .25);
}
/* Dark palette: applies when the system is dark and the user hasn't forced light, or when the user forced dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f16; --panel: #1b1a28; --panel-2: #23222f; --ink: #f1f0f7; --muted: #9b98b3; --line: #2f2d40;
    --accent: #a78bfa; --accent-soft: #8b7cff; --accent-ink: #17162a; --stripe: rgba(167, 139, 250, .07);
    --ok: #6fd39a; --warn: #ffc466;
    --check1: #2a2937; --check2: #1b1a28;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -16px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
    --bg: #0f0f16; --panel: #1b1a28; --panel-2: #23222f; --ink: #f1f0f7; --muted: #9b98b3; --line: #2f2d40;
    --accent: #a78bfa; --accent-soft: #8b7cff; --accent-ink: #17162a; --stripe: rgba(167, 139, 250, .07);
    --ok: #6fd39a; --warn: #ffc466;
    --check1: #2a2937; --check2: #1b1a28;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -16px rgba(0, 0, 0, .6);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9em; }
main, .top { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 22px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo-mark { flex: none; }
.wordmark { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.wordmark .accent { color: var(--accent); }
.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.topnav a:hover { color: var(--accent); }
.theme-toggle { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; }
}
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }
.hero { margin-top: 26px; }
.hero h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; line-height: 1.2; }
.lede { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { padding: 0 18px; height: 42px; font-size: 15px; border-radius: 10px; }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 500; }

/* ---- workbench: intake (left) + settings (right) ---- */
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 20px; }
@media (max-width: 900px) { .workbench { grid-template-columns: 1fr; } }

.intake { display: flex; flex-direction: column; gap: 12px; }
.dropzone { position: relative; display: flex; align-items: center; gap: 18px; min-height: 148px; padding: 16px 20px; border: 2px dashed var(--accent-soft); border-radius: var(--radius); background: var(--panel) repeating-linear-gradient(135deg, transparent 0 14px, var(--stripe) 14px 28px); transition: border-color .15s, box-shadow .15s; }
.dropzone.drag, .dropzone:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px var(--stripe); outline: none; }
.dz-source { display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; flex: none; }
.dz-title { margin: 0; font-weight: 700; font-size: 14px; line-height: 1.3; text-align: center; }
.preview { width: 56px; height: 56px; border-radius: 10px; padding: 4px; background: conic-gradient(var(--check1) 25%, var(--check2) 0 50%, var(--check1) 0 75%, var(--check2) 0) 0 0 / 12px 12px; border: 1px solid var(--line); }
.dz-actions { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; min-width: 0; }
.dz-actions .btn.big { flex: 1 1 130px; }
.urlform { flex: 1 1 130px; display: flex; }
.urlform input { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--ink); font: inherit; font-size: 14px; }
.urlform input:focus { border-color: var(--accent); outline: none; }
.sample-row { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 2px; }
.sample { width: 50px; height: 50px; padding: 6px; border: 2px solid var(--line); border-radius: 10px; background: var(--panel) conic-gradient(var(--check1) 25%, var(--check2) 0 50%, var(--check1) 0 75%, var(--check2) 0) 0 0 / 12px 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.sample:hover { border-color: var(--accent-soft); }
.sample.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--stripe), 0 0 0 1px var(--accent); }
.sample img { width: 100%; height: 100%; object-fit: contain; display: block; }

.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-content: start; }
@media (max-width: 480px) { .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.setting { position: relative; display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; color: var(--ink); font: inherit; text-align: left; transition: border-color .15s; }
.setting:hover, .setting:focus-within { border-color: var(--accent); }
.setting-icon { flex: none; width: 22px; height: 22px; display: grid; place-items: center; color: var(--muted); }
.setting-icon svg { width: 18px; height: 18px; }
.setting-icon .mini-preview { width: 22px; height: 22px; border-radius: 5px; object-fit: contain; }
.setting-icon .arrow { transition: transform .2s; }
.setting-icon .arrow.dir-down { transform: rotate(90deg); }
.setting-icon .arrow.dir-left { transform: rotate(180deg); }
.setting-icon .arrow.dir-up { transform: rotate(-90deg); }
.setting-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.setting-label { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.setting-value { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setting .chevron { flex: none; width: 16px; height: 16px; color: var(--muted); }
.setting select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; appearance: none; border: 0; margin: 0; }
.setting-btn .setting-value { font-size: 14px; }

/* ---- results ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 20px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .n { font-weight: 500; opacity: .7; font-size: 11px; }
.star { color: var(--warn); font-size: 11px; }
.toolbar input { padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); font: inherit; width: 260px; max-width: 100%; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; padding-bottom: 60px; }
.card { display: flex; flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.card[hidden] { display: none; }
.thumb { position: relative; flex: none; width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; overflow: hidden; background: conic-gradient(var(--check1) 25%, var(--check2) 0 50%, var(--check1) 0 75%, var(--check2) 0) 0 0 / 8px 8px; }
.thumb img { width: 32px; height: 32px; object-fit: contain; display: block; }
.card.loading .thumb img { opacity: .25; }
.spinner { position: absolute; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: none; }
.card.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.name { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.actions { display: flex; align-items: center; gap: 4px; flex: none; }
.icon-btn { width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); text-decoration: none; cursor: pointer; font: inherit; font-size: 14px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; z-index: 10; }

/* ---- about / SEO copy ---- */
.about { margin-top: 44px; max-width: 860px; }
.about h2 { font-size: 20px; margin: 0 0 10px; letter-spacing: -.01em; }
.about h3 { font-size: 15px; margin: 18px 0 6px; }
.about p { margin: 0; color: var(--muted); }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { margin: 6px 0; }
.steps strong, .steps em { color: var(--ink); }
.style-list { columns: 2; column-gap: 28px; list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--muted); }
@media (max-width: 640px) { .style-list { columns: 1; } }
.style-list li { break-inside: avoid; margin: 4px 0; }
.style-list code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: var(--ink); }
.foot { max-width: 1140px; margin: 48px auto 32px; padding: 16px 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.foot a { color: inherit; }
