/* ==========================================================================
   Comic-Vault - Global Stylesheet
   --------------------------------------------------------------------------
    1. Theme tokens (dark + light)    9. Home page
    2. Base & reset                  10. Browse page
    3. Layout & typography           11. Series & profile pages
    4. Header, menu & search         12. Creator pages (publish, edit, dashboard)
    5. Footer & toasts               13. Login / account pages
    6. Buttons                       14. Reader
    7. Forms                         15. Text pages (about, terms)
    8. Comic cards, grids & rows     16. Touch devices, utilities, motion
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Anton&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

/* ---------- 1. Theme tokens --------------------------------------------- */
/* "Ink & paper": printed-manga look. Yellow highlighter accent, black ink
   outlines, hard (not blurred) shadows, halftone dots.
   Dark ("ink") is the default; light ("paper") applies when the device
   prefers it (unless the user picked dark) or via the header toggle.
   All text colours meet WCAG AA contrast (4.5:1) on their backgrounds. */
:root,
.reader-body.bg-black,
.reader-body.bg-gray {
  color-scheme: dark;
  --bg: #101114;                /* ink */
  --bg-raised: #17181d;
  --surface: #1f2026;
  --surface-hover: #292a31;
  --border: #2f3038;
  --border-strong: #4a4b56;
  --ink-border: #3a3b44;        /* panel outlines */

  --text: #f5f2ea;
  --text-muted: #bdb9af;
  --text-faint: #8f8b82;

  --accent: #ffd400;            /* highlighter yellow: fills, bars, buttons */
  --accent-hover: #ffe14a;
  --accent-text: #ffd84d;       /* yellow text/links on dark */
  --accent-soft: rgba(255, 212, 0, 0.14);
  --on-accent: #141414;         /* text on yellow (12.9:1) */
  --focus: #ffd400;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #93c5fd;
  --info-soft: rgba(147, 197, 253, 0.12);

  --sticker-bg: #ffd400;
  --sticker-fg: #141414;
  --btn-border: #141414;
  --btn-shadow: #000;
  --dot: rgba(255, 212, 0, 0.14);  /* halftone dots */
  --header-bg: rgba(16, 17, 20, 0.92);
  --reader-bg: #0a0a0c;
  --shadow: 5px 5px 0 #000;
  --shadow-sm: 3px 3px 0 #000;
}

:root {
  --mode-infinite: #2ec5f0;     /* badge fills (cyan / magenta / lime), ink text >= 6:1 */
  --mode-rtl: #ff4fae;
  --mode-ltr: #a3e635;
  --danger-strong: #c62f2f;

  --font-display: "Anton", Impact, "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius-sm: 3px;
  --radius: 4px;
  --radius-lg: 6px;
  --header-h: 64px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f0e6;                /* newsprint paper */
    --bg-raised: #fffdf7;
    --surface: #ebe5d6;
    --surface-hover: #e2dac8;
    --border: #d6cdb8;
    --border-strong: #9d937e;
    --ink-border: #141414;        /* panel outlines */
    --text: #141414;
    --text-muted: #45413a;
    --text-faint: #6b6559;
    --accent-text: #1d3ccf;       /* links: blue ink (yellow is unreadable on paper) */
    --accent-hover: #f2c500;
    --focus: #1d3ccf;
    --success: #15803d;
    --success-soft: rgba(21, 128, 61, 0.1);
    --danger: #b91c1c;
    --danger-soft: rgba(185, 28, 28, 0.08);
    --info: #1d4ed8;
    --info-soft: rgba(29, 78, 216, 0.08);
    --sticker-bg: #141414;
    --sticker-fg: #ffd400;
    --btn-border: #141414;
    --btn-shadow: #141414;
    --dot: rgba(20, 20, 20, 0.16);  /* halftone dots */
    --header-bg: rgba(244, 240, 230, 0.94);
    --reader-bg: #e9e3d4;
    --shadow: 5px 5px 0 #141414;
    --shadow-sm: 3px 3px 0 #141414;
  }
}

:root[data-theme="light"],
.reader-body.bg-white {
  color-scheme: light;
  --bg: #f4f0e6;                /* newsprint paper */
  --bg-raised: #fffdf7;
  --surface: #ebe5d6;
  --surface-hover: #e2dac8;
  --border: #d6cdb8;
  --border-strong: #9d937e;
  --ink-border: #141414;        /* panel outlines */
  --text: #141414;
  --text-muted: #45413a;
  --text-faint: #6b6559;
  --accent-text: #1d3ccf;       /* links: blue ink (yellow is unreadable on paper) */
  --accent-hover: #f2c500;
  --focus: #1d3ccf;
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.1);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.08);
  --info: #1d4ed8;
  --info-soft: rgba(29, 78, 216, 0.08);
  --sticker-bg: #141414;
  --sticker-fg: #ffd400;
  --btn-border: #141414;
  --btn-shadow: #141414;
  --dot: rgba(20, 20, 20, 0.16);  /* halftone dots */
  --header-bg: rgba(244, 240, 230, 0.94);
  --reader-bg: #e9e3d4;
  --shadow: 5px 5px 0 #141414;
  --shadow-sm: 3px 3px 0 #141414;
}

