:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --ink: #1f1b16;
  --ink-2: #5b5348;
  --ink-3: #8a8174;
  --line: #e4ddd0;
  --accent: #1d5c63;
  --accent-soft: #e3efef;
  --gloss: #7a4b12;
  --note-bg: #fff6d6;
  --note-line: #e8cf78;
  --hl: #fdeec0;
  --hl-soft: #f2ebdc;
  --tr-line: #a9cbcd;
  --star: #c4921a;
  --danger: #a33a2a;
  --shadow: 0 6px 24px rgba(40, 30, 10, .14);
  --ar-size: 1.75rem;
  --uz-size: 1.02rem;
  --lh: 1;
  --ar-font: "Scheherazade New", "Amiri", "Noto Naskh Arabic", serif;
  --ui-font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --surface: #1d1a15; --ink: #ece6da; --ink-2: #b9b0a1; --ink-3: #857c6e;
    --line: #2f2a22; --accent: #7cc4c9; --accent-soft: #1f3335; --gloss: #e3b06a;
    --note-bg: #2b2614; --note-line: #6b5a1f; --hl: #3a3215; --hl-soft: #24211a; --tr-line: #2f5a5d;
    --star: #e3b448; --danger: #e08070; --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15130f; --surface: #1d1a15; --ink: #ece6da; --ink-2: #b9b0a1; --ink-3: #857c6e;
  --line: #2f2a22; --accent: #7cc4c9; --accent-soft: #1f3335; --gloss: #e3b06a;
  --note-bg: #2b2614; --note-line: #6b5a1f; --hl: #3a3215; --hl-soft: #24211a; --tr-line: #2f5a5d;
  --star: #e3b448; --danger: #e08070; --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--ui-font);
}
body.noscroll { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
button:focus-visible, .w:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.hint { color: var(--ink-3); font-size: .82rem; margin: 6px 0; }
kbd {
  font: 600 .78rem/1 var(--ui-font); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 2px 6px; background: var(--bg); white-space: nowrap;
}

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transition: transform .22s ease;
}
.bar.hide { transform: translateY(-100%); }
.bar-in {
  max-width: 1240px; margin: 0 auto; padding: 6px 12px;
  display: flex; align-items: center; gap: 8px;
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; min-width: 0; overflow: hidden; }
.brand .home { text-decoration: none; color: var(--ink-3); font-size: .85rem; }
.brand .t-ar { font-family: var(--ar-font); font-size: 1.35rem; line-height: 1.2; white-space: nowrap; }
.brand .t-ch {
  border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--ink-2); font-size: .9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.brand .t-ch::before { content: "›"; margin-right: 8px; color: var(--ink-3); }
