/* ==========================================================================
   연면유색 (连绵有色) — UI Styles
   ========================================================================== */

/* Design Tokens & CSS Custom Properties */
:root {
  /* Common metrics */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 36px;
  --space-xxl: 56px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --header-height: 56px;
  --reader-max-width: 680px;

  /* Font Stacks */
  --font-serif: 'KoPubWorldBatang', 'Nanum Myeongjo', 'Batang', 'Song Myung', Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", Roboto, sans-serif;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --danger-fill: #a83330;
}

/* Theme: Night (Default - 어두운 먹빛·달빛 은색·청록) */
[data-theme="night"] {
  --bg-app: #0b0f14;
  --bg-surface: #121820;
  --bg-card: rgba(22, 30, 40, 0.75);
  --bg-card-hover: rgba(30, 40, 54, 0.85);
  --bg-dialog: #141b24;
  --bg-header: rgba(11, 15, 20, 0.88);
  --bg-input: #0e141c;

  --text-primary: #e8eef4;
  --text-secondary: #a4b7c6;
  --text-muted: #728494;

  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.2);
  --border-focus: #5cc2d0;

  --accent-cyan: #46b3c2;
  --accent-cyan-subtle: rgba(70, 179, 194, 0.15);
  --accent-gold: #d8b248;
  --accent-gold-subtle: rgba(216, 178, 72, 0.15);
  --accent-crimson: #f19893;
  --accent-crimson-subtle: rgba(217, 83, 79, 0.15);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
  --backdrop-color: rgba(4, 7, 10, 0.75);

  --progress-track: #1b2430;
  --progress-fill: #46b3c2;
}

/* Theme: Paper (종이 - 한지 톤·먹물 묵독) */
[data-theme="paper"] {
  --bg-app: #f6f3eb;
  --bg-surface: #ede8dc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-dialog: #fbf9f4;
  --bg-header: rgba(246, 243, 235, 0.92);
  --bg-input: #ffffff;

  --text-primary: #1c1a18;
  --text-secondary: #4a443d;
  --text-muted: #6e655c;

  --border-subtle: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.25);
  --border-focus: #9c4c23;

  --accent-cyan: #226b77;
  --accent-cyan-subtle: rgba(34, 107, 119, 0.12);
  --accent-gold: #966b26;
  --accent-gold-subtle: rgba(150, 107, 38, 0.12);
  --accent-crimson: #a62b2b;
  --accent-crimson-subtle: rgba(166, 43, 43, 0.12);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(60, 50, 40, 0.18);
  --backdrop-color: rgba(30, 24, 18, 0.45);

  --progress-track: #dfd9cb;
  --progress-fill: #226b77;
}

/* Font Size Settings */
[data-font-size="18"] {
  --reader-font-size: 18px;
  --reader-line-height: 1.8;
}
[data-font-size="20"] {
  --reader-font-size: 20px;
  --reader-line-height: 1.85;
}
[data-font-size="22"] {
  --reader-font-size: 22px;
  --reader-line-height: 1.9;
}
[data-font-size="24"] {
  --reader-font-size: 24px;
  --reader-line-height: 1.95;
}

/* Base Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: auto;
  overflow-x: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

[data-motion="off"] html,
[data-motion="off"] *,
[data-motion="off"] *::before,
[data-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Accessible Focus States */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 3px;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  z-index: 1000;
  background: var(--accent-gold);
  color: #000;
  padding: var(--space-xs) var(--space-md);
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: var(--space-md);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 80;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.nav-btn-cover {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.nav-btn-cover:hover {
  background-color: var(--border-subtle);
}

.nav-brand-emblem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Header Progress Bar */
.header-progress-wrap {
  flex: 1;
  max-width: 260px;
  margin: 0 var(--space-xs);
}

progress#reading-progress {
  width: 100%;
  height: 6px;
  display: block;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: var(--radius-full);
  overflow: hidden;
  background-color: var(--progress-track);
}

progress#reading-progress::-webkit-progress-bar {
  background-color: var(--progress-track);
  border-radius: var(--radius-full);
}