/* Reader background choices (reader settings) */
.reader-body.bg-black { --reader-bg: #000; }
.reader-body.bg-gray { --reader-bg: #2b2b30; }
.reader-body.bg-white { --reader-bg: #fff; }

/* ---------- 2. Base & reset --------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

body > main { flex: 1 0 auto; }
main:focus { outline: none; }

img { display: block; max-width: 100%; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex-shrink: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }

[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 500;
  background: var(--accent); color: var(--on-accent); font-weight: 700; border: 2px solid var(--on-accent);
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 0.75rem; color: var(--on-accent); }

/* ---------- 3. Layout & typography -------------------------------------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }

/* Anton has a single weight (400); asking for bold would make the browser fake it */
h1, h2 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; letter-spacing: 0.015em; text-transform: uppercase; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
h2 { font-size: 1.5rem; }
h3 { font-family: var(--font-body); font-size: 1rem; font-weight: 700; line-height: 1.3; }

.page-header { padding: 2.5rem 0 1.5rem; }
.page-header p { color: var(--text-muted); margin-top: 0.35rem; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }

.section { margin-top: 3rem; }
.section-heading-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.75rem 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.section-heading { font-size: 1.7rem; display: flex; align-items: center; gap: 0.55rem; }
.section-heading::before {
  content: ""; width: 0.5em; height: 0.85em; flex-shrink: 0;
  background: var(--accent); transform: skewX(-14deg);
}
.section-actions { display: flex; align-items: center; gap: 0.75rem; }
.see-all { font-size: 0.9rem; font-weight: 600; }

.muted { color: var(--text-muted); }

/* ---------- 4. Header, menu & search ------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 2px solid var(--ink-border);
}

.nav-wrapper { display: flex; align-items: center; gap: 0.75rem; height: var(--header-h); }

.logo {
  display: inline-flex; align-items: center; gap: 0.55rem; flex-shrink: 0;
  font-family: var(--font-display); font-weight: 400; font-size: 1.5rem; text-transform: uppercase;
  color: var(--text); letter-spacing: 0.03em; margin-right: 0.5rem;
}
.logo:hover { color: var(--text); text-decoration: none; }
.logo-mark { display: block; width: 34px; height: 34px; flex-shrink: 0; }
.logo-mark svg { display: block; width: 100%; height: 100%; }

.header-search { position: relative; flex: 1 1 auto; max-width: 420px; min-width: 0; }
.header-search .input-field {
  height: 40px; padding: 0 0.9rem 0 2.35rem; border-radius: var(--radius-sm); background: var(--surface);
}
.search-icon {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; display: flex;
}
.search-icon svg { width: 16px; height: 16px; }

.search-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 280px; z-index: 70;
  list-style: none; padding: 0.35rem; max-height: min(70vh, 430px); overflow-y: auto;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.suggestion {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.suggestion:hover, .suggestion.is-active { background: var(--surface-hover); }
.suggestion img, .sugg-fallback {
  width: 34px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--surface); flex-shrink: 0;
}
.sugg-text { display: flex; flex-direction: column; min-width: 0; }
.sugg-title { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-meta { font-size: 0.78rem; color: var(--text-faint); }
.suggestion-all { justify-content: center; font-size: 0.88rem; font-weight: 600; color: var(--accent-text); min-height: 40px; }
.suggestion-empty { padding: 0.6rem; color: var(--text-faint); font-size: 0.88rem; list-style: none; }

.site-nav { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.nav-links { display: flex; align-items: center; gap: 0.2rem; list-style: none; }
.nav-links a {
  display: block; padding: 0.45rem 0.75rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 0.95rem; white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-links a.active { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }

.nav-user { display: flex; align-items: center; gap: 0.5rem; min-height: 36px; }
.nav-username { display: none; font-weight: 600; }
.nav-avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.95rem; flex-shrink: 0;
  border: 2px solid var(--on-accent);
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-avatar:hover { color: var(--on-accent); text-decoration: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn[aria-disabled="true"], .icon-btn:disabled { opacity: 0.35; pointer-events: none; }

.nav-toggle { display: none; }
.header-search--panel { display: none; }

/* Tablets & small laptops: links + account move into a dropdown menu */
@media (max-width: 1099px) {
  .nav-toggle { display: inline-grid; }
  .header-search--bar { margin-left: auto; }
  .site-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0; margin: 0;
    display: none; flex-direction: column; align-items: stretch; gap: 0.75rem;
    padding: 1rem 1.25rem 1.25rem; max-height: calc(100vh - var(--header-h)); overflow-y: auto;
    background: var(--bg-raised); border-bottom: 2px solid var(--ink-border); box-shadow: var(--shadow);
  }
  .site-nav.open { display: flex; }
  .nav-links { flex-direction: column; align-items: stretch; gap: 0.15rem; }
  .nav-links a { padding: 0.75rem 0.8rem; font-size: 1rem; }
  .nav-user { flex-wrap: wrap; padding-top: 0.85rem; border-top: 1px solid var(--border); }
  .nav-username { display: inline; margin-right: auto; }
}

/* Phones: the search box moves into the menu too */
@media (max-width: 640px) {
  .header-search--bar { display: none; }
  .header-search--panel { display: block; max-width: none; }
  .theme-toggle { margin-left: auto; }
  .logo { font-size: 1.2rem; }
}

/* The browse page has its own big search box */
.page-browse .header-search { display: none !important; }
.page-browse .theme-toggle { margin-left: auto; }
@media (min-width: 1100px) { .page-browse .theme-toggle { margin-left: 0; } }

/* ---------- 5. Footer & toasts ------------------------------------------ */
.site-footer {
  border-top: 3px solid var(--accent); margin-top: 4rem; padding: 2.5rem 0 2rem;
  color: var(--text-faint); font-size: 0.88rem;
}
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem 3rem; flex-wrap: wrap; }
.footer-brand { display: flex; flex-direction: column; gap: 0.5rem; max-width: 340px; }
.footer-brand .logo { font-size: 1.1rem; }
.footer-brand .logo-mark { width: 28px; height: 28px; }
.footer-brand p { color: var(--text-muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }
.footer-copy { width: 100%; padding-top: 1.25rem; border-top: 1px solid var(--border); }

.toast-region {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 400;
  display: flex; flex-direction: column; gap: 0.5rem; width: min(92vw, 440px); pointer-events: none;
}
.reader-body .toast-region { bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
.toast {
  pointer-events: auto; padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.92rem;
  background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow);
  border: 2px solid var(--ink-border); border-left: 6px solid var(--info);
  animation: toast-in 0.2s ease-out;
}
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 6. Buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); border: 2px solid var(--btn-border);
  font-weight: 700; font-size: 0.92rem; line-height: 1.2; white-space: nowrap; cursor: pointer;
  background: var(--accent); color: var(--on-accent); box-shadow: 3px 3px 0 var(--btn-shadow);
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.1s, color 0.15s;
}
.btn:hover { background: var(--accent-hover); color: var(--on-accent); text-decoration: none; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--btn-shadow); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--btn-shadow); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; box-shadow: 2px 2px 0 var(--btn-shadow); }
.btn-large { padding: 0.8rem 1.6rem; font-size: 1rem; }
.btn-full { width: 100%; }