.brand .t-ch:hover { color: var(--accent); }
.controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.toggles { display: flex; gap: 6px; margin-right: 4px; }
.tg {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 4px 12px; font-size: .85rem; cursor: pointer; color: var(--ink-2);
}
.tg[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.tg:disabled { opacity: .4; cursor: default; }
.tg.sm { padding: 2px 10px; font-size: .8rem; }
.ib {
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2);
  display: inline-grid; place-items: center; cursor: pointer; padding: 0; position: relative;
}
.ib:hover { background: var(--accent-soft); color: var(--accent); }
.ib.aa { font: 600 1.05rem/1 Georgia, serif; }
.ib.aa.owner::after {
  content: ""; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent);
}
.ic { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.progress { height: 2px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* ---------- reading column ---------- */
main { max-width: 860px; margin: 0 auto; padding: 8px 16px 120px; }
body.rows main { max-width: 920px; }
.ch-head { text-align: center; padding: 28px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.ch-head .ar { text-align: center; font-size: calc(var(--ar-size) * 1.15); line-height: 1.7; }
.ch-head .ar.sub { font-size: var(--ar-size); color: var(--accent); }
.ch-head .uz { color: var(--ink-2); margin-top: 6px; }
.ch-head .pages { color: var(--ink-3); font-size: .85rem; }
.flow-hint { text-align: center; margin: -6px 0 14px; }

.pg { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: .8rem; margin: 22px 0 8px; }
.pg::before, .pg::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.pg-b {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid transparent; background: transparent;
  color: var(--ink-3); font-size: .8rem; padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.pg-b:hover { border-color: var(--line); color: var(--accent); background: var(--surface); }
.pg-b .ic { width: 15px; height: 15px; }
.pgi {
  font: .45em/1 var(--ui-font); color: var(--ink-3); border: 1px dashed var(--line); background: transparent;
  border-radius: 6px; padding: 3px 6px; vertical-align: .3em; white-space: nowrap;
}
button.pgi { cursor: pointer; }
button.pgi:hover { color: var(--accent); border-color: var(--accent); }

.blk { margin: 0 0 18px; }

.ar {
  font-family: var(--ar-font); font-size: var(--ar-size); line-height: calc(2.25 * var(--lh));
  direction: rtl; text-align: right; word-spacing: .06em;
}

/* rows: one sentence per row, number on the right (where Arabic starts) */
.s {
  display: grid; grid-template-columns: minmax(0, 1fr) 34px;
  grid-template-areas: "ar gut" "tr gut" "notes gut";
  column-gap: 8px; padding: 4px 8px; margin: 0 -8px; border-radius: 10px;
  scroll-margin-top: 80px; transition: background .15s;
}
.s > .ar { grid-area: ar; }
.s > .tr { grid-area: tr; }
.s > .notes { grid-area: notes; }
.gut { grid-area: gut; display: flex; justify-content: center; padding-top: calc((var(--ar-size) * 2.25 * var(--lh) - 28px) / 2); }
.num {
  min-width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; padding: 0 4px;
  color: var(--ink-3); cursor: pointer; font-size: .78rem; font-variant-numeric: tabular-nums;
}
.num:hover { background: var(--accent-soft); color: var(--accent); }
.s.hd { margin-top: 10px; }
.s.hd > .ar { color: var(--accent); font-weight: 700; font-size: calc(var(--ar-size) * 1.08); }
.s.hd > .tr { color: var(--accent); font-weight: 600; border-color: transparent; }
.s.hot, .sx.hot, .pti.hot { background: var(--hl-soft); }
.s.cur, .sx.cur, .pti.cur { background: var(--accent-soft); }
.s.flash, .sx.flash, .fn.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--hl); } to { background: transparent; } }

/* flow: paragraphs as continuous text, sentence numbers inline */
.para { line-height: calc(2.35 * var(--lh)); text-align: justify; }
body.inter .para { text-align: right; }
.sx {
  border-radius: 6px; scroll-margin-top: 80px; transition: background .15s;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.sn {
  position: relative; display: inline-grid; place-items: center; min-width: 1.55em; height: 1.55em; padding: 0 .35em;
  margin: 0 .05em; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-3); font: 600 .5em/1 var(--ar-font); vertical-align: .35em; cursor: pointer;
}
.sn::after { content: ""; position: absolute; inset: -9px -6px; }
.sn:hover { border-color: var(--accent); color: var(--accent); }
.sn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.ptr { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 0; }
.pti { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 0 6px; align-items: start; border-radius: 8px; padding: 2px 4px; }
.pti .num { margin-top: 1px; }
.pti-b { min-width: 0; }

.w { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.w:hover, .w.on { background: var(--hl); }
.w.has-note { text-decoration: underline dotted var(--note-line) 2px; text-underline-offset: 10px; }
.w.saved .t { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--star) 55%, transparent); }
.w .g { display: none; }
.fnref {
  font-family: var(--ui-font); font-size: .55em; color: var(--accent); cursor: pointer;
  vertical-align: super; line-height: 0; padding: 0 2px;
}

/* interlinear (word-by-word) */
body.inter .ar:not(.ch-head .ar) { line-height: calc(1.5 * var(--lh)); }
body.inter .w {
  display: inline-flex; flex-direction: column; align-items: center; vertical-align: top;
  margin: 0 .14em 10px; padding: 2px 3px; line-height: 1.5;
}
body.inter .w .g {
  display: block; direction: ltr; font-family: var(--ui-font); font-size: .78rem; line-height: 1.25;
  color: var(--gloss); max-width: 9.5em; text-align: center; margin-top: 2px;
}