progress#reading-progress::-webkit-progress-value {
  background-color: var(--progress-fill);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

progress#reading-progress::-moz-progress-bar {
  background-color: var(--progress-fill);
  border-radius: var(--radius-full);
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}

.nav-btn:hover {
  background-color: var(--border-subtle);
  color: var(--text-primary);
}

.nav-btn .badge {
  background-color: var(--accent-cyan);
  color: #0b0f14;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 2px;
}

[data-theme="paper"] .nav-btn .badge {
  color: #ffffff;
}

/* ==========================================================================
   Main Content & Cover Section
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.noscript-banner {
  background-color: var(--danger-fill);
  color: #ffffff;
  padding: var(--space-md);
  text-align: center;
  font-size: 0.95rem;
}

.cover-section {
  position: relative;
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-md);
  overflow: hidden;
}

.cover-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.85;
}

.cover-bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 70% 30%;
}

[data-theme="paper"] .cover-backdrop {
  opacity: 0.28;
  filter: contrast(110%) sepia(20%);
}

.cover-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  background-color: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.cover-emblem {
  margin-bottom: var(--space-sm);
  display: inline-block;
}

.cover-genre {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.cover-title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.cover-title .title-hanzi {
  font-size: 0.55em;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.cover-author {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.cover-teaser {
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  border-left: 2px solid var(--accent-gold);
  border-right: 2px solid var(--accent-gold);
  background-color: var(--accent-gold-subtle);
  border-radius: var(--radius-sm);
}

.teaser-quote {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.teaser-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Cover Outline Preview */
.cover-toc-preview {
  margin-bottom: var(--space-xl);
  text-align: left;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-md) 0;
}

.preview-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.preview-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.preview-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  background-color: var(--border-subtle);
}

.preview-item .item-num {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-gold);
  min-width: 24px;
  text-align: center;
}

.preview-item .item-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: block;
}

.preview-item .item-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
}

/* Call to Action Buttons */
.cover-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent-cyan);
  color: #080d12;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

[data-theme="paper"] .btn-primary {
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background-color: var(--border-subtle);
  border-color: var(--text-secondary);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.btn-danger {
  background-color: var(--danger-fill);
  color: #ffffff;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Load Error State */
.load-error {
  background-color: var(--accent-crimson-subtle);
  border: 1px solid var(--accent-crimson);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.btn-retry {
  padding: 8px 18px;
  font-size: 0.9rem;
  background-color: var(--danger-fill);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.cover-footer {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-md);
}

/* ==========================================================================
   Reader & Scenes
   ========================================================================== */
.reader-container {
  width: 100%;
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-xxl);
  flex: 1;
}

.chapter-separator {
  margin: var(--space-xxl) 0 var(--space-xl);
  text-align: center;
  position: relative;
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.chapter-separator:first-child {
  margin-top: var(--space-md);
}

.chapter-number {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-gold);
  display: block;
  margin-bottom: var(--space-xs);
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  letter-spacing: -0.02em;
}

.chapter-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Scene Styles */
.scene {
  scroll-margin-top: calc(var(--header-height) + 16px);
  margin-bottom: var(--space-xxl);
  padding: var(--space-xl) var(--space-lg);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-normal);
  position: relative;
  overflow: hidden;
}

/* Scene Atmosphere Subtle Overlays */
.scene::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  transition: opacity var(--transition-normal);
}

.scene.atmosphere-snow::before {
  background: radial-gradient(circle at 10% 10%, rgba(180, 220, 240, 0.15), transparent 60%);
  border-top: 2px solid rgba(180, 220, 240, 0.4);
}

.scene.atmosphere-water::before {
  background: radial-gradient(circle at 80% 20%, rgba(70, 179, 194, 0.18), transparent 70%);
  border-top: 2px solid rgba(70, 179, 194, 0.4);
}

.scene.atmosphere-stars::before {
  background: radial-gradient(circle at 50% 0%, rgba(160, 140, 220, 0.15), transparent 70%);
  border-top: 2px solid rgba(160, 140, 220, 0.4);
}

