:root {
  --bg: #f7f5f0;
  --bg-elev: #ffffff;
  --bg-soft: #ede9e0;
  --text: #1f1d1a;
  --text-soft: #5b574f;
  --text-muted: #8a857c;
  --accent: #8a3a2a;
  --accent-soft: #c7714a;
  --border: #e1ddd2;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 6px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif KR', Georgia, serif;
  --reader-ff: 'Noto Serif KR', Georgia, serif;
  --reader-fs: 18px;
  --reader-lh: 1.95;
  --reader-width: 720px;
}

[data-theme="dark"] {
  --bg: #14110d;
  --bg-elev: #1d1a15;
  --bg-soft: #25211b;
  --text: #ece8e0;
  --text-soft: #b8b2a5;
  --text-muted: #807a6e;
  --accent: #d99776;
  --accent-soft: #b76e4e;
  --border: #2e2a23;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.3);
  --shadow-hover: 0 2px 6px rgba(0,0,0,0.5), 0 12px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; letter-spacing: -0.01em;
}
.brand-mark { font-size: 22px; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  padding: 7px 11px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
  min-width: 38px; height: 36px;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
#themeBtn .theme-icon-dark { display: none; }
[data-theme="dark"] #themeBtn .theme-icon-light { display: none; }
[data-theme="dark"] #themeBtn .theme-icon-dark { display: inline; }

.app {
  flex: 1; width: 100%; max-width: 1080px; margin: 0 auto;
  padding: 32px 20px 64px;
}
.loading { text-align: center; color: var(--text-muted); padding: 80px 20px; font-size: 14px; }

.footer { border-top: 1px solid var(--border); padding: 24px 20px; color: var(--text-muted); font-size: 13px; }
.footer-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 8px; justify-content: center; }
.footer-link:hover { color: var(--accent); }
.footer-sep { opacity: 0.6; }

/* ---- Home view ---- */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.page-subtitle { color: var(--text-muted); margin: 0 0 32px; font-size: 15px; }
.lore-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.lore-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}
.lore-link-icon { font-size: 16px; line-height: 1; }

.home-version {
  margin-top: 56px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
.novel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.novel-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
}
.novel-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-soft);
}
.novel-cover {
  width: 100%; aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 100%);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-family: var(--font-serif);
  font-weight: 700; font-size: 20px;
  text-align: center; padding: 16px; line-height: 1.4;
  letter-spacing: -0.01em; word-break: keep-all;
  overflow: hidden;
  position: relative;
}
.novel-cover.has-image {
  padding: 0;
  background: var(--bg-soft);
}
.novel-cover.has-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.novel-title { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; line-height: 1.4; }
.novel-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--text-muted); }
.tag { background: var(--bg-soft); padding: 3px 9px; border-radius: 20px; font-size: 11.5px; color: var(--text-soft); }
.novel-desc {
  color: var(--text-soft); font-size: 14px; line-height: 1.6; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.novel-status { font-size: 12px; color: var(--text-muted); margin-top: auto; padding-top: 4px; }

/* ---- Novel detail view ---- */
.reader-breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.reader-breadcrumb a:hover { color: var(--accent); }
.novel-hero {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  margin-bottom: 36px;
  align-items: start;
}
.novel-hero .novel-cover { font-size: 20px; }
.novel-hero-info h1 { font-size: 32px; font-weight: 700; margin: 0 0 10px; letter-spacing: -0.02em; line-height: 1.3; }
.novel-hero-info .author { color: var(--text-soft); font-size: 15px; margin-bottom: 14px; }
.novel-hero-info .novel-meta { margin-bottom: 18px; }
.novel-hero-info .description {
  color: var(--text-soft); line-height: 1.75; font-size: 15px;
  margin: 0 0 22px; white-space: pre-wrap;
}
.continue-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14.5px; border: none; cursor: pointer;
  transition: all 0.15s ease; text-decoration: none;
}
.continue-btn:hover { background: var(--accent-soft); transform: translateY(-1px); }

