/* FileHost: one stylesheet for every page. No inline styles (CSP). */

:root {
  color-scheme: light dark;
  --bg: #f4f4f2;
  --ink: #18181b;
  --muted: #6b6b70;
  --faint: #a1a1a6;
  --line: #e4e4e0;
  --line-strong: #d2d2cd;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --hover: #f0f0ee;
  --tint: #eef1f5;
  --track: #e4e4e0;
  --track-solid: #e4e4e0;
  --accent: #46658f;

  --error: #c0392b;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --ring: 0 0 0 3px rgb(70 101 143 / 25%);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --radius: 20px;
  --radius-sm: 14px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --ink: #ededee;
    --muted: #9c9ca3;
    --faint: #66666d;
    --line: #26262a;
    --line-strong: #34343a;
    --surface: #18181b;
    --surface-2: #202024;
    --hover: #222226;
    --tint: #1c2027;
    --track: #2c2c31;
    --track-solid: #2c2c31;
    --accent: #8ea7c9;
    --error: #ff7b6e;
    --ok: #6fcf97;
    --warn: #f0b45a;
    --ring: 0 0 0 3px rgb(142 167 201 / 30%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { margin: 0; min-height: 100vh; min-height: 100dvh; }

::selection { background: rgb(70 101 143 / 22%); }

/* ---------------------------------------------------------------- layout */

.shell {
  width: min(100% - 48px, 1140px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 3vh 0 10vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0;
}
.topbar nav { display: flex; align-items: center; gap: 6px; }
.topbar nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color .15s, color .15s;
}
.topbar nav a:hover { color: var(--ink); background: var(--hover); }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.mark { display: block; width: 22px; height: 22px; border-radius: 7px; transition: transform .3s var(--spring); }
.wordmark:hover .mark { transform: rotate(-8deg) scale(1.08); }

/* ---------------------------------------------------------------- apps menu (same on every ecchan site) */

.apps { position: relative; }
.apps > summary {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color .15s, color .15s;
}
.apps > summary::-webkit-details-marker { display: none; }
.apps > summary:hover, .apps[open] > summary { color: var(--ink); background: var(--hover); }
.apps-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 100;
  display: grid;
  grid-template-columns: repeat(3, 84px);
  gap: 4px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: pop-in .3s var(--spring);
}
.topbar .apps-menu a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: none;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .15s;
}
.topbar .apps-menu a:hover { background: var(--hover); }
.topbar .apps-menu a[aria-current] { background: var(--tint); }
.app-icon { display: block; width: 40px; height: 40px; border-radius: 12px; }

/* home: one wide centered column, header sitting right on top of it */
.home { width: min(100%, 640px); margin: 0 auto; }
body[data-page="index"] .shell { justify-content: center; padding: 4vh 0 10vh; }
body[data-page="index"] .topbar { width: min(100%, 640px); margin: 0 auto; padding: 0 4px 14px 6px; }
body[data-page="index"] main { flex: 0 0 auto; padding: 0; }
.nojs-note { padding: 0 12px 6px; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* other pages: one flat sheet, header sitting right on top of it like on home */
body:not([data-page="index"]):not([data-page="view"]) .shell { justify-content: center; padding: 4vh 0 10vh; }
body:not([data-page="index"]):not([data-page="view"]) .topbar { width: min(100%, 780px); margin: 0 auto; padding: 0 4px 14px 6px; }
body[data-page="faq"] main { flex: 0 0 auto; padding: 0; }
body:not([data-page="index"]) main > * { width: min(100%, 780px); margin-inline: auto; }
body:not([data-page="index"]) main {
  align-items: stretch;
}
.sheet, body:not([data-page="index"]) main > .prose,
body[data-page="notfound"] main, body[data-page="bundle"] main {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
body[data-page="notfound"] main, body[data-page="bundle"] main {
  flex: 0 0 auto;
  width: min(100%, 780px);
  margin: 0 auto;
  padding: clamp(26px, 4vw, 48px);
}
body[data-page="faq"] main > .prose { padding: clamp(26px, 4vw, 56px); }

/* ---------------------------------------------------------------- type */

a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: currentColor; }

h1 { font-family: var(--serif); font-size: 34px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 8px; word-break: break-word; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 20px 0 6px; }
p { margin: 0 0 12px; }

.muted { color: var(--muted); }
.fineprint, .small-print { font-size: 12px; color: var(--faint); }
.error { color: var(--error); }
.warn { color: var(--muted); }
.ok { color: var(--ok); }
p.error:empty { display: none; }

code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 7px; word-break: break-all; }
pre { background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px; overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; word-break: normal; }

