/* =================== WARM ORANGE THEME - 小多绘本 =================== */
@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700;800&display=swap');

/* =================== RESET & BASE =================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Kid-mode palette - warm orange */
  --kid: #FF7A45;
  --kid-dark: #E8632E;
  --kid-light: #FFE9DA;
  --kid-soft: #FFF6EE;

  --sun: #FFC93C;
  --sun-dark: #E8A800;
  --sun-light: #FFF6D9;

  --leaf: #48B57E;
  --leaf-light: #E6F7EE;

  --berry: #F16B6B;
  --berry-light: #FFECEC;

  --sky: #45B8D6;
  --sky-light: #E8F8FC;

  --lavender: #A78BFA;
  --lavender-light: #F0ECFE;

  /* Grown-up mode palette - cool gray */
  --grownup: #56697C;
  --grownup-dark: #3E4E5E;
  --grownup-light: #EAEFF2;

  /* Warm, kid-friendly backgrounds */
  --bg: #FFF9F2;
  --bg-card: #FFFFFF;
  --text: #3B2F27;
  --text-light: #9C8F82;

  /* Soft, blurred shadows */
  --shadow: 0 6px 18px rgba(232,98,46,0.14);
  --shadow-lg: 0 12px 30px rgba(232,98,46,0.2);
  --shadow-flat: 0 2px 10px rgba(50,35,20,0.08);
  --shadow-card: 0 4px 16px rgba(50,35,20,0.10);

  /* Rounded, child-friendly corners */
  --radius: 20px;
  --radius-lg: 28px;
  --radius-sm: 14px;
  --radius-xs: 9px;
  --pill: 999px;

  /* Fonts */
  --font-display: 'Baloo 2', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
  --font-title: 'Baloo 2', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --header-h: 56px;
  --footer-h: 96px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image: radial-gradient(ellipse at 20% 50%, rgba(255,122,69,0.06) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(255,201,60,0.06) 0%, transparent 60%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

/* =================== VIEWS =================== */
.view {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  z-index: 1;
}
.view.active { display: flex; }

/* =================== HEADER =================== */
.app-header {
  height: var(--header-h);
  min-height: var(--header-h);
  padding: 0 12px;
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  box-shadow: var(--shadow-flat);
  z-index: 10;
  position: relative;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; min-width: 60px; }
.header-right { justify-content: flex-end; }
.header-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text);
}
.header-title .hicon { font-size: 20px; display: inline-flex; color: var(--kid); }

/* Child-facing screens - warm orange gradient */
.child-header, .quiz-header, .wrong-header {
  background: linear-gradient(135deg, #FF7A45 0%, #FF9A6C 40%, #FFB088 100%);
}
.child-header .header-title, .quiz-header .header-title, .wrong-header .header-title {
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.child-header .icon-btn, .quiz-header .icon-btn, .wrong-header .icon-btn,
.quiz-header .page-indicator {
  color: #fff;
  background: rgba(255,255,255,0.2);
  border-color: transparent;
  box-shadow: none;
}
.child-header .icon-btn:active, .quiz-header .icon-btn:active, .wrong-header .icon-btn:active {
  background: rgba(255,255,255,0.3);
  transform: scale(0.95);
  box-shadow: none;
}

.read-header {
  background: var(--bg-card);
  box-shadow: var(--shadow-flat);
}

/* Grown-up screens - cool gray gradient */
.parent-header, .mark-header {
  background: linear-gradient(135deg, var(--grownup-dark), var(--grownup));
}
.parent-header .header-title, .mark-header .header-title { color: #fff; }
.parent-header .icon-btn, .mark-header .icon-btn {
  color: #fff;
  background: rgba(255,255,255,0.15);
  border-color: transparent;
  box-shadow: none;
}
.parent-header .icon-btn:active, .mark-header .icon-btn:active {
  background: rgba(255,255,255,0.25);
  transform: scale(0.95);
  box-shadow: none;
}

/* =================== BUTTONS =================== */
.icon-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 18px;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-flat);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active {
  transform: scale(0.92);
  box-shadow: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 32px;
  border: none;
  border-radius: var(--pill);
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  width: 100%;
  position: relative;
  overflow: hidden;
  text-transform: none;
  color: #fff;
  letter-spacing: 0.5px;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.25) 0%, transparent 50%);
  pointer-events: none;
  border-radius: inherit;
}
.btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.btn:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important; }

