/* Miffy-inspired palette: warm paper white + ink black (light), and the same bunny inverted (dark).
   --bg-rgb / --ink-rgb let translucent overlays follow the theme: rgb(var(--ink-rgb) / .1) */
:root {
  color-scheme: light;
  --bg: #fbf9f6;
  --bg-rgb: 251 249 246;
  --bg-2: #f5f2ed;
  --surface: #efebe5;
  --surface-2: #e6e1d9;
  --surface-3: #ffffff;
  --ink-rgb: 20 20 20;
  --line: rgb(var(--ink-rgb) / .08);
  --line-2: rgb(var(--ink-rgb) / .14);
  --text: #141414;
  --text-2: #4b4945;
  --muted: #8a867f;
  --faint: #c3beb6;
  --accent: #141414;
  --on-accent: #fbf9f6;
  --grad: linear-gradient(var(--accent), var(--accent));
  --good: #2f9e6a;
  --title-shadow: 0 2px 22px rgb(var(--bg-rgb) / .9);
  --shadow-card: 0 18px 40px -20px rgba(0, 0, 0, .45);
  --shadow-pop: 0 14px 40px rgba(0, 0, 0, .14);
  --radius: 16px;
  --display: "Fredoka", "Nunito", ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --gutter: max(16px, var(--sl));
  --gutter-r: max(16px, var(--sr));
  --tabbar-h: 62px;
}