/* Variants come after the sizes so they win */
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-secondary { background: var(--bg-raised); border-color: var(--ink-border); color: var(--text); }
.btn-secondary:hover { background: var(--surface); color: var(--text); }
.btn-outline { background: transparent; border-color: var(--ink-border); color: var(--text); }
.btn-outline:hover { background: var(--surface); color: var(--text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); box-shadow: none; }
.btn-ghost:hover { background: var(--surface); color: var(--text); box-shadow: none; transform: none; }
.btn-danger { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
.btn-danger:hover { background: #a82626; color: #fff; }

/* ---------- 7. Forms ---------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; flex: 1; min-width: 0; }
.form-group label, .field-label { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.form-hint { font-size: 0.82rem; color: var(--text-faint); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.short-input { flex: 0 0 130px; }

.input-field, .select-field {
  width: 100%; padding: 0.7rem 0.9rem; font-size: 0.95rem;
  background: var(--bg-raised); color: var(--text);
  border: 2px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-field::placeholder { color: var(--text-faint); opacity: 1; }
.input-field:hover, .select-field:hover { border-color: var(--ink-border); }
.input-field:focus, .select-field:focus { outline: none; border-color: var(--focus); box-shadow: 3px 3px 0 var(--accent); }
.select-field {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8a95' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.85rem center;
}
.select-field option { background: var(--bg-raised); color: var(--text); }
.textarea-field { resize: vertical; min-height: 110px; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.check-row { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin-top: 0.15rem; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }

.status-box, .upload-status, .auth-message {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.92rem;
}
.upload-status a, .status-box a { color: inherit; font-weight: 700; text-decoration: underline; }
.upload-status-info { background: var(--info-soft); color: var(--info); }
.upload-status-success { background: var(--success-soft); color: var(--success); }
.upload-status-error { background: var(--danger-soft); color: var(--danger); }
.status-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.65rem; }

/* ---------- 8. Comic cards, grids & rows -------------------------------- */
.comic-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem 1.1rem; list-style: none;
}
@media (max-width: 420px) {
  .comic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 0.85rem; }
}

.card-item { position: relative; min-width: 0; }
.comic-card { display: flex; flex-direction: column; color: inherit; height: 100%; }
.comic-card:hover { color: inherit; text-decoration: none; }

.cover-container {
  position: relative; aspect-ratio: 2 / 3; overflow: hidden;
  border-radius: var(--radius-sm); border: 2px solid var(--ink-border); background: var(--surface);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.cover-container .comic-cover { width: 100%; height: 100%; object-fit: cover; }
img.comic-cover { opacity: 0; transition: opacity 0.35s ease; }
img.comic-cover.is-loaded { opacity: 1; }
a.comic-card:hover .cover-container, a.comic-card:focus-visible .cover-container {
  transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--accent);
}