/* Main action button - warm orange with glow */
.btn-child {
  background: linear-gradient(135deg, #FF7A45 0%, #FF9A6C 50%, #FFB088 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(255,122,69,0.4), 0 2px 6px rgba(255,122,69,0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Parent button - cool gray */
.btn-parent {
  background: linear-gradient(135deg, var(--grownup) 0%, var(--grownup-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(86,105,124,0.3), 0 2px 6px rgba(86,105,124,0.2);
}

.btn-small {
  padding: 10px 22px;
  font-size: 13px;
  width: auto;
  border-radius: var(--pill);
  background: linear-gradient(135deg, var(--sky) 0%, #3AA4C2 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(69,184,214,0.3);
  border: none;
  font-family: var(--font-title);
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-small:active { transform: scale(0.96); box-shadow: 0 2px 6px rgba(69,184,214,0.2) !important; }
.btn-small::after { border-radius: var(--pill); }

.btn-link {
  background: none;
  color: var(--sky);
  text-decoration: underline;
  font-size: 14px;
  width: auto;
  padding: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  box-shadow: none;
  border: none;
  text-decoration-style: solid;
  text-underline-offset: 2px;
  border-radius: 0;
}
.btn-link::after { display: none; }
.btn-link:active { transform: none; box-shadow: none !important; }

.btn-save {
  background: linear-gradient(135deg, var(--leaf) 0%, #3AA06C 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(72,181,126,0.35) !important;
  border: none !important;
}
.btn-save::after { border-radius: var(--pill); }

.btn-mark {
  background: linear-gradient(135deg, var(--kid) 0%, var(--kid-dark) 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(255,122,69,0.35) !important;
  border: none !important;
}
.btn-mark::after { border-radius: var(--pill); }

.btn-edit {
  background: linear-gradient(135deg, var(--grownup) 0%, var(--grownup-dark) 100%) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(86,105,124,0.3) !important;
  border: none !important;
}
.btn-edit::after { border-radius: var(--pill); }

.page-indicator {
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  padding: 0 8px;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
}

/* =================== LOGIN =================== */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 14px;
  position: relative;
  background: linear-gradient(160deg, #FFF6EE 0%, #FFE9DA 30%, #FFD4B8 60%, #FFC9A8 100%);
  overflow: hidden;
}

/* Floating blob decorations */
.login-container::before {
  content: '';
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,122,69,0.15) 0%, transparent 70%);
  top: -60px; right: -60px;
  animation: floatBlob 12s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
.login-container::after {
  content: '';
  position: absolute;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,201,60,0.15) 0%, transparent 70%);
  bottom: 10%; left: -40px;
  animation: floatBlob 10s ease-in-out infinite reverse;
  pointer-events: none;
  z-index: 0;
}

.login-decor-block {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
}
.login-decor-block.green {
  width: 80px; height: 80px;
  background: radial-gradient(circle, rgba(72,181,126,0.12) 0%, transparent 70%);
  top: 10%; right: 5%;
  animation: floatBlob 14s ease-in-out infinite 2s;
}
.login-decor-block.blue {
  width: 60px; height: 60px;
  background: radial-gradient(circle, rgba(69,184,214,0.12) 0%, transparent 70%);
  bottom: 25%; left: 5%;
  animation: floatBlob 11s ease-in-out infinite 1s;
}

@keyframes floatBlob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(12px, -16px) scale(1.05); }
  50% { transform: translate(8px, -32px) scale(0.95); }
  75% { transform: translate(-8px, -16px) scale(1.02); }
}

.login-logo-wrapper {
  position: relative;
  margin-bottom: 8px;
  animation: float-bob 3s ease-in-out infinite;
  background: var(--bg-card);
  padding: 8px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(255,122,69,0.15);
  z-index: 1;
}
.login-logo {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--radius);
}

/* Sparkle decorations around logo */
.login-sparkle {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--sun);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255,201,60,0.6);
}
.login-sparkle:nth-child(2) { top: -5px; right: -8px; animation: twinkle 2s ease-in-out infinite; }
.login-sparkle:nth-child(3) { top: 20px; left: -14px; width: 8px; height: 8px; background: var(--sky); box-shadow: 0 0 8px rgba(69,184,214,0.6); animation: twinkle 2.5s ease-in-out infinite 0.5s; }
.login-sparkle:nth-child(4) { bottom: 10px; right: -8px; width: 7px; height: 7px; background: var(--leaf); box-shadow: 0 0 8px rgba(72,181,126,0.6); animation: twinkle 1.8s ease-in-out infinite 1s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

@keyframes float-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-title {
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 800;
  color: var(--kid-dark);
  position: relative;
  z-index: 1;
  letter-spacing: 2px;
}
.login-subtitle {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}
.login-container .btn { max-width: 280px; position: relative; z-index: 1; }

/* Wave at bottom */
.login-wave {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  pointer-events: none;
  z-index: 1;
}

/* =================== LOGIN BG IMAGE VARIANT =================== */
.login-bg-image {
  background-image: url('../images/login-bg.jpg');
  background-size: cover;
  background-position: center 40%;
  padding: 0;
  justify-content: flex-end;
}
/* Wide screens use the landscape background */
@media (orientation: landscape) {
  .login-bg-image {
    background-image: url('../images/login-bg-wide.jpg');
    background-position: center 35%;
  }
}
.login-bg-image::before,
.login-bg-image::after { display: none; }

.login-bottom-area {
  width: 100%;
  padding: 30px 28px 40px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.08) 20%, rgba(0,0,0,0.3) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 2;
}

/* Minecraft-style 3D pixel title */
.login-bg-image .login-title {
  font-family: var(--font-body);
  font-size: 32px;
  font-weight: 900;
  color: #FFFAF0;
  letter-spacing: 6px;
  margin-bottom: 0;
  /* 3D block text effect - Minecraft title style */
  text-shadow:
    3px 3px 0 #8B6914,
    5px 5px 0 #5C3D0E,
    0 0 10px rgba(255,200,60,0.4),
    0 0 30px rgba(255,122,69,0.2);
  /* Pixel-like letter spacing */
  -webkit-text-stroke: 1px rgba(139,105,20,0.3);
}

.login-bg-image .login-subtitle {
  color: rgba(255,255,255,0.9);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: 2px;
  text-shadow:
    2px 2px 0 rgba(0,0,0,0.4),
    0 0 8px rgba(255,255,255,0.2);
}

/* Minecraft wooden plank button - start reading */
.login-bg-image .btn {
  max-width: 280px;
  border: 3px solid;
  border-color: #C4943A #7A5B28 #5C3D0E #C4943A;
  border-radius: 4px;
  font-size: 17px;
  padding: 14px 32px;
  letter-spacing: 2px;
  position: relative;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}
.login-bg-image .btn::after {
  /* Wood grain top highlight */
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.05) 40%, transparent 60%);
  border-radius: 2px;
}
.login-bg-image .btn-child {
  background: linear-gradient(180deg, #C4943A 0%, #A67B2E 40%, #8B6914 100%);
  color: #FFFAF0;
  box-shadow:
    0 4px 0 #5C3D0E,
    0 5px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.15);
}
.login-bg-image .btn-child:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #5C3D0E,
    0 3px 4px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Minecraft stone button - parent mode */
.login-bg-image .btn-parent {
  background: linear-gradient(180deg, #A0A0A0 0%, #808080 40%, #666 100%);
  color: #E8E8E8;
  border-color: #B0B0B0 #666 #4A4A4A #B0B0B0;
  box-shadow:
    0 4px 0 #4A4A4A,
    0 5px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.12);
}
.login-bg-image .btn-parent:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #4A4A4A,
    0 3px 4px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.12);
}
.login-bg-image .btn-parent svg { filter: brightness(0.9); }
.login-wave svg {
  width: 100%; height: 100%;
  display: block;
}

.pin-section {
  margin-top: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.pin-section p { font-size: 14px; color: var(--text-light); font-weight: 500; font-family: var(--font-body); }
.pin-inputs { display: flex; gap: 12px; }
.pin-digit {
  width: 50px; height: 58px;
  border: 2px solid var(--grownup-light);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  background: #fff;
  font-family: var(--font-display);
  box-shadow: var(--shadow-flat);
  color: var(--text);
}
.pin-digit:focus {
  border-color: var(--kid);
  box-shadow: 0 0 0 3px rgba(255,122,69,0.2);
  transform: scale(1.02);
}

/* PIN Modal */
.pin-modal-card {
  max-width: 320px;
  padding: 24px 28px;
}
.pin-modal-card h3 {
  font-size: 16px;
  margin-bottom: 20px;
  text-align: center;
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--text);
}
.pin-modal-card .pin-inputs {
  justify-content: center;
  margin-bottom: 16px;
}
.pin-error {
  color: var(--berry);
  font-size: 13px;
  text-align: center;
  margin-bottom: 8px;
  font-family: var(--font-body);
  font-weight: 600;
}