/* dark theme; the reader always uses it so pages sit on black */
:root[data-theme="dark"], body.reading {
  color-scheme: dark;
  --bg: #0c0c0c;
  --bg-rgb: 12 12 12;
  --bg-2: #141414;
  --surface: #1b1b1b;
  --surface-2: #242424;
  --surface-3: #313131;
  --ink-rgb: 245 241 234;
  --line: rgb(245 241 234 / .08);
  --line-2: rgb(245 241 234 / .14);
  --text: #f5f1ea;
  --text-2: #bdb8b0;
  --muted: #86827b;
  --faint: #4a4845;
  --accent: #f5f1ea;
  --on-accent: #0c0c0c;
  --good: #4cd391;
  --title-shadow: 0 4px 30px rgba(0, 0, 0, .6);
  --shadow-card: 0 24px 50px -16px rgba(0, 0, 0, .9);
  --shadow-pop: 0 14px 40px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 500 15px/1.45 "Nunito", ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { -webkit-user-drag: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

svg.i {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
svg.i.fill { fill: currentColor; stroke: none; }

/* ======================================================================
   Shared controls
   ====================================================================== */
.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text);
  transition: background .15s ease, transform .12s ease;
}
.icon-btn:active { transform: scale(.92); background: rgb(var(--ink-rgb) / .08); }
.icon-btn.glass {
  background: rgb(var(--bg-rgb) / .6);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid rgb(var(--ink-rgb) / .08);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; max-width: 100%;
  border: 0; border-radius: 12px;
  font-weight: 700; font-size: 15px; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: transform .12s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn > span { overflow: hidden; text-overflow: ellipsis; }
.btn { border-radius: 999px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 24px -14px rgb(var(--ink-rgb) / .7); }
.btn-primary:hover { filter: brightness(1.15); }
.btn-secondary { background: rgb(var(--ink-rgb) / .06); color: var(--text); border: 1px solid var(--line-2); }
.btn-secondary:hover { background: rgb(var(--ink-rgb) / .1); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-danger { background: rgba(255, 70, 90, .12); color: #ff6b7d; border: 1px solid rgba(255, 70, 90, .25); }
.btn-block { display: flex; width: 100%; }
.btn-square { width: 48px; padding: 0; flex: none; }
.btn svg.i { width: 20px; height: 20px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.tag { height: 26px; padding: 0 10px; font-size: 12px; color: var(--text-2); background: rgb(var(--ink-rgb) / .06); border-color: transparent; }

.pbar { height: 3px; background: rgb(var(--ink-rgb) / .14); border-radius: 2px; overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; min-width: 0; height: 40px; margin: 0;
  background: transparent; --fill: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), rgb(var(--ink-rgb) / .16) var(--fill));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px;
  border: 3px solid var(--bg); border-radius: 50%; background: var(--accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgb(var(--ink-rgb) / .16); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 3px solid var(--bg); border-radius: 50%; background: var(--accent); }

.field {
  width: 100%; height: 52px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font-size: 16px;
  outline: none; transition: border-color .15s;
}
.field:focus { border-color: var(--accent); }

.message { padding: 72px 32px calc(var(--sb) + 40px); text-align: center; color: var(--muted); }
.message .message-title { color: var(--text); font: 700 19px/1.3 var(--display); margin: 0 0 6px; }
.message p { margin: 0 0 20px; }
.message code { color: var(--text-2); word-break: break-all; }

.spinner {
  width: 28px; height: 28px; margin: 80px auto;
  border: 3px solid rgb(var(--ink-rgb) / .1); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }

/* lazy images fade in */
.art { position: relative; overflow: hidden; background: var(--surface); }
.art img { width: 100%; height: 100%; display: block; object-fit: cover; opacity: 0; transition: opacity .4s ease; }
.art img.ok { opacity: 1; }
.art picture { display: contents; }

/* ======================================================================
   Brand
   ====================================================================== */
.logo { display: inline-flex; align-items: center; gap: 6px; font: 600 26px/1 var(--display); letter-spacing: .01em; color: var(--text); }
.logo-mark {
  width: 32px; height: 32px; flex: none;
  background: currentColor;                        /* bunny silhouette in the text colour; eyes are see-through */
  -webkit-mask: url("/bunny.png") center / contain no-repeat;
          mask: url("/bunny.png") center / contain no-repeat;
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.4);
}
.logo:hover .logo-mark { transform: rotate(-8deg) scale(1.06); }
.logo-text { color: inherit; }
.bunny {
  display: inline-block; background: currentColor;
  -webkit-mask: url("/bunny.png") center / contain no-repeat;
          mask: url("/bunny.png") center / contain no-repeat;
}

/* ======================================================================
   Avatars
   ====================================================================== */
.avatar {
  --c1: #ff8a3d; --c2: #ff3d6e;
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .35), transparent 55%), linear-gradient(140deg, var(--c1), var(--c2));
  color: #fff; font: 700 20px/1 "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  user-select: none;
}
.avatar .av-bunny { width: 56%; height: 56%; color: #fff; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.glyphs .av-bunny { width: 58%; height: 58%; }
.avatar .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.xl { width: 112px; height: 112px; font-size: 50px; }
.avatar.lg { width: 84px; height: 84px; font-size: 38px; }
.avatar.sm { width: 32px; height: 32px; font-size: 15px; }

/* ======================================================================
   Full screens: gate + profile picker
   ====================================================================== */
.screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--st) + 28px) var(--gutter-r) calc(var(--sb) + 32px) var(--gutter);
  background:
    radial-gradient(120% 60% at 50% -10%, rgb(var(--ink-rgb) / .05), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgb(var(--ink-rgb) / .04), transparent 60%),
    var(--bg);
}
.screen .logo { margin-bottom: auto; animation: fade .6s ease both; }
.screen-body { width: 100%; max-width: 560px; margin: 40px 0 auto; text-align: center; animation: rise .5s ease both; }
.screen h1 { font: 700 30px/1.15 var(--display); margin: 0 0 8px; letter-spacing: -.01em; }
.screen .sub { color: var(--muted); margin: 0 0 34px; }

.profile-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 26px 14px; justify-items: center;
  max-width: 520px; margin: 0 auto;
}
.pf {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: 112px; padding: 0; border: 0; background: none;
  animation: pop .4s cubic-bezier(.2, .9, .3, 1.2) both;
}
.pf .avatar { transition: transform .2s ease, box-shadow .2s ease; }
.pf:hover .avatar, .pf:focus-visible .avatar { transform: scale(1.05); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }
.pf:active .avatar { transform: scale(.95); }
.pf-name { font-weight: 600; font-size: 15px; color: var(--text-2); max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf:hover .pf-name { color: var(--text); }
.pf-add .avatar { background: transparent; border: 2px dashed var(--line-2); box-shadow: none; color: var(--muted); }
.pf-edit {
  position: absolute; inset: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .55); color: #fff;
}
.pf-edit svg.i { width: 30px; height: 30px; }
.manage-row { margin-top: 44px; }