.cover-fallback {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 1rem;
  text-align: center; font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; text-transform: uppercase;
  color: var(--text-muted); background-color: var(--surface);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.7px); background-size: 9px 9px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block; padding: 0.2rem 0.45rem; border-radius: var(--radius-sm); white-space: nowrap;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: #141414; background: #d6d0c2; border: 1.5px solid #141414;
}
.badge-infinite { background: var(--mode-infinite); }
.badge-rtl { background: var(--mode-rtl); }
.badge-ltr { background: var(--mode-ltr); }
.cover-container .badge { position: absolute; top: 8px; left: 8px; z-index: 1; box-shadow: 2px 2px 0 #141414; }

.cover-flag {
  position: absolute; top: 8px; right: 8px; z-index: 1; padding: 0.2rem 0.45rem; border-radius: var(--radius-sm);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: #141414; color: #ffd400; border: 1.5px solid #141414; box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}
.cover-flag.is-updated { background: #fff; color: #141414; }

.card-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, 0.45); z-index: 1; }
.card-progress span { display: block; height: 100%; background: var(--accent); }

.comic-meta { padding: 0.65rem 0.15rem 0; min-width: 0; }
.comic-title {
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
a.comic-card:hover .comic-title { color: var(--accent-text); }
.comic-author { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }
.comic-chapter { display: block; font-size: 0.8rem; color: var(--text-faint); margin-top: 0.2rem; }
.comic-synopsis { display: none; }

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
a.tag:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.tag-mode { display: none; }

.card-remove {
  position: absolute; top: 6px; right: 6px; z-index: 3; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; border: 0; font-size: 1.1rem; line-height: 1;
  background: rgba(0, 0, 0, 0.7); color: #fff;
}
.card-remove:hover { background: rgba(0, 0, 0, 0.9); }

/* List view (browse page toggle) */
.comic-grid.is-list { grid-template-columns: 1fr; gap: 0.75rem; }
.is-list .comic-card {
  flex-direction: row; gap: 1rem; padding: 0.75rem;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.is-list a.comic-card:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--accent); }
.is-list .cover-container { width: 92px; flex-shrink: 0; align-self: flex-start; }
.is-list a.comic-card:hover .cover-container { transform: none; box-shadow: none; }
.is-list .cover-container .badge { display: none; }
.is-list .comic-meta { padding: 0; flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.is-list .comic-title { font-family: var(--font-display); font-weight: 400; text-transform: uppercase; letter-spacing: 0.015em; font-size: 1.3rem; -webkit-line-clamp: 1; line-clamp: 1; }
.is-list .tag-mode { display: inline-block; }
.is-list .comic-synopsis {
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--text-muted); font-size: 0.9rem; margin-top: 0.35rem;
}

/* Horizontal rows (home page, "more like this") */
.row-wrap { position: relative; }
.comic-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 170px); gap: 1.1rem;
  overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  padding: 0.3rem 0.3rem 1rem; margin: 0 -0.3rem; scrollbar-width: thin;
}
.comic-row > * { scroll-snap-align: start; }
@media (max-width: 640px) { .comic-row { grid-auto-columns: 42%; gap: 0.85rem; } }
.row-btn {
  position: absolute; top: 38%; z-index: 4; width: 44px; height: 44px; border-radius: 50%;
  display: none; place-items: center; transform: translateY(-50%);
  background: var(--bg-raised); color: var(--text); border: 2px solid var(--ink-border); box-shadow: var(--shadow-sm);
}
.row-btn svg { width: 20px; height: 20px; }
.row-btn.prev { left: -14px; }
.row-btn.next { right: -14px; }
@media (hover: hover) and (pointer: fine) {
  .row-wrap:hover .row-btn { display: grid; }
}

.grid-message {
  grid-column: 1 / -1; text-align: center; color: var(--text-muted);
  padding: 3.5rem 1rem; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.grid-message h2 { color: var(--text); margin-bottom: 0.4rem; }
.grid-message .btn { margin-top: 1rem; }

/* Loading skeletons */
.skeleton .comic-cover, .skeleton-line, .skeleton-block {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s infinite linear;
}
.skeleton .comic-cover { aspect-ratio: 2 / 3; border-radius: var(--radius); }
.skeleton-line { height: 0.8rem; border-radius: 4px; margin-top: 0.6rem; }
.skeleton-line.short { width: 55%; }
@keyframes skeleton-shimmer { to { background-position: -200% 0; } }

/* ---------- 9. Home page ------------------------------------------------ */
.hero { padding: 1.75rem 0 0.5rem; }

.carousel { position: relative; }
.carousel-track { display: grid; }
.hero-card {
  grid-area: 1 / 1; position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; gap: 2.25rem; padding: 2.25rem; min-height: 320px;
  background: var(--bg-raised); border: 3px solid var(--ink-border); border-radius: var(--radius-sm);
  box-shadow: 8px 8px 0 var(--accent);
  opacity: 0; visibility: hidden; transition: opacity 0.5s ease, visibility 0.5s;
}
.hero-card.is-active { opacity: 1; visibility: visible; }
/* Halftone dots fading in from the right, like a printed page */
.hero-card::after {
  content: ""; position: absolute; inset: 0 0 0 40%; z-index: -1;
  background-image: radial-gradient(var(--dot) 1.5px, transparent 2px); background-size: 13px 13px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 70%); mask-image: linear-gradient(90deg, transparent, #000 70%);
}
.hero-cover-link { flex-shrink: 0; }
.hero-cover {
  width: 190px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); transform: rotate(-2deg); border: 3px solid var(--ink-border);
}
.hero-text { display: flex; flex-direction: column; gap: 0.75rem; flex: 1; min-width: 0; }
.hero-eyebrow {
  align-self: flex-start; padding: 0.25rem 0.6rem; border-radius: var(--radius-sm); transform: rotate(-2deg);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--sticker-fg); background: var(--sticker-bg);
}
.hero-title { font-size: clamp(2.2rem, 5.5vw, 3.6rem); line-height: 1; }
.hero-description {
  color: var(--text-muted); max-width: 60ch;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.35rem; }

.carousel-controls { display: flex; align-items: center; justify-content: center; gap: 0.25rem; margin-top: 0.9rem; }
.carousel-btn { border-radius: 50%; }
.carousel-dot { width: 28px; height: 28px; border: 0; background: transparent; display: grid; place-items: center; }
.carousel-dot::before {
  content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong);
  transition: width 0.2s, background-color 0.2s;
}
.carousel-dot[aria-current="true"]::before { width: 22px; background: var(--accent); }

