/* Satchel — deep teal (#0E5E63) and warm sand (#E2C79F) */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --brand: #0E5E63;          /* white text on it: 7.5:1 */
  --brand-strong: #0A4A4E;
  --brand-text: #0E5E63;     /* teal used as text on light surfaces */
  --on-brand: #FFFFFF;
  --sand: #E2C79F;
  --on-sand: #3B2A12;        /* 10:1 on sand */
  --accent-text: #85561A;    /* sand hue darkened for text and links: 5.6:1 on white */
  --bg: #F7F4EE;
  --surface: #FFFFFF;
  --surface-2: #F1ECE3;
  --hover: rgba(14, 94, 99, 0.08);
  --text: #1D2324;
  --muted: #586264;          /* 5.6:1 on bg */
  --border: #DDD5C8;
  --mark: #F4E3C3;
  --notice: #FBF3E4;
  --danger: #B3261E;
  --focus: #0E5E63;
  --pdf-bg: #E6E1D8;
  --j-key: #0E5E63;
  --j-str: #1A6B33;
  --j-num: #1E4FA8;
  --j-bool: #8A3FA0;
  --j-null: #586264;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --reading-size: 16px;
  --radius: 12px;
  --ease: 180ms ease;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

html[data-theme="dark"] {
  --brand: #0E5E63;
  --brand-strong: #0A4A4E;
  --brand-text: #7CC8CB;
  --accent-text: #E2C79F;
  --bg: #121416;
  --surface: #1B1E21;
  --surface-2: #25292D;
  --hover: rgba(124, 200, 203, 0.10);
  --text: #E8E6E1;
  --muted: #A3ABAD;
  --border: #353B40;
  --mark: #5C4A28;
  --notice: #2A2620;
  --danger: #E0645C;
  --focus: #7CC8CB;
  --pdf-bg: #0D0F10;
  --j-key: #7CC8CB;
  --j-str: #8FD19E;
  --j-num: #8DB4FF;
  --j-bool: #D69CF0;
  --j-null: #A3ABAD;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --brand: #0E5E63;
    --brand-strong: #0A4A4E;
    --brand-text: #7CC8CB;
    --accent-text: #E2C79F;
    --bg: #121416;
    --surface: #1B1E21;
    --surface-2: #25292D;
    --hover: rgba(124, 200, 203, 0.10);
    --text: #E8E6E1;
    --muted: #A3ABAD;
    --border: #353B40;
    --mark: #5C4A28;
    --notice: #2A2620;
    --danger: #E0645C;
    --focus: #7CC8CB;
    --pdf-bg: #0D0F10;
    --j-key: #7CC8CB;
    --j-str: #8FD19E;
    --j-num: #8DB4FF;
    --j-bool: #D69CF0;
    --j-null: #A3ABAD;
    color-scheme: dark;
  }
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }

.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { flex: none; width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: var(--radius); transition: background var(--ease); }
.icon-btn:hover { background: var(--hover); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  transition: opacity var(--ease), transform var(--ease), visibility 0s linear 0s;
}
.screen:not(.active) {
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--ease), transform var(--ease), visibility 0s linear 180ms;
}
#home:not(.active) { transform: translateX(-24px); }
#viewer:not(.active) { transform: translateX(24px); }

.home-head, .topbar {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + var(--sat));
  padding: var(--sat) max(6px, var(--sar)) 0 max(6px, var(--sal));
  background: var(--brand);
  color: var(--on-brand);
}
.home-head .icon-btn:hover, .topbar .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.home-head .icon-btn:focus-visible, .topbar .icon-btn:focus-visible { outline-color: var(--sand); }