/* ======================================================================
   App shell: top bar + tab bar
   ====================================================================== */
#app { padding-bottom: calc(var(--tabbar-h) + var(--sb) + 24px); }
.view { animation: fade .25s ease both; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--st) + 10px) var(--gutter-r) 10px var(--gutter);
  background: linear-gradient(180deg, rgb(var(--bg-rgb) / .94), rgb(var(--bg-rgb) / .8));
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: background .25s ease, border-color .25s ease;
}
.topbar.over { position: fixed; left: 0; right: 0; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.topbar.over.scrolled { background: rgb(var(--bg-rgb) / .9); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border-bottom-color: var(--line); }
.topbar h1 { flex: 1; margin: 0; font: 700 26px/1.1 var(--display); letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }
.topbar .avatar-btn { padding: 0; border: 0; background: none; border-radius: 50%; }
.topbar-title { flex: 1; min-width: 0; font: 600 17px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s; }
.topbar.scrolled .topbar-title { opacity: 1; }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--sb));
  padding: 0 var(--sr) var(--sb) var(--sl);
  background: rgb(var(--bg-rgb) / .9);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); font-size: 11px; font-weight: 600;
  transition: color .15s;
}
.tab svg.i { width: 24px; height: 24px; transition: transform .2s cubic-bezier(.2, .9, .3, 1.3); }
.tab.on { color: var(--text); }
.tab.on svg.i { color: var(--accent); transform: translateY(-1px) scale(1.06); }
.tab:active svg.i { transform: scale(.88); }

/* ======================================================================
   Home: hero carousel
   ====================================================================== */