@media (max-width: 900px) {
  .hero-card { gap: 1.5rem; padding: 1.75rem; }
  .hero-cover { width: 160px; }
}
@media (max-width: 640px) {
  .hero-card { flex-direction: column; align-items: flex-start; padding: 1.5rem; gap: 1.25rem; min-height: 0; }
  .hero-cover { width: 120px; }
  .hero-card::after { inset: 0 0 55% 0; -webkit-mask-image: linear-gradient(0deg, transparent, #000 80%); mask-image: linear-gradient(0deg, transparent, #000 80%); }
}

/* ---------- 10. Browse page --------------------------------------------- */
.filter-section { margin-bottom: 1.5rem; }
.filter-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.filter-search { flex: 2 1 260px; min-width: 0; position: relative; }
.filter-search .search-icon { left: 0.95rem; }
.filter-search .input-field { padding-left: 2.5rem; height: 44px; }
.filter-panel { display: flex; gap: 0.75rem; flex: 1 1 360px; }
.filter-panel .select-field { flex: 1; min-width: 0; height: 44px; padding-top: 0; padding-bottom: 0; }
.filters-toggle { display: none; height: 44px; }
.filter-count {
  display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.3rem; padding: 0 0.3rem;
  border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); font-size: 0.72rem; font-weight: 700;
}
.view-toggle { display: inline-flex; flex-shrink: 0; border: 2px solid var(--ink-border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button {
  width: 44px; height: 42px; display: grid; place-items: center;
  background: transparent; border: 0; color: var(--text-faint);
}
.view-toggle button + button { border-left: 2px solid var(--ink-border); }
.view-toggle button[aria-pressed="true"] { background: var(--surface-hover); color: var(--text); }
.view-toggle svg { width: 18px; height: 18px; }

.chip-row { display: flex; gap: 0.5rem; margin-top: 0.85rem; overflow-x: auto; padding: 0.15rem 0.15rem 0.35rem; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 0.45rem 0.95rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.88rem;
  background: var(--bg-raised); border: 2px solid var(--border-strong); color: var(--text-muted);
}
.chip:hover { border-color: var(--ink-border); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.results-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; margin-top: 0.85rem; }
.results-info { color: var(--text-faint); font-size: 0.88rem; min-height: 1.3em; }
.results-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

@media (max-width: 760px) {
  .filters-toggle { display: inline-flex; }
  .filter-panel { display: none; flex-basis: 100%; flex-direction: column; }
  .filter-panel.open { display: flex; }
  .filter-panel .select-field { flex: none; }
}

.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0.4rem; margin-top: 3rem; }
.pagination button {
  min-width: 42px; height: 42px; padding: 0 0.85rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem;
  background: var(--bg-raised); border: 2px solid var(--border-strong);
}
.pagination button:hover:not(:disabled) { border-color: var(--ink-border); background: var(--surface-hover); }
.pagination button.active { background: var(--accent); border-color: var(--ink-border); color: var(--on-accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.page-gap { color: var(--text-faint); padding: 0 0.25rem; }
.load-more-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-top: 2rem; color: var(--text-faint); font-size: 0.88rem; }

/* ---------- 11. Series & profile pages ---------------------------------- */
.series-hero { display: grid; grid-template-columns: 240px 1fr; gap: 2.5rem; align-items: start; padding: 2.5rem 0 1rem; }
.series-cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 3px solid var(--ink-border); box-shadow: var(--shadow); }
.series-info { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.series-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.92rem; }
.series-meta .dot { color: var(--text-faint); }
.series-meta a:not(.tag) { color: var(--text); font-weight: 600; }
.series-synopsis { color: var(--text-muted); max-width: 70ch; white-space: pre-line; }
.series-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.35rem; }

.chapter-list { list-style: none; border: 2px solid var(--ink-border); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); }
.chapter-item { display: flex; align-items: stretch; background: var(--bg-raised); }
.chapter-item + .chapter-item { border-top: 1px solid var(--border); }
.chapter-row {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.1rem;
  color: var(--text); transition: background-color 0.15s;
}
.chapter-row:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.chapter-row-num { font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; letter-spacing: 0.02em; color: var(--accent-text); min-width: 3.5rem; }
.chapter-row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-row-date { color: var(--text-faint); font-size: 0.85rem; white-space: nowrap; }
.chapter-pill {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); white-space: nowrap;
}
.chapter-pill.is-reading { background: var(--info-soft); color: var(--info); }
.chapter-edit {
  display: flex; align-items: center; gap: 0.35rem; padding: 0 1rem; font-size: 0.85rem; font-weight: 600;
  border-left: 1px solid var(--border); color: var(--text-muted);
}
.chapter-edit:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.chapter-edit svg { width: 15px; height: 15px; }

