/* Story Land — Main Styles */

:root {
  --purple: #7B4FBF;
  --purple-dark: #5A2D91;
  --purple-light: #9B6FD4;
  --purple-nav: #6B3FA0;
  --yellow: #FFD54F;
  --yellow-btn: #FFC107;
  --pink: #FF6B9D;
  --green: #4CAF50;
  --cream: #FFF8E1;
  --cream-card: #FFF9E6;
  --white: #ffffff;
  --text: #333;
  --text-light: #666;
  --shadow: 0 4px 20px rgba(90, 45, 145, 0.25);
  --shadow-lg: 0 8px 32px rgba(90, 45, 145, 0.3);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --nav-height: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font-body); color: var(--text); background: #87CEEB; overflow-x: hidden; min-height: 100vh; min-height: 100dvh; }
#app { min-height: 100vh; min-height: 100dvh; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; position: relative; }
.screen.active { display: flex; flex-direction: column; }
.hidden { display: none !important; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
img { max-width: 100%; display: block; }

#screen-home { overflow: hidden; padding-bottom: var(--nav-height); }
/* Home screen styles → see css/home.css */

.home-header { position: relative; z-index: 10; display: flex; align-items: flex-start; justify-content: space-between; padding: 12px 16px 0; gap: 8px; }
.logo-block { flex: 1; text-align: center; padding-top: 4px; }
.site-logo-link { display: inline-flex; align-items: center; justify-content: center; max-width: min(58vw, 560px); width: 100%; text-decoration: none; transform: translateX(-90px); }
.site-logo { display: block; width: 100%; max-width: 560px; height: auto; max-height: 155px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.18)); }
.site-logo--library { max-width: 320px; max-height: 92px; }
.logo-text { font-family: var(--font-display); font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 700; line-height: 1.1; display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; }
.logo-text span:nth-child(1) { color: #E53935; } .logo-text span:nth-child(2) { color: #FB8C00; } .logo-text span:nth-child(3) { color: #FDD835; }
.logo-text span:nth-child(4) { color: #43A047; } .logo-text span:nth-child(5) { color: #1E88E5; } .logo-space { width: 8px; }
.logo-text span:nth-child(7) { color: #8E24AA; } .logo-text span:nth-child(8) { color: #E91E63; } .logo-text span:nth-child(9) { color: #00ACC1; } .logo-text span:nth-child(10) { color: #5E35B1; }
.logo-banner { display: inline-block; margin-top: 6px; padding: 4px 20px; background: var(--purple); color: var(--white); font-size: 0.75rem; font-weight: 700; border-radius: var(--radius-pill); box-shadow: var(--shadow); position: relative; }
.logo-banner::before, .logo-banner::after { content: '★'; position: absolute; top: 50%; transform: translateY(-50%); color: var(--yellow); font-size: 0.65rem; }
.logo-banner::before { left: 6px; } .logo-banner::after { right: 6px; }

.icon-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--white); font-size: 0.65rem; font-weight: 700; }
.icon-btn svg { width: 36px; height: 36px; padding: 8px; background: var(--purple); border-radius: 50%; box-shadow: var(--shadow); }
.parent-btn-header svg { background: var(--yellow); color: var(--purple-dark); }
.menu-btn .hamburger { display: block; width: 36px; height: 36px; background: var(--purple); border-radius: 50%; box-shadow: var(--shadow); position: relative; }
.menu-btn .hamburger::before { content: '☰'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: white; }
.header-actions { display: flex; gap: 8px; }

.home-main { position: relative; z-index: 5; flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
/* book-card, continue-section, home bottom-nav → css/home.css */

.search-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(90, 45, 145, 0.85); padding: 80px 20px 20px; }
.search-box { display: flex; gap: 8px; max-width: 500px; margin: 0 auto; }
.search-box input { flex: 1; padding: 14px 20px; border: none; border-radius: var(--radius-pill); font-size: 1rem; }
.search-close { width: 48px; height: 48px; background: var(--white); border-radius: 50%; font-size: 1.5rem; color: var(--purple); }
.search-result-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: white; border-radius: var(--radius-sm); margin-bottom: 8px; cursor: pointer; }
.search-result-item img {
  width: 40px;
  height: 54px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.book-badge { position: absolute; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 0.65rem; font-weight: 800; color: white; text-transform: uppercase; z-index: 2; }
.book-badge.continue { background: var(--purple); }
.book-badge.new { background: var(--pink); }
.pdf-book-cover-card {
  width: 100%;
  height: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
  color: var(--white);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.24), transparent 42%),
    linear-gradient(160deg, var(--purple-light), var(--purple-dark));
  border-radius: 12px;
  box-shadow: inset -10px 0 0 rgba(0,0,0,0.12);
}
.pdf-book-cover-card::before {
  content: '';
  width: 48px;
  height: 62px;
  border-radius: 8px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 8px 16px rgba(0,0,0,0.16);
}
.pdf-book-cover-card strong {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.15;
}
.pdf-book-cover-card small,
.pdf-cover-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--yellow);
}

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; display: flex; background: var(--purple-nav); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,0.2); }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; color: rgba(255,255,255,0.7); font-size: 0.65rem; font-weight: 700; border-radius: var(--radius-pill); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { background: var(--white); color: var(--purple); }