/* =================== BOOKSHELF =================== */
/* Make collection containers full-height flex so children can scroll */
#collection-view,
#collection-detail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.child-name-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--grownup-light);
  font-size: 14px; color: var(--text-light);
  font-weight: 500;
}
.child-name-bar select {
  padding: 6px 12px;
  border: 1.5px solid var(--kid-light);
  border-radius: var(--radius-xs);
  font-size: 13px;
  background: var(--kid-soft);
  color: var(--kid-dark);
  font-weight: 600;
  font-family: var(--font-body);
  transition: border-color 0.15s ease;
}
.child-name-bar select:focus { border-color: var(--kid); outline: none; }
.child-name-bar .icon-btn {
  width: 34px; height: 34px;
  background: var(--kid);
  color: #fff;
  border-radius: var(--radius-xs);
  box-shadow: 0 3px 10px rgba(255,122,69,0.3);
}

.bookshelf {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 14px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: min-content;
  gap: 16px;
  align-content: start;
}

/* Collection list */
.collection-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.collection-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-left: 5px solid var(--c-color, var(--kid));
}
.collection-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-flat);
}
.collection-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius);
  background: var(--kid-soft);
  color: var(--c-color, var(--kid));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.collection-cover-img {
  width: 60px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(50,35,20,0.15);
  display: block;
}
.collection-info { flex: 1; min-width: 0; }
.collection-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 2px; font-family: var(--font-body); }
.collection-subtitle { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
.collection-progress-bar {
  height: 8px;
  background: var(--grownup-light);
  border-radius: var(--pill);
  overflow: hidden;
  margin-bottom: 6px;
}
.collection-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-color, var(--kid)), var(--sun));
  border-radius: var(--pill);
  transition: width 0.3s ease;
}
.collection-stats { font-size: 12px; color: var(--text-light); }
.collection-arrow { color: var(--text-light); font-size: 18px; flex-shrink: 0; }

/* Book card */
.book-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}
.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(50,35,20,0.15);
}
.book-card:active {
  transform: translateY(-1px) scale(0.98);
}

.book-number {
  position: absolute; top: 8px; left: 8px;
  background: linear-gradient(135deg, var(--leaf) 0%, #3AA06C 100%);
  color: #fff;
  font-size: 11px; font-weight: 700;
  font-family: var(--font-display);
  width: 26px; height: 26px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(72,181,126,0.3);
}

/* Badges on cover - like parent mode */
.book-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.book-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--pill);
  color: #fff;
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.book-badge svg { width: 11px; height: 11px; }
.book-badge.complete {
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-dark) 100%);
}
.book-badge.read {
  background: rgba(72,181,126,0.9);
}
.book-badge.progress {
  background: rgba(59, 130, 246, 0.9);
}
.book-badge.quiz {
  background: rgba(167,139,250,0.9);
}
.book-badge.pages {
  background: rgba(72,181,126,0.9);
}

.book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--kid-light), var(--leaf-light));
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.book-cover img, .book-cover canvas {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}
.book-cover-placeholder { color: var(--kid-dark); opacity: 0.4; }
.book-cover-placeholder svg { width: 40px; height: 40px; }

.book-info {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.book-card-number {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 700;
  font-family: var(--font-display);
}
.book-info h3 {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
  margin: 0;
}
.book-status {
  font-size: 11px; color: var(--text-light); font-weight: 600;
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-body);
}
.book-status svg { width: 11px; height: 11px; }
.book-status.complete { color: var(--sun-dark); font-weight: 700; }
.book-status.read { color: var(--leaf); font-weight: 600; }
.book-status.progress { color: var(--sky); font-weight: 600; }

.book-progress {
  margin-top: 2px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 15px;
  font-weight: 500;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-family: var(--font-body);
  line-height: 1.6;
}
.empty-state svg { width: 56px; height: 56px; color: var(--grownup); opacity: 0.5; }

/* =================== READER =================== */
.reader-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg) 0%, #FFE9DA 50%, var(--bg) 100%);
  position: relative;
}

.pdf-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.page-stack {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  perspective: 1500px;
  padding-top: 8px;
}