.profile-header { display: flex; align-items: center; gap: 1.5rem; padding: 2.5rem 0 1.5rem; flex-wrap: wrap; }
.profile-avatar {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-family: var(--font-display); font-weight: 400; font-size: 2.6rem;
  border: 3px solid var(--ink-border); box-shadow: var(--shadow-sm);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.profile-info p { color: var(--text-muted); }

@media (max-width: 900px) {
  .series-hero { grid-template-columns: 200px 1fr; gap: 1.75rem; }
}
@media (max-width: 640px) {
  .series-hero { grid-template-columns: 1fr; gap: 1.25rem; padding-top: 1.5rem; }
  .series-cover { width: 150px; }
  .chapter-row { gap: 0.75rem; padding: 0.85rem 0.9rem; }
  .chapter-row-date { display: none; }
  .chapter-edit { padding: 0 0.85rem; }
  .chapter-edit span { display: none; }
}

/* ---------- 12. Creator pages (publish, edit, dashboard) ----------------- */
.creator-page .page-header { max-width: 820px; }
.upload-form { display: flex; flex-direction: column; gap: 1.5rem; max-width: 820px; }

.mode-switch {
  display: inline-flex; gap: 4px; padding: 4px; align-self: flex-start;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius-sm);
}
.mode-switch label {
  position: relative; padding: 0.55rem 1rem; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 600; font-size: 0.9rem; color: var(--text-muted); transition: background-color 0.15s, color 0.15s;
}
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch label:has(input:checked) { background: var(--text); color: var(--bg); }
.mode-switch label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.mode-switch label:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

.form-section { border: 2px solid var(--ink-border); border-radius: var(--radius-sm); padding: 1.5rem; background: var(--bg-raised); box-shadow: var(--shadow-sm); }
.form-section legend { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; letter-spacing: 0.02em; text-transform: uppercase; padding: 0 0.5rem; margin-left: -0.5rem; }
.danger-zone { border-color: var(--danger); }
.danger-zone legend { color: var(--danger); }
.danger-zone p { color: var(--text-muted); margin-bottom: 1rem; }

.file-dropzone {
  position: relative; text-align: center; color: var(--text-muted); padding: 2rem 1rem;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg);
  transition: border-color 0.15s, background-color 0.15s;
}
.file-dropzone:hover, .file-dropzone.is-dragover, .file-dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.file-dropzone p { color: var(--text); font-weight: 600; margin-top: 0.4rem; }
.file-dropzone small { color: var(--text-faint); }
/* Invisible input covers the whole zone so click AND native drag-drop work */
.file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-icon { font-size: 2rem; line-height: 1; }

.cover-thumb { position: relative; display: inline-block; margin-top: 0.85rem; }
.cover-thumb img { width: 150px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cover-thumb figcaption { font-size: 0.8rem; color: var(--text-faint); margin-top: 0.35rem; }
.thumb-remove {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--bg-raised); background: var(--danger-strong); color: #fff; font-size: 0.95rem; line-height: 1;
}

.file-list-preview { margin-top: 0.85rem; }
.empty-list-note, .page-count-note { color: var(--text-faint); font-size: 0.88rem; margin-bottom: 0.5rem; }
.page-items { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; max-height: 460px; overflow-y: auto; padding-right: 0.25rem; }
.page-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0.6rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.page-num { width: 2rem; text-align: right; color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.page-thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--surface); }
.page-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.page-tag {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.15rem 0.45rem; border-radius: 999px; background: var(--success-soft); color: var(--success);
}
.page-actions { display: flex; gap: 0.25rem; }
.page-actions button {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.page-actions button:hover:not(:disabled) { background: var(--surface-hover); }
.page-actions button:disabled { opacity: 0.3; cursor: not-allowed; }
.page-actions button[data-action="remove"]:hover { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }

.upload-progress { height: 8px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.upload-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }

.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; }

.dash-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.dash-item {
  display: grid; grid-template-columns: 84px 1fr; gap: 1rem 1.25rem; padding: 1rem;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.dash-cover, .dash-cover-fallback {
  width: 84px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface);
}
.dash-cover-fallback { display: grid; place-items: center; padding: 0.35rem; font-size: 0.7rem; text-align: center; color: var(--text-faint); }
.dash-main { min-width: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.dash-title { font-size: 1.2rem; }
.dash-title a { color: var(--text); }
.dash-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.75rem; color: var(--text-muted); font-size: 0.88rem; }
.dash-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.dash-chapters { grid-column: 1 / -1; }
.dash-chapters summary { cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 0.9rem; padding: 0.3rem 0; }
.dash-chapters summary:hover { color: var(--text); }
.dash-chapter-list { list-style: none; margin-top: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dash-chapter { display: flex; align-items: center; gap: 0.5rem 0.75rem; padding: 0.55rem 0.9rem; flex-wrap: wrap; }
.dash-chapter + .dash-chapter { border-top: 1px solid var(--border); }
.dash-ch-num { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.02em; color: var(--accent-text); min-width: 3.2rem; }
.dash-chapter-title { flex: 1; min-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-chapter-date { color: var(--text-faint); font-size: 0.82rem; }
@media (max-width: 520px) {
  .dash-item { grid-template-columns: 64px 1fr; padding: 0.85rem; }
  .dash-cover, .dash-cover-fallback { width: 64px; }
}

/* ---------- 13. Login / account pages ----------------------------------- */
.auth-container { display: flex; justify-content: center; align-items: flex-start; padding: 3.5rem 1.25rem; }
.auth-card {
  width: 100%; max-width: 420px; padding: 2rem;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 1.75rem;
  background: var(--bg); border: 2px solid var(--ink-border); border-radius: var(--radius-sm);
}
.tab-btn {
  display: block; text-align: center; padding: 0.55rem; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); font-weight: 600;
}
.tab-btn:hover { color: var(--text); text-decoration: none; }
.tab-btn.active { background: var(--text); color: var(--bg); }
.auth-form h1, .auth-form h2 { font-size: 1.5rem; }
.auth-subtitle { color: var(--text-muted); font-size: 0.92rem; margin: 0.3rem 0 1.5rem; }
.auth-message:empty { display: none; }
.auth-message { margin-top: 1rem; }
.auth-switch { text-align: center; margin-top: 1.25rem; font-size: 0.9rem; color: var(--text-muted); }
.auth-links-row { display: flex; justify-content: flex-end; margin: -0.35rem 0 1.1rem; font-size: 0.88rem; }

/* ---------- 14. Reader -------------------------------------------------- */
/* overscroll-behavior-x stops sideways page swipes from triggering the browser's "back" gesture */
.reader-body { background: var(--reader-bg); --reader-chrome: 150px; overscroll-behavior-x: none; }
.reader-container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 1rem 2rem; }
.reader-body.is-spread-mode .reader-container { max-width: 1500px; }

