:root {
  --bg: #090909;
  --surface: #151515;
  --surface-2: #1d1d1d;
  --surface-3: #292929;
  --fg: #f5f5f5;
  --fg-2: #c2c2c2;
  --fg-3: #949494;
  --brand: #f5f5f5;
  --brand-2: #d9d9d9;
  --brand-ink: #111111;
  --accent: #cccccc;
  --warn: #d4d4d4;
  --danger: #f49b91;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --line-3: rgba(255, 255, 255, .27);
  --sans: 'IBM Plex Sans Thai', 'DM Sans', system-ui, sans-serif;
  --display: 'DM Sans', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --r: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .45);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --reader-width: 1240px;
  --reader-gap: 0px;
  --reader-brightness: .9;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; letter-spacing: 0; }
html { scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 15px; line-height: 1.6; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button, a, input { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
::selection { background: var(--brand); color: var(--brand-ink); }
::-webkit-scrollbar { width: 8px; height: 6px; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 8px; background: var(--line-3); background-clip: content-box; }
svg { flex-shrink: 0; }

.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 36px; height: calc(68px + var(--safe-t)); padding: var(--safe-t) 32px 0; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); }
.brand-mark svg { width: 19px; height: 19px; }
.brand-word { font-family: var(--display); font-size: 19px; font-weight: 700; }
.brand-accent { color: var(--brand); }
.desktop-nav { display: flex; align-items: stretch; gap: 26px; align-self: stretch; }
.nav-link { display: flex; align-items: center; border-bottom: 2px solid transparent; color: var(--fg-3); font-size: 14px; }
.nav-link:hover { color: var(--fg); }
.nav-link.active { border-color: var(--brand); color: var(--fg); }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--fg-2); }
.icon-button:hover { background: var(--surface-3); color: var(--fg); }
.icon-button svg { width: 19px; height: 19px; }
.search-shortcut { margin-right: 5px; }
.mobile-menu-button { display: none; }
.provider-switch { position: relative; display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
.provider-option { position: relative; z-index: 1; min-width: 42px; height: 28px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--fg-3); font-family: var(--display); font-size: 11px; font-weight: 700; }
.provider-option.active { color: var(--brand-ink); }
.provider-glider { position: absolute; top: 3px; left: 3px; width: calc(50% - 3px); height: 28px; border-radius: 4px; background: var(--brand); transition: transform .2s; }
.provider-switch[data-index="1"] .provider-glider { transform: translateX(100%); }