/* ---------- home ---------- */
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding-left: 10px; }
.brand img { border-radius: 9px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .01em; }
.home-scroll { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.home-inner {
  max-width: 640px; margin: 0 auto;
  padding: 24px max(16px, var(--sar)) calc(32px + var(--sab)) max(16px, var(--sal));
}
.open-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; min-height: 72px;
  border-radius: var(--radius);
  background: var(--brand); color: var(--on-brand);
  font-size: 20px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(14, 94, 99, .28);
  transition: background var(--ease), transform var(--ease);
}
.open-btn .ic { width: 28px; height: 28px; }
.open-btn:hover { background: var(--brand-strong); }
.open-btn:active { transform: scale(.985); }
.privacy { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 0; color: var(--muted); font-size: 15px; }
.privacy .ic { width: 18px; height: 18px; color: var(--brand-text); }
.drop-hint { display: none; margin: 4px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
@media (hover: hover) and (pointer: fine) { .drop-hint { display: block; } }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-top: 32px; }
.section-head h2 { margin: 0; font-size: 18px; }
.link-btn {
  min-height: 44px; padding: 0 8px;
  color: var(--accent-text); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
  border-radius: 8px;
}
.link-btn:hover { background: var(--hover); }

#recent-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
#recent-list:empty { display: none; }
.recent-item { display: flex; align-items: center; }
.recent-item + .recent-item { border-top: 1px solid var(--border); }
.recent-open {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 8px 4px 8px 12px;
  text-align: left;
  transition: background var(--ease);
}
.recent-open:hover { background: var(--hover); }
.recent-text { flex: 1; min-width: 0; }
.recent-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-remove { margin-right: 6px; color: var(--muted); }
.recent-note { margin: 8px 0 0; padding: 16px; text-align: center; color: var(--muted); font-size: 15px; border: 1px dashed var(--border); border-radius: var(--radius); }
.formats-row { display: flex; justify-content: center; margin-top: 24px; }

.drop-overlay {
  position: absolute; inset: 12px;
  display: none; place-items: center;
  border: 3px dashed var(--brand-text); border-radius: var(--radius);
  background: rgba(14, 94, 99, .12);
  color: var(--brand-text); font-size: 22px; font-weight: 700;
  pointer-events: none;
}
#home.dragging .drop-overlay { display: grid; }