#screen-library { padding-bottom: var(--home-nav-height, 96px); }

.back-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(123, 79, 191, 0.1);
  color: var(--purple);
}
.back-btn svg { width: 24px; height: 24px; }

#screen-reader { background: #F5F0FF; }
.reader-header { display: flex; align-items: center; padding: 12px 16px; background: var(--white); box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.reader-header h1 { font-family: var(--font-display); font-size: 1.1rem; color: var(--purple-dark); flex: 1; text-align: center; }
.reader-header-actions { display: flex; gap: 4px; }
.icon-btn-sm { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--yellow-btn); }
.icon-btn-sm svg { width: 22px; height: 22px; }

.reader-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 8px; position: relative; min-height: 0; }
.open-book { display: flex; max-width: 1080px; width: min(96vw, 1080px); background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; min-height: min(78vh, 680px); }
.book-spine { width: 8px; background: linear-gradient(90deg, #ccc, #eee, #ccc); flex-shrink: 0; }
.book-page { flex: 1; min-width: 0; }
.book-page-left { background: #fff; padding: 0; overflow: hidden; }
.page-image-wrap { position: relative; width: 100%; height: 100%; min-height: min(78vh, 680px); overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; }
.page-image-wrap img, .page-image-wrap canvas { width: 100%; height: 100%; min-height: min(78vh, 680px); object-fit: cover; object-position: center; display: block; }
.effects-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.book-page-right { display: flex; flex-direction: column; padding: 20px; min-height: 200px; overflow-y: auto; }
.page-title { font-family: var(--font-display); font-size: 1.2rem; color: var(--purple-dark); margin-bottom: 16px; }
.page-text { font-size: 1rem; line-height: 1.7; flex: 1; color: var(--text); min-height: 4rem; }
.page-text .highlight { background: rgba(255, 213, 79, 0.4); border-radius: 2px; }
.page-divider { margin-top: 20px; height: 4px; background: linear-gradient(90deg, transparent, var(--purple-light), transparent); border-radius: 2px; }

.page-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; background: var(--purple); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); z-index: 5; }
.page-prev { left: 4px; } .page-next { right: 4px; }
.page-nav svg { width: 28px; height: 28px; }
.page-indicator { text-align: center; font-family: var(--font-display); font-size: 0.9rem; color: var(--purple); padding: 8px; }
.reader-debug { display: none; }
.audio-status { display: none; }

.reader-controls { background: var(--cream); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 2px solid rgba(123, 79, 191, 0.15); }
.controls-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.controls-main { margin-bottom: 12px; }
.ctrl-btn { display: flex; align-items: center; gap: 4px; padding: 8px 14px; font-size: 0.8rem; font-weight: 700; color: var(--purple); border-radius: var(--radius-pill); }
.ctrl-btn svg { width: 18px; height: 18px; }
.ctrl-play { width: 56px; height: 56px; padding: 0; justify-content: center; background: var(--purple); color: white; border-radius: 50%; box-shadow: var(--shadow); }
.ctrl-play svg { width: 28px; height: 28px; }
.controls-secondary { flex-wrap: wrap; gap: 6px; }
.ctrl-chip { display: flex; align-items: center; gap: 4px; padding: 8px 12px; font-size: 0.72rem; font-weight: 700; color: var(--purple); background: var(--white); border-radius: var(--radius-pill); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.ctrl-chip.active { background: var(--purple); color: white; }
.ctrl-chip.disabled { opacity: 0.45; }
.ctrl-chip svg { width: 16px; height: 16px; }

.effect-sparkle { position: absolute; width: 8px; height: 8px; background: var(--yellow); border-radius: 50%; animation: sparkle 2s ease-in-out infinite; box-shadow: 0 0 6px var(--yellow); }
@keyframes sparkle { 0%, 100% { opacity: 0; transform: scale(0); } 50% { opacity: 1; transform: scale(1); } }
.effect-snow { position: absolute; width: 6px; height: 6px; background: white; border-radius: 50%; animation: snowfall linear infinite; opacity: 0.8; }
@keyframes snowfall { 0% { transform: translateY(-10px); opacity: 1; } 100% { transform: translateY(300px); opacity: 0.3; } }
.effect-magic { position: absolute; width: 20px; height: 20px; background: radial-gradient(circle, rgba(155, 111, 212, 0.8), transparent); border-radius: 50%; animation: magic-pulse 2s ease-in-out infinite; }
@keyframes magic-pulse { 0%, 100% { transform: scale(0.5); opacity: 0.3; } 50% { transform: scale(1.5); opacity: 0.8; } }

.modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: white; border-radius: var(--radius); padding: 24px; max-width: 360px; width: 100%; text-align: center; }
.modal-content h3 { font-family: var(--font-display); color: var(--purple-dark); margin-bottom: 16px; }
.timer-options, .timer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.timer-opt { padding: 12px; border: 2px solid var(--purple-light); border-radius: var(--radius-sm); font-weight: 700; color: var(--purple); }
.timer-opt.active, .timer-opt:hover { background: var(--purple); color: white; border-color: var(--purple); }
.btn-primary { display: block; width: 100%; padding: 14px; background: var(--purple); color: white; font-family: var(--font-display); font-weight: 600; border-radius: var(--radius-pill); box-shadow: var(--shadow); margin-bottom: 8px; }
.btn-outline { padding: 10px 20px; border: 2px solid var(--purple); color: var(--purple); font-weight: 700; border-radius: var(--radius-pill); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-text { color: var(--text-light); font-size: 0.9rem; padding: 8px; }

#screen-parent { background: #F3E5F5; }
.parent-layout, .admin-layout { display: flex; min-height: 100vh; width: 100%; }
.parent-sidebar, .admin-sidebar { width: 220px; background: var(--purple-dark); color: white; padding: 24px 0; flex-shrink: 0; }
.sidebar-title, .admin-logo { font-family: var(--font-display); font-size: 1.2rem; padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.admin-logo { font-size: 1.1rem; line-height: 1.3; }
.admin-logo small { font-size: 0.7rem; opacity: 0.7; letter-spacing: 2px; }
.sidebar-nav { display: flex; flex-direction: column; padding: 12px 0; }
.sidebar-link { padding: 12px 20px; text-align: left; color: rgba(255,255,255,0.75); font-weight: 600; font-size: 0.9rem; border-left: 3px solid transparent; }
.sidebar-link:hover, .sidebar-link.active { background: rgba(255,255,255,0.1); color: white; border-left-color: var(--yellow); }
.sidebar-logout { margin-top: 20px; opacity: 0.7; }
.parent-main, .admin-main { flex: 1; padding: 24px; overflow-y: auto; }
.parent-tab, .admin-tab { display: none; } .parent-tab.active, .admin-tab.active { display: block; }

.profile-card { display: flex; align-items: center; gap: 16px; background: white; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; }
.profile-avatar { width: 64px; height: 64px; background: var(--purple); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.settings-group { background: white; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.settings-group h3 { font-family: var(--font-display); color: var(--purple-dark); margin-bottom: 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.toggle { position: relative; width: 48px; height: 26px; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #ccc; border-radius: var(--radius-pill); cursor: pointer; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .toggle-slider { background: var(--purple); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }
.volume-row { display: grid; grid-template-columns: 100px 1fr 48px; align-items: center; gap: 12px; padding: 10px 0; }
.volume-row input[type="range"] { accent-color: var(--purple); }
.profile-form label { display: block; margin-bottom: 16px; font-weight: 600; }
.profile-form input { display: block; width: 100%; margin-top: 6px; padding: 10px 14px; border: 2px solid #e0e0e0; border-radius: var(--radius-sm); font-family: var(--font-body); }
.history-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: white; border-radius: var(--radius-sm); margin-bottom: 8px; }
.history-item img { width: 40px; height: 54px; object-fit: cover; border-radius: 4px; }
.help-list { margin-top: 16px; padding-left: 20px; line-height: 1.8; }

#screen-admin { background: #EDE7F6; }
.admin-gate { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.gate-card { background: white; padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 400px; width: 100%; text-align: center; }
.gate-card h2 { font-family: var(--font-display); color: var(--purple-dark); margin-bottom: 8px; }
.gate-card input { width: 100%; padding: 12px 16px; border: 2px solid #e0e0e0; border-radius: var(--radius-sm); margin: 16px 0; font-size: 1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.stat-card { background: white; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.stat-num { display: block; font-family: var(--font-display); font-size: 2rem; color: var(--purple); font-weight: 700; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.books-table-wrap { overflow-x: auto; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.books-table { width: 100%; border-collapse: collapse; }
.books-table th, .books-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.books-table img { width: 40px; height: 54px; object-fit: cover; border-radius: 4px; }
.status-badge { display: inline-block; padding: 4px 10px; border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 700; }
.status-badge.published { background: #E8F5E9; color: #2E7D32; }
.status-badge.draft { background: #FFF3E0; color: #E65100; }
.action-btn { padding: 6px 10px; margin-right: 4px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; color: var(--purple); background: rgba(123, 79, 191, 0.1); }
.action-btn.danger { color: #C62828; background: rgba(198, 40, 40, 0.1); }
.book-form { background: white; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.form-col label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 0.9rem; }
.form-col input, .form-col textarea, .form-col select { display: block; width: 100%; margin-top: 6px; padding: 10px 14px; border: 2px solid #e0e0e0; border-radius: var(--radius-sm); font-family: var(--font-body); }
.upload-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 160px; border: 2px dashed var(--purple-light); border-radius: var(--radius-sm); padding: 20px; text-align: center; cursor: pointer; margin-bottom: 16px; }
.upload-zone.dragover { border-color: var(--purple); background: rgba(123, 79, 191, 0.05); }
.upload-preview { max-width: 120px; max-height: 160px; border-radius: 8px; margin: 8px 0; }
.upload-btn { display: inline-block; padding: 12px 20px; background: rgba(123, 79, 191, 0.1); color: var(--purple); font-weight: 700; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 8px; }
.file-name { display: block; font-size: 0.8rem; color: var(--text-light); margin-bottom: 12px; }
.form-hint { font-size: 0.75rem; color: var(--text-light); margin: -4px 0 12px; line-height: 1.4; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid #f0f0f0; }
.category-list { list-style: none; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.category-list li { padding: 14px 20px; border-bottom: 1px solid #f0f0f0; font-weight: 600; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.media-item { background: white; padding: 12px; border-radius: var(--radius-sm); text-align: center; font-size: 0.8rem; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.media-item img { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; margin-bottom: 6px; }

@media (min-width: 768px) { /* home quick-links → home.css */ }
@media (max-width: 767px) {
  .open-book { display: flex; max-width: 1080px; width: min(96vw, 1080px); background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; min-height: min(78vh, 680px); } .book-spine { display: none; }
  .book-page-left, .page-image-wrap, .page-image-wrap img { min-height: 200px; max-height: 45vh; }
  .book-page-right { min-height: 160px; padding: 16px; }
  .page-image-wrap img, .page-image-wrap canvas { width: 100%; height: 100%; min-height: min(78vh, 680px); object-fit: cover; object-position: center; display: block; }
  .page-nav { width: 36px; height: 36px; }
  .controls-secondary .ctrl-chip { flex: 1 1 calc(50% - 6px); justify-content: center; }
  .parent-layout, .admin-layout { flex-direction: column; }
  .parent-sidebar, .admin-sidebar { width: 100%; padding: 12px 0; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 8px 12px; gap: 4px; }
  .sidebar-link { white-space: nowrap; padding: 8px 14px; border-left: none; border-radius: var(--radius-pill); font-size: 0.8rem; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .header-actions .icon-btn span { display: none; } }


/* Image-first reader: crop uploaded chapter sheets to the illustration area. */
.book-page-left { background: #fff; overflow: hidden; }
.page-image-wrap { height: 100%; min-height: min(78vh, 680px); overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; }
.page-image-wrap img, .page-image-wrap canvas { width: 100%; height: 100%; min-height: min(78vh, 680px); object-fit: cover; object-position: center; display: block; }
#open-book[data-renderer="image-first/full-left"] .book-page-left img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transform: scale(2.35);
  transform-origin: center 18%;
}
#open-book[data-renderer="pdf-fallback/cropped"] .book-page-left canvas { width: 100%; height: 100%; object-fit: cover; }


.page-images-section { margin: 18px 0; padding: 14px; border: 1px solid rgba(123,79,191,0.18); border-radius: 8px; background: rgba(255,255,255,0.72); }
.page-images-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.page-images-header h3 { margin: 0 0 4px; color: var(--purple-dark); font-family: var(--font-display); font-size: 1rem; }
.page-images-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 10px; }
.page-image-row { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: center; padding: 8px; border: 1px solid rgba(0,0,0,0.08); border-radius: 8px; background: #fff; }
.page-image-preview { width: 62px; height: 82px; object-fit: cover; object-position: center; border-radius: 5px; background: #f1eef8; border: 1px solid rgba(123,79,191,0.15); }
.page-image-meta { min-width: 0; }
.page-image-title { font-weight: 700; font-size: 0.82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-image-path { font-size: 0.68rem; color: var(--muted); overflow-wrap: anywhere; margin: 2px 0 6px; }
.page-image-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.page-image-actions .upload-btn, .page-image-actions .action-btn { padding: 6px 8px; font-size: 0.72rem; }
.empty-note { color: var(--muted); font-size: 0.85rem; }

/* PDF-only reading room */
#screen-pdf-reader {
  background: #eee8fa;
  min-height: 100vh;
  min-height: 100dvh;
}

.pdf-reader-header {
  flex: 0 0 auto;
}

.pdf-tool-btn {
  background: rgba(123, 79, 191, 0.1);
  color: var(--purple-dark);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.pdf-reader-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 64px;
  overflow: auto;
}

.pdf-book-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8px minmax(0, 1fr);
  align-items: center;
  width: min(1180px, 100%);
  min-height: 70vh;
  background: #d7cee8;
  border-radius: 8px;
  box-shadow: 0 16px 44px rgba(49, 27, 82, 0.3);
  overflow: hidden;
}

.pdf-sheet {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 70vh;
  padding: 12px;
  background: #f7f5ef;
  overflow: auto;
}

.pdf-sheet canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

.pdf-spine {
  align-self: stretch;
  background: linear-gradient(90deg, #b8afc6, #f7f5ef, #b8afc6);
}

.pdf-book-stage.single-page {
  grid-template-columns: minmax(0, 1fr);
  max-width: 680px;
}

.pdf-book-stage.single-page .pdf-spine {
  display: none;
}

.pdf-reader-prev { left: 12px; }
.pdf-reader-next { right: 12px; }
.pdf-reader-prev:disabled,
.pdf-reader-next:disabled { opacity: 0.35; cursor: default; }

.pdf-reader-controls {
  flex: 0 0 auto;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  text-align: center;
  background: var(--cream);
  color: var(--purple-dark);
  font-family: var(--font-display);
  font-weight: 600;
  border-top: 1px solid rgba(123, 79, 191, 0.18);
}

@media (max-width: 767px) {
  .pdf-reader-body { padding: 12px 44px; }
  .pdf-book-stage,
  .pdf-book-stage.single-page {
    display: block;
    min-height: auto;
  }
  .pdf-sheet {
    min-height: auto;
    padding: 8px;
  }
  .pdf-spine,
  .pdf-sheet-right { display: none; }
  .pdf-reader-header h1 { font-size: 0.95rem; }
}

@media (max-width: 767px) {
  .site-logo-link { max-width: min(60vw, 300px); transform: translateX(-18px); }
  .site-logo { max-width: 300px; max-height: 88px; }
  .site-logo--library { max-width: 220px; max-height: 64px; }
}

@media (max-width: 420px) {
  .site-logo-link { max-width: 56vw; transform: translateX(-10px); }
  .site-logo { max-height: 72px; }
}