.page-image {
  max-width: 100%;
  max-height: calc(100% - 16px);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  background: #fff;
  object-fit: contain;
  object-position: top center;
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  margin: 0 auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.page-image-next {
  opacity: 0;
  z-index: 0;
}
.page-image:not(.page-image-next) {
  z-index: 1;
}
.page-image.loading {
  opacity: 0.4;
  transform: scale(0.98);
}
/* Page turn animation - realistic book page flip for kids */
.page-image.turning-left {
  animation: flipOutLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: right center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.page-image.turning-right {
  animation: flipOutRight 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: left center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.page-image-next.turning-in-left {
  animation: flipInLeft 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: left center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.page-image-next.turning-in-right {
  animation: flipInRight 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-origin: right center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

@keyframes flipOutLeft {
  0% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
    box-shadow: var(--shadow-lg);
  }
  40% {
    transform: rotateY(-50deg) scale(1.02);
    opacity: 0.9;
    box-shadow: -15px 8px 30px rgba(0,0,0,0.25);
  }
  70% {
    transform: rotateY(-80deg) scale(0.98);
    opacity: 0.6;
    box-shadow: -20px 4px 25px rgba(0,0,0,0.2);
  }
  100% {
    transform: rotateY(-90deg) scale(0.95);
    opacity: 0;
    box-shadow: -25px 2px 20px rgba(0,0,0,0.1);
  }
}

@keyframes flipInLeft {
  0% {
    transform: rotateY(90deg) scale(0.95);
    opacity: 0;
    box-shadow: 25px 2px 20px rgba(0,0,0,0.1);
  }
  30% {
    transform: rotateY(70deg) scale(0.98);
    opacity: 0.5;
    box-shadow: 20px 4px 25px rgba(0,0,0,0.2);
  }
  60% {
    transform: rotateY(40deg) scale(1.02);
    opacity: 0.85;
    box-shadow: 15px 8px 30px rgba(0,0,0,0.25);
  }
  100% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
    box-shadow: var(--shadow-lg);
  }
}

@keyframes flipOutRight {
  0% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
    box-shadow: var(--shadow-lg);
  }
  40% {
    transform: rotateY(50deg) scale(1.02);
    opacity: 0.9;
    box-shadow: 15px 8px 30px rgba(0,0,0,0.25);
  }
  70% {
    transform: rotateY(80deg) scale(0.98);
    opacity: 0.6;
    box-shadow: 20px 4px 25px rgba(0,0,0,0.2);
  }
  100% {
    transform: rotateY(90deg) scale(0.95);
    opacity: 0;
    box-shadow: 25px 2px 20px rgba(0,0,0,0.1);
  }
}

@keyframes flipInRight {
  0% {
    transform: rotateY(-90deg) scale(0.95);
    opacity: 0;
    box-shadow: -25px 2px 20px rgba(0,0,0,0.1);
  }
  30% {
    transform: rotateY(-70deg) scale(0.98);
    opacity: 0.5;
    box-shadow: -20px 4px 25px rgba(0,0,0,0.2);
  }
  60% {
    transform: rotateY(-40deg) scale(1.02);
    opacity: 0.85;
    box-shadow: -15px 8px 30px rgba(0,0,0,0.25);
  }
  100% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
    box-shadow: var(--shadow-lg);
  }
}

/* Page nav overlay */
.page-nav-overlay {
  position: absolute; inset: 0;
  background: rgba(59,47,39,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}
.page-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}
.page-nav-item {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  transition: all 0.2s ease;
  color: #fff; font-weight: 600;
  font-size: 12px;
  font-family: var(--font-display);
}
.page-nav-item.active {
  border-color: var(--sun);
  box-shadow: 0 0 0 2px var(--sun), 0 0 12px rgba(255,201,60,0.3);
}
.page-nav-item:active { background: rgba(255,255,255,0.15); transform: scale(0.96); }
.page-nav-item canvas { width: 100%; height: auto; display: block; border-radius: var(--radius-xs); }
.page-nav-item img { width: 100%; height: auto; display: block; border-radius: var(--radius-xs); }

/* Book finished overlay */
.book-finished-overlay {
  position: absolute; inset: 0;
  background: rgba(59,47,39,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.book-finished-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.3s ease-out;
}
.finished-icon { color: var(--sun-dark); font-size: 56px; margin-bottom: 14px; }
.finished-title {
  color: var(--text); font-size: 18px; font-weight: 700;
  margin-bottom: 6px;
  font-family: var(--font-title);
}
.finished-subtitle { color: var(--text-light); font-size: 14px; margin-bottom: 28px; line-height: 1.6; font-family: var(--font-body); }
.finished-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.finished-actions .btn { flex: 1; min-width: 130px; white-space: nowrap; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Reader footer */
.reader-footer {
  background: var(--bg-card);
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--grownup-light);
  z-index: 10;
  position: relative;
}

/* Audio controls */
.audio-controls {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}
.audio-btn {
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kid-light), var(--kid-soft));
  color: var(--kid-dark);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-flat);
}
.audio-btn svg { width: 20px; height: 20px; }
.audio-btn:active { transform: scale(0.9); box-shadow: none; }
#btn-play-pause {
  width: 56px; height: 56px;
  font-size: 24px;
  background: linear-gradient(135deg, var(--kid) 0%, var(--kid-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255,122,69,0.35);
}
#btn-play-pause svg { width: 26px; height: 26px; }
#btn-play-pause:active { transform: scale(0.92); }

.speed-control { margin-left: 6px; }
.speed-btn {
  width: 38px; height: 38px;
  border: 1.5px solid var(--grownup-light);
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  font-family: var(--font-display);
  font-size: 11px; font-weight: 700;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-flat);
  transition: all 0.15s ease;
}
.speed-btn:active { transform: scale(0.92); }

/* Progress bar - warm gradient */
.progress-bar-container {
  position: relative;
  height: 22px;
  background: var(--grownup-light);
  border-radius: var(--pill);
  cursor: pointer;
  overflow: visible;
  border: none;
  z-index: 1;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--kid) 0%, var(--sun) 100%);
  border-radius: var(--pill);
  transition: width 0.1s linear;
  width: 0%;
  position: relative;
  box-shadow: 0 2px 8px rgba(255,122,69,0.25);
}
.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 100%);
  pointer-events: none;
  border-radius: var(--pill) var(--pill) 0 0;
}
.page-markers {
  position: absolute; inset: 0;
  display: flex;
  pointer-events: none;
  overflow: hidden;
  border-radius: var(--pill);
}
.page-marker {
  height: 100%;
  background: transparent;
  border-right: 1.5px solid rgba(255,255,255,0.5);
  position: relative;
}
.page-marker.active::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%,-50%);
  box-shadow: 0 0 4px rgba(255,255,255,0.5);
}

/* =================== QUIZ =================== */
.quiz-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.quiz-question-card { max-width: 520px; margin: 0 auto; }

.quiz-question {
  font-family: var(--font-body);
  font-size: 16px; font-weight: 700;
  text-align: center;
  margin-bottom: 22px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border-top: 4px solid var(--kid);
  line-height: 1.7;
  color: var(--text);
}

.quiz-options {
  display: flex; flex-direction: column; gap: 12px;
}

/* Quiz options - soft card style with light border */
.quiz-option {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border: 2px solid var(--grownup-light);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  font-family: var(--font-body);
  background: var(--bg-card);
  color: var(--text);
}
.quiz-option:nth-child(1) { border-left: 4px solid var(--kid); }
.quiz-option:nth-child(2) { border-left: 4px solid var(--sky); }
.quiz-option:nth-child(3) { border-left: 4px solid var(--leaf); }
.quiz-option:nth-child(4) { border-left: 4px solid var(--lavender); }
.quiz-option:hover { border-color: var(--kid-light); box-shadow: 0 2px 12px rgba(255,122,69,0.12); }
.quiz-option:active { transform: scale(0.98); }
.quiz-option:disabled { cursor: default; }
.quiz-option.correct {
  border-color: var(--leaf) !important;
  background: var(--leaf-light) !important;
  color: var(--leaf) !important;
  animation: pop-correct 0.4s ease;
  box-shadow: 0 4px 16px rgba(72,181,126,0.2) !important;
  border-left-width: 4px !important;
}
.quiz-option.wrong {
  border-color: var(--berry) !important;
  background: var(--berry-light) !important;
  color: var(--berry) !important;
  animation: shake 0.4s ease;
  box-shadow: 0 4px 16px rgba(241,107,107,0.2) !important;
  border-left-width: 4px !important;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes pop-correct {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.option-key {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kid) 0%, var(--kid-dark) 100%);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255,122,69,0.25);
}
.option-text { flex: 1; line-height: 1.5; }