.page-shell { width: min(1320px, calc(100% - 64px)); margin: 0 auto; padding: 36px 0 64px; }
.home-page { padding-top: 30px; }
.home-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.home-heading h1 { margin: 0; font-family: var(--display); font-size: 36px; font-weight: 700; line-height: 1.2; }
.home-heading h1 span { color: var(--brand); }
.home-heading-actions { display: flex; align-items: center; gap: 12px; }
.home-search { border-color: var(--line-2); background: var(--surface); }
.provider-badge, .shelf-count { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-3); font-size: 12px; white-space: nowrap; }
.live-dot { display: inline-block; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.section-heading, .page-title-row, .chapter-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading h2, .chapter-heading h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin: 0; font-size: 21px; font-weight: 600; line-height: 1.5; }
.section-heading h2 svg { width: 19px; height: 19px; color: var(--brand); }
.chapter-heading small { margin-left: 5px; color: var(--fg-3); font-size: 12px; font-weight: 400; }
.text-link { display: inline-flex; align-items: center; gap: 7px; color: var(--fg-3); font-size: 12px; white-space: nowrap; }
.text-link:hover { color: var(--brand); }
.text-link svg { width: 15px; height: 15px; }
.shelf-section { margin-top: 36px; }
.manga-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 18px; }
.home-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.manga-card { display: block; min-width: 0; }
.cover-wrap { position: relative; display: block; aspect-ratio: .7; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); transition: border-color .2s; }
.manga-card:hover .cover-wrap { border-color: var(--brand); }
.cover-wrap img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-type, .cover-src { position: absolute; top: 8px; padding: 3px 6px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 4px; background: rgba(9, 9, 9, .9); color: #ededed; font-size: 9px; font-weight: 500; }
.cover-type { left: 8px; }
.cover-src { right: 8px; color: #c2c2c2; font-family: var(--display); text-transform: uppercase; }
.cover-play { position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; background: var(--brand); color: var(--brand-ink); opacity: 0; transition: opacity .2s; }
.cover-play svg { width: 16px; height: 16px; }
.manga-card:hover .cover-play, .manga-card:focus-visible .cover-play { opacity: 1; }
.manga-meta { display: block; padding-top: 10px; }
.manga-title { display: -webkit-box; min-height: 3.1em; overflow: hidden; font-size: 14px; font-weight: 500; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.manga-sub { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; color: var(--fg-3); font-size: 11px; }
.manga-sub > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manga-rating { display: inline-flex; align-items: center; gap: 3px; color: var(--warn); white-space: nowrap; }
.manga-rating svg { width: 11px; height: 11px; fill: currentColor; }
.rail-wrap { position: relative; }
.manga-rail { display: grid; grid-auto-flow: column; grid-auto-columns: 172px; gap: 18px; padding-bottom: 10px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; }
.manga-rail > * { scroll-snap-align: start; }
.manga-rail::-webkit-scrollbar, .catalog-genre-list::-webkit-scrollbar { display: none; }
.rail-controls { display: flex; justify-content: flex-end; gap: 5px; margin-top: 6px; }
.rail-controls .icon-button { width: 32px; height: 32px; border-color: var(--line-2); }
.genre-band { margin-top: 36px; padding: 26px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.genre-list { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border: 1px solid var(--line-2); border-radius: 6px; background: transparent; color: var(--fg-2); font-size: 12px; }
.genre-chip:hover, .genre-chip.selected { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.genre-chip svg { width: 13px; height: 13px; }
.genre-chip-all { color: var(--brand); }
.continue-section { margin-top: 28px; }
.continue-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 320px); gap: 20px; overflow-x: auto; scrollbar-width: none; }
.continue-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.continue-item img { width: 46px; height: 64px; border-radius: 4px; object-fit: cover; }
.continue-item > span { display: flex; flex: 1; flex-direction: column; gap: 5px; min-width: 0; }
.continue-item b { overflow: hidden; color: var(--fg); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.continue-item small { color: var(--fg-3); font-size: 11px; }
.continue-item > svg { width: 16px; height: 16px; color: var(--brand); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; max-width: 100%; padding: 8px 16px; border: 1px solid transparent; border-radius: 6px; font-size: 13px; font-weight: 500; text-align: center; }
.button svg { width: 16px; height: 16px; }
.button-primary { background: var(--brand); color: var(--brand-ink); }
.button-primary:hover { background: var(--brand-2); }
.button-quiet { border-color: var(--line-2); background: var(--surface-2); color: var(--fg); }
.button-outline { border-color: var(--line-2); background: transparent; color: var(--fg-2); }
.button-outline:hover { border-color: var(--brand); }
.page-title-row h1 { margin: 0; font-size: 30px; font-weight: 600; line-height: 1.5; }
.catalog-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.catalog-search-wrap { flex: 1 1 260px; min-width: 0; }
.control-label { display: block; margin-bottom: 7px; color: var(--fg-3); font-size: 12px; }
.catalog-search { display: flex; align-items: center; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); }
.catalog-search:focus-within { border-color: var(--brand); }
.catalog-search > svg { width: 18px; height: 18px; margin-right: 10px; color: var(--fg-3); }
.catalog-search input { width: 100%; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; }
input::placeholder { color: var(--fg-3); }
.clear-search { display: grid; flex-shrink: 0; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--fg-3); }
.clear-search svg { width: 15px; height: 15px; }
.select-field { min-width: 150px; }
.select-field select { width: 100%; height: 44px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); font-size: 13px; }
.catalog-genre-list { display: flex; gap: 7px; padding: 16px 0 0; overflow-x: auto; scrollbar-width: none; }
.catalog-genre-list .genre-chip { flex-shrink: 0; }
.catalog-results { min-height: 280px; padding-top: 26px; }
.catalog-loading, .reader-loading { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 260px; color: var(--fg-3); font-size: 14px; }
.reader-loading { min-height: 80vh; }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .75s linear infinite; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 40px; color: var(--fg-3); font-size: 13px; }
.empty-state, .shelf-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 300px; padding: 32px 16px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--brand); }
.empty-icon svg { width: 22px; height: 22px; }
.empty-state h2, .shelf-empty h2 { margin: 0; font-size: 19px; font-weight: 500; }
.empty-state p, .shelf-empty p { max-width: 560px; margin: 0 0 8px; color: var(--fg-3); font-size: 13px; overflow-wrap: anywhere; }
.detail-loading { min-height: 460px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; color: var(--fg-3); font-size: 12px; }
.breadcrumbs a:hover { color: var(--brand); }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 500; }
.detail-hero { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: start; gap: 40px; padding-bottom: 36px; border-bottom: 1px solid var(--line); }
.detail-cover { width: 210px; aspect-ratio: .7; }
.detail-cover img { display: block; width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; }
.cover-frame { display: none; }
.detail-copy h1 { margin: 6px 0 14px; font-size: 30px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.detail-alternatives { margin: 0 0 14px; color: var(--fg-2); font-size: 13px; }
.detail-alternatives summary { width: fit-content; min-height: 28px; cursor: pointer; }
.detail-alternatives summary span { margin-left: 6px; color: var(--fg-3); font-size: 11px; }
.detail-alternatives ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 24px; margin: 8px 0 0; padding: 0 0 0 20px; }
.detail-alternatives li { overflow-wrap: anywhere; }
@media (max-width: 560px) { .detail-alternatives ul { grid-template-columns: minmax(0, 1fr); } }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-tags span { color: var(--fg-3); font-size: 12px; }
.detail-tags span + span::before { content: '/'; margin-right: 8px; color: var(--line-3); }
.detail-description { max-width: 760px; margin: 20px 0 0; color: var(--fg-2); font-size: 14px; line-height: 1.85; }
.detail-facts { display: flex; flex-wrap: wrap; gap: 16px 30px; margin-top: 20px; }
.detail-facts div { display: flex; flex: 1 1 130px; flex-direction: column; gap: 4px; min-width: 0; }
.detail-facts span { color: var(--fg-3); font-size: 11px; }
.detail-facts b { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.chapter-section { padding-top: 28px; }
.chapter-heading > div { min-width: 0; }
.chapter-search { display: flex; align-items: center; gap: 8px; width: 220px; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--fg-3); }
.chapter-search svg { width: 17px; height: 17px; }
.chapter-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; }
.chapter-list { display: flex; flex-direction: column; }
.chapter-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 130px 20px; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; text-align: left; }
.chapter-row:hover { background: var(--surface-2); }
.chapter-row svg { width: 17px; height: 17px; color: var(--fg-3); }
.chapter-number span { display: inline-grid; place-items: center; min-width: 34px; height: 28px; padding: 0 4px; border-radius: 4px; background: var(--surface-3); color: var(--fg-3); font-size: 11px; }
.chapter-title { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.chapter-date { color: var(--fg-3); font-size: 12px; }
.chapter-row.was-read .chapter-title { color: var(--brand); }
.empty-chapters { padding: 30px; color: var(--fg-3); text-align: center; }
.saved-tabs { display: flex; gap: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
.saved-tab { padding: 10px 0; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--fg-3); font-size: 14px; }
.saved-tab.active { border-color: var(--brand); color: var(--fg); }
.saved-tab span { margin-left: 6px; color: var(--fg-3); font-size: 11px; }
.history-row { display: flex; align-items: center; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.history-row img { width: 48px; height: 66px; border-radius: 4px; object-fit: cover; }
.history-row > span { display: flex; flex: 1; flex-direction: column; gap: 5px; min-width: 0; }
.history-row b { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.history-row small { color: var(--fg-3); font-size: 12px; }
.history-row > svg { width: 18px; height: 18px; color: var(--brand); }

body.reading-mode {
  --bg: #070707;
  --surface: #151515;
  --surface-2: #1d1d1d;
  --surface-3: #292929;
  --fg: #f5f5f5;
  --fg-2: #c2c2c2;
  --fg-3: #949494;
  --brand: #f5f5f5;
  --brand-2: #d9d9d9;
  --brand-ink: #111111;
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .16);
  --line-3: rgba(255, 255, 255, .27);
  background: var(--bg);
  color: var(--fg);
}
body.reading-mode .topbar, body.reading-mode .mobile-nav { display: none; }
.reader-page { min-height: 100vh; padding-bottom: calc(80px + var(--safe-b)); background: var(--bg); }
.reader-topbar { position: fixed; top: 0; right: 0; left: 0; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr); align-items: center; gap: 16px; min-height: calc(60px + var(--safe-t)); padding: calc(8px + var(--safe-t)) 24px 8px; border-bottom: 1px solid var(--line-2); background: rgba(15, 15, 15, .96); transition: transform .16s ease, opacity .16s ease; }
.reader-back { display: inline-flex; align-items: center; justify-self: start; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 6px; color: var(--fg-2); font-size: 13px; }
.reader-back svg { width: 19px; height: 19px; }
.reader-back:hover { background: var(--surface-3); }
.reader-title { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.reader-title b, .reader-title span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-title b { font-size: 13px; font-weight: 500; }
.reader-title span { color: var(--fg-3); font-size: 11px; }
.reader-options { display: flex; justify-content: flex-end; gap: 4px; }
.reader-icon { display: grid; flex-shrink: 0; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--fg-2); }
.reader-icon:hover { background: var(--surface-3); color: var(--fg); }
.reader-icon svg { width: 19px; height: 19px; }
.reader-icon[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); }
.reader-progress { position: fixed; top: calc(60px + var(--safe-t)); right: 0; left: 0; z-index: 11; height: 2px; background: var(--line); transition: opacity .16s; }
.reader-progress span { display: block; width: 0; height: 100%; background: var(--brand); }
.reader-body { width: min(var(--reader-width), 100%); margin: 0 auto; }
.reader-image { display: block; width: 100%; height: auto; aspect-ratio: auto .7; margin: 0 auto var(--reader-gap); background: #111111; filter: brightness(var(--reader-brightness)); opacity: 0; transition: opacity .12s linear, filter .3s linear; }
.soft-images .reader-image { transition: opacity .65s ease-out, filter .3s linear; }
.reader-image.is-loaded { opacity: 1; }
.reader-image.is-error { min-height: 160px; color: var(--fg-3); font-size: 14px; }
.reader-chapter { scroll-margin-top: 0; }
.auto-chapter { padding-top: 24px; border-top: 1px solid var(--line-2); }
.auto-chapter-heading { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 12px 16px 22px; }
.auto-chapter-heading svg { width: 18px; height: 18px; color: var(--brand); }
.auto-chapter-heading h2 { margin: 0; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.reader-single .reader-image, .reader-single .reader-chapter:not(.active-chapter), .reader-single .auto-chapter-heading { display: none; }
.reader-single .reader-image.active-page { display: block; }
.reader-single .auto-chapter { padding-top: 0; border: 0; }
.auto-next-sentinel { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; min-height: 90px; margin-top: 20px; padding: 16px; color: var(--fg-3); font-size: 13px; }
.auto-next-sentinel > svg { width: 18px; height: 18px; color: var(--brand); }
.auto-loader-ring { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .75s linear infinite; }
.auto-loader-error { color: var(--danger); }
.reader-bottom { position: fixed; right: 0; bottom: 0; left: 0; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 420px) minmax(0, 1fr); align-items: center; gap: 20px; min-height: 70px; padding: 12px 24px calc(12px + var(--safe-b)); border-top: 1px solid var(--line-2); background: rgba(15, 15, 15, .96); transition: transform .16s ease, opacity .16s ease; }
.chapter-direction { display: inline-flex; align-items: center; justify-self: start; gap: 8px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface-2); color: var(--fg-2); font-size: 13px; white-space: nowrap; }
.chapter-direction svg { width: 18px; height: 18px; }
.chapter-direction:hover { border-color: var(--brand); }
.chapter-direction[aria-disabled="true"] { opacity: .3; }
.next-direction { justify-self: end; }
.chapter-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; min-width: 0; min-height: 46px; padding: 5px 14px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); text-align: left; }
.chapter-picker span { color: var(--fg-3); font-size: 10px; }
.chapter-picker b { grid-column: 1; overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.chapter-picker svg { grid-column: 2; grid-row: 1 / 3; width: 17px; height: 17px; color: var(--brand); }
.chapter-picker-popover { position: fixed; right: 50%; bottom: calc(88px + var(--safe-b)); z-index: 13; display: flex; flex-direction: column; width: min(420px, calc(100% - 24px)); max-height: min(420px, calc(100dvh - 180px)); overflow: auto; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2); box-shadow: var(--shadow-lg); transform: translateX(50%); overscroll-behavior: contain; }
.chapter-picker-popover a { flex-shrink: 0; padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--fg-2); font-size: 13px; overflow-wrap: anywhere; }
.chapter-picker-popover a.current { border-left: 3px solid var(--brand); background: var(--surface-3); color: var(--brand); }
.chapter-picker-popover a:hover { background: var(--surface-3); }
.reader-settings-panel { position: fixed; top: calc(72px + var(--safe-t)); right: 24px; z-index: 14; display: flex; flex-direction: column; gap: 16px; width: 300px; max-height: calc(100dvh - 170px - var(--safe-t) - var(--safe-b)); padding: 18px; overflow: auto; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2); box-shadow: var(--shadow-lg); overscroll-behavior: contain; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-heading b { font-size: 15px; font-weight: 500; }
.settings-heading .reader-icon { width: 28px; height: 28px; }
.device-status { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); color: var(--fg-3); font-size: 12px; }
.device-status svg { width: 16px; height: 16px; color: var(--accent); }
.setting-range { display: flex; flex-direction: column; gap: 8px; color: var(--fg-2); font-size: 12px; }
.setting-range > span { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.setting-range output { color: var(--fg-3); font-family: var(--display); font-size: 11px; white-space: nowrap; }
.setting-range input { width: 100%; margin: 0; accent-color: var(--brand); }
.setting-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--fg-2); font-size: 12px; }
.setting-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.single-page-controls { position: fixed; right: 24px; bottom: calc(90px + var(--safe-b)); z-index: 11; display: flex; align-items: center; gap: 8px; padding: 4px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface-2); transition: opacity .16s; }
.single-page-controls button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--fg-2); }
.single-page-controls button svg { width: 19px; height: 19px; }
.single-page-controls span { min-width: 65px; color: var(--fg-2); font-size: 12px; text-align: center; }
body.chrome-hidden .reader-topbar { transform: translateY(-100%); opacity: 0; pointer-events: none; }
body.chrome-hidden .reader-bottom { transform: translateY(100%); opacity: 0; pointer-events: none; }
body.chrome-hidden .reader-progress, body.chrome-hidden .single-page-controls { opacity: 0; pointer-events: none; }
body[data-reader-tv="true"] .reader-icon { width: 52px; height: 52px; }
body[data-reader-tv="true"] .reader-icon svg { width: 25px; height: 25px; }
body[data-reader-tv="true"] .reader-topbar { min-height: 78px; }
body[data-reader-tv="true"] .reader-progress { top: 78px; }
body[data-reader-tv="true"] .reader-title b { font-size: 18px; }
body[data-reader-tv="true"] .reader-title span { font-size: 14px; }
body[data-reader-tv="true"] .reader-bottom { min-height: 88px; }
body[data-reader-tv="true"] .chapter-picker b, body[data-reader-tv="true"] .chapter-direction { font-size: 17px; }
body[data-reader-tv="true"] .chapter-picker { min-height: 58px; }
body[data-reader-tv="true"] .chapter-picker-popover { bottom: calc(106px + var(--safe-b)); }
body[data-reader-tv="true"] .chapter-picker-popover a { padding: 15px 20px; font-size: 17px; }
body[data-reader-tv="true"] .reader-settings-panel { top: 90px; width: 350px; }
body[data-reader-tv="true"] .setting-toggle, body[data-reader-tv="true"] .setting-range { font-size: 15px; }