/* ---------------------------------------------------------------- JS / no-JS */

html.js .no-js-only, html:not(.js) .js-only { display: none !important; }
[hidden] { display: none !important; }
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------- buttons */

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 15px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color .2s, border-color .2s, color .2s, opacity .2s, box-shadow .2s, transform .25s var(--spring);
}
.button:hover, button:hover { border-color: var(--line-strong); }
.button:active, button:active { transform: scale(.94); transition-duration: .08s; }
.button.copied, button.copied, button.copied:disabled { color: var(--ok) !important; opacity: 1; animation: pop .35s var(--spring); }
.button.primary, button.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.button.primary:hover, button.primary:hover { opacity: .88; }
.button.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.ghost:hover, button.ghost:hover { color: var(--ink); background: var(--hover); }
#delete-all.danger, #delete-all.danger:hover { color: var(--error); background: transparent; border-color: currentColor; animation: nudge .4s var(--ease); }
button.wide { width: 100%; }
button:disabled, .button.disabled { opacity: .45; cursor: default; pointer-events: none; }

:focus-visible { outline: none; box-shadow: var(--ring); }
a:focus-visible { border-radius: 6px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0; }

/* ---------------------------------------------------------------- upload card */

.card {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 300px;
  padding: 40px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--tint);
  text-align: center;
  cursor: pointer;
  transition: border-color .25s, background-color .25s, transform .35s var(--spring);
}
.drop:hover { border-color: var(--accent); }
.drop:hover .drop-icon { transform: translateY(-4px); color: var(--accent); border-color: var(--accent); }
.drop:active { transform: scale(.99); }
body.dragging .drop { transform: scale(1.015); }
body.dragging .drop-icon { color: var(--accent); border-color: var(--accent); animation: bob 1s var(--ease) infinite; }
.drop:focus-within { box-shadow: var(--ring); }
body.dragging .drop { border-style: solid; border-color: var(--accent); }

html.js .drop input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
html:not(.js) .drop input[type="file"] { font: inherit; font-size: 13px; }

.drop-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  transition: transform .35s var(--spring), color .25s, border-color .25s;
}
.drop-title { font-size: 16px; font-weight: 500; }
.drop-title u { text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.drop-hint { font-size: 13px; color: var(--muted); }
.drop-limit { margin-top: 6px; font-size: 12px; }

/* expiry: a radio group drawn as a segmented control. Without JS the checked segment is
   highlighted directly; with JS a glider slides to it (app.js sets --n and --i). */
.expiry-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 2px 2px 8px;
}
.expiry-label { font-size: 13.5px; font-weight: 500; }

.segments {
  --n: 1;
  --i: 0;
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.segment {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 56px;
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  user-select: none;
  transition: color .2s, background-color .2s, box-shadow .2s;
}
.segment input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segment span { transition: transform .25s var(--spring); }
.segment:hover { color: var(--ink); }
.segment:active span { transform: scale(.92); }
.segment:has(input:checked) { color: var(--ink); font-weight: 600; }
.segment:has(input:focus-visible) { box-shadow: var(--ring); }

.segment-glider, html:not(.js) .segment:has(input:checked) {
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgb(0 0 0 / 8%);
}
.segment-glider {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--n));
  border-radius: 999px;
  transform: translateX(calc(var(--i) * 100%));
}
.segments.ready .segment-glider { transition: transform .4s var(--spring); }

@media (max-width: 520px) {
  .segments { width: 100%; }
  .segment { min-width: 0; padding: 0 6px; }
}

.nojs-row { display: flex; justify-content: flex-end; padding: 14px 2px 2px; }

/* ---------------------------------------------------------------- results and history */

#results:empty { display: none; }

.notice, .batch, #results > .rows, #history-list, #resume-list > .rows {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}
.notice { font-size: 13px; color: var(--muted); padding: 12px 16px; margin: 0 0 12px; }
.batch { margin-bottom: 12px; }
.batch:last-child, #results > :last-child { margin-bottom: 0; }