.section-title {
  font-size: 18px; font-weight: 700; margin: 0 0 14px; letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: space-between;
}
.chapter-count { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.chapter-list {
  list-style: none; padding: 0; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elev);
}
.chapter-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.15s ease; gap: 12px;
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: var(--bg-soft); }
.chapter-info { flex: 1; min-width: 0; }
.chapter-name {
  font-size: 15px; font-weight: 500; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chapter-sub { font-size: 12.5px; color: var(--text-muted); }
.chapter-badge {
  font-size: 11px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 3px 8px; border-radius: 12px; font-weight: 600; white-space: nowrap;
}

/* ---- Worldbuilding (설정집) ---- */
.lore-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.lore-tab {
  border: none;
  background: transparent;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  margin-bottom: -1px;
  transition: color 0.15s ease;
}
.lore-tab:hover { color: var(--text-soft); }
.lore-tab.active { color: var(--accent); }
.lore-tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.lore-pane[hidden] { display: none; }
.lore-header {
  margin-bottom: 36px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.lore-eyebrow {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lore-title {
  font-size: 30px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.lore-section { margin-bottom: 44px; }
.lore-section:last-child { margin-bottom: 0; }
.lore-section-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.lore-section-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 2px;
}
.lore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.lore-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color 0.15s ease;
}
.lore-card:hover { border-color: var(--accent-soft); }
.lore-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.lore-card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: keep-all;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.character-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}
.character-card:hover { border-color: var(--accent-soft); }
.character-card.has-portrait {
  padding: 0;
  overflow: hidden;
}
.character-portrait {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--bg-soft);
  overflow: hidden;
  position: relative;
}
.character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.character-card.has-portrait .character-info {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.character-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.character-name {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.character-role {
  font-size: 12.5px;
  color: var(--text-muted);
}
.character-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.character-body {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: keep-all;
}

.lore-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.lore-hub-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
}
.lore-hub-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-soft);
  box-shadow: var(--shadow-hover);
}
.lore-hub-cover {
  width: 64px;
  aspect-ratio: 2 / 3;
  flex-shrink: 0;
  font-size: 11px !important;
  padding: 4px !important;
}
.lore-hub-info h3 {
  font-size: 15px;
  margin: 0 0 4px;
  font-weight: 700;
}
.lore-hub-meta {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---- Future plans tab ---- */
.future-warning {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 20px;
  font-weight: 500;
}
.future-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.future-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 24px 26px;
  transition: border-color 0.15s ease;
}
.future-card:hover { border-color: var(--accent-soft); border-left-color: var(--accent); }
.future-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.4;
}
.future-summary {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-soft);
  font-style: italic;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}
.future-section { margin-bottom: 16px; }
.future-section:last-child { margin-bottom: 0; }
.future-section-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.future-section > p {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: keep-all;
}
.future-char-grid {
  margin-top: 8px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.future-char-grid .character-card {
  padding: 16px 18px;
  background: var(--bg);
}
.future-char-grid .character-name { font-size: 15px; }
.future-char-grid .character-body { font-size: 13.5px; }

.future-scenes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.future-scene {
  background: var(--bg);
  border-left: 2px solid var(--accent-soft);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
}
.future-scene-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.future-scene-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: keep-all;
}