.reader-toolbar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem 0 0.9rem;
}
.comic-title-info { min-width: 0; }
.back-link { display: inline-block; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.back-link:hover { color: var(--text); }
.comic-title-info h1 { font-size: clamp(1.35rem, 3vw, 1.9rem); }
.comic-title-info h1 a { color: var(--text); }
.comic-title-info h1 a:hover { color: var(--accent-text); text-decoration: none; }
.chapter-subtitle { display: block; color: var(--text-muted); margin-top: 0.15rem; }
.toolbar-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.toolbar-controls .select-field { width: auto; min-width: 190px; max-width: 280px; height: 40px; padding-top: 0; padding-bottom: 0; }

.reader-tip { color: var(--text-faint); font-size: 0.82rem; margin-bottom: 0.9rem; }
kbd {
  font-family: inherit; font-size: 0.75rem; padding: 0.05rem 0.4rem; color: var(--text-muted);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface);
}

.reader-display { position: relative; display: flex; justify-content: center; }
.reader-loading { width: 100%; max-width: 800px; aspect-ratio: 2 / 3; border-radius: var(--radius); }

/* Vertical (webtoon) mode */
.infinite-wrapper { width: 100%; max-width: 800px; display: flex; flex-direction: column; }
.chapter-segment { display: flex; flex-direction: column; }
.webtoon-page { width: 100%; height: auto; min-height: 50vh; background: var(--surface); }
.webtoon-page.is-loaded { min-height: 0; background: none; }
.reader-body.has-gaps .webtoon-page + .webtoon-page { margin-top: 14px; }
.segment-divider {
  margin: 2.5rem 0 1.25rem; padding: 1rem; text-align: center; font-size: 1.4rem;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius-sm);
}
.segment-divider small { display: block; margin-bottom: 0.15rem; font-family: var(--font-body); font-weight: 600; font-size: 0.78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }

/* Single-page mode (LTR / RTL) */
.single-page-wrapper {
  position: relative; display: flex; justify-content: center; width: 100%;
  user-select: none; -webkit-user-select: none; touch-action: pan-y pinch-zoom;
}
.page-stage { display: flex; justify-content: center; align-items: flex-start; max-width: 100%; box-shadow: var(--shadow); transition: opacity 0.15s; }
.page-stage.is-rtl { flex-direction: row-reverse; }
.page-stage img {
  display: block; width: auto; height: auto; max-width: 100%; flex-shrink: 0;
  max-height: calc(100vh - var(--reader-chrome)); object-fit: contain; -webkit-user-drag: none;
}
@supports (height: 100svh) {
  .page-stage img { max-height: calc(100svh - var(--reader-chrome)); }
}
.page-stage.is-spread img { max-width: 50%; flex-shrink: 1; }

.reader-body.fit-width .page-stage { width: 100%; }
.reader-body.fit-width .page-stage img { width: 100%; max-height: none; }
.reader-body.fit-width .page-stage.is-spread img { width: 50%; }

/* Zoomed in (double-tap / double-click / Z) */
.single-page-wrapper.is-zoomed { touch-action: auto; }
.single-page-wrapper.is-zoomed .page-nav-overlay { display: none; }
.single-page-wrapper.is-zoomed .page-stage {
  width: 100%; overflow: auto; justify-content: flex-start; cursor: zoom-out; overscroll-behavior: contain;
  max-height: calc(100vh - var(--reader-chrome));
}
@supports (height: 100svh) {
  .single-page-wrapper.is-zoomed .page-stage { max-height: calc(100svh - var(--reader-chrome)); }
}
.single-page-wrapper.is-zoomed .page-stage img { width: 200%; max-width: none; max-height: none; flex-shrink: 0; }
.single-page-wrapper.is-zoomed .page-stage.is-spread img { width: 100%; }

.page-nav-overlay {
  position: absolute; top: 0; bottom: 0; width: 35%; z-index: 2; padding: 0 1rem;
  display: flex; align-items: center; border: 0; background: transparent; cursor: pointer;
  font-size: 3rem; color: #fff; opacity: 0; transition: opacity 0.2s; -webkit-tap-highlight-color: transparent;
}
.prev-overlay { left: 0; justify-content: flex-start; background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent); }
.next-overlay { right: 0; justify-content: flex-end; background: linear-gradient(270deg, rgba(0, 0, 0, 0.35), transparent); }
.page-nav-overlay:focus-visible { opacity: 1; outline-offset: -4px; }
@media (hover: hover) {
  .single-page-wrapper:hover .page-nav-overlay { opacity: 0.5; }
  .single-page-wrapper .page-nav-overlay:hover { opacity: 1; }
}