.batch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  background: var(--tint);
}
.batch-title { font-weight: 600; flex: 1; }

.rows { list-style: none; margin: 0; padding: 0; }

.row, .history-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.rows > li:first-child { border-top: 0; }
.row, .history-row.enter, .notice, .batch { animation: rise .4s var(--ease) both; }
.history-row { transition: background-color .2s; }
.history-row:hover { background: var(--hover); }
.row.failed { animation: nudge .4s var(--ease); }

.row-name {
  order: 0;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
a.row-name:hover { text-decoration: underline; }

.pct, .row-status, .expiry, .size, .downloads, .countdown {
  order: 1;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.row-status.error { color: var(--error); white-space: normal; }
.row.failed .row-name { color: var(--muted); }
.countdown.expired { color: var(--error); }

.row-actions { order: 2; display: flex; gap: 2px; }
.row-actions .button { background: transparent; border-color: transparent; color: var(--muted); }
.row-actions .button:hover { color: var(--ink); background: var(--hover); }

.row progress { order: 3; flex-basis: 100%; }

progress {
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent) 0 35%, color-mix(in srgb, var(--accent) 55%, var(--surface)) 50%, var(--accent) 65% 100%) 0 0 / 300% 100%;
  animation: shimmer 1.6s linear infinite;
  transition: width .3s var(--ease);
}
progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent) 0 35%, color-mix(in srgb, var(--accent) 55%, var(--surface)) 50%, var(--accent) 65% 100%) 0 0 / 300% 100%;
  animation: shimmer 1.6s linear infinite;
}

#resume-list > p { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }

#history { margin-top: 18px; }

/* Recent: type icon, name over one line of facts, icon actions on the right */
#history-list { border-radius: 16px; }
.history-row { flex-wrap: nowrap; gap: 12px; padding: 10px 8px 10px 12px; }
.row-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--tint);
  color: var(--muted);
}
.history-row.e2e .row-icon { color: var(--accent); }
.row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-main .row-name { flex: none; font-size: 14px; }
.row-meta { display: flex; flex-wrap: wrap; align-items: baseline; font-size: 12px; color: var(--muted); }
.row-meta > * { order: 0; }
.row-meta > [hidden] { display: none; }
.row-meta > :not(:first-child)::before { content: "·"; margin: 0 6px; color: var(--faint); }
.row-meta .ttl.soon, .row-meta .ttl.soon .countdown { color: var(--warn); }
.row-meta .ttl.expired, .row-meta .ttl.expired .countdown { color: var(--error); }
.row-meta .row-error { color: var(--error); }
.history-row .row-actions { flex: none; gap: 0; }
.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
}
.icon-button:hover { color: var(--ink); background: var(--hover); border-color: transparent; }
.history-row:hover .icon-button:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.icon-button.danger:hover { color: var(--error); }
.icon-button.busy { opacity: .4; cursor: progress; }
.icon-button.copied svg { display: none; }
.icon-button.copied::after { content: "✓"; font-size: 15px; }
@media (max-width: 520px) {
  .history-row { gap: 10px; }
  .row-icon { display: none; }
}
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding: 0 6px; }
#history-note { margin: 12px 0 0; text-align: center; }

/* ---------------------------------------------------------------- view and bundle pages */

.filename { margin-bottom: 4px; }
.preview { margin: 20px 0; }
.preview:empty { display: none; }
.preview img, .preview video {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.preview audio { width: 100%; }
.text-preview { max-height: 55vh; white-space: pre-wrap; word-break: break-word; }

/* single file: no sheet, the file itself is the page. Header, hero and info row share one
   column (--col); for images and video it is the width the media renders at (e2e.js sets
   --ar and --nw from the decoded media), never narrower than a readable header. */
body[data-page="view"] { --stage-h: calc(100dvh - 260px); --col: min(100%, 680px); }
body[data-page="view"][data-kind="text"] { --col: min(100%, 880px); }
body[data-page="view"][data-kind="image"], body[data-page="view"][data-kind="video"] { --col: 100%; }
body[data-page="view"].hero-ready { --col: max(min(var(--nw), var(--stage-h) * var(--ar), 100%), min(100%, 420px)); }
body[data-page="view"] .shell { justify-content: center; padding: 3vh 0 6vh; }
body[data-page="view"] .topbar { width: var(--col); margin: 0 auto; padding: 0 0 12px; }
body[data-page="view"] main { flex: 0 0 auto; padding: 0; }
body[data-page="view"] main > * { width: var(--col); }
body[data-page="view"].hero-ready #view-body .preview img,
body[data-page="view"].hero-ready #view-body .preview video {
  width: 100%; height: auto; max-width: min(100%, var(--nw), var(--stage-h) * var(--ar)); max-height: none;
}

