:root {
  --paper: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --ink: #17171c;
  --ink-2: #3a3a42;
  --muted: #6b6a72;
  --line: #e3dfd6;
  --line-strong: #cfc9bd;
  --accent: #e4572e;
  --danger: #c23a3a;
  --ok: #1d7f55;
  --radius: 10px;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
main.wrap { flex: 1; padding-top: 40px; padding-bottom: 72px; }
.muted { color: var(--muted); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246, 244, 239, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; letter-spacing: -.01em; flex: none; }
.brand img { display: block; }
.crumb { display: flex; align-items: baseline; gap: 6px; }
.crumb-station { color: var(--muted); font-weight: 500; }
.crumb-slash { color: var(--line-strong); }
.crumb b { font-weight: 600; }
.brand:hover .crumb-station { color: var(--ink-2); }
.privacy-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 5px 10px; border-radius: 99px;
  font-size: 13px; color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 22%, var(--surface));
}
.privacy-pill svg, .station-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.station-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.station-link:hover { color: var(--ink); }

/* hero */
.hero { margin-bottom: 26px; }
.eyebrow { margin: 0 0 12px; font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0; font-size: clamp(30px, 4vw, 44px); line-height: 1.1; letter-spacing: -.025em; font-weight: 600; max-width: 16em; }
.hero p { margin: 14px 0 0; color: var(--ink-2); font-size: 17px; max-width: 38em; }