.quiz-feedback {
  margin-top: 20px;
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.feedback-icon { margin-bottom: 8px; display: flex; align-items: center; justify-content: center; }
.feedback-icon svg { width: 48px; height: 48px; }
.feedback-icon.correct { color: var(--sun-dark); animation: bounceIn 0.4s ease; }
.feedback-icon.wrong { color: var(--berry); }
@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); }
}
.feedback-text { font-family: var(--font-title); font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.feedback-text.correct { color: var(--leaf); }
.feedback-text.wrong { color: var(--berry); }
.feedback-explanation { font-size: 14px; color: var(--text-light); line-height: 1.6; font-weight: 500; font-family: var(--font-body); }

.btn-next-quiz {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 22px auto 0;
  padding: 14px 40px;
  background: linear-gradient(135deg, var(--kid) 0%, var(--kid-dark) 100%);
  color: #fff;
  border: none;
  border-radius: var(--pill);
  font-family: var(--font-title);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,122,69,0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-next-quiz:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(255,122,69,0.2); }
.btn-next-quiz svg { width: 16px; height: 16px; transform: scaleX(-1); }

/* Quiz result */
.quiz-result {
  text-align: center;
  padding: 40px 20px;
  animation: slideUp 0.3s ease;
}
.result-icon { margin-bottom: 16px; display: flex; align-items: center; justify-content: center; color: var(--sun-dark); }
.result-icon svg { width: 80px; height: 80px; }
#result-title { font-family: var(--font-title); font-size: 20px; margin-bottom: 8px; font-weight: 700; color: var(--text); }
#result-score { font-size: 14px; color: var(--text-light); margin-bottom: 20px; font-weight: 500; font-family: var(--font-body); }
.result-stars { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 28px; }
.result-stars svg { width: 38px; height: 38px; }
.result-stars .star { color: var(--sun); filter: drop-shadow(0 2px 4px rgba(255,201,60,0.4)); }
.result-stars .star-empty { color: var(--grownup-light); }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.result-actions .btn { max-width: 210px; }

/* =================== PARENT MODE =================== */
.parent-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--grownup-light);
  border-radius: var(--radius);
}
.parent-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}
.parent-tab svg { width: 16px; height: 16px; stroke-width: 2; }
.parent-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-card);
}
.parent-tab:active { transform: scale(0.97); }

.parent-tab-content {
  display: none;
}
.parent-tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.parent-section.compact {
  padding: 14px 16px;
  margin-bottom: 14px;
}
.parent-section.compact .section-desc {
  margin-bottom: 10px;
}
.parent-section.compact h2 {
  font-size: 15px;
  margin-bottom: 2px;
  font-family: var(--font-title);
  font-weight: 700;
}

.parent-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  -webkit-overflow-scrolling: touch;
  position: relative;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Parent sections - clean card style */
.parent-section {
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.parent-section h2 {
  font-size: 15px; font-weight: 700; margin-bottom: 4px;
  display: flex; align-items: center; gap: 7px;
  color: var(--grownup-dark);
  font-family: var(--font-title);
}
.parent-section h2 svg { width: 18px; height: 18px; }
.section-desc { font-size: 13px; color: var(--text-light); margin-bottom: 14px; font-family: var(--font-body); }

/* ===== Parent mode - Book management (redesigned with covers) ===== */

.parent-collection-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.parent-collection-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  border-left: 4px solid var(--c-color, var(--kid));
  transition: all 0.2s ease;
  box-shadow: var(--shadow-card);
}
.parent-collection-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(50,35,20,0.12);
}
.parent-collection-item:active { transform: scale(0.98); }

.parent-collection-cover {
  width: 56px;
  height: 76px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--grownup-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(50,35,20,0.15);
}
.parent-collection-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.parent-collection-cover .icon-placeholder {
  font-size: 24px;
  color: var(--c-color, var(--kid));
}

.parent-collection-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.parent-collection-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parent-collection-count {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 4px;
}
.parent-collection-count .progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--leaf);
}
.parent-collection-count .progress-dot.pending { background: var(--grownup); }

.parent-collection-arrow {
  color: var(--text-light);
  font-size: 18px;
  flex-shrink: 0;
}

/* Book grid - card layout with covers */
.parent-book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.parent-book-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.parent-book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(50,35,20,0.15);
}
.parent-book-card:active { transform: translateY(-1px) scale(0.98); }

.parent-book-cover {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, var(--kid-light), var(--leaf-light));
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.parent-book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.parent-book-cover-placeholder {
  font-size: 36px;
  color: var(--kid-dark);
  opacity: 0.4;
}