.scene.atmosphere-blood::before {
  background: radial-gradient(circle at 20% 80%, rgba(217, 83, 79, 0.18), transparent 70%);
  border-top: 2px solid rgba(217, 83, 79, 0.4);
}

.scene.atmosphere-quiet::before {
  background: radial-gradient(circle at 50% 50%, rgba(100, 120, 140, 0.08), transparent 80%);
  border-top: 2px solid var(--border-subtle);
}

.scene-header, .scene-body {
  position: relative;
  z-index: 1;
}

.scene-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.scene-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-xs);
}

.scene-eyebrow {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.03em;
}

.scene-location {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.scene-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.02em;
}

.scene-glossary-banner {
  margin-top: var(--space-sm);
}

.btn-scene-record {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--accent-cyan-subtle);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.loading-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  text-align: center;
}

.scene-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--space-sm);
  background-color: var(--accent-cyan-subtle);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-primary);
}

.btn-clear-filter {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-clear-filter:hover {
  color: var(--text-primary);
}

[data-theme="paper"] .btn-scene-record:hover {
  color: #ffffff;
}

/* Scene Story Blocks */
.scene-body {
  font-family: var(--font-serif);
  font-size: var(--reader-font-size, 20px);
  line-height: var(--reader-line-height, 1.85);
  word-break: keep-all;
  overflow-wrap: break-word;
}

.block {
  margin-bottom: 1.4em;
}

.block-narration {
  color: var(--text-primary);
  text-indent: 0.8em;
}

.block-dialogue {
  margin-left: var(--space-xs);
  padding-left: var(--space-sm);
  border-left: 2px solid var(--accent-cyan);
  color: var(--text-primary);
}

.block-dialogue .speaker {
  font-family: var(--font-sans);
  font-size: 0.82em;
  font-weight: 700;
  color: var(--accent-cyan);
  display: inline-block;
  margin-right: 6px;
}

.block-dialogue .speech {
  font-weight: 500;
}

.block-thought {
  margin-left: var(--space-xs);
  padding-left: var(--space-sm);
  border-left: 2px solid var(--accent-gold);
  color: var(--text-secondary);
  font-style: normal;
}

.block-thought .thought-speaker {
  font-family: var(--font-sans);
  font-size: 0.8em;
  font-weight: 700;
  color: var(--accent-gold);
  display: inline-block;
  margin-right: 6px;
}

.block-thought .thought-text {
  font-style: italic;
}

/* Ability Special Block */
.block-ability {
  margin: 1.8em 0;
  padding: var(--space-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  text-align: center;
  box-shadow: 0 4px 14px rgba(216, 178, 72, 0.15);
}

.ability-tag {
  font-family: var(--font-sans);
  font-size: 0.75em;
  font-weight: 800;
  padding: 3px 8px;
  background-color: var(--accent-gold);
  color: #0b0f14;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.ability-text {
  font-family: var(--font-serif);
  font-size: 1.15em;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.02em;
}

/* DICE Special Styling */
.block-ability.ability-dice {
  border-color: var(--accent-crimson);
  background-color: var(--accent-crimson-subtle);
  box-shadow: 0 4px 14px rgba(217, 83, 79, 0.2);
}

.block-ability.ability-dice .ability-tag {
  background-color: var(--danger-fill);
  color: #ffffff;
}

.block-ability.ability-dice .ability-text {
  color: var(--accent-crimson);
}

.dice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--danger-fill);
  color: #ffffff;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: 800;
  font-family: var(--font-sans);
}