#view-body .preview { margin: 0 0 16px; }
#view-body .preview img, #view-body .preview video {
  width: auto;
  max-height: var(--stage-h);
  min-height: 0;
  border: 0;
  border-radius: 12px;
  background: #000;
}
#view-body .preview img { background: none; }
#view-body .text-preview { max-height: calc(100dvh - 300px); margin: 0; }
.preview-loading {
  display: grid;
  place-items: center;
  min-height: 40vh;
  margin: 0;
  border-radius: 12px;
  background: var(--tint);
}
#view-body[data-kind="audio"] .preview-loading, #view-body[data-kind="text"] .preview-loading { min-height: 120px; }

.view-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.view-title { flex: 1 1 280px; min-width: 0; }
.view-title .filename {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.view-title p { margin: 0; font-size: 13px; }
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#view-body > .error:not(:empty) { margin: 14px 0 0; }

/* bundles: name, then Download all · Copy link · QR on one line, then the files */
body[data-page="view"][data-kind="bundle"] { --col: min(100%, 780px); }
.bundle-info .view-title .filename { font-size: 22px; }
.bundle-info .view-actions { flex-wrap: nowrap; }
.filename.renamed { animation: pop .35s var(--spring); }
.filename.editable { cursor: text; border-radius: 8px; transition: background-color .2s, box-shadow .2s; }
.filename.editable:hover { background: var(--hover); box-shadow: 0 0 0 6px var(--hover); }
.rename-input {
  width: 100%;
  height: 36px;
  margin: 0 0 2px;
  padding: 0 10px;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--ring);
  outline: none;
  animation: fade .2s var(--ease);
}
.rename-error:empty { display: none; }
.rename-error { margin: 10px 0 0; font-size: 13px; }

/* nothing to show: name and actions stand alone, centered */
#view-body[data-kind="none"] .view-info { flex-direction: column; text-align: center; }
#view-body[data-kind="none"] .view-title { flex: none; max-width: 100%; }
#view-body[data-kind="none"] .filename { font-family: var(--serif); font-size: 30px; font-weight: 400; white-space: normal; word-break: break-word; }
#view-body[data-kind="none"] .view-title p { margin-top: 6px; }