.parent-book-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  z-index: 2;
}
.parent-book-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--pill);
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  color: var(--text);
  font-family: var(--font-display);
}
.parent-book-badge.ready { background: rgba(72,181,126,0.9); color: #fff; }
.parent-book-badge.pending { background: rgba(86,105,124,0.8); color: #fff; }
.parent-book-badge.quiz { background: rgba(167,139,250,0.9); color: #fff; }

.parent-book-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.parent-book-number {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 700;
  font-family: var(--font-display);
}
.parent-book-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.parent-book-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}
.parent-book-actions .btn-small {
  flex: 1;
  font-size: 11px;
  padding: 8px 10px;
  font-weight: 600;
}
.parent-book-actions .btn-icon-only {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--grownup-light);
  color: var(--grownup);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 14px;
}
.parent-book-actions .btn-icon-only:hover { background: var(--berry-light); color: var(--berry); }
.parent-book-actions .btn-icon-only:active { transform: scale(0.92); }
.parent-book-actions .btn-icon-only svg { width: 16px; height: 16px; }

/* Back button area */
.parent-list-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.parent-list-header h3 {
  font-size: 17px;
  color: var(--text);
  font-weight: 700;
  font-family: var(--font-title);
}

/* Section header with count */
.parent-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.parent-section-header h2 { margin-bottom: 0 !important; }
.parent-section-count {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
  background: var(--grownup-light);
  padding: 4px 10px;
  border-radius: var(--pill);
}

.stats-panel { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.stats-table {
  width: 100%; border-collapse: collapse;
}
.stats-table th, .stats-table td {
  padding: 12px 12px; text-align: center; font-size: 13px;
  border-bottom: 1px solid var(--grownup-light);
  font-family: var(--font-body);
}
.stats-table th {
  background: var(--grownup-dark);
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  font-family: var(--font-title);
}
.stats-table tr:last-child td { border-bottom: none; }
.text-wrong { color: var(--berry); font-weight: 700; }

/* =================== AUDIO MARKER =================== */
.mark-body {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.mark-current-page {
  text-align: center; font-size: 13px; font-weight: 600;
  padding: 9px; background: var(--bg-card);
  color: var(--grownup-dark);
  border-bottom: 1px solid var(--grownup-light);
  font-family: var(--font-display);
}

.mark-canvas-area {
  height: 180px;
  display: flex; align-items: center; justify-content: center;
  background: var(--grownup-dark);
  overflow: hidden;
}
.mark-page-img { max-width: 100%; max-height: 100%; object-fit: contain; }

.mark-player {
  background: var(--bg-card);
  padding: 8px 16px;
  border-top: 1px solid var(--grownup-light);
}

.mark-time-display {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-light);
  margin-bottom: 4px;
  font-family: var(--font-display);
}
.mark-range-label { color: var(--grownup-dark); font-weight: 600; font-size: 12px; font-family: var(--font-body); }

.mark-controls {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 0;
}
.mark-controls .audio-btn {
  background: var(--grownup-light);
  color: var(--grownup-dark);
  box-shadow: var(--shadow-flat);
}
.mark-controls .audio-btn:active { background: var(--grownup-light); }
.mark-btn-start {
  background: linear-gradient(135deg, var(--sky) 0%, #3AA4C2 100%) !important;
  color: #fff !important;
  width: 46px; height: 46px;
  font-size: 11px !important; font-weight: 700;
  box-shadow: 0 3px 10px rgba(69,184,214,0.3) !important;
  font-family: var(--font-display);
}
.mark-btn-end {
  background: linear-gradient(135deg, var(--leaf) 0%, #3AA06C 100%) !important;
  color: #fff !important;
  width: 46px; height: 46px;
  font-size: 11px !important; font-weight: 700;
  box-shadow: 0 3px 10px rgba(72,181,126,0.3) !important;
  font-family: var(--font-display);
}
.mark-btn-start.active {
  box-shadow: 0 0 0 3px rgba(69,184,214,0.4), 0 3px 10px rgba(69,184,214,0.3) !important;
}

.mark-hint {
  text-align: center;
  font-size: 12px;
  color: var(--grownup-dark);
  font-weight: 500;
  padding: 6px 0;
  background: var(--grownup-light);
  border-radius: var(--radius-sm);
  margin: 0 16px 8px;
  font-family: var(--font-body);
  line-height: 1.5;
}

.mark-page-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--grownup-light);
}
.mark-page-nav .icon-btn {
  width: auto; padding: 0 18px; height: 38px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--grownup-light);
  color: var(--grownup-dark);
  font-weight: 600;
  font-family: var(--font-body);
  box-shadow: none;
  border: 1px solid var(--grownup-light);
}
.mark-page-nav .icon-btn:active { transform: scale(0.96); box-shadow: none; }
.mark-page-info { font-size: 12px; font-weight: 600; color: var(--grownup-dark); font-family: var(--font-display); }

.marks-table-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.marks-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.marks-table th, .marks-table td {
  padding: 8px 8px; text-align: center; font-size: 12px;
  border-bottom: 1px solid var(--grownup-light);
  font-family: var(--font-body);
}
.marks-table th {
  background: var(--grownup-dark);
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  font-family: var(--font-title);
}
.marks-table .active-row { background: var(--sun-light); }

/* =================== WRONG ANSWERS =================== */
.wrong-body { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }

.wrong-child-label {
  text-align: center;
  font-size: 12px; color: #fff; font-weight: 600;
  margin-bottom: 16px; padding: 10px;
  background: linear-gradient(135deg, var(--grownup-dark), var(--grownup));
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
}

.wrong-book-group {
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.wrong-book-group h3 {
  font-family: var(--font-title);
  font-size: 15px; font-weight: 700;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--berry) 0%, #E05555 100%);
  color: #fff;
}

.wrong-item {
  background: var(--bg-card);
  padding: 14px 16px;
}
.wrong-item + .wrong-item { border-top: 1px solid var(--grownup-light); }
.wrong-question { font-size: 15px; font-weight: 700; margin-bottom: 8px; font-family: var(--font-body); color: var(--text); }
.wrong-selected { font-size: 14px; color: var(--berry); margin-bottom: 4px; font-weight: 600; font-family: var(--font-body); }
.wrong-correct { font-size: 14px; color: var(--leaf); font-weight: 700; margin-bottom: 4px; font-family: var(--font-body); }
.wrong-explanation { font-size: 13px; color: var(--text-light); font-style: italic; font-family: var(--font-body); }

.wrong-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* =================== TOAST =================== */
.toast {
  position: fixed;
  bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(59,47,39,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px 28px;
  border-radius: var(--pill);
  font-size: 13px; font-weight: 600;
  opacity: 0; transition: all 0.25s ease;
  z-index: 1000; pointer-events: none;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =================== LOADING OVERLAY =================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #FFF6EE 0%, #FFE9DA 50%, #FFD4B8 100%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,122,69,0.15);
  border-top-color: var(--kid);
  border-right-color: var(--sun);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: relative;
  z-index: 1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  position: relative;
  z-index: 1;
}

.loading-progress-bar {
  width: 200px;
  height: 8px;
  background: rgba(255,122,69,0.12);
  border-radius: var(--pill);
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.loading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--kid), var(--sun));
  border-radius: var(--pill);
  transition: width 0.3s ease;
}
.loading-size {
  color: var(--text-light);
  font-size: 12px;
  font-family: var(--font-body);
  position: relative;
  z-index: 1;
}
.btn-cancel {
  background: rgba(59,47,39,0.08);
  color: var(--text-light);
  border: 1.5px solid var(--grownup-light);
  padding: 8px 24px;
  border-radius: var(--pill);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
  font-weight: 600;
  position: relative;
  z-index: 1;
  box-shadow: none;
}
.btn-cancel:active { background: rgba(59,47,39,0.15); transform: scale(0.96); }
.btn-cancel::after { display: none; }

/* =================== HIDDEN =================== */
.hidden { display: none !important; }

/* =================== MODAL =================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(59,47,39,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 300px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.25s ease-out;
}
.modal-card h3 {
  font-family: var(--font-title);
  font-size: 16px;
  margin-bottom: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
}
.modal-card input {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--grownup-light);
  border-radius: var(--radius-sm);
  font-size: 15px; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #fff;
  font-family: var(--font-body);
  color: var(--text);
}
.modal-card input:focus { border-color: var(--kid); box-shadow: 0 0 0 3px rgba(255,122,69,0.15); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* =================== RESPONSIVE =================== */
/*
  Mobile-first approach — phone portrait (<600px) is the default.
  Breakpoints use min-width and are layered so wider rules add to narrower ones.
*/