.hero { position: relative; margin-bottom: 8px; }
.hero-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.hero-track::-webkit-scrollbar { display: none; }
.slide {
  position: relative; flex: 0 0 100%; scroll-snap-align: start;
  height: min(128vw, 640px);
  overflow: hidden; isolation: isolate;
}
.slide .bg { position: absolute; inset: 0; z-index: -2; }
.slide .bg img { object-position: 50% 12%; }
.slide .bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgb(var(--bg-rgb) / .92) 0%, rgb(var(--bg-rgb) / .55) 12%, rgb(var(--bg-rgb) / 0) 26%, rgb(var(--bg-rgb) / 0) 40%, rgb(var(--bg-rgb) / .85) 72%, var(--bg) 100%);
}
.slide .poster { display: none; }
.slide-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 var(--gutter-r) 34px var(--gutter);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.slide-kicker {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 8px;
}
.slide h2 {
  margin: 0 0 8px; font: 800 clamp(30px, 8.5vw, 52px)/1.02 var(--display); letter-spacing: -.02em;
  text-shadow: var(--title-shadow);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.slide-meta { color: var(--text-2); font-size: 13px; margin-bottom: 18px; }
.slide-meta .dot { margin: 0 6px; color: var(--faint); }
.slide-desc { display: none; }
.slide-actions { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.slide-actions .btn-primary { flex: 1; }
.dots { position: absolute; left: 0; right: 0; bottom: 12px; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: rgb(var(--ink-rgb) / .22); transition: width .3s ease, background .3s ease; }
.dots i.on { width: 20px; background: var(--accent); }

/* ======================================================================
   Rails & cards
   ====================================================================== */
.rail { margin: 22px 0 6px; animation: rise .45s ease both; }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 var(--gutter-r) 0 var(--gutter); margin-bottom: 12px; }
.rail-head h3 { margin: 0; font: 700 19px/1.2 var(--display); letter-spacing: -.005em; }
.rail-head a { font-size: 13px; font-weight: 600; color: var(--text-2); }
.rail-head a:hover { color: var(--accent); }
.rail-track {
  display: flex; gap: 12px; overflow-x: auto;
  padding: 2px var(--gutter-r) 6px var(--gutter);
  scroll-snap-type: x proximity; scroll-padding: 0 var(--gutter);
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.rail-track::-webkit-scrollbar { display: none; }
.rail-track > * { scroll-snap-align: start; flex: none; }

.poster-card { width: 128px; display: block; }
.poster-card .art { aspect-ratio: 2 / 3; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); transition: transform .2s ease; }
.poster-card:hover .art { transform: translateY(-3px); }
.poster-card:active .art { transform: scale(.97); }
.poster-card .pbar { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 0; height: 4px; background: rgba(0, 0, 0, .55); }
.art .pbar > i { background: #fff; }               /* bars drawn over cover art are always white */
.poster-title { margin-top: 9px; font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poster-sub { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  height: 20px; padding: 0 7px; border-radius: 5px;
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent); color: var(--on-accent);
}
.badge.done { background: rgba(10, 10, 14, .78); color: var(--good); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

.cont-card { width: 248px; display: block; }
.cont-card .art { aspect-ratio: 16 / 10; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.cont-card .art img { object-position: 50% 18%; }
.cont-card .art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, .7)); }
.cont-card .play {
  position: absolute; z-index: 1; right: 10px; bottom: 12px;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .95); color: #000;
  transition: transform .2s ease;
}
.cont-card:hover .play { transform: scale(1.1); }
.cont-card .play svg.i { width: 16px; height: 16px; margin-left: 2px; }
.cont-card .pct { position: absolute; z-index: 1; left: 12px; bottom: 14px; font-size: 12px; font-weight: 700; color: #fff; }
.cont-card .pbar { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: 4px; border-radius: 0; background: rgba(255, 255, 255, .2); }
.cont-card:active .art { transform: scale(.98); }
.cont-title { margin-top: 10px; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cont-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 22px 12px; padding: 4px var(--gutter-r) 0 var(--gutter);
}
.grid .poster-card { width: auto; animation: rise .4s ease both; }

.empty {
  margin: 22px var(--gutter-r) 0 var(--gutter); padding: 40px 24px;
  text-align: center; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: var(--radius);
}
.empty svg.i { width: 36px; height: 36px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font: 600 17px/1.3 var(--display); margin-bottom: 4px; }

/* ======================================================================
   Browse
   ====================================================================== */
.search {
  position: relative; margin: 4px var(--gutter-r) 12px var(--gutter);
}
.search svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search input { padding-left: 44px; height: 48px; border-radius: 14px; background: var(--surface); border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 var(--gutter-r) 14px var(--gutter); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.result-count { padding: 0 var(--gutter-r) 12px var(--gutter); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.sort-btn { border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; padding: 6px 0; }
.sort-btn svg.i { width: 16px; height: 16px; }

/* ======================================================================
   My list / history
   ====================================================================== */
.seg { display: flex; margin: 4px var(--gutter-r) 18px var(--gutter); padding: 4px; border-radius: 12px; background: var(--surface); }
.seg button {
  flex: 1; height: 38px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: background .2s, color .2s;
}
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.hist { list-style: none; margin: 0; padding: 0 var(--gutter-r) 0 var(--gutter); }
.hist-day { margin: 18px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hist-item { display: flex; gap: 14px; align-items: center; padding: 8px 0; animation: rise .35s ease both; }
.hist-item .art { width: 58px; aspect-ratio: 2 / 3; border-radius: 8px; flex: none; }
.hist-body { flex: 1; min-width: 0; }
.hist-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-sub { font-size: 13px; color: var(--muted); margin: 1px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-item .pbar { max-width: 180px; }

/* ======================================================================
   Me / profile
   ====================================================================== */
.me-head { display: flex; flex-direction: column; align-items: center; padding: 16px var(--gutter-r) 8px var(--gutter); text-align: center; }
.me-head h2 { margin: 14px 0 2px; font: 700 26px/1.2 var(--display); }
.me-head .sub { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px var(--gutter-r) 8px var(--gutter); }
.stat { padding: 16px 8px; border-radius: var(--radius); background: var(--surface); text-align: center; }
.stat b { display: block; font: 600 28px/1.1 var(--display); color: var(--text); }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.group { margin: 22px var(--gutter-r) 0 var(--gutter); }
.group-title { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 4px 8px; }
.group-box { border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 56px; padding: 10px 16px;
  border: 0; background: none; text-align: left; color: var(--text);
  font-size: 15px; font-weight: 500;
}
.item + .item { border-top: 1px solid var(--line); }
button.item:active, a.item:active { background: var(--surface-2); }
.item > svg.i:first-child { color: var(--text-2); }
.item .grow { flex: 1; min-width: 0; }
.item .val { color: var(--muted); font-size: 14px; }
.item .chev { color: var(--faint); width: 18px; height: 18px; }
.item.col { flex-direction: column; align-items: stretch; gap: 10px; }
.opts { display: flex; gap: 6px; padding: 4px; border-radius: 10px; background: var(--bg-2); }
.opts button { flex: 1; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; }
.opts button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.bright-row { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.bright-row svg.i { width: 18px; height: 18px; }
.foot-note { margin: 26px var(--gutter-r) 0 var(--gutter); color: var(--faint); font-size: 12px; text-align: center; }

/* ======================================================================
   Series detail
   ====================================================================== */
.sd-hero { position: relative; isolation: isolate; padding: calc(var(--st) + 70px) var(--gutter-r) 0 var(--gutter); }
.sd-bg { position: absolute; inset: 0 0 auto 0; height: 420px; z-index: -1; overflow: hidden; }
.sd-bg img { width: 100%; height: 100%; object-fit: cover; filter: blur(28px) saturate(1.3); transform: scale(1.25); opacity: .55; }
.sd-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(var(--bg-rgb) / .3), var(--bg) 95%); }
.sd-top { display: flex; flex-direction: column; align-items: center; text-align: center; }
.sd-poster { width: 168px; aspect-ratio: 2 / 3; border-radius: 12px; box-shadow: var(--shadow-card), 0 0 0 1px var(--line-2); animation: pop .45s ease both; }
.sd-info { margin-top: 20px; width: 100%; }
.sd-info h1 { margin: 0 0 6px; font: 800 30px/1.08 var(--display); letter-spacing: -.015em; }
.sd-by { color: var(--text-2); font-size: 14px; margin-bottom: 10px; }
.sd-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 18px; }
.sd-actions { display: flex; gap: 10px; margin: 6px 0 16px; }
.sd-actions .btn-primary { flex: 1; }
.sd-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.sd-progress .pbar { flex: 1; height: 5px; }
.sd-desc { color: var(--text-2); font-size: 14px; line-height: 1.6; margin: 0 0 4px; text-align: left; white-space: pre-line; }
.sd-bg.banner img { filter: blur(6px) saturate(1.2); transform: scale(1.06); opacity: .5; }
.sd-desc.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.more-btn { border: 0; background: none; padding: 4px 0; color: var(--text); font-weight: 600; font-size: 13px; }

.ch-head {
  position: sticky; top: calc(var(--st) + 62px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 22px; padding: 12px var(--gutter-r) 12px var(--gutter);
  background: rgb(var(--bg-rgb) / .92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.ch-head h3 { margin: 0; font: 700 18px/1.2 var(--display); }
.ch-head .tools { display: flex; gap: 2px; }
.chapters { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; padding-right: max(6px, var(--sr)); position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter-r); border-top: 1px solid var(--line); }
.row-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 66px; padding: 8px 0 8px var(--gutter); }
.row-link:active { background: var(--surface); }
.row-num {
  width: 46px; height: 46px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  font: 700 15px/1 var(--display); font-variant-numeric: tabular-nums;
}
.row-main { flex: 1; min-width: 0; }
.row-num { align-content: center; gap: 2px; line-height: 1; }
.row-num small { font: 700 9px/1 var(--display); letter-spacing: .08em; opacity: .65; }
.ch-divider {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 22px var(--gutter-r) 8px var(--gutter);
  font: 600 15px/1.2 var(--display); color: var(--text);
}
.ch-divider small { font: 600 12px/1 "Nunito", sans-serif; color: var(--muted); }
.ch-divider + .row::before { display: none; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-status { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 8px; }
.row-status .pbar { width: 70px; }
.row-new { color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: .06em; }
.row.done .row-title { color: var(--muted); }
.row.done .row-num { color: var(--faint); }
.row.current .row-num { background: var(--accent); color: var(--on-accent); }
.row.current .row-title { color: var(--text); }

.check { width: 52px; height: 52px; flex: none; display: grid; place-items: center; padding: 0; border: 0; background: transparent; }
.check svg.i { width: 26px; height: 26px; transition: transform .15s ease; }
.check circle { stroke: var(--faint); fill: transparent; transition: fill .15s ease, stroke .15s ease; }
.check path { stroke: transparent; stroke-width: 2.4; transition: stroke .15s ease; }
.check[aria-pressed="true"] circle { stroke: var(--good); fill: var(--good); }
.check[aria-pressed="true"] path { stroke: #06140d; }
.check:active svg.i { transform: scale(.82); }

/* ======================================================================
   Bottom sheet
   ====================================================================== */
#sheetRoot { position: fixed; inset: 0; z-index: 80; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); animation: fade .2s ease both; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 auto; max-width: 560px;
  padding: 10px var(--gutter-r) calc(var(--sb) + 22px) var(--gutter);
  border-radius: 22px 22px 0 0;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0;
  animation: sheetUp .32s cubic-bezier(.2, .9, .3, 1) both;
}
.sheet.closing { animation: sheetDown .2s ease both; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 18px; font: 700 21px/1.2 var(--display); text-align: center; }
.sheet .avatar-preview { display: flex; justify-content: center; margin-bottom: 12px; }
.avatar-pick { position: relative; padding: 0; border: 0; background: none; border-radius: 50%; }
.avatar-pick .cam {
  position: absolute; right: -2px; bottom: -2px;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--text); color: var(--bg); box-shadow: 0 0 0 3px var(--bg-2);
}
.avatar-pick .cam svg.i { width: 17px; height: 17px; }
.avatar-pick:active .avatar { transform: scale(.95); }
.photo-btns { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.photo-btns svg.i { width: 16px; height: 16px; }
.sheet label.lbl { display: block; margin: 18px 2px 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.glyphs { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.glyphs button {
  aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--surface);
  display: grid; place-items: center; padding: 0;
  font: 600 20px/1 "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; color: var(--text-2);
}
.glyphs button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.swatches button { aspect-ratio: 1; border: 0; border-radius: 50%; padding: 0; transition: transform .15s; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 5px var(--text); transform: scale(.92); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }

/* AniList match picker */
.match-status { color: var(--muted); text-align: center; margin: 12px 0 0; font-size: 13px; min-height: 1em; }
.match-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.match {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 8px; border: 0; border-radius: 12px; background: transparent; text-align: left;
}
.match:hover, .match:active { background: var(--surface); }
.match .art { width: 48px; aspect-ratio: 2 / 3; border-radius: 6px; flex: none; }
.match-body { min-width: 0; display: flex; flex-direction: column; }
.match-body b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-body span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ======================================================================
   Snackbar + dimmer
   ====================================================================== */
.snack {
  position: fixed; z-index: 90;
  left: var(--gutter); right: var(--gutter-r); bottom: calc(var(--sb) + var(--tabbar-h) + 12px);
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 6px 6px 6px 16px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px;
  font-size: 14px; box-shadow: var(--shadow-pop);
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
}
body.reading .snack { bottom: calc(var(--sb) + 16px); }
.snack.on { transform: none; opacity: 1; pointer-events: auto; }
.snack span { flex: 1; min-width: 0; }
.snack button { flex: none; height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 700; }

#dim { position: fixed; inset: 0; z-index: 9999; background: #000; opacity: 0; pointer-events: none; }

/* ======================================================================
   Reader
   ====================================================================== */
body.reading { background: #000; }
body.paged-reading { overflow: hidden; overscroll-behavior: none; }
#reader { background: #000; min-height: 100vh; }
.pages { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.page { position: relative; width: 100%; max-width: 900px; margin: 0 auto; background: #000; }
.pages.gaps .page + .page { margin-top: 10px; }
.page::before {
  content: attr(data-n); position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #26262e; font: 600 14px/1 var(--display); font-variant-numeric: tabular-nums;
}
.page img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .18s ease; }
.page.ok img { opacity: 1; }
.page.ok::before { content: none; }

/* paged mode: one page per screen, swipe / tap sides to turn */
.pages.paged {
  position: fixed; inset: 0; overflow: hidden;
  touch-action: pinch-zoom;
}
.pages.paged.zoomed { touch-action: auto; }
.pages.paged .strip { display: flex; height: 100%; will-change: transform; }
.pages.paged .strip.anim { transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.pages.paged.rtl .strip { flex-direction: row-reverse; }
.pages.paged .page { flex: 0 0 100%; height: 100%; max-width: none; aspect-ratio: auto !important; margin: 0; }
.pages.paged .page img { object-fit: contain; }
.pages.paged .page.endslide { display: grid; place-items: center; }
.pages.paged .page.endslide::before { content: none; }

.chapter-end { padding: 70px 28px calc(var(--sb) + 90px); text-align: center; }
.chapter-end:empty { display: none; }
.pages.paged ~ .chapter-end { display: none; }
.end-card { max-width: 380px; margin: 0 auto; }
.end-kicker { font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--good); display: inline-flex; gap: 6px; align-items: center; }
.end-kicker svg.i { width: 16px; height: 16px; }
.end-title { margin: 8px 0 30px; font: 700 22px/1.25 var(--display); color: var(--text); }
.end-next { display: flex; gap: 14px; align-items: center; padding: 12px; margin-bottom: 14px; border-radius: 16px; background: var(--surface); text-align: left; }
.end-next .art { width: 64px; aspect-ratio: 2 / 3; border-radius: 8px; flex: none; }
.end-next small { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.end-next b { display: block; font: 700 17px/1.3 var(--display); margin-top: 2px; }

/* HUD */
.hud-top, .hud-bottom {
  position: fixed; left: 0; right: 0; z-index: 50;
  background: rgba(10, 10, 14, .9);
  -webkit-backdrop-filter: blur(20px) saturate(1.3); backdrop-filter: blur(20px) saturate(1.3);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
  opacity: 0; pointer-events: none;
}
.hud-top {
  top: 0; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--st) + 6px) max(6px, var(--sr)) 8px max(6px, var(--sl));
  border-bottom: 1px solid var(--line); transform: translateY(-100%);
}
.hud-bottom {
  bottom: 0; padding: 8px var(--gutter-r) calc(var(--sb) + 14px) var(--gutter);
  border-top: 1px solid var(--line); transform: translateY(100%);
}
body.hud-on .hud-top, body.hud-on .hud-bottom { transform: none; opacity: 1; pointer-events: auto; }
.hud-title { flex: 1; min-width: 0; padding: 0 4px; }
.hud-series, .hud-chapter { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-series { font-size: 12px; color: var(--muted); font-weight: 500; }
.hud-chapter { font: 600 16px/1.25 var(--display); }
.hud-top .check { width: 42px; height: 42px; }
.hud-row { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.hud-num { min-width: 30px; font-size: 12px; font-weight: 600; text-align: center; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hud-nav { display: flex; gap: 10px; margin-top: 6px; }
.nav-btn {
  flex: 1; min-width: 0; height: 56px;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); text-align: left;
}
.nav-btn.next { justify-content: flex-end; text-align: right; }
.nav-btn span { min-width: 0; display: flex; flex-direction: column; }
.nav-btn small { font-size: 11px; color: var(--muted); font-weight: 600; }
.nav-btn b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-btn .nav-ico { color: var(--muted); }
.nav-btn .nav-ico svg.i { width: 18px; height: 18px; }
.nav-btn:active { background: var(--surface-2); }
.nav-btn:disabled { opacity: .3; pointer-events: none; }

/* ======================================================================
   Wider screens: top nav instead of tab bar, roomier layout
   ====================================================================== */
@media (min-width: 900px) {
  :root { --gutter: max(48px, var(--sl)); --gutter-r: max(48px, var(--sr)); --tabbar-h: 0px; }
  #app { padding-bottom: 60px; }
  #tabbar {
    top: 0; bottom: auto; height: 68px; left: 50%; right: auto; transform: translateX(-50%);
    justify-content: center; gap: 6px; padding: 0;
    background: transparent; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
    pointer-events: none;
  }
  .tab {
    pointer-events: auto; flex: none; max-width: none;
    flex-direction: row; gap: 8px; height: 40px; margin-top: 14px; padding: 0 16px;
    border-radius: 999px; font-size: 14px;
  }
  .tab svg.i { width: 19px; height: 19px; }
  .tab:hover { color: var(--text); background: rgb(var(--ink-rgb) / .06); }
  .tab.on { background: rgb(var(--ink-rgb) / .09); }
  body.on-series #tabbar { display: none; }
  .topbar { padding-top: calc(var(--st) + 14px); padding-bottom: 14px; }
  .topbar h1 { font-size: 30px; }

  .slide { height: min(62vw, 620px); }
  .slide .bg img { filter: blur(30px) saturate(1.3); transform: scale(1.2); opacity: .6; }
  .slide.has-banner .bg img { filter: saturate(1.1); transform: none; opacity: .75; object-position: 50% 30%; }
  .sd-bg.banner { height: 460px; }
  .sd-bg.banner img { filter: none; transform: none; opacity: .55; }
  .slide .bg::after { background: linear-gradient(180deg, rgb(var(--bg-rgb) / .75), transparent 22%), linear-gradient(90deg, rgb(var(--bg-rgb) / .95) 0%, rgb(var(--bg-rgb) / .6) 45%, rgb(var(--bg-rgb) / .2) 100%), linear-gradient(180deg, transparent 60%, var(--bg)); }
  .slide .poster {
    display: block; position: absolute; right: calc(var(--gutter-r) + 40px); top: 50%;
    width: min(26vw, 330px); aspect-ratio: 2 / 3; transform: translateY(-46%) rotate(2deg);
    border-radius: 14px; box-shadow: var(--shadow-card), 0 0 0 1px var(--line-2);
  }
  .slide-body { top: 0; right: auto; width: min(52vw, 640px); justify-content: center; align-items: flex-start; text-align: left; padding-bottom: 20px; }
  .slide h2 { font-size: clamp(40px, 4.6vw, 68px); }
  .slide-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--text-2); margin: 0 0 24px; max-width: 520px; line-height: 1.6; }
  .slide-actions { max-width: 380px; }

  .poster-card { width: 168px; }
  .cont-card { width: 320px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 30px 20px; }
  .rail-head h3 { font-size: 22px; }

  .sd-hero { padding-top: calc(var(--st) + 90px); }
  .sd-top { flex-direction: row; align-items: flex-end; text-align: left; gap: 36px; max-width: 1100px; }
  .sd-poster { width: 240px; }
  .sd-info { margin: 0; flex: 1; }
  .sd-info h1 { font-size: 46px; }
  .sd-tags { justify-content: flex-start; }
  .sd-actions { max-width: 460px; }
  .ch-head, .chapters { max-width: 1100px; margin-left: auto; margin-right: auto; }
  .ch-head { top: calc(var(--st) + 70px); padding-left: 0; padding-right: 0; margin-left: var(--gutter); margin-right: var(--gutter-r); }
  .chapters { margin: 0 var(--gutter-r) 0 var(--gutter); }
  .row-link { padding-left: 0; }
  .row + .row::before { left: 0; right: 0; }
  .row-link:hover { background: transparent; }
  .row:hover .row-title { color: var(--accent); }

  .stats, .group, .me-head, .seg, .hist, .search, .chips, .result-count { max-width: 760px; }
  #v-me > *, #v-list > .seg, #v-list > .hist { margin-left: auto; margin-right: auto; }
  .snack { bottom: 24px; }
  .hud-bottom > * { max-width: 760px; margin-left: auto; margin-right: auto; }
  .hud-nav { margin-top: 6px; }
}

@media (min-width: 1400px) {
  .poster-card { width: 190px; }
}

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