/* Quote & Note Blocks */
.block-quote {
  margin: 1.8em 0;
  padding: var(--space-md) var(--space-lg);
  background-color: var(--border-subtle);
  border-left: 3px solid var(--text-muted);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.block-quote p {
  font-family: var(--font-serif);
  font-size: 1.05em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.block-quote cite {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.85em;
  color: var(--text-muted);
  text-align: right;
  font-style: normal;
}

.block-note {
  margin: 1.8em 0;
  padding: var(--space-md);
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9em;
  color: var(--text-secondary);
}

.block-note .note-badge {
  font-size: 0.75em;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

/* Reading Complete Section */
.reading-complete {
  margin: var(--space-xxl) 0;
  padding: var(--space-xl) var(--space-lg);
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.complete-emblem {
  margin-bottom: var(--space-sm);
  display: inline-block;
}

.complete-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.complete-desc {
  font-size: 0.98rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
}

.complete-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.app-dialog {
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  max-width: 540px;
  width: calc(100vw - 24px);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

.app-dialog::backdrop {
  background-color: var(--backdrop-color);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog-card {
  background-color: var(--bg-dialog);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.dialog-card-wide {
  max-width: 680px;
}

.dialog-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.dialog-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.dialog-badge {
  background-color: var(--accent-cyan-subtle);
  color: var(--accent-cyan);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.dialog-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.dialog-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--border-subtle);
}

.dialog-body {
  padding: var(--space-lg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dialog-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  background-color: var(--bg-surface);
}

.dialog-footer-split {
  justify-content: space-between;
}

/* Settings Controls */
.setting-item {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.setting-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.setting-select {
  padding: 10px var(--space-md);
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  cursor: pointer;
}

/* Table of Contents List */
.toc-body {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.toc-chapter-group {
  margin-bottom: var(--space-xs);
}

.toc-chapter-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: var(--space-xs);
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border-subtle);
}

.toc-scene-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.toc-scene-btn {
  width: 100%;
  text-align: left;
  background-color: transparent;
  border: 1px solid transparent;
  padding: 8px var(--space-sm);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  transition: all var(--transition-fast);
}

.toc-scene-btn:hover {
  background-color: var(--border-subtle);
  border-color: var(--border-strong);
}

.toc-scene-btn.active {
  background-color: var(--accent-cyan-subtle);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.toc-scene-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.toc-scene-eyebrow {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Glossary Filter & Search */
.glossary-filter-bar {
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  background-color: var(--bg-surface);
}

.glossary-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  background-color: var(--border-subtle);
  color: var(--text-primary);
}

.tab-btn.active {
  background-color: var(--accent-cyan);
  color: #0b0f14;
}

[data-theme="paper"] .tab-btn.active {
  color: #ffffff;
}

.search-input {
  width: 100%;
  padding: 8px var(--space-md);
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-family: var(--font-sans);
}

/* Glossary Cards */
.glossary-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.glossary-card {
  padding: var(--space-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.glossary-card:hover {
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-xs);
}

.card-symbol {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-gold);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-gold-subtle);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.card-headings {
  flex: 1;
}

.card-category-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: 2px;
  display: block;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.glossary-empty {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Restart Modal Details */
.restart-warning {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-md);
}

.restart-question {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-crimson);
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
@media (max-width: 600px) {
  .header-inner {
    padding: 0 var(--space-xs);
  }

  .nav-brand-text,
  .btn-label {
    display: none;
  }

  .nav-btn {
    padding: 6px 8px;
    font-size: 1rem;
  }

  .header-progress-wrap {
    max-width: 70px;
    margin: 0 2px;
  }

  .cover-section {
    padding: var(--space-md) var(--space-xs);
  }

  .cover-content {
    padding: var(--space-lg) var(--space-md);
  }

  .cover-title {
    font-size: 2.2rem;
  }

  .preview-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .scene {
    padding: var(--space-lg) var(--space-md);
    margin-bottom: var(--space-xl);
  }

  .scene-title {
    font-size: 1.35rem;
  }

  .dialog-body {
    padding: var(--space-md);
  }
}

/* 320px ultra-small devices */
@media (max-width: 360px) {
  .header-inner {
    padding: 0 4px;
  }

  .header-progress-wrap {
    display: none;
  }

  .nav-btn {
    padding: 6px 6px;
  }

  .btn {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .cover-content {
    padding: var(--space-md) 8px;
  }

  .scene {
    padding: var(--space-md) 8px;
  }

  .scene-body {
    font-size: var(--reader-font-size, 18px);
  }
}