.tree {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.tree-row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.tree-row:first-child { border-top: 0; }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
a.tree-name:hover { text-decoration: underline; }
.tree-row.dir .tree-name { color: var(--muted); }
.depth-1 { padding-left: calc(16px + 1 * 16px); }
.depth-2 { padding-left: calc(16px + 2 * 16px); }
.depth-3 { padding-left: calc(16px + 3 * 16px); }
.depth-4 { padding-left: calc(16px + 4 * 16px); }
.depth-5 { padding-left: calc(16px + 5 * 16px); }
.depth-6 { padding-left: calc(16px + 6 * 16px); }
.depth-7 { padding-left: calc(16px + 7 * 16px); }
.depth-8 { padding-left: calc(16px + 8 * 16px); }
.depth-9 { padding-left: calc(16px + 9 * 16px); }
.depth-10 { padding-left: calc(16px + 10 * 16px); }
.depth-11 { padding-left: calc(16px + 11 * 16px); }
.depth-12 { padding-left: calc(16px + 12 * 16px); }
.depth-13 { padding-left: calc(16px + 13 * 16px); }
.depth-14 { padding-left: calc(16px + 14 * 16px); }
.depth-15 { padding-left: calc(16px + 15 * 16px); }

/* ---------------------------------------------------------------- QR dialog */

.qr-dialog {
  max-width: min(92vw, 360px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: none;
}
.qr-dialog::backdrop { background: rgb(0 0 0 / 35%); animation: fade .25s var(--ease); }
.qr-dialog[open] { animation: pop-in .35s var(--spring); }
.qr-inner { padding: 22px; display: flex; flex-direction: column; align-items: center; }
.qr-svg { width: 220px; height: auto; padding: 12px; background: #fff; border-radius: 16px; }
.qr-dialog .actions { margin: 14px 0 0; justify-content: center; }

/* ---------------------------------------------------------------- prose (FAQ) */

.prose h1 { font-size: 44px; margin-bottom: 18px; }
.prose h2 { font-size: 15px; font-weight: 600; color: var(--ink); margin: 32px 0 8px; }
.prose p, .prose li, .prose dd { color: var(--muted); line-height: 1.7; }
.prose strong { color: var(--ink); font-weight: 500; }
.prose ul { padding-left: 18px; margin: 0 0 12px; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--accent); }
.prose table { border-collapse: collapse; width: 100%; font-size: 13px; }
.prose td { border-top: 1px solid var(--line); padding: 8px 10px 8px 0; vertical-align: top; }

/* ---------------------------------------------------------------- small screens, motion */

@media (max-width: 520px) {
  .shell { width: min(100% - 28px, 1140px); }
  .topbar { padding: 18px 0; }
  .drop { min-height: 200px; }
}

/* ---------------------------------------------------------------- motion */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(8px); } }
@keyframes nudge { 20%, 60% { transform: translateX(-3px); } 40%, 80% { transform: translateX(3px); } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.tree-row { transition: background-color .2s; }
.tree-row:hover { background: var(--hover); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- admin */

.admin-shell main { justify-content: flex-start; padding-top: 0; }
.admin-shell canvas.globe { --globe-sea: #e9edf3; --globe-land: #d3d8df; --globe-edge: rgb(255 255 255 / 70%); }
@media (prefers-color-scheme: dark) {
  .admin-shell canvas.globe { --globe-sea: #171b22; --globe-land: #2e333b; --globe-edge: rgb(0 0 0 / 45%); }
}

.admin-gate { width: min(100%, 380px); margin: 8vh auto 0; padding: 32px 28px 26px; text-align: center; }
.admin-gate h1 { margin: 14px 0 4px; font-size: 20px; letter-spacing: -0.01em; }
.admin-gate .muted { margin: 0 0 20px; }
.admin-gate-icon {
  width: 52px; height: 52px; margin: 0 auto; display: grid; place-items: center;
  border-radius: 50%; background: var(--tint); color: var(--accent);
}
.admin-gate-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.admin-input {
  width: 100%; height: 38px; margin: 0 0 10px; padding: 0 14px;
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px;
}
.admin-input:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.admin-alt { margin-top: 6px; }
.admin-msg { min-height: 1.4em; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.admin-msg.error { color: var(--error); }

.admin { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.admin-geo { position: sticky; top: 16px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.admin-geo-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.globe-wrap { aspect-ratio: 1; width: 100%; }
canvas.globe { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
canvas.globe:active { cursor: grabbing; }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--hover); border-radius: 999px; }
.seg button { height: 26px; padding: 0 10px; font-size: 12px; border-color: transparent; background: transparent; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.seg button:active { transform: none; }

.geo-top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.geo-top button {
  position: relative; width: 100%; height: 34px; padding: 0 10px; gap: 10px; justify-content: flex-start;
  border-color: transparent; background: transparent; border-radius: var(--radius-sm); overflow: hidden;
}
.geo-top button:hover, .geo-top button.on { background: var(--hover); }
.geo-top button:active { transform: none; }
.geo-flag { font-size: 16px; line-height: 1; }
.geo-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.geo-n { font-variant-numeric: tabular-nums; color: var(--muted); }
.geo-bar { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; border-radius: 2px; background: var(--track); }
.geo-bar::after { content: ""; display: block; width: var(--w); height: 100%; border-radius: inherit; background: var(--accent); }
.geo-empty { padding: 8px 10px; }
.geo-note { margin: 0; font-size: 12px; }

.admin-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.site-switch { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; }
.site-switch.off { border-color: color-mix(in srgb, var(--error) 50%, var(--line)); background: color-mix(in srgb, var(--error) 7%, var(--surface)); }
.site-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.site-switch.off .site-dot { background: var(--error); box-shadow: 0 0 0 4px color-mix(in srgb, var(--error) 18%, transparent); }
.site-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.site-switch.off .site-text strong { color: var(--error); }
.site-switch button { flex: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stat-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat strong { white-space: nowrap; font-size: 21px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--faint); }

.admin-list { padding: 6px 6px 8px; }
.admin-list > header { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; }
.admin-list h2 { margin: 0; font-size: 14px; }
.admin-list .chip { padding: 1px 8px; font-size: 12px; border-radius: 999px; background: var(--hover); color: var(--muted); font-variant-numeric: tabular-nums; }
.admin-list.held { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.admin-list.held h2 { color: var(--warn); }
.admin-empty { padding: 4px 12px 10px; margin: 0; }

.frow {
  display: grid; grid-template-columns: minmax(0, 1fr) 130px 64px auto; align-items: center; gap: 14px;
  padding: 8px 8px 8px 12px; border-radius: var(--radius-sm);
}
.frow:hover { background: var(--hover); }
.fmain { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fname { color: var(--ink); text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname:hover { text-decoration: underline; }
.fmeta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.fmeta > span:nth-child(3) { font-family: var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
.fmeta .tag { color: var(--accent); font-weight: 600; }
.fbudget { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { display: block; height: 4px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter::after { content: ""; display: block; height: 100%; width: calc(var(--v) * 100%); background: var(--accent); border-radius: inherit; }
.meter.hot::after { background: var(--warn); }
.fleft { order: 0; font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.factions { display: flex; gap: 4px; justify-content: flex-end; }
button.small { height: 28px; padding: 0 11px; font-size: 12px; }
button.danger:hover { color: var(--error); }

/* security events */
.admin-list.security > header { flex-wrap: wrap; }
.sec-note { margin-left: auto; font-size: 12px; }
.sec-kinds { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.sec-kind {
  height: 30px; padding: 0 10px; gap: 8px; font-size: 12px; color: var(--muted);
  background: var(--hover); border-color: transparent; border-radius: 999px;
}
.sec-kind strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.sec-kind.on { background: var(--surface-2); border-color: var(--accent); color: var(--ink); }
.sec-kind:active { transform: none; }
.sec-chart { display: flex; align-items: flex-end; gap: 2px; height: 56px; margin: 0 12px 10px; }
.sec-bar { flex: 1; min-width: 1px; height: max(2px, calc(var(--h) * 100%)); border-radius: 2px 2px 0 0; background: var(--warn); opacity: .85; }
.sec-bar.zero { background: var(--track); opacity: 1; }
.sec-bar:hover { opacity: 1; }
.sec-countries { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 0 12px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.sec-events { display: flex; flex-direction: column; }
.sec-row {
  display: grid; grid-template-columns: 58px 100px 30px minmax(0, 1fr) 22px; align-items: center; gap: 10px;
  padding: 6px 8px 6px 12px; border-radius: var(--radius-sm); font-size: 12px;
}
.sec-row:hover { background: var(--hover); }
.sec-when { color: var(--muted); white-space: nowrap; }
.sec-tag { color: var(--warn); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-tag.k-ratelimit, .sec-tag.k-held { color: var(--muted); }
.sec-status { color: var(--faint); font-variant-numeric: tabular-nums; }
.sec-req { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: baseline; white-space: nowrap; }
.sec-method { font-family: var(--mono); color: var(--muted); }
.sec-path { font-family: var(--mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.sec-ua { grid-column: 1 / -1; font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
.sec-cc { font-size: 14px; text-align: center; }
.sec-more { margin: 6px 12px 2px; align-self: flex-start; }

.admin-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; font-size: 12px; }

@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .admin-geo { position: static; }
  .globe-wrap { width: min(100%, 320px); margin: 0 auto; }
}
@media (max-width: 560px) {
  .frow { grid-template-columns: minmax(0, 1fr) auto; }
  .fbudget, .fleft { display: none; }
  .sec-row { grid-template-columns: 52px 84px minmax(0, 1fr) 22px; gap: 8px; }
  .sec-status { display: none; }
  .sec-note { margin-left: 0; width: 100%; }
}