.page-spinner {
  position: absolute; top: 50%; left: 50%; z-index: 3; width: 38px; height: 38px; margin: -19px 0 0 -19px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; display: none; pointer-events: none;
}
.single-page-wrapper.is-loading .page-spinner { display: block; }
.single-page-wrapper.is-loading .page-stage { opacity: 0.45; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-error { padding: 3rem 1rem; text-align: center; color: var(--text-muted); }
.page-error .btn { margin-top: 1rem; }

.page-counter { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-top: 0.75rem; font-variant-numeric: tabular-nums; }

.reader-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 120; pointer-events: none; }
.reader-progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }

.chapter-end {
  text-align: center; padding: 2.5rem 1rem; margin-top: 2rem;
  background: var(--bg-raised); border: 2px solid var(--ink-border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.chapter-end h2 { font-size: 1.3rem; }
.chapter-end p { color: var(--text-muted); margin: 0.35rem 0 1.25rem; }
.chapter-end-actions { display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }

.reader-bottom-nav { display: flex; justify-content: space-between; gap: 0.75rem; margin: 2rem 0 1rem; }

.reader-error { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.reader-error h1, .reader-error h2 { color: var(--text); margin-bottom: 0.5rem; font-size: 1.6rem; }
.reader-error .btn { margin-top: 1.25rem; }

/* Phone bottom bar */
.reader-mobile-bar { display: none; }
@media (max-width: 760px) {
  .reader-body { --reader-chrome: 190px; }
  .reader-mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
    background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .reader-mobile-bar .select-field { flex: 1; min-width: 0; height: 44px; padding-top: 0; padding-bottom: 0; }
  .reader-mobile-bar .icon-btn { width: 44px; height: 44px; }
  .reader-body main { padding-bottom: 5.5rem; }
  .reader-bottom-nav { display: none; }
  .toolbar-controls .select-field, .toolbar-controls #settings-btn { display: none; }
  .reader-toolbar { align-items: flex-start; }
  .page-nav-overlay { font-size: 2.25rem; }
}

/* Immersive mode: tap the middle of the page to hide everything else */
.reader-body.is-immersive { --reader-chrome: 56px; }
.reader-body.is-immersive .site-header,
.reader-body.is-immersive .reader-toolbar,
.reader-body.is-immersive .reader-tip,
.reader-body.is-immersive .reader-bottom-nav,
.reader-body.is-immersive .reader-mobile-bar { display: none; }
.reader-body.is-immersive .reader-container { padding-top: 0.5rem; }
.reader-body.is-immersive main { padding-bottom: 1rem; }

/* Reader settings dialog */
.settings-dialog {
  margin: auto; width: min(92vw, 440px); max-height: 85vh; padding: 0;
  background: var(--bg-raised); color: var(--text); border: 2px solid var(--ink-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.settings-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.settings-form { display: flex; flex-direction: column; gap: 1.25rem; padding: 1.25rem 1.25rem 1.5rem; }
.settings-head { display: flex; justify-content: space-between; align-items: center; }
.settings-head h2 { font-size: 1.2rem; }
.setting { border: 0; display: flex; flex-direction: column; gap: 0.55rem; min-width: 0; }
.setting legend, .setting h3 {
  font-family: var(--font-body); font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 0.45rem;
}
.pill-group { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.radio-pill { position: relative; }
.radio-pill input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.radio-pill span {
  display: inline-block; padding: 0.45rem 0.85rem; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 600;
  border: 2px solid var(--border-strong); color: var(--text-muted);
}
.radio-pill input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); }
.radio-pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.radio-pill input:disabled + span { opacity: 0.45; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 0.9rem; font-size: 0.88rem; color: var(--text-muted); }
.shortcut-list dt { white-space: nowrap; }
@media (hover: none) and (pointer: coarse) { .settings-dialog .shortcuts { display: none; } }

/* ---------- 15. Text pages (about, terms) ------------------------------- */
.prose { max-width: 720px; padding: 2.5rem 0 1rem; }
.prose h1 { margin-bottom: 0.75rem; }
.prose h2 { font-size: 1.35rem; margin: 2.25rem 0 0.65rem; }
.prose p, .prose li { color: var(--text-muted); margin-bottom: 0.75rem; }
.prose ul { padding-left: 1.25rem; }
.prose a { text-decoration: underline; }
.prose strong { color: var(--text); }
.prose .lead { font-size: 1.1rem; color: var(--text); }

/* ---------- 16. Touch devices, utilities, motion ------------------------ */
/* Bigger tap targets on touch screens (44px minimum) */
@media (pointer: coarse) {
  .btn-sm { min-height: 44px; }
  .icon-btn, .page-actions button, .card-remove { width: 44px; height: 44px; }
  .pagination button { min-width: 44px; height: 44px; }
  .thumb-remove { width: 36px; height: 36px; top: -12px; right: -12px; }
  .chip { padding: 0.65rem 1.05rem; }
  .carousel-dot { width: 40px; height: 44px; }
  .nav-avatar { width: 44px; height: 44px; }
  .header-search .input-field { height: 44px; }
  .radio-pill span { padding: 0.65rem 1rem; }
  .tab-btn { padding: 0.7rem; }
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

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