/* -------------------------------------------------------
   2. Phone Landscape  (orientation: landscape, max-height: 500px)
   ------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --header-h: 46px;
    --footer-h: 74px;
  }

  /* Header */
  .header-title { font-size: 14px; }

  /* Login */
  .login-bottom-area {
    padding: 16px 24px 24px;
  }
  .login-bg-image .login-title {
    font-size: 22px;
    margin-bottom: 0;
  }
  .login-bg-image .login-subtitle {
    font-size: 12px;
    margin-bottom: 10px;
  }

  /* Bookshelf */
  .book-card { overflow: hidden; }
  .book-info { padding: 8px 10px; }

  /* Reader - compact footer and page */
  .reader-footer { padding: 6px 16px; }
  .reader-body .pdf-container { padding: 8px; }
  .reader-body .page-stack { max-height: 100%; }
  .audio-btn { width: 38px; height: 38px; font-size: 18px; }
  .audio-btn svg { width: 18px; height: 18px; }
  #btn-play-pause { width: 48px; height: 48px; font-size: 22px; }
  #btn-play-pause svg { width: 22px; height: 22px; }
  .audio-controls { gap: 8px; margin-bottom: 6px; }
  .progress-bar-container { height: 18px; }

  /* Quiz - 2x2 option grid */
  .quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .quiz-option {
    padding: 12px 14px;
    font-size: 14px;
  }
  .option-key { width: 30px; height: 30px; font-size: 11px; }
  .quiz-question { padding: 16px 20px; margin-bottom: 16px; font-size: 15px; }
  .quiz-body { padding: 14px; }

  /* Audio marker */
  .mark-canvas-area { height: 140px; }
  .mark-controls .audio-btn { width: 34px; height: 34px; font-size: 16px; }
  .mark-btn-start, .mark-btn-end { width: 38px; height: 38px; font-size: 10px !important; }
  .mark-page-nav .icon-btn { height: 34px; }

  /* General spacing reduction */
  .pin-inputs { gap: 8px; }
  .pin-digit { width: 44px; height: 52px; font-size: 20px; }

  /* Wrong answers */
  .wrong-body { padding: 12px; }
  .wrong-item { padding: 10px 12px; }
}

/* -------------------------------------------------------
   3. Tablet Portrait  (min-width: 600px) — iPad portrait
   ------------------------------------------------------- */
@media (min-width: 600px) {
  /* Login */
  .login-bg-image .login-title {
    font-size: 32px;
    letter-spacing: 4px;
  }
  .login-bg-image .login-subtitle {
    font-size: 16px;
  }
  .login-bg-image .btn {
    max-width: 360px;
  }
  .login-bg-image .login-bottom-area {
    padding: 40px 32px 48px;
  }
  .login-container .btn { max-width: 360px; }
  .login-title { font-size: 34px; }
  .login-logo { width: 140px; height: 140px; }

  /* Bookshelf */
  .bookshelf {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 20px;
  }
  .book-info { padding: 12px 14px; }
  .book-info h3 { font-size: 14px; }

  /* Collection list */
  .collection-list {
    padding: 20px;
    gap: 14px;
  }
  .collection-card { padding: 22px; }
  .collection-icon { width: 64px; height: 64px; font-size: 32px; }
  .collection-cover-img { width: 72px; height: 96px; }
  .collection-title { font-size: 16px; }

  /* Reader - center page image like a book */
  .reader-body .pdf-container {
    max-width: 60%;
    height: 100%;
  }
  .reader-body .page-stack {
    max-width: 100%;
    max-height: 100%;
  }
  .page-image {
    max-width: 100%;
    max-height: calc(100% - 16px);
    object-fit: contain;
  }

  /* Quiz */
  .quiz-body { padding: 28px; }
  .quiz-question-card { max-width: 600px; }
  .quiz-question {
    font-size: 18px;
    padding: 28px 32px;
  }
  .quiz-option {
    font-size: 16px;
    padding: 18px 20px;
  }
  .option-key { width: 40px; height: 40px; font-size: 14px; }

  /* Parent mode - 2-column grid */
  .parent-body { padding: 24px; max-width: 640px; }
  .parent-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .parent-section {
    margin-bottom: 0;
  }

  /* Audio marker */
  .marks-table-container { padding: 0 12px 12px; }
  .marks-table th, .marks-table td { padding: 10px 12px; font-size: 13px; }
  .mark-canvas-area { height: 220px; }

  /* PIN modal */
  .pin-modal-card { max-width: 380px; padding: 28px 32px; }
}

/* -------------------------------------------------------
   4. Tablet Landscape  (min-width: 900px) and (orientation: landscape)
   ------------------------------------------------------- */
@media (min-width: 900px) and (orientation: landscape) {
  :root {
    --header-h: 52px;
    --footer-h: 88px;
  }

  /* Login - buttons side by side */
  .login-bg-image .login-bottom-area {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px 40px 32px;
  }
  .login-bg-image .login-title,
  .login-bg-image .login-subtitle {
    width: 100%;
    text-align: center;
  }
  .login-bg-image .btn {
    max-width: 220px;
    flex: 1;
  }
  .login-bg-image .pin-section {
    width: 100%;
  }

  /* Bookshelf */
  .bookshelf {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
    padding: 24px;
  }

  /* Collection list - 2-column grid */
  .collection-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 24px;
  }

  /* Reader - better spacing on landscape */
  #read-view .reader-body .pdf-container {
    padding: 16px;
  }
  #read-view .reader-body .page-stack {
    max-width: 100%;
    max-height: 100%;
  }

  /* Quiz - 2x2 grid */
  .quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .quiz-question-card { max-width: 640px; }

  /* Parent mode - 2-column */
  .parent-body { padding: 24px 28px; max-width: 850px; }
  .parent-tabs { gap: 8px; margin-bottom: 20px; }
  .parent-tab { font-size: 14px; padding: 12px 12px; }

  /* Audio marker - side by side using grid */
  .mark-body {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    grid-template-columns: 1fr 300px;
    flex-direction: column;
  }
  .mark-current-page {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .mark-canvas-area {
    grid-column: 1;
    grid-row: 2 / 4;
    flex: 1;
    height: auto;
    min-height: 150px;
  }
  .mark-player {
    grid-column: 2;
    grid-row: 2;
    border-left: 1px solid var(--grownup-light);
    border-top: none;
  }
  .mark-page-nav {
    grid-column: 2;
    grid-row: 3;
    border-left: 1px solid var(--grownup-light);
    border-top: 1px solid var(--grownup-light);
  }
  .marks-table-container {
    grid-column: 2;
    grid-row: 4;
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    border-left: 1px solid var(--grownup-light);
    border-top: 1px solid var(--grownup-light);
    max-height: none;
  }
}

/* -------------------------------------------------------
   5. Large Tablet / Desktop  (min-width: 1200px)
   ------------------------------------------------------- */