.tr {
  color: var(--ink-2); font-size: var(--uz-size); line-height: 1.6;
  border-left: 3px solid var(--tr-line); padding: 2px 0 4px 12px; margin: 0 0 4px;
}
.tr .edited { color: var(--ink-3); font-size: .75rem; margin-left: 6px; }

/* side by side on wide screens: Uzbek left, Arabic right, number at the far right */
@media (min-width: 1000px) {
  body.rows.par main { max-width: 1240px; }
  body.rows.par .s {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 34px;
    grid-template-areas: "tr ar gut" "notes notes gut";
    column-gap: 28px; padding: 6px 10px;
  }
  body.rows.par .s > .tr {
    margin: 0; border-left: 0; padding: calc((var(--ar-size) * 2.25 * var(--lh) - var(--uz-size) * 1.6) / 2) 0 4px;
  }
  body.rows.par.inter .s > .tr { padding-top: 6px; }
  body.rows.par .s:not(.hd) > .ar { border-left: 1px solid var(--line); padding-left: 24px; }
}

.notes { display: flex; flex-direction: column; gap: 6px; }
.note {
  background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 10px;
  padding: 8px 12px; font-size: .95rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.note .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--ink-3); font-size: .78rem; margin-bottom: 2px; }
.note .meta .word { font-family: var(--ar-font); font-size: 1.05rem; color: var(--ink); }
.note .meta .acts { margin-left: auto; display: flex; gap: 4px; }
.note .meta button { border: 0; background: transparent; cursor: pointer; color: var(--accent); font-size: .78rem; padding: 0 4px; }
.note .meta button.del { color: var(--danger); }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: .7rem; }

/* footnotes */
.fns { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 12px; }
.fns h3 { font-size: .9rem; color: var(--ink-3); font-weight: 600; margin: 0 0 8px; }
.fn { padding: 8px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 80px; }
.fn .ar { font-size: calc(var(--ar-size) * .78); line-height: 1.9; }
.fn .k { color: var(--accent); font-family: var(--ui-font); font-size: .8rem; margin-left: 6px; }
.fn .uz { color: var(--ink-2); font-size: .9rem; }

/* previous / next chapter */
.chnav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; }
.cn {
  display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--line);
  background: var(--surface); border-radius: 14px; padding: 14px 16px; cursor: pointer;
}
.cn:hover { border-color: var(--accent); }
.cn.next { text-align: right; align-items: flex-end; }
.cn-k { color: var(--accent); font-size: .82rem; font-weight: 600; }
.cn-t { font-weight: 600; }
.cn-s { color: var(--ink-2); font-size: .88rem; }
.cn.end { cursor: default; color: var(--ink-3); font-size: .9rem; text-align: center; justify-content: center; margin: 0; border-style: dashed; background: transparent; }

/* ---------- popover ---------- */
.pop {
  position: absolute; z-index: 60; width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 14px; max-height: min(80vh, 640px); overflow: auto;
}
.pop[hidden] { display: none; }
.pop .p-ar { font-family: var(--ar-font); font-size: 1.9rem; line-height: 1.6; direction: rtl; text-align: right; }
.pop .p-plain { font-family: var(--ar-font); color: var(--ink-3); font-size: 1.1rem; direction: rtl; text-align: right; }
.pop .p-gl { display: flex; align-items: center; gap: 6px; margin: 4px 0 6px; }
.pop .p-g { color: var(--gloss); font-size: 1.1rem; font-weight: 600; flex: 1; }
.pop .p-uz { color: var(--ink-2); }
.pop .sep { border-top: 1px solid var(--line); margin: 10px 0; }
.pop label { display: block; font-size: .8rem; color: var(--ink-3); margin: 10px 0 4px; }
.pop input[type=text], .pop input[type=password], .pop textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 9px;
}
.pop textarea { min-height: 84px; resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.row.center { justify-content: center; }
.pop .chk { display: flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--ink-2); margin-right: auto; }
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--surface);
  border-radius: 8px; padding: 5px 12px; cursor: pointer; font-size: .88rem;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { padding: 3px 10px; font-size: .8rem; }
