/* =========================================================================
 * Tủ truyện: kệ (#/stories, #/stories/lv<n>), bìa truyện, màn đọc (#/story/<mã>, dựng trên khung .ses-* của session.css),
 * câu hỏi và màn hết truyện. Chỉ dùng biến của skin; màu cấp là màu tuyến (--line) nên tự đổi theo các bảng màu.
 * ========================================================================= */

/* ---------- bìa ---------- */
.st-cv {
  --plate: color-mix(in oklab, var(--line, var(--l-green)) var(--plate-mix, 100%), var(--bg));
  position: relative; display: block; aspect-ratio: 1; border-radius: 14px; overflow: hidden; container-type: inline-size;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 4px;
}
.st-cv > img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* bìa vẽ cho truyện không tranh: tường gạch mosaic của ga MTR màu theo cấp, giữa là ô mạt chược mang chữ đầu tên */
.st-cv-gen {
  display: grid; place-items: center; background-color: var(--plate); border-color: color-mix(in srgb, var(--plate) 70%, #000);
  background-image: linear-gradient(color-mix(in srgb, var(--hk-cream, var(--cream)) 13%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--hk-cream, var(--cream)) 13%, transparent) 1px, transparent 1px);
  background-size: 12.5% 12.5%; background-position: -1px -1px;
}
.st-mj {
  width: 46%; aspect-ratio: 3 / 4; margin-top: -15%; display: grid; place-items: center; border-radius: 12% / 9%;
  background: var(--hk-cream, var(--cream)); color: var(--plate);
  font-family: var(--font-zh-serif); font-weight: 900; font-size: 2.4rem; font-size: 32cqw; line-height: 1;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--hk-cream, var(--cream)) 62%, #000), 0 9px 14px rgba(0, 0, 0, .28);
}
/* số trang trên bảng LED minibus; nhãn "trang" đỏ cam như chữ "NGÀY" của bảng LED trang chủ */
.st-led {
  position: absolute; right: 6px; bottom: 6px; display: inline-flex; align-items: baseline; gap: 3px; padding: 4px 6px 3px; line-height: 1;
  border-radius: 6px; background: var(--led-bg); border: 1px solid var(--ink-line);
}
.st-led b { font-family: var(--font-led); font-weight: 400; font-size: .76rem; color: var(--led-on); letter-spacing: .03em; }
.st-led i { font-style: normal; font-size: .56rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--led-on-2); }
.st-cv-au { position: absolute; left: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--led-bg); color: var(--led-on); }
.st-cv-au svg { width: 15px; height: 15px; }
.st-done { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: var(--on-ok, #fff); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.st-done svg { width: 15px; height: 15px; }
.st-cv-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, .35); }
.st-cv-bar > i { display: block; height: 100%; background: var(--sign-gold); }
.st-cv:has(.st-cv-bar) .st-led { bottom: 11px; }
.st-cv.big { border-radius: 20px; border-bottom-width: 6px; }
.st-cv.big .st-led { right: 10px; bottom: 10px; padding: 6px 9px 5px; }
.st-cv.big .st-led b { font-size: 1.1rem; }
.st-cv.big .st-led i { font-size: .7rem; }
.st-cv.big .st-cv-au { width: 34px; height: 34px; left: 10px; top: 10px; }
.st-cv.big .st-cv-au svg { width: 19px; height: 19px; }