@media (min-width: 1200px) {
  /* Bookshelf */
  .bookshelf {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 32px;
  }

  /* Reader - more padding on larger tablets */
  #read-view .reader-body .pdf-container {
    padding: 20px;
  }

  /* Quiz */
  .quiz-body { padding: 36px; }
  .quiz-question-card { max-width: 700px; }
  .quiz-question {
    font-size: 20px;
    padding: 32px 36px;
  }
  .quiz-option { font-size: 17px; padding: 20px 22px; }
  .option-key { width: 42px; height: 42px; font-size: 15px; }

  /* Parent mode */
  .parent-body {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 32px;
  }

  .parent-tabs { gap: 10px; margin-bottom: 28px; padding: 6px; max-width: 720px; margin-left: auto; margin-right: auto; }
  .parent-tab { font-size: 15px; padding: 14px 20px; }
  .parent-tab svg { width: 18px; height: 18px; }

  .parent-section {
    padding: 22px 26px;
    margin-bottom: 22px;
  }
  .parent-section h2 {
    font-size: 17px;
    margin-bottom: 6px;
  }
  .parent-section h2 svg { width: 20px; height: 20px; }
  .section-desc { font-size: 14px; margin-bottom: 16px; }

  /* Collection list - grid layout on wide screens */
  .parent-collection-list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
  }
  .parent-collection-item {
    padding: 16px;
    gap: 16px;
  }
  .parent-collection-cover {
    width: 64px;
    height: 86px;
  }
  .parent-collection-title { font-size: 15px; }
  .parent-collection-count { font-size: 13px; }

  /* Book grid - more columns on wide screens */
  .parent-book-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
  }
  .parent-book-title { font-size: 14px; }
  .parent-book-number { font-size: 12px; }

  /* Settings tab - responsive columns on wide screens */
  #tab-settings.active {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 24px;
  }
  #tab-settings.active .parent-section {
    margin-bottom: 0;
  }

  /* Audio marker - wider right panel */
  .mark-body {
    grid-template-columns: 1fr 360px;
  }

  /* Loading */
  .loading-progress-bar { width: 280px; }

  /* Collection list */
  .collection-list {
    max-width: 900px;
    margin: 0 auto;
    padding: 28px;
  }
}

/* Ultra-wide screens - constrain page width for better readability */
@media (min-width: 1600px) {
  #read-view .reader-body .pdf-container {
    max-width: 1100px;
    margin: 0 auto;
  }
}

@media (min-width: 2000px) {
  #read-view .reader-body .pdf-container {
    max-width: 1300px;
    margin: 0 auto;
  }
}

/* Ultra-wide screens - parent mode improvements */
@media (min-width: 1600px) {
  .parent-body {
    max-width: 1400px;
    padding: 32px 40px;
  }

  /* Settings tab - responsive columns for compact sections */
  #tab-settings.active {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 28px;
  }
  #tab-settings.active .parent-section {
    margin-bottom: 0;
  }

  .parent-tabs {
    margin-bottom: 32px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    padding: 7px;
  }
  .parent-tab {
    font-size: 16px;
    padding: 15px 24px;
  }
  .parent-tab svg { width: 19px; height: 19px; }

  .parent-section {
    padding: 26px 30px;
    margin-bottom: 26px;
  }
  .parent-section h2 {
    font-size: 18px;
    margin-bottom: 8px;
  }
  .parent-section h2 svg { width: 22px; height: 22px; }
  .section-desc {
    font-size: 15px;
    margin-bottom: 18px;
  }

  /* Collection grid - wider on ultra-wide */
  .parent-collection-list {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 18px;
  }
  .parent-collection-item {
    padding: 18px;
    gap: 18px;
  }
  .parent-collection-cover {
    width: 72px;
    height: 96px;
  }
  .parent-collection-title { font-size: 16px; }
  .parent-collection-count { font-size: 14px; }

  /* Book grid - more columns on ultra-wide */
  .parent-book-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 22px;
  }
  .parent-book-title { font-size: 14px; }
}

@media (min-width: 2000px) {
  .parent-body {
    max-width: 1700px;
    padding: 36px 48px;
  }
  .parent-collection-list {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
  }
  .parent-book-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
  }
}

/* -------------------------------------------------------
   Parent mode - width-only breakpoints (smooth progression regardless of orientation)
   These ensure parent-body width grows monotonically with screen width
   ------------------------------------------------------- */
@media (min-width: 900px) {
  .parent-body {
    max-width: 850px;
    padding: 24px 28px;
  }

  /* Bookshelf - consistent width-based layout */
  .bookshelf {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px;
    padding: 24px;
  }

  /* Collection list */
  .collection-list {
    padding: 24px;
    gap: 16px;
  }
  .collection-card { padding: 20px; }
}

@media (min-width: 1200px) {
  .parent-body {
    max-width: 1100px;
    padding: 28px 32px;
  }

  /* Bookshelf - wide screens */
  .bookshelf {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 32px;
  }

  /* Collection list */
  .collection-list {
    max-width: 900px;
    margin: 0 auto;
    padding: 28px;
  }
}

@media (min-width: 1600px) {
  .parent-body {
    max-width: 1400px;
    padding: 32px 40px;
  }
}

@media (min-width: 2000px) {
  .parent-body {
    max-width: 1700px;
    padding: 36px 48px;
  }
}

/* -------------------------------------------------------
   6. PWA Standalone mode (safe-area insets for notch devices)
   ------------------------------------------------------- */
@media (display-mode: standalone) {
  :root {
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
  }
}

/* -------------------------------------------------------
   7. Short viewport height fix (landscape on any device)
   ------------------------------------------------------- */
@media (max-height: 600px) and (orientation: landscape) {
  /* Login */
  .login-bottom-area {
    padding: 16px 24px 24px;
  }
  .login-container {
    padding: 24px 32px;
    gap: 10px;
  }
  .login-container .login-subtitle { margin-bottom: 12px; }

  /* Reduce gaps in flex layouts */
  .login-bottom-area { gap: 8px; }
  .audio-controls { gap: 8px; }
  .collection-list { gap: 8px; }
  .quiz-options { gap: 8px; }
  .quiz-body { padding: 12px; }

  /* Header compact */
  .header-title { font-size: 14px; }

  /* Reader footer compact */
  .reader-footer { padding: 6px 12px; }
  .audio-controls { margin-bottom: 6px; }
  .progress-bar-container { height: 18px; }

  /* Parent mode */
  .parent-body { padding: 12px 16px; }
  .parent-section { padding: 12px 14px; margin-bottom: 12px; }
  .parent-sections-grid { gap: 10px; }
  .parent-tabs { margin-bottom: 12px; padding: 3px; }

  /* Modal */
  .modal-card { padding: 20px 24px; }
  .pin-modal-card { padding: 20px 24px; }

  /* Toast */
  .toast { bottom: 80px; }

  /* Book finished */
  .book-finished-card { padding: 24px 20px; }
}