.toast-region { position: fixed; right: 20px; bottom: 24px; z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2); box-shadow: var(--shadow); opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.visible { opacity: 1; transform: none; }
.toast svg { width: 18px; height: 18px; color: var(--brand); }
.mobile-nav { display: none; }
.rise-in { opacity: 0; transition: opacity .28s ease; }
.rise-in.revealed { opacity: 1; }
.boot { display: grid; place-items: center; min-height: 70vh; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
  .topbar { gap: 24px; padding-right: 20px; padding-left: 20px; }
  .desktop-nav { gap: 18px; }
  .page-shell { width: calc(100% - 40px); }
  .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .reader-bottom { grid-template-columns: minmax(0, 1fr) minmax(140px, 320px) minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 820px) {
  .topbar { height: calc(60px + var(--safe-t)); gap: 12px; padding-right: 16px; padding-left: 16px; }
  .desktop-nav, .chrome-toggle { display: none; }
  .brand-word { font-size: 18px; }
  .page-shell { width: calc(100% - 32px); padding: 24px 0 calc(96px + var(--safe-b)); }
  .home-heading { padding-bottom: 20px; }
  .home-heading h1 { font-size: 30px; }
  .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .shelf-section { margin-top: 28px; }
  .manga-grid { gap: 20px 14px; }
  .manga-rail { grid-auto-columns: 150px; gap: 14px; }
  .mobile-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 10px calc(6px + var(--safe-b)); border-top: 1px solid var(--line-2); background: var(--bg); }
  .mobile-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; color: var(--fg-3); font-size: 10px; }
  .mobile-nav-item svg { width: 20px; height: 20px; }
  .mobile-nav-item.active { color: var(--brand); }
  .detail-hero { grid-template-columns: 150px minmax(0, 1fr); gap: 22px; }
  .detail-cover { width: 150px; }
  .detail-copy h1 { font-size: 24px; }
  .chapter-row { grid-template-columns: 40px minmax(0, 1fr) 18px; gap: 10px; }
  .chapter-date { display: none; }
  .catalog-search-wrap { flex-basis: 100%; }
  .select-field { flex: 1; min-width: 0; }
  .reader-topbar { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding-right: 10px; padding-left: 10px; }
  .reader-back { padding: 0; width: 40px; justify-content: center; }
  .reader-back span { display: none; }
  .reader-title { text-align: left; }
  .reader-title b { font-size: 11px; }
  .reader-title span { font-size: 10px; }
  .reader-options { gap: 2px; }
  .reader-bottom { grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 10px; padding-right: 12px; padding-left: 12px; }
  .chapter-direction { justify-content: center; width: 44px; min-height: 44px; padding: 0; }
  .chapter-direction span { display: none; }
  .reader-settings-panel { right: 12px; }
  .single-page-controls { right: 12px; }
  .toast-region { right: 12px; bottom: calc(80px + var(--safe-b)); left: 12px; }
  .toast { justify-content: center; }
}
@media (max-width: 560px) {
  .theme-toggle { display: none; }
  .topbar-actions { gap: 3px; }
  .search-shortcut { margin-right: 0; }
  .brand { gap: 7px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-word { font-size: 17px; }
  .provider-option { min-width: 35px; padding: 0 7px; }
  .home-heading h1 { font-size: 28px; }
  .home-heading-actions { gap: 10px; }
  .home-heading-actions .provider-badge { font-size: 10px; }
  .section-heading h2, .chapter-heading h2 { font-size: 19px; }
  .section-heading { margin-bottom: 16px; }
  .manga-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px 10px; }
  .manga-title { font-size: 12px; }
  .manga-sub { font-size: 10px; }
  .manga-rating { display: none; }
  .cover-type, .cover-src, .cover-play { display: none; }
  .manga-rail { grid-auto-columns: 132px; gap: 12px; }
  .rail-controls { display: none; }
  .genre-band { margin-top: 28px; padding: 24px 0; }
  .genre-chip { font-size: 11px; }
  .detail-hero { display: block; }
  .detail-cover { float: left; width: 100px; margin: 0 16px 16px 0; }
  .detail-copy h1 { font-size: 21px; }
  .detail-alternatives, .detail-description, .detail-facts, .detail-actions { clear: both; }
  .detail-description { margin-top: 16px; font-size: 13px; }
  .detail-facts, .detail-actions { margin-top: 20px; }
  .detail-actions .button { flex: 1 1 140px; }
  .detail-tags span { font-size: 10px; }
  .chapter-heading { flex-wrap: wrap; }
  .chapter-search { width: 100%; }
  .chapter-title { font-size: 12px; }
  .chapter-row { padding-right: 0; padding-left: 0; }
  .page-title-row h1 { font-size: 26px; }
  .pagination { gap: 10px; justify-content: space-between; }
  .pagination .button { padding: 8px 12px; font-size: 12px; }
  .reader-title { display: none; }
  .reader-topbar { grid-template-columns: 1fr auto; }
  .reader-settings-panel { width: min(300px, calc(100% - 24px)); }
  .history-row small { font-size: 10px; }
  body[data-reader-tv="true"] .reader-settings-panel { width: calc(100% - 24px); }
  body[data-reader-tv="true"] .reader-icon { width: 44px; height: 44px; }
}
@media (max-width: 360px) {
  .brand-mark { display: none; }
  .home-grid, .manga-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manga-title { font-size: 13px; }
}

body.light-theme:not(.reading-mode) {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #eeeeee;
  --surface-3: #e5e5e5;
  --fg: #161616;
  --fg-2: #505050;
  --fg-3: #6d6d6d;
  --brand: #161616;
  --brand-2: #333333;
  --brand-ink: #ffffff;
  --accent: #505050;
  --warn: #585858;
  --line: rgba(0, 0, 0, .09);
  --line-2: rgba(0, 0, 0, .16);
  --line-3: rgba(0, 0, 0, .27);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .rise-in { opacity: 1; }
}