.pop .close { position: absolute; top: 6px; left: 8px; border: 0; background: transparent; font-size: 1.3rem; color: var(--ink-3); cursor: pointer; width: 32px; height: 32px; }
.o-h { font-size: .78rem; color: var(--ink-3); margin-bottom: 4px; }
.occ { list-style: none; margin: 0; padding: 0; }
.occ button {
  display: block; width: 100%; border: 0; background: transparent; text-align: left;
  padding: 5px 8px; border-radius: 8px; cursor: pointer;
}
.occ button:hover { background: var(--accent-soft); }
.occ-ar { display: block; font-family: var(--ar-font); font-size: 1.15rem; line-height: 1.75; direction: rtl; text-align: right; }
.occ-m { display: block; font-size: .78rem; color: var(--ink-3); }
.star {
  flex-shrink: 0; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-3); cursor: pointer; display: inline-grid; place-items: center; padding: 0;
}
.star:hover { background: var(--accent-soft); }
.star[aria-pressed="true"] { color: var(--star); }
.star[aria-pressed="true"] .ic { fill: currentColor; }

/* settings */
.set-h { font-weight: 600; margin: 2px 0 8px 30px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg .fs { font-size: 1.1rem; line-height: 1; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--accent); }
.range output { min-width: 3em; text-align: right; font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.keys { border-collapse: collapse; width: 100%; font-size: .9rem; }
.keys td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.keys td:first-child { width: 1%; white-space: nowrap; }

/* ---------- panels: contents, search, word list ---------- */
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(20, 15, 5, .35); }
.scrim[hidden], .panel[hidden], .viewer[hidden] { display: none; }
.panel { position: fixed; z-index: 50; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.panel.left { top: 0; bottom: 0; left: 0; width: min(400px, 92vw); border-right: 1px solid var(--line); }
.panel.right { top: 0; bottom: 0; right: 0; width: min(480px, 100vw); border-left: 1px solid var(--line); }
.panel.top {
  top: 6vh; left: 50%; transform: translateX(-50%); width: min(720px, calc(100vw - 32px));
  max-height: 86vh; border-radius: 16px; border: 1px solid var(--line);
}
.panel-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.panel-h h2 { font-size: 1.05rem; margin: 0; flex: 1; }
.panel-h .x { border: 0; background: transparent; font-size: 1.6rem; line-height: 1; color: var(--ink-3); cursor: pointer; width: 40px; height: 40px; border-radius: 8px; }
.panel-h .x:hover { background: var(--accent-soft); }
.panel-b { overflow: auto; padding: 12px 18px 28px; flex: 1; overscroll-behavior: contain; }
.empty { color: var(--ink-3); text-align: center; padding: 40px 12px; }

.toc-book { margin-bottom: 12px; }
.toc-book .ar { font-size: 1.7rem; line-height: 1.6; }
.toc-book .meta { color: var(--ink-2); font-size: .88rem; }
.toc, .toc-heads { list-style: none; margin: 0; padding: 0; }
.toc > li { border-top: 1px solid var(--line); padding: 6px 0; }
.toc-ch {
  display: grid; gap: 1px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.toc-ch:hover, .toc li.cur > .toc-ch { background: var(--accent-soft); }
.toc-t { font-weight: 600; }
.toc-s { color: var(--ink-2); font-size: .9rem; }
.toc-ar { font-family: var(--ar-font); font-size: 1.2rem; line-height: 1.7; direction: rtl; text-align: right; color: var(--accent); }
.toc-p { font-size: .78rem; color: var(--ink-3); }
.toc-heads button {
  display: flex; flex-direction: column; width: 100%; border: 0; background: transparent; text-align: left;
  padding: 3px 10px 3px 24px; border-radius: 8px; cursor: pointer;
}
.toc-heads button:hover { background: var(--accent-soft); }
.toc-heads .ar { font-size: 1.05rem; line-height: 1.7; }
.toc-heads .uz { font-size: .82rem; color: var(--ink-2); }

.q {
  width: 100%; font-size: 1.1rem; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg);
}
.q.sm { font-size: .95rem; padding: 7px 10px; margin-bottom: 8px; }
.r-n { font-size: .8rem; color: var(--ink-3); margin: 8px 0 4px; }
.hit {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: 10px 8px; cursor: pointer; border-radius: 6px;
}
.hit:hover { background: var(--accent-soft); }
.hit-m { display: block; font-size: .78rem; color: var(--ink-3); }
.hit-ar { display: block; font-family: var(--ar-font); font-size: 1.3rem; line-height: 1.8; direction: rtl; text-align: right; }
.hit-uz { display: block; color: var(--ink-2); font-size: .92rem; }

.tabs3 { margin-bottom: 12px; }
.vlist { list-style: none; margin: 0; padding: 0; }
.ve { border-bottom: 1px solid var(--line); }
.ve-row { display: flex; align-items: center; gap: 4px; }
.ve-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: transparent;
  text-align: left; padding: 6px 6px; border-radius: 8px; cursor: pointer;
}
.ve-main:hover { background: var(--accent-soft); }
.ve-g { flex: 1; min-width: 0; color: var(--gloss); font-size: .92rem; }
.ve-n, .lvl { font-size: .75rem; color: var(--ink-3); white-space: nowrap; }
.lvl { letter-spacing: 1px; color: var(--accent); }
.ve-ar { order: 3; font-family: var(--ar-font); font-size: 1.45rem; line-height: 1.6; direction: rtl; white-space: nowrap; }
.ve.open { background: var(--bg); border-radius: 8px; }
.ve-occ .occ { padding: 0 6px 8px; }
.review-row { margin: 0 0 4px; }
.card {
  border: 1px solid var(--line); border-radius: 16px; padding: 22px 18px; text-align: center;
  margin: 8px 0 12px; background: var(--bg);
}
.card-n { font-size: .8rem; color: var(--ink-3); }
.card-ar { font-family: var(--ar-font); font-size: 2.8rem; line-height: 1.8; direction: rtl; margin: 6px 0 12px; }
.card-g { color: var(--gloss); font-size: 1.25rem; font-weight: 600; margin: 4px 0 8px; }
.card-ctx { font-family: var(--ar-font); direction: rtl; font-size: 1.2rem; line-height: 1.8; color: var(--ink-2); margin-bottom: 8px; }