/* ---- Empty / error ---- */
.empty-state { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.empty-state h2 { font-size: 20px; font-weight: 600; color: var(--text-soft); margin: 0 0 8px; }
.empty-state p { margin: 0 0 16px; font-size: 14px; }
.empty-state a { color: var(--accent); font-weight: 500; }

/* =====================================================
   READER (fullscreen)
   ===================================================== */
body[data-page="reader"] .topbar,
body[data-page="reader"] .footer {
  display: none;
}
body[data-page="reader"] {
  overflow: hidden;
  /* Prevent iOS bounce */
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
body[data-page="reader"] .app {
  max-width: none;
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.reader-fullscreen {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Common reader body typography */
.reader-body {
  font-family: var(--reader-ff);
  font-size: var(--reader-fs);
  line-height: var(--reader-lh);
  color: var(--text);
  word-break: keep-all;
  overflow-wrap: break-word;
}
.reader-title,
.cover-chapter-name {
  font-family: var(--reader-ff);
}
.reader-body p { margin: 0 0 1.05em; }
.reader-body p:empty { display: none; }

/* ---- Scroll mode ---- */
.reader-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.reader-scroll-inner {
  max-width: var(--reader-width);
  margin: 0 auto;
  padding: 80px 28px 120px;
}
.reader-cover-image {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 2 / 3;
  margin: 0 auto 32px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.08);
  background: var(--bg-soft);
}
.reader-cover-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.reader-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.35;
}
.reader-novel-label {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.reader-end-nav {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
}
.end-btn {
  flex: 1;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.end-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.end-btn.next { text-align: right; }
.end-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.end-btn.next.disabled { justify-content: flex-end; }

/* ---- Page mode ---- */
.reader-pages {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: pan-y;
}
.pages-strip {
  display: flex;
  height: 100%;
  width: 100%;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.page {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  padding: 72px 36px 80px;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.page > .reader-body { flex: 1; min-height: 0; overflow: hidden; }

.page.page-cover {
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  text-align: center;
}
.cover-art {
  width: min(280px, 70vw);
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(0,0,0,0.22), 0 4px 10px rgba(0,0,0,0.1);
  margin: 0 auto 32px;
  background: var(--bg-soft);
  flex: 0 0 auto;
}
.cover-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-text { max-width: 100%; }
.cover-novel-name {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.cover-chapter-name {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
  line-height: 1.35;
  word-break: keep-all;
}
.cover-author {
  font-size: 13px;
  color: var(--text-muted);
}
.measure-body {
  /* For pagination measurement only; same typography as reader-body */
}

/* ---- Tap zones ---- */
.tap-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  z-index: 5;
  pointer-events: none;
}
.tap-zone {
  background: transparent;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  outline: none;
}
.tap-zone.left { flex: 0 0 30%; cursor: e-resize; }
.tap-zone.center { flex: 1; cursor: pointer; }
.tap-zone.right { flex: 0 0 30%; cursor: w-resize; }
.tap-zone:focus-visible { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---- Reader overlay (top / bottom bars) ---- */
.reader-overlay {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
}
.reader-overlay.top {
  top: 0;
  border-bottom: 1px solid var(--border);
  transform: translateY(-100%);
  padding-top: max(14px, env(safe-area-inset-top));
}
.reader-overlay.bottom {
  bottom: 0;
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding-top: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
body[data-reader-ui="visible"] .reader-overlay {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.overlay-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.overlay-btn:hover { background: var(--bg-soft); }
.overlay-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1.25;
}
.overlay-novel {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overlay-chapter {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.overlay-progress {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 70px;
}
.reader-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  gap: 12px;
}
.progress-chapter {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress-position {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-soft);
}
.progress-bar {
  position: relative;
  height: 18px;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
}
.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  pointer-events: none;
}
.progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  width: 0;
  pointer-events: none;
  transition: width 0.18s ease;
}
.progress-handle {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.18s ease;
}
.progress-bar:hover .progress-handle,
.progress-bar:focus-visible .progress-handle {
  width: 16px;
  height: 16px;
}
.overlay-chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.overlay-chap-btn {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.overlay-chap-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.overlay-chap-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}

/* ---- Settings panel ---- */
.reader-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.reader-settings-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: min(440px, 100%);
  background: var(--bg-elev);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
  z-index: 50;
  padding: 12px 24px 28px;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.reader-fullscreen[data-settings="open"] .reader-settings-panel {
  transform: translateX(-50%) translateY(0);
}
.reader-fullscreen[data-settings="open"] .reader-settings-backdrop {
  opacity: 1;
  pointer-events: auto;
}
.settings-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 8px auto 18px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.settings-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
}
.settings-options { display: flex; align-items: center; gap: 4px; }
.seg {
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 4px;
  gap: 0;
}
.seg-stretch {
  width: 100%;
  display: flex;
}
.seg-stretch .seg-btn {
  flex: 1 1 0;
  padding-left: 8px;
  padding-right: 8px;
  min-width: 0;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.seg-btn.active {
  background: var(--bg-elev);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.font-preview-serif    { font-family: 'Noto Serif KR', Georgia, serif; }
.font-preview-sans     { font-family: 'Noto Sans KR', -apple-system, sans-serif; }
.font-preview-myeongjo { font-family: 'Nanum Myeongjo', 'Noto Serif KR', serif; }
.step-btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 38px;
  transition: all 0.15s ease;
}
.step-btn:hover { border-color: var(--accent); color: var(--accent); }
.step-val {
  font-size: 13px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: center;
  font-weight: 500;
}

/* ---- Responsive ---- */
@media (max-width: 720px) {
  .app { padding: 24px 16px 48px; }
  .topbar-inner { padding: 10px 16px; }
  .brand-name { font-size: 16px; }
  .page-title { font-size: 22px; }
  .lore-title { font-size: 24px; }
  .lore-link { padding: 7px 12px; font-size: 13px; }
  .home-header { gap: 10px; }
  .novel-hero {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .novel-hero .novel-cover { max-width: 180px; margin: 0 auto; }
  .novel-hero-info h1 { font-size: 24px; text-align: center; }
  .novel-hero-info .author,
  .novel-hero-info .novel-meta { justify-content: center; text-align: center; }
  .novel-hero-info .novel-meta { display: flex; }
  .novel-grid { grid-template-columns: 1fr; gap: 14px; }
  .reader-scroll-inner { padding: 70px 20px 100px; }
  .reader-title { font-size: 22px; }
  .page { padding: 64px 22px 76px; }
  .reader-overlay { padding: 12px 14px; }
  .overlay-chap-btn { padding: 7px 10px; font-size: 12.5px; }
  .reader-overlay.bottom { gap: 10px; }
  .overlay-progress { min-width: 60px; font-size: 12px; }
}

@media (max-width: 420px) {
  .overlay-chapter-nav .overlay-chap-btn { padding: 6px 8px; font-size: 12px; }
  .page-title-inline { font-size: 20px; }
}

/* ---- Tap zone visual cue on touch (subtle) ---- */
@media (hover: none) {
  .tap-zone.left:active,
  .tap-zone.right:active {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
  }
}