/* ---------- thẻ truyện ---------- */
.st-card { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--text); text-decoration: none !important; scroll-snap-align: start; }
.st-card .st-cv { margin-bottom: 6px; transition: transform .12s; }
.st-card:hover .st-cv { transform: translateY(-2px); }
.st-card:active .st-cv { transform: translateY(2px); border-bottom-width: 2px; margin-bottom: 8px; }
.st-title { font-size: 1.08rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-card .st-vi { color: var(--muted); font-size: .8rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-card .st-meta { font-size: .72rem; color: var(--faint); line-height: 1.3; }
.st-card-more .st-cv { display: grid; place-content: center; justify-items: center; gap: 2px; color: var(--muted); border-style: dashed; }
.st-card-more .st-cv svg { width: 28px; height: 28px; }
.st-card-more .st-cv b { font-size: 1.1rem; }
.st-card-more small { color: var(--muted); font-weight: 700; font-size: .82rem; }

/* ---------- đầu trang: đọc tiếp ---------- */
.st-resume { display: flex; align-items: center; gap: 14px; margin: 0 0 4px; padding: 12px; color: var(--text); text-decoration: none !important; }
.st-resume > .st-cv { flex: 0 0 auto; width: 84px; border-radius: 12px; border-bottom-width: 3px; }
.st-resume > .st-cv .st-led i { display: none; }
.st-resume-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.st-kicker { color: var(--accent); font-weight: 800; font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; }
.st-resume-tx > b { font-size: 1.15rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-resume-tx .st-vi { color: var(--muted); font-size: .88rem; line-height: 1.3; }
.st-resume-tx .st-meta { color: var(--faint); font-size: .76rem; margin-top: 4px; }
.st-resume-pg { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.st-resume-pg .progress { flex: 1; }
.st-resume-pg small { font-size: .76rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-resume-go { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink, #fff); border: 2px solid var(--ink-line); box-shadow: var(--print-shadow); }
.st-resume-go svg { width: 20px; height: 20px; }

/* ---------- tab lọc dạng viên ---------- */
.st-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; scrollbar-width: none; }
.st-tabs::-webkit-scrollbar { display: none; }
.st-tabs .chip { flex: 0 0 auto; min-height: 38px; padding: 7px 14px; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 700; color: var(--text); background: var(--surface); }
.st-tabs .chip b { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-tabs .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.st-tabs .chip.on b { color: inherit; opacity: .8; }
.st-empty { padding: 32px 0; }

/* ---------- kệ ngang theo cấp ---------- */
.st-shelf { --plate: color-mix(in oklab, var(--line) var(--plate-mix, 100%), var(--bg)); margin-top: 18px; }
.st-shelf-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.st-lv {
  flex: 0 0 auto; width: 34px; height: 38px; display: grid; place-items: center; border-radius: 8px;
  background: var(--plate); color: var(--hk-cream, var(--cream)); font-family: var(--font-zh-serif); font-weight: 900; font-size: 1.15rem;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--plate) 65%, #000);
}
.st-shelf-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.st-shelf-t h2 { margin: 0; font-size: 1.1rem; }
.st-shelf-t small { color: var(--muted); font-size: .78rem; }
.st-more { flex: 0 0 auto; font-weight: 700; font-size: .88rem; white-space: nowrap; }
.st-more b { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
/* điện thoại: 2,3 thẻ một màn, kéo ngang; máy lớn hơn thì nhiều thẻ hơn */
.st-row { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 2 * 12px) / 2.3); gap: 12px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; padding-bottom: 8px; scrollbar-width: thin; }
@media (min-width: 600px) { .st-row { grid-auto-columns: calc((100% - 3 * 14px) / 3.3); gap: 14px; } }
@media (min-width: 1100px) { .st-row { grid-auto-columns: calc((100% - 4 * 14px) / 4.3); } }
@media (min-width: 1400px) { .st-row { grid-auto-columns: calc((100% - 5 * 14px) / 5.3); } }
@media (max-width: 860px) {
  .st-row, .st-tabs { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; scroll-padding: 0 16px; }
  .st-row { scrollbar-width: none; }
  .st-row::-webkit-scrollbar { display: none; }
}
/* Xem tất cả: lưới 2 cột (điện thoại) → 5 cột */
.st-grid { display: grid; gap: 18px 14px; margin-top: 14px; grid-template-columns: repeat(auto-fill, minmax(min(44%, 170px), 1fr)); }

/* ---------- màn đọc ---------- */
.st-read { --st-fs: 1.35rem; }
.st-read[data-fs="0"] { --st-fs: 1.1rem; }
.st-read[data-fs="2"] { --st-fs: 1.7rem; }
@media (min-width: 900px) {
  .st-read { --st-fs: 1.55rem; }
  .st-read[data-fs="0"] { --st-fs: 1.25rem; }
  .st-read[data-fs="2"] { --st-fs: 1.95rem; }
}
.st-read .ses-top a.ses-x { text-decoration: none; }
/* màn trượt vào (slide-in) không làm hiện thanh cuộn ngang thoáng qua */
.st-read .ses-stage { overflow-x: hidden; }
.st-pgno { flex: 0 0 auto; min-width: 3em; text-align: right; font-weight: 700; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-pgno:empty { display: none; }
.st-pg { gap: 14px; }
.st-img { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 14px; background: var(--surface-2); }
.st-lines { display: flex; flex-direction: column; gap: 10px; }
.st-line {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); border-bottom-width: 3px; transition: background-color .2s, border-color .2s;
}
.st-line.has-say { padding-left: 8px; }
.st-line.playing { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.st-tx { flex: 1; min-width: 0; }
.st-say {
  flex: 0 0 auto; width: 42px; height: 42px; margin-top: 8px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 0; background: color-mix(in srgb, var(--accent-2) 16%, var(--surface)); color: var(--accent-2);
}
.st-say svg { width: 22px; height: 22px; }
.st-say:hover { background: color-mix(in srgb, var(--accent-2) 26%, var(--surface)); }
.st-say.on { background: var(--accent-2); color: var(--bg); }
.st-playall { align-self: flex-start; }
.st-ws { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 3px; }
.st-g { display: inline-flex; align-items: flex-end; min-width: 0; }
/* từ bấm được: gạch chấm mờ dưới chữ; trỏ / chọn thì có khung; từ đã tra tô nền vàng */
.st-w {
  background: none; border: 0; border-bottom: 2px dotted color-mix(in srgb, var(--faint) 60%, transparent); border-radius: 6px 6px 0 0;
  padding: 0 2px; cursor: pointer; color: var(--text); font: inherit;
}
.st-w:hover, .st-w:focus-visible { background: color-mix(in srgb, var(--accent) 10%, transparent); border-bottom-color: var(--accent); }
.st-w.seen { background: color-mix(in srgb, var(--gold) 18%, transparent); border-bottom-color: var(--gold); }
.st-read .st-w .line-zh { font-size: var(--st-fs); }
.st-pc { font-size: var(--st-fs, 1.1rem); padding-bottom: 4px; }
.st-line .vi { margin-top: 2px; font-size: calc(var(--st-fs) * .68); line-height: 1.45; }
.st-read.hide-jp .st-w rt { display: none; }
.st-read.hide-jp .st-w .line-zh { line-height: 1.7; }
.st-vi-btn { display: none; }
.st-read.hide-vi .st-line:not(.reveal) .vi { display: none; }
.st-read.hide-vi .st-line:not(.reveal) .st-vi-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 3px 10px; border-radius: 999px;
  border: 1px dashed var(--border); background: transparent; color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer;
}
.st-vi-btn svg { width: 14px; height: 14px; }
/* trang bìa */
.st-cvpg { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 6px; text-align: center; }
.st-cvpg > .st-cv { width: min(60%, 240px); }
.st-cvpg > .st-img { max-height: 40vh; }
.st-cvpg-t { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.st-cvpg-zh { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.st-cvpg-zh .st-ws { justify-content: center; }
.st-cvpg-zh .line-zh, .st-read .st-cvpg-zh .st-w .line-zh { font-family: var(--font-zh-serif); font-weight: 900; font-size: calc(var(--st-fs) * 1.45); }
.st-cvpg-zh .st-say { margin-top: 0; }
.st-cvpg h1 { margin: 0; font-size: 1.3rem; line-height: 1.3; }
.st-syn { margin: 0; max-width: 520px; color: var(--muted); }
.st-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.st-chips .chip svg { width: 14px; height: 14px; }
.st-by { margin: 0; color: var(--faint); max-width: 520px; }
/* thanh dưới: nút trang trước nhỏ + "Trang sau" to */
.st-read .ses-btns { flex-wrap: nowrap; }
.st-prev { flex: 0 0 auto; width: 54px; min-height: 50px; padding: 0; display: grid; place-items: center; }
.st-prev svg { width: 22px; height: 22px; }
.st-prev[hidden] { display: none; }
.st-quiz .ses-step { display: flex; align-items: center; gap: 6px; }
.st-quiz .ses-step svg { width: 18px; height: 18px; }

/* ---------- bảng cài đặt trượt từ dưới lên (mọi khổ màn hình) ---------- */
.modal-wrap.st-sheet { place-items: end center; padding: 0; }
.modal-wrap.st-sheet .modal { width: min(100%, 520px); max-height: 88vh; border-radius: 20px 20px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
:root:not([data-fx="less"]) .modal-wrap.st-sheet .modal { animation: rise-in .2s ease-out; }
.st-opts h2 { display: flex; align-items: center; gap: 8px; margin: 0 44px 8px 0; font-size: 1.15rem; }
.st-opts h2 svg { width: 22px; height: 22px; }
.st-opts .switch { font-weight: 600; }
.st-seg { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.st-seg button { min-height: 36px; padding: 4px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-family: inherit; font-weight: 700; cursor: pointer; }
.st-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--border), 0 2px 6px rgba(0, 0, 0, .15); }
.st-about { margin-top: 12px; }
.st-about summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 700; color: var(--muted); }
.st-about summary svg { width: 18px; height: 18px; }

/* ---------- hết truyện ---------- */
.st-fin .ses-fin { padding-bottom: 40px; }
.st-fin .ses-tile.t-words { --c: var(--accent-2); --on-c: var(--bg); }
:root[data-theme="light"] .st-fin .ses-tile.t-words { --on-c: var(--hk-cream); }
.st-fin .st-fin-note { font-size: .92rem; }
.st-fin-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 520px; }
.st-fin-words .chip { cursor: pointer; font-size: .84rem; color: var(--text); }
.st-fin .st-next { width: 100%; max-width: 420px; margin: 4px 0 0; text-align: left; }
.st-fin .st-credit { max-width: 560px; margin-top: 8px; text-align: left; }
.st-credit { margin-top: 16px; color: var(--muted); }
