/* Sun-Manga Collector — theme A "กระจกยามค่ำ" (matches the Sun Homelab dashboard); light theme at the end */
:root {
  --bg: #120f1d; --glass: rgba(255,255,255,.07); --glass2: rgba(255,255,255,.11); --line: rgba(255,255,255,.12);
  --text: #f1eefb; --dim: #a9a3c4; --accent: #ffb347; --accent2: #ff6f61; --ink: #2a1220;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --ok: #6fd3a0; --bad: #ff6b81; --radius: 18px; --tabbar: 64px;
  font-family: "Anuphan", "Noto Sans Thai", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); background: transparent; }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 55% at 15% -5%, #3b2a66 0%, transparent 60%),
    radial-gradient(90% 45% at 105% 25%, #5a2340 0%, transparent 60%),
    radial-gradient(80% 40% at 50% 110%, #2a1d4d 0%, transparent 60%), var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
b, strong, h1, h2, h3 { font-weight: 600; }
.loading, .empty { padding: 3rem 1rem; text-align: center; color: var(--dim); }
.muted { color: var(--dim); font-size: .85rem; }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- layout */
header.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem;
  background: rgba(18,15,29,.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
header.top .brand { font-weight: 600; font-size: 1.1rem; display: flex; align-items: center; gap: .55rem; white-space: nowrap; flex: 1; }
/* horizontal logo 575x160 (ratio 3.59:1): fixed height, width follows */
header.top .brand img.logo-h { height: 36px; width: auto; max-width: 60vw; display: block; }
html[data-theme="light"] .logo-dark, html:not([data-theme="light"]) .logo-light { display: none !important; }
@media (min-width: 700px) { header.top .brand img.logo-h { height: 44px; } }
header.top .back {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  background: var(--glass); font-size: 1.3rem; flex: none;
}
header.top h1 { font-size: 1.02rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
main { padding: 1rem; max-width: 1200px; margin: 0 auto; padding-bottom: calc(var(--tabbar) + 1.5rem + env(safe-area-inset-bottom)); }
h2.sec { font-size: .95rem; margin: 1.5rem 0 .75rem; display: flex; justify-content: space-between; align-items: baseline; }
h2.sec small { font-size: .78rem; color: var(--dim); font-weight: 400; }
h2.flush { margin-top: 0; }

/* bottom tab bar */
nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  padding: .45rem 0 calc(.45rem + env(safe-area-inset-bottom));
  background: rgba(18,15,29,.86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,.07);
}
nav.tabbar a { display: grid; justify-items: center; gap: 2px; font-size: .7rem; color: var(--dim); min-width: 64px; padding: .2rem 0; }
nav.tabbar a svg { width: 23px; height: 23px; }
nav.tabbar a.on { color: var(--accent); }

/* --------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; background: var(--glass); border: 1px solid var(--line);
  border-radius: 999px; padding: .55rem 1.1rem; font-size: .95rem;
}
.btn.primary { background: var(--grad); color: var(--ink); border: 0; font-weight: 600; box-shadow: 0 6px 18px rgba(255,111,97,.25); }
.btn.small { padding: .32rem .8rem; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; }
input[type=text], input[type=password], input[type=search], select {
  width: 100%; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 14px; padding: .7rem 1rem;
}
input::placeholder { color: var(--dim); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
select option { background: #221c36; }
.search { margin-bottom: 1rem; }
.chips { display: flex; gap: .45rem; overflow-x: auto; padding: .1rem 0 .3rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: .4rem .95rem; white-space: nowrap; font-size: .88rem; }
.chip.on { background: var(--grad); color: var(--ink); border-color: transparent; font-weight: 600; }
.chip .n { color: var(--dim); margin-left: .25rem; font-size: .8rem; }
.chip.on .n { color: rgba(42,18,32,.7); }

/* ------------------------------------------------------------------ cards */
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
         backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 104px; gap: .8rem; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: none; }
.row::-webkit-scrollbar { display: none; }
.card { display: block; min-width: 0; }
.cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, #2c2447, #1b1630); box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.cover img.ok { opacity: 1; }
.cover .badge { position: absolute; top: .35rem; right: .35rem; background: rgba(18,15,29,.8); border-radius: 7px; font-size: .7rem; padding: .05rem .4rem; }
.cover .new { position: absolute; top: .35rem; left: .35rem; background: var(--accent2); color: #fff; border-radius: 7px; font-size: .68rem; padding: .05rem .4rem; font-weight: 600; }
.cover .done { position: absolute; top: .35rem; left: .35rem; background: var(--ok); color: #10241a; border-radius: 7px; font-size: .68rem; padding: .05rem .4rem; font-weight: 600; }
.card .title { font-size: .84rem; margin-top: .4rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { font-size: .72rem; color: var(--dim); margin-top: .1rem; }
.prog { height: 4px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; margin-top: .45rem; }
.prog i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 4px; }

/* "continue reading" hero */
.hero { display: flex; gap: .9rem; padding: .85rem; align-items: center; }
.hero .cover { width: 84px; flex: none; }
.hero .meta { min-width: 0; flex: 1; }
.hero .t { font-weight: 600; font-size: 1.05rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hero .s { font-size: .8rem; color: var(--dim); margin: .25rem 0 .65rem; }
.hero .prog { margin-top: .7rem; }

/* home banner (owner picked mockup 4): big uncropped cover cards, centred with the previous/next
   ones peeking at the sides (scroll-snap); title, status and buttons under the centred card */
.feat { margin: .4rem -1rem 0; }
.slides { --card: min(62vw, 260px); display: flex; gap: .9rem; overflow-x: auto; scroll-snap-type: x mandatory;
          padding: .4rem calc((100% - var(--card)) / 2) .2rem; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 var(--card); scroll-snap-align: center; min-width: 0; }
.slide .poster { display: block; position: relative; transition: transform .3s, filter .3s; transform: scale(.88); filter: brightness(.5); }
.slide.on .poster { transform: none; filter: none; }
.slide .poster .cover { border-radius: 20px; box-shadow: 0 16px 34px rgba(0,0,0,.5); }
.slide .poster .cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(10,8,18,.8), transparent 30%); }
.slide .tag { position: absolute; top: .7rem; left: .7rem; z-index: 1; background: var(--accent2); color: #fff; border-radius: 999px;
              font-size: .74rem; font-weight: 700; padding: .15rem .6rem; }
.slide .meta { position: absolute; left: .8rem; right: .8rem; bottom: .65rem; z-index: 1; font-size: .78rem; color: #eee9f8;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slide .info { text-align: center; margin: .8rem -2.5rem 0; opacity: 0; transition: opacity .25s; pointer-events: none; }
.slide.on .info { opacity: 1; pointer-events: auto; }
.slide .tt { font-size: 1.1rem; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slide .ss { font-size: .82rem; color: var(--dim); margin: .2rem 0 .7rem; }
.slide .acts { display: flex; gap: .55rem; justify-content: center; align-items: center; }
.btn.icon { width: 2.5rem; height: 2.5rem; padding: 0; justify-content: center; font-size: 1.05rem; border-radius: 50%; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: .7rem; }
.dots button { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 4px; background: var(--line); transition: width .2s; }
.dots button.on { width: 18px; background: var(--accent); }
@media (min-width: 700px) { .feat { margin: .4rem 0 0; } }

/* list rows (shelf) */
.list { display: grid; gap: .6rem; }
.item { display: flex; gap: .8rem; align-items: center; padding: .6rem; }
.item .cover { width: 54px; flex: none; border-radius: 9px; }
.item .meta { min-width: 0; flex: 1; }
.item .t { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: .78rem; color: var(--dim); }

/* ------------------------------------------------------------ series page */
.series-head { display: flex; gap: 1rem; align-items: flex-end; margin-bottom: 1.2rem; }
.series-head .cover { width: 118px; flex: none; }
.series-head .meta { min-width: 0; }
.series-head h1 { font-size: 1.3rem; margin: 0 0 .3rem; line-height: 1.25; }
.series-head .sub { color: var(--dim); font-size: .85rem; margin-bottom: .8rem; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .55rem; }
.book { display: flex; flex-direction: column; gap: .25rem; padding: .7rem .8rem; border-radius: 14px; }
.book .n { font-weight: 600; }
.book .s { font-size: .76rem; color: var(--dim); }
.book.done { opacity: .62; }
.book.done .n::after { content: " ✓"; color: var(--ok); }
.book.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.book .prog { margin-top: .3rem; height: 3px; }

/* ------------------------------------------------------------ forms/admin */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.panel { padding: 1.6rem; width: 100%; max-width: 380px; }
.panel h1 { margin: .6rem 0 1.2rem; font-size: 1.3rem; text-align: center; }
.panel .logo { display: block; width: 76px; height: 76px; margin: 0 auto; border-radius: 19.5%; box-shadow: 0 10px 30px rgba(255,111,97,.25); }
.field { margin-bottom: .85rem; }
.field label { display: block; font-size: .82rem; color: var(--dim); margin-bottom: .3rem; }
.err { color: var(--bad); min-height: 1.3em; font-size: .88rem; margin: .3rem 0; }
.box { padding: 1rem; margin-bottom: 1rem; }
.menu { display: grid; }
.menu a, .menu button { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; background: none; border: 0;
  border-bottom: 1px solid rgba(255,255,255,.07); text-align: left; width: 100%; }
.menu > :last-child { border-bottom: 0; }
.profile { display: flex; align-items: center; gap: .9rem; padding: 1rem; margin-bottom: 1rem; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--grad); color: var(--ink); display: grid; place-items: center; font-weight: 600; font-size: 1.3rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.checks label { display: flex; gap: .3rem; align-items: center; font-size: .88rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.stat { background: rgba(255,255,255,.06); border-radius: 14px; padding: .75rem; }
.stat b { display: block; font-size: 1.35rem; }

/* ----------------------------------------------------------------- reader */
body.reading { overflow: hidden; background: #000; }
body.reading::before { display: none; }
body.reading.vertical { overflow: auto; }
body.reading nav.tabbar { display: none; }
.reader { position: fixed; inset: 0; background: #000; user-select: none; -webkit-user-select: none; }
.reader.vertical { position: static; }
.reader .stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.reader .stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.reader.fitw .stage { overflow-y: auto; align-items: flex-start; }
.reader.fitw .stage img { max-height: none; width: 100%; height: auto; }
.reader .strip { max-width: 900px; margin: 0 auto; }
.reader .strip img { display: block; width: 100%; min-height: 60vh; background: #0d0b14; }
.reader .strip img.loaded { min-height: 0; background: none; }
.reader .stripend { padding: 2rem; text-align: center; }
.reader .zones { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; }
.reader .bars { transition: opacity .2s; }
.reader .bars.hide { opacity: 0; pointer-events: none; }
.reader .topbar, .reader .bottombar {
  position: fixed; left: .6rem; right: .6rem; z-index: 5; display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem;
  background: rgba(18,15,29,.78); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 18px;
}
.reader .topbar { top: calc(.6rem + env(safe-area-inset-top)); }
.reader .bottombar { bottom: calc(.6rem + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.reader .topbar .back { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--glass); font-size: 1.25rem; flex: none; }
.reader .topbar .t { flex: 1; min-width: 0; }
.reader .topbar .t b, .reader .topbar .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader .topbar .t span { font-size: .78rem; color: var(--dim); }
.reader .modesel { width: auto; max-width: 42vw; padding: .45rem .7rem; border-radius: 12px; font-size: .85rem; }
.reader input[type=range] { flex: 1; min-width: 140px; accent-color: var(--accent); }
.reader input[type=range].rtl { direction: rtl; }
.reader .pageno { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: center; font-size: .9rem; }
.reader .endcard { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1rem; }
.reader .endcard .box { max-width: 340px; }
.reader .spinner { position: absolute; color: var(--dim); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 1rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(34,28,54,.95); border: 1px solid var(--line); border-radius: 14px; padding: .6rem 1.1rem; z-index: 50; max-width: 90vw;
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .row { grid-auto-columns: 130px; }
  .hero .cover { width: 110px; }
  .series-head .cover { width: 160px; }
}

/* cover editor (admin) */
.cvbtn { margin-top: .5rem; }
.coveredit { display: flex; gap: 1rem; align-items: flex-start; }
.coveredit .cover { width: 120px; flex: none; }
.cvcontrols { flex: 1; min-width: 0; display: grid; gap: .55rem; justify-items: start; }
.cvcontrols .field { width: 100%; margin: 0; }
.cvpage { display: flex; align-items: center; gap: .6rem; width: 100%; }
.cvpage input { flex: 1; accent-color: var(--accent); }
.cvpage span { font-size: .82rem; color: var(--dim); white-space: nowrap; }
.cvcontrols select { max-width: 100%; min-width: 0; }
.cvpage input { min-width: 0; }
@media (max-width: 480px) {
  .coveredit .cover { width: 92px; }
  .cvpage { flex-wrap: wrap; }
  .cvpage input { flex-basis: 100%; }
}

/* remove-from-list buttons */
.hero { position: relative; }
.rm {
  position: absolute; top: .4rem; right: .4rem; z-index: 2; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(18,15,29,.78); color: var(--text); font-size: 1rem; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.hero .rm { top: .5rem; right: .5rem; }
.item .btn { flex: none; }
.toastbtn { margin-left: .8rem; background: none; border: 0; color: var(--accent); font-weight: 600; padding: 0; }
.list > * { min-width: 0; }

/* upload (admin) */
.upmenu { margin-bottom: 1rem; }
.pill { font-size: .72rem; padding: .1rem .55rem; border-radius: 999px; background: rgba(111,211,160,.15); color: var(--ok); }
.drop { display: grid; justify-items: center; gap: .15rem; text-align: center; padding: 1.1rem .8rem; margin: .3rem 0 .6rem;
  border: 1.5px dashed rgba(255,179,71,.55); border-radius: 16px; background: rgba(255,179,71,.05); cursor: pointer; font-size: 1.4rem; }
.drop b { font-size: .95rem; }
.drop .muted { font-size: .76rem; }
.upfile { padding: .65rem .85rem; margin-bottom: .5rem; border-radius: 14px; }
.upfile .n { display: flex; justify-content: space-between; gap: .6rem; font-size: .9rem; }
.upfile .n span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upfile .n b { flex: none; font-weight: 600; font-size: .84rem; }
.upfile .muted { font-size: .76rem; margin-top: .15rem; overflow-wrap: anywhere; }
.upfile .prog { height: 5px; }
.upfile .ok { color: var(--ok); }
.upfile .acc { color: var(--accent); }
.upfile .bad { color: var(--bad); }
.uplock { text-align: center; padding: 2rem 1.2rem; }
.uplock .ic { font-size: 2.6rem; }
.uplock h3 { margin: .6rem 0 .4rem; }
.uplock .addr { margin: 1rem 0 .4rem; padding: .65rem; border-radius: 12px; background: rgba(0,0,0,.3); border: 1px solid var(--line);
  font-family: ui-monospace, monospace; color: var(--accent); overflow-wrap: anywhere; }

/* ------------------------------------------- manage mode / trash (admin deletes) */
.btn.danger { background: rgba(255,107,129,.16); color: var(--bad); border-color: rgba(255,107,129,.45); font-weight: 600; }
.mgtools { display: flex; gap: .7rem; align-items: center; margin: 0 0 .7rem; font-size: .85rem; }
body.managing .book { cursor: pointer; padding-left: 2.3rem; position: relative; }
body.managing .book::before { content: ""; position: absolute; left: .75rem; top: .8rem; width: 1.05rem; height: 1.05rem; border-radius: 6px; border: 1.5px solid var(--line); }
body.managing .book.sel { border-color: var(--bad); background: rgba(255,107,129,.10); box-shadow: none; }
body.managing .book.sel::before { content: "✓"; background: var(--bad); border-color: var(--bad); color: #fff; font-size: .75rem; display: grid; place-items: center; }
body.managing main { padding-bottom: calc(var(--tabbar) + 5rem); }
.actbar { position: fixed; left: .7rem; right: .7rem; bottom: calc(var(--tabbar) + .6rem + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; gap: .5rem; align-items: center; padding: .6rem .7rem; border-radius: 18px; background: rgba(30,22,44,.96); box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 720px; margin: 0 auto; }
.actbar .cnt { flex: 1; font-size: .85rem; }
.sheetwrap { position: fixed; inset: 0; z-index: 60; background: rgba(5,3,10,.62); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding: 1rem 1.2rem calc(1.4rem + env(safe-area-inset-bottom)); background: #1d1630; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto .8rem; }
.sheet h3 { margin: 0 0 .6rem; font-size: 1.05rem; }
.sheet .btn.block { margin-top: .5rem; }
.dellist { background: rgba(0,0,0,.25); border-radius: 12px; padding: .5rem .8rem .5rem 1.6rem; margin: 0 0 .6rem; font-size: .88rem; line-height: 1.7; max-height: 40vh; overflow: auto; }
.trashitem { margin-bottom: .5rem; }
.trashitem .t.wrap { white-space: normal; }
.nocover { aspect-ratio: 2 / 3; display: grid; place-items: center; background: var(--glass); font-size: 1.3rem; }
.box.muted { margin-bottom: .8rem; font-size: .88rem; }
.actbar { flex-wrap: wrap; }
.actbar .cnt { flex-basis: 100%; padding: 0 .2rem .1rem; }
.actbar .btn { flex: 1; justify-content: center; }
.zrow { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

/* account: theme switch */
.menu .themerow { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--sep, rgba(255,255,255,.07)); }
.seg { display: inline-flex; background: rgba(0,0,0,.22); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: .35rem .6rem; font-size: .84rem; color: var(--dim); white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--glass2); color: var(--text); font-weight: 600; }

/* =========================================================== light theme
   Applied with html[data-theme="light"] (static/theme.js). Scoped to
   body:not(.reading) so the reader always stays black for comfortable reading. */
html[data-theme="light"] { --bg: #f6f1ea; background: var(--bg); color-scheme: light; }
html[data-theme="light"] body:not(.reading) {
  --bg: #f6f1ea; --glass: rgba(255,255,255,.72); --glass2: rgba(255,255,255,.95); --line: rgba(60,40,25,.13);
  --text: #1e1a24; --dim: #675f72; --accent: #c25e05; --accent2: #d9483b; --ink: #2a1220;
  --grad: linear-gradient(135deg, #ffb347, #ff6f61);
  --ok: #1e8a57; --bad: #c8284a; --sep: rgba(60,40,25,.09);
  color: var(--text);
}
html[data-theme="light"] body:not(.reading)::before {
  background:
    radial-gradient(120% 55% at 15% -5%, #ffdcbc 0%, transparent 60%),
    radial-gradient(90% 45% at 105% 25%, #f7d3e2 0%, transparent 60%),
    radial-gradient(80% 40% at 50% 110%, #e3dcf6 0%, transparent 60%), var(--bg);
}
html[data-theme="light"] body:not(.reading) header.top { background: rgba(250,247,242,.8); border-bottom-color: var(--sep); }
html[data-theme="light"] body:not(.reading) nav.tabbar { background: rgba(250,247,242,.92); border-top-color: var(--sep); }
html[data-theme="light"] body:not(.reading) .glass { box-shadow: 0 4px 16px rgba(80,50,30,.06); }
html[data-theme="light"] body:not(.reading) input[type=text], html[data-theme="light"] body:not(.reading) input[type=password],
html[data-theme="light"] body:not(.reading) input[type=search], html[data-theme="light"] body:not(.reading) select { background: rgba(255,255,255,.85); }
html[data-theme="light"] body:not(.reading) select option { background: #fff; }
html[data-theme="light"] body:not(.reading) .cover { background: linear-gradient(160deg, #e9e1ee, #dcd2e4); box-shadow: 0 6px 16px rgba(70,45,30,.16); }
html[data-theme="light"] body:not(.reading) .cover .badge { color: #f1eefb; }
html[data-theme="light"] body:not(.reading) .prog { background: rgba(60,40,25,.12); }
html[data-theme="light"] body:not(.reading) .menu a, html[data-theme="light"] body:not(.reading) .menu button { border-bottom-color: var(--sep); }
html[data-theme="light"] body:not(.reading) th, html[data-theme="light"] body:not(.reading) td { border-bottom-color: var(--sep); }
html[data-theme="light"] body:not(.reading) .stat { background: rgba(255,255,255,.7); }
html[data-theme="light"] body:not(.reading) .chip.on .n { color: rgba(42,18,32,.7); }
html[data-theme="light"] body:not(.reading) .rm { background: rgba(255,255,255,.92); }
html[data-theme="light"] body:not(.reading) .pill { background: rgba(30,138,87,.12); }
html[data-theme="light"] body:not(.reading) .drop { border-color: rgba(194,94,5,.45); background: rgba(255,179,71,.09); }
html[data-theme="light"] body:not(.reading) .uplock .addr,
html[data-theme="light"] body:not(.reading) .dellist { background: rgba(60,40,25,.05); }
html[data-theme="light"] body:not(.reading) .seg { background: rgba(60,40,25,.07); }
html[data-theme="light"] body:not(.reading) .btn.danger { background: rgba(200,40,74,.09); border-color: rgba(200,40,74,.35); }
html[data-theme="light"] body:not(.reading).managing .book.sel { background: rgba(200,40,74,.07); }
html[data-theme="light"] body:not(.reading) #toast { background: rgba(255,255,255,.97); box-shadow: 0 8px 24px rgba(70,45,30,.18); }
html[data-theme="light"] body:not(.reading) .actbar { background: rgba(255,255,255,.97); box-shadow: 0 10px 30px rgba(70,45,30,.18); }
html[data-theme="light"] body:not(.reading) .sheetwrap { background: rgba(40,25,30,.35); }
html[data-theme="light"] body:not(.reading) .sheet { background: #fbf8f3; }

/* header 18+ switch */
.adultsw { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .35rem .3rem .7rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--dim); font-size: .82rem; font-weight: 600; }
.adultsw .knob { width: 34px; height: 20px; border-radius: 999px; background: rgba(128,128,128,.35); position: relative; transition: background .2s; }
.adultsw .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.adultsw.on { color: var(--accent); border-color: var(--accent); }
.adultsw.on .knob { background: var(--grad); }
.adultsw.on .knob::after { transform: translateX(14px); }
header.top .brand { flex: 0 1 auto; min-width: 0; }

/* manage mode: page-1 thumbnail + cover status on each file */
body.managing .book .bthumb { position: absolute; left: 2.25rem; top: .6rem; width: 30px; border-radius: 5px; box-shadow: none; }
body.managing .book:has(.bthumb) { padding-left: 4.4rem; min-height: 4.1rem; }
.book .cvst { font-size: .7rem; }
.book .cvst.ok { color: var(--ok); } .book .cvst.acc { color: var(--accent); }
.mgtools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* cover sheet */
.sheet .step { font-size: .72rem; color: var(--accent); }
.sheet .seg { display: flex; width: 100%; margin: .7rem 0 .6rem; }
.sheet .seg button { flex: 1; }
.seg button.on { background: var(--glass2); color: var(--text); font-weight: 600; }
.sheet .seg.fit { margin: 0; }
.sheet .seg.fit button { font-size: .76rem; }
.hasc { font-size: .82rem; line-height: 1.55; padding: .75rem; margin: .6rem 0 0; }
.hasc .acts { margin: .45rem 0 .3rem; }
.pages { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; max-height: 46vh; overflow-y: auto; }
.pg { position: relative; display: block; padding: 0; border: 0; background: none; color: inherit; text-align: left; }
.pg .cover, .ba .cover { display: block; }
.pg .cover { border-radius: 7px; box-shadow: none; }
.pg .no { position: absolute; left: 4px; bottom: 4px; font-size: .62rem; background: rgba(0,0,0,.65); color: #fff; padding: 0 .3rem; border-radius: 5px; }
.pg.color::after { content: "ภาพสี"; position: absolute; top: 4px; right: 4px; font-size: .58rem; font-weight: 700;
                   background: var(--accent); color: var(--ink); padding: 0 .3rem; border-radius: 5px; }
.pg.on .cover { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.cover.blank { display: grid; place-items: center; text-align: center; font-size: .6rem; color: var(--dim); line-height: 1.3; }
.pg.all .cover { background: var(--glass); font-size: .7rem; color: var(--dim); }
.ba[hidden] { display: none; }
.ba { display: flex; align-items: center; gap: .6rem; margin: .7rem 0 .2rem; padding: .6rem; }
.ba .cover { width: 46px; flex: none; border-radius: 6px; box-shadow: none; }
.ba .cover img { opacity: 1; }
.ba .newp { outline: 2px solid var(--accent); }
.ba .ar { color: var(--accent); }
.ba .m { flex: 1; min-width: 0; font-size: .74rem; color: var(--dim); line-height: 1.5; overflow-wrap: anywhere; }
.ba .m b { color: var(--text); font-weight: 600; }