.chips {
  display: flex; gap: 6px; margin: 0 0 24px; padding: 4px; overflow-x: auto; scrollbar-width: none;
  width: fit-content; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
}
.chip:hover { background: var(--paper); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* layout */
.tool-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .tool-layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.options { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
@media (max-width: 900px) { .options { position: static; max-height: none; } }

/* drop zone */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 44px 16px; text-align: center; cursor: pointer;
  color: var(--muted); transition: border-color .15s, background .15s; background: var(--paper);
}
.drop svg { width: 34px; height: 34px; margin-bottom: 6px; fill: none; stroke: var(--ink-2); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.drop.over, .drop:hover, .drop:focus-visible { border-color: var(--ink); background: var(--surface-2); outline: none; }
.drop strong { color: var(--ink); font-size: 17px; font-weight: 600; }
.has-files .drop { flex-direction: row; justify-content: center; padding: 14px 16px; gap: 10px; }
.has-files .drop svg { width: 20px; height: 20px; margin: 0; }
.has-files .drop strong { font-size: 14.5px; }
.has-files .drop span { display: none; }

.list-head { display: flex; align-items: center; gap: 12px; margin: 16px 0 0; font-size: 14px; flex-wrap: wrap; }
.list-head #list-count { font-weight: 600; }
.list-head .btn { margin-left: auto; }

/* file list */
.files { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 10px; background: var(--paper); border: 1px solid var(--line);
}
.thumb { width: 48px; height: 48px; border-radius: 6px; overflow: hidden; display: grid; place-items: center;
  background: repeating-conic-gradient(#e9e5dc 0 25%, #f7f5f0 0 50%) 0 0 / 10px 10px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ext { font: 500 11px var(--mono); color: var(--muted); }
.file-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.file-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font: 12.5px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .arrow { color: var(--muted); margin-right: 6px; }
.file-meta .out { color: var(--ink-2); }
.file-meta.err { color: var(--danger); font-family: var(--sans); white-space: normal; }
.file-meta.note { font-family: var(--sans); }
.file-side { display: flex; align-items: center; gap: 4px; }
.badge { font: 500 12.5px var(--mono); padding: 2px 7px; border-radius: 6px; margin-right: 4px; white-space: nowrap; }
.badge.down { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.badge.up { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.state { font-size: 12.5px; color: var(--muted); margin-right: 6px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.state.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.file.stale .badge, .file.stale .out { opacity: .45; }

.icon-btn {
  border: 0; background: transparent; cursor: pointer; width: 32px; height: 32px; border-radius: 7px;
  display: grid; place-items: center; color: var(--muted); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.dl { color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.icon-btn.dl:hover { border-color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* options */
.opt-group { display: flex; flex-direction: column; gap: 9px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.ctl-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sub-label { display: block; font-size: 12.5px; color: var(--muted); margin: 2px 0 6px; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.hint:empty { display: none; }
.fmt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.fmt-grid button {
  padding: 9px 4px; border: 1.5px solid var(--line); border-radius: 9px; background: var(--paper);
  font: 500 13.5px var(--mono); cursor: pointer; transition: border-color .12s, background .12s;
}
.fmt-grid button:hover { border-color: var(--line-strong); }
.fmt-grid button[aria-checked="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; }
.seg-btn { flex: 1; padding: 7px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--ink); }
.range-row output { font: 500 13.5px var(--mono); min-width: 2.5em; text-align: right; }
.inline-row { display: flex; align-items: center; gap: 8px; }
.num, .select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); outline: none;
}
.num { width: 84px; }
.num.wide { width: 120px; }
.select { width: 100%; }
.num:focus, .select:focus { border-color: var(--ink); }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; }
.check.disabled { color: var(--muted); cursor: default; }
#r-box { display: flex; flex-direction: column; gap: 8px; }
.ico-sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ico-sizes label {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font: 13px var(--mono); cursor: pointer;
}
.ico-sizes input { accent-color: var(--ink); margin: 0; }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); cursor: pointer; }
#bg-note { font-size: 12.5px; }
.info-box { margin: 0 0 14px; padding: 10px 12px; border-radius: 9px; background: var(--paper); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 11px 18px;
  border: 1px solid var(--ink); border-radius: 8px; background: var(--ink); color: var(--paper); font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--ink-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.block { width: 100%; }
.btn.block + .btn.block { margin-top: 8px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.small { padding: 6px 12px; font-size: 13.5px; }

/* compare viewer */
body.no-scroll { overflow: hidden; }
.cmp-back { position: fixed; inset: 0; z-index: 50; background: rgba(23,23,28,.7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; }
.cmp {
  position: relative; max-width: min(1100px, 100%); max-height: calc(100vh - 110px); overflow: hidden; border-radius: 8px; user-select: none; touch-action: none; cursor: ew-resize;
  background: repeating-conic-gradient(#e9e5dc 0 25%, #f7f5f0 0 50%) 0 0 / 16px 16px;
}
.cmp img { display: block; max-width: 100%; max-height: calc(100vh - 110px); }
.cmp .after { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; clip-path: inset(0 0 0 var(--cut, 50%)); }
.cmp .bar { position: absolute; top: 0; bottom: 0; left: var(--cut, 50%); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); pointer-events: none; }
.cmp .bar::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.cmp .tag { position: absolute; top: 10px; padding: 3px 8px; border-radius: 6px; background: rgba(23,23,28,.75); color: #fff; font: 12px var(--mono); pointer-events: none; }
.cmp .tag.l { left: 10px; }
.cmp .tag.r { right: 10px; }
.cmp-foot { display: flex; align-items: center; gap: 14px; color: #fff; font-size: 14px; }
.cmp-foot .btn { background: #fff; color: var(--ink); border-color: #fff; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px; transition: .2s; z-index: 60; font-size: 14px;
}
#toast.show { transform: translateX(-50%); opacity: 1; }

.site-footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: 14px; }
.footer-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 28px; }
  .topbar-row { gap: 10px; }
  .crumb-station, .crumb-slash, .station-link { display: none; }
  .panel { padding: 14px; }
  .file { grid-template-columns: 44px minmax(0, 1fr); }
  .thumb { width: 44px; height: 44px; }
  .file-side { grid-column: 1 / -1; justify-content: flex-end; }
}

/* background editor */
.rm-row { justify-content: space-between; }
.rm-row span { font-size: 12.5px; }
.bg-editor {
  display: flex; flex-direction: column; gap: 14px; width: min(760px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 18px; border-radius: 14px; background: var(--surface);
}
.bg-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bg-head h2 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; }
.bg-head .select { width: auto; max-width: 100%; }
.bg-stage {
  position: relative; display: grid; place-items: center; min-height: 200px; border-radius: 10px; overflow: hidden;
  background: repeating-conic-gradient(#e9e5dc 0 25%, #f7f5f0 0 50%) 0 0 / 16px 16px;
}
.bg-stage canvas { display: block; max-width: 100%; max-height: 55vh; }
.bg-loading { position: absolute; font-size: 14px; color: var(--muted); }
.bg-controls { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 14px; }
.bg-controls .hint { grid-column: 1 / -1; }
.bg-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bg-foot .grow { flex: 1; }
[data-act="hold"] { user-select: none; touch-action: none; }