/* badges: white text on each colour is at least 4.5:1 */
.badge {
  flex: none;
  display: inline-grid; place-items: center;
  min-width: 50px; height: 30px; padding: 0 6px;
  border-radius: 8px;
  background: var(--b, #3F454B); color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: .05em;
}
.badge[data-f="pdf"]  { --b: #A63A2B; }
.badge[data-f="markdown"] { --b: #3D5A80; }
.badge[data-f="docx"] { --b: #2B579A; }
.badge[data-f="xlsx"] { --b: #1E6E42; }
.badge[data-f="csv"]  { --b: #4F6D2A; }
.badge[data-f="json"] { --b: #8A4B08; }
.badge[data-f="code"] { --b: #4B4F9C; }
.badge[data-f="image"] { --b: #9C3D6E; }
.badge[data-f="audio"] { --b: #7A3E9D; }
.badge[data-f="video"] { --b: #B0304F; }
.badge[data-f="zip"]  { --b: #6E5A2E; }
.badge[data-f="html"] { --b: #A0451A; }
.badge[data-f="text"] { --b: #55606A; }
.badge[data-f="hex"]  { --b: #3F454B; }
.badge.sand { background: var(--sand); color: var(--on-sand); }

/* ---------- viewer ---------- */
#viewer-title { flex: 1; min-width: 0; margin: 0 4px; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.vroot { position: absolute; inset: 0; display: flex; flex-direction: column; }
.viewer-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.subbar {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  min-height: 48px;
  padding: 2px max(6px, var(--sar)) 2px max(12px, var(--sal));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.subbar-info { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 12px;
  border-radius: var(--radius);
  font-size: 15px; font-weight: 600;
  transition: background var(--ease), color var(--ease);
}
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.chip .ic { width: 20px; height: 20px; }
.zoom-label { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }
.notice { flex: none; margin: 0; padding: 8px 16px; background: var(--notice); border-bottom: 1px solid var(--border); font-size: 14px; }
.notice.error-line { color: var(--danger); font-weight: 600; }

.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; height: 100%; padding: 24px; color: var(--muted); text-align: center; }
.loading p { margin: 0; max-width: 100%; overflow-wrap: anywhere; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--border); border-top-color: var(--brand-text); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-card { max-width: 460px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.error-card .ic { width: 48px; height: 48px; color: var(--danger); }
.error-card h2 { margin: 12px 0 8px; font-size: 19px; overflow-wrap: anywhere; }
.error-card p { margin: 0 0 24px; color: var(--muted); }
.error-card .btn-row { justify-content: center; }
.empty-note { padding: 48px 24px; text-align: center; color: var(--muted); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; text-decoration: none;
  transition: background var(--ease), filter var(--ease);
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.danger { background: var(--danger); color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* find */
.find-bar {
  flex: none;
  display: flex; align-items: center; gap: 2px;
  padding: 4px max(4px, var(--sar)) 4px max(8px, var(--sal));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
#find-input {
  flex: 1; min-width: 0; height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px;
}
#find-count { flex: none; min-width: 60px; padding: 0 4px; text-align: center; font-size: 14px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
mark.find-hit { background: var(--mark); color: inherit; border-radius: 2px; }
mark.find-hit.cur { background: var(--sand); color: var(--on-sand); box-shadow: 0 0 0 2px var(--accent-text); }

/* ---------- sheets ---------- */
#sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .42);
  opacity: 0; visibility: hidden;
  transition: opacity var(--ease), visibility 0s linear 180ms;
}
#sheet-backdrop.open { opacity: 1; visibility: visible; transition: opacity var(--ease); }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; max-height: 86vh; max-height: 86dvh;
  margin: 0 auto;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px max(16px, var(--sar)) calc(16px + var(--sab)) max(16px, var(--sal));
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .2);
  transform: translateY(100%); visibility: hidden;
  transition: transform var(--ease), visibility 0s linear 180ms;
}
#sheet.open { transform: none; visibility: visible; transition: transform var(--ease); }
.sheet-grip { width: 40px; height: 4px; margin: 0 auto 4px; border-radius: 2px; background: var(--border); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#sheet-title { margin: 0; font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
#sheet-body { padding-top: 8px; }
#sheet-body p { margin: 0 0 12px; }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: 16px;
  width: 100%; min-height: 52px; padding: 0 8px;
  border-radius: var(--radius);
  color: var(--text); text-align: left; text-decoration: none; font-size: 17px;
}
.menu-list button:hover, .menu-list a:hover { background: var(--hover); }
.menu-list .ic { color: var(--brand-text); }
.toc a { min-height: 44px; font-size: 16px; }
.toc .lv2 { padding-left: 24px; }
.toc .lv3 { padding-left: 40px; color: var(--muted); }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.field-label { display: block; margin: 16px 0 8px; font-weight: 600; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--surface-2); }
.seg button { flex: 1; min-height: 44px; border-radius: 9px; font-weight: 600; transition: background var(--ease), color var(--ease); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.size-preview { margin: 12px 0 0; color: var(--muted); }
.cell-full { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.goto-row { display: flex; gap: 8px; }
.goto-row input {
  flex: 1; min-width: 0; height: 48px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; font-size: 18px;
}
.formats-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.formats-list li { display: flex; gap: 12px; align-items: flex-start; }
.formats-list strong { display: block; }
.formats-list span.ext { display: block; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--sab)); z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: var(--radius);
  background: #1D2324; color: #fff; font-size: 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity var(--ease), transform var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reading (markdown, docx) ---------- */
.reading {
  max-width: 760px; margin: 0 auto;
  padding: 16px max(16px, var(--sar)) calc(64px + var(--sab)) max(16px, var(--sal));
  font-size: var(--reading-size); line-height: 1.65;
  overflow-wrap: break-word;
}
.reading h1, .reading h2, .reading h3, .reading h4 { line-height: 1.25; margin: 1.4em 0 .5em; scroll-margin-top: 8px; }
.reading h1 { font-size: 1.75em; }
.reading h2 { font-size: 1.4em; padding-bottom: .2em; border-bottom: 1px solid var(--border); }
.reading h3 { font-size: 1.18em; }
.reading > :first-child { margin-top: 0; }
.reading a { color: var(--accent-text); }
.reading img { max-width: 100%; height: auto; }
.reading code { font-family: var(--mono); font-size: .88em; padding: .1em .35em; border-radius: 5px; background: var(--surface-2); }
.reading pre { overflow-x: auto; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); line-height: 1.5; }
.reading pre code, .reading pre code.hljs { padding: 0; background: transparent; font-size: .85em; }
.reading blockquote { margin: 1em 0; padding: 0 0 0 16px; border-left: 4px solid var(--sand); color: var(--muted); }
.reading table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1em 0; }
.reading th, .reading td { padding: 6px 12px; border: 1px solid var(--border); }
.reading th { background: var(--surface-2); }
.reading hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.reading ul, .reading ol { padding-left: 1.5em; }
.reading li > input[type="checkbox"] { margin: 0 .4em 0 -1.3em; vertical-align: middle; }
.reading li:has(> input[type="checkbox"]) { list-style: none; }
.blocked-img { display: inline-block; padding: 2px 8px; border: 1px dashed var(--border); border-radius: 6px; color: var(--muted); font-size: .85em; }

/* ---------- code ---------- */
.code-scroll { background: var(--surface); }
.code {
  width: max-content; min-width: 100%;
  padding: 8px 0 calc(48px + var(--sab));
  font-family: var(--mono); font-size: calc(var(--reading-size) * .85); line-height: 1.6;
  counter-reset: ln;
  -webkit-text-size-adjust: none;
}
.code .ln { display: flex; min-height: 1.6em; }
.code .ln::before {
  counter-increment: ln; content: counter(ln);
  position: sticky; left: 0; z-index: 1;
  flex: none; width: var(--gw, 4ch); padding: 0 10px 0 8px; box-sizing: content-box;
  text-align: right; color: var(--muted);
  background: var(--surface-2); border-right: 1px solid var(--border);
  -webkit-user-select: none; user-select: none;
}
.code .lc { flex: 1 1 auto; padding: 0 16px 0 12px; white-space: pre; }
.code.wrap { width: auto; }
.code.wrap .lc { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.code .ln.ln-err { background: rgba(179, 38, 30, .12); }
.code .ln.ln-err::before { color: var(--danger); font-weight: 700; }

/* ---------- table (csv, xlsx) ---------- */
.table-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.table-scroll { background: var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 14px; }
.grid th, .grid td { padding: 0; white-space: nowrap; text-align: left; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.grid th:first-child, .grid td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border); }
.grid th:first-child { z-index: 3; }
.grid th button { display: flex; align-items: center; gap: 4px; width: 100%; min-height: 44px; padding: 0 8px 0 12px; font-weight: 700; white-space: nowrap; text-align: left; }
.grid th button:hover { background: var(--hover); }
.grid .sort-ind { width: 14px; flex: none; color: var(--brand-text); font-size: 11px; }
.grid td .cv { max-width: 240px; padding: 0 12px; line-height: 44px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid td .cv.cut { cursor: pointer; }
.grid tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.sheet-tabs {
  flex: none;
  display: flex; gap: 4px;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 4px max(8px, var(--sar)) calc(4px + var(--sab)) max(8px, var(--sal));
  background: var(--surface); border-top: 1px solid var(--border);
}
.sheet-tabs button {
  flex: none; max-width: 200px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-tabs button[aria-selected="true"] { background: var(--brand); color: var(--on-brand); }

/* ---------- pdf ---------- */
.pdf-scroll { position: relative; background: var(--pdf-bg); touch-action: pan-x pan-y; }
.pdf-pages {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: max-content; min-width: 100%;
  padding: 16px 16px calc(88px + var(--sab));
  transform-origin: 0 0;
}
.pdf-page { position: relative; flex: none; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.28); }
.pdf-page canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.pdf-pill {
  position: absolute; left: 50%; bottom: calc(16px + var(--sab)); z-index: 5;
  transform: translateX(-50%);
  min-height: 44px; padding: 0 18px; border-radius: 22px;
  background: rgba(20, 26, 28, .86); color: #fff;
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

/* ---------- image ---------- */
.img-stage {
  position: relative; overflow: hidden; touch-action: none; cursor: zoom-in;
  background-color: var(--surface-2);
  background-image: conic-gradient(var(--surface) 25%, transparent 0 50%, var(--surface) 0 75%, transparent 0);
  background-size: 20px 20px;
}
.img-stage.zoomed { cursor: grab; }
.img-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }

/* ---------- media ---------- */
.media-scroll { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px max(16px, var(--sar)) calc(24px + var(--sab)) max(16px, var(--sal)); }
.media-scroll video { display: block; max-width: 100%; max-height: 68vh; border-radius: var(--radius); background: #000; }
.media-scroll audio { width: 100%; max-width: 520px; }
.media-art { width: 120px; height: 120px; display: grid; place-items: center; border-radius: 24px; background: var(--brand); color: var(--sand); }
.media-art .ic { width: 56px; height: 56px; }
.media-name { margin: 0; max-width: 100%; font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.media-dur { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- html ---------- */
iframe.html-frame { flex: 1; min-height: 0; width: 100%; border: 0; display: block; background: #fff; }

/* ---------- zip ---------- */
.zip-list { list-style: none; margin: 0; padding: 4px 0 calc(32px + var(--sab)); }
.zip-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 52px;
  padding: 4px max(16px, var(--sar)) 4px calc(max(16px, var(--sal)) + var(--d, 0) * 18px);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
button.zip-row:hover { background: var(--hover); }
.zip-row .ic { color: var(--brand-text); }
.zip-dir { color: var(--muted); font-weight: 600; }
.zip-dir .ic { color: var(--accent-text); }
.zip-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zip-size { flex: none; color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- hex ---------- */
.hex { width: max-content; min-width: 100%; margin: 0; padding: 8px 12px calc(48px + var(--sab)); font-family: var(--mono); font-size: 13px; line-height: 1.6; white-space: pre; }
.hex .o { color: var(--muted); }
.hex .a { color: var(--accent-text); }

/* ---------- json ---------- */
.json-tree { padding: 8px 0 calc(48px + var(--sab)); font-family: var(--mono); font-size: calc(var(--reading-size) * .85); line-height: 1.5; }
.jrow { display: flex; align-items: flex-start; gap: 6px; width: 100%; min-height: 30px; padding: 3px 12px 3px calc(12px + var(--d, 0) * 16px); text-align: left; }
button.jrow { min-height: 44px; align-items: center; }
button.jrow:hover { background: var(--hover); }
.jcaret { flex: none; width: 16px; display: inline-grid; place-items: center; color: var(--muted); transition: transform 150ms ease; }
.jcaret .ic { width: 16px; height: 16px; }
.jnode.open > .jrow .jcaret { transform: rotate(90deg); }
.jleaf .jcaret { visibility: hidden; }
.jk { color: var(--j-key); flex: none; max-width: 60%; overflow-wrap: anywhere; }
.jv { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.j-str { color: var(--j-str); }
.j-num { color: var(--j-num); }
.j-bool { color: var(--j-bool); font-weight: 600; }
.j-null { color: var(--j-null); font-style: italic; }
.jsum { color: var(--muted); }
.jnode.open > .jrow .jsum { display: none; }
.jnode:not(.open) > .jkids, .jnode:not(.open) > .jclose { display: none; }
.jnode.open > .jrow .jclosed { display: none; }

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