/* ---------- page scan viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(15, 12, 8, .94); display: flex; flex-direction: column; }
.v-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; padding: 10px; color: #eee; }
.v-bar .tg { background: #2b2720; color: #eee; border-color: #4a4438; }
.v-p { min-width: 4.5em; text-align: center; font-weight: 600; }
.v-img { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 0 12px 16px; }
.v-img img { max-width: 100%; max-height: calc(100dvh - 72px); background: #fff; border-radius: 4px; cursor: zoom-in; }
.v-img img.zoom { max-width: none; max-height: none; width: min(1300px, 180vw); cursor: zoom-out; }

@media (max-width: 760px) {
  .toggles, .brand .t-ch, .brand .home { display: none; }
}
@media (max-width: 640px) {
  :root { --ar-size: 1.5rem; }
  .bar-in { gap: 4px; padding: 4px 6px; }
  .s { grid-template-columns: minmax(0, 1fr) 28px; column-gap: 4px; }
  .num { min-width: 26px; }
  .pti { grid-template-columns: 28px minmax(0, 1fr); }
  .pop {
    position: fixed; left: 0 !important; right: 0; bottom: 0; top: auto !important;
    width: 100%; border-radius: 16px 16px 0 0; max-height: 58vh;
  }
  .panel.left, .panel.right { width: 100vw; border: 0; }
  .panel.top { top: 0; width: 100vw; max-height: none; height: 100dvh; border-radius: 0; border: 0; }
  .chnav { grid-template-columns: 1fr; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: .9rem;
}
