/* Marrow PWA — matched to the IPA (v12.4.0)
   Colours: ThemeList.plist (Default) + values sampled from source-of-truth screenshots.
   Explanation typography: MCQWebViewCSS from ThemeList.plist. */

:root {
  /* ThemeList.plist */
  --primary: #62c8df;
  --bg: #f6f6f6;
  --card-bg: #ffffff;
  --correct-bg: #c0ee86;
  --correct-text: #82c42d;
  --high-yield: #104957;

  /* Sampled from the running app */
  --teal-deep: #1999b0;      /* auth background */
  --teal-active: #4fbcd6;    /* selected tab / segment */
  --teal-number: #3e808e;    /* ring value, rail numbers */
  --ink: #454d4f;            /* nav titles, glass icons */
  --title: #878f91;          /* card + question titles */
  --slate: #557077;          /* tracker / tile secondary */
  --muted: #a9abaa;          /* section labels, captions */
  --hairline: #dfe5e6;
  --track: #e6eaea;
  --progress: #c6ea90;
  --incorrect-bg: #ffbdbd;
  --incorrect-text: #e25c5c;

  /* One tight contact shadow, as on the IPA's cards — no stacked blurs */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.13);
  --shadow-float: 0 1px 4px rgba(0, 0, 0, 0.16);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: calc(var(--safe-top) + 66px);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.3125;
  color: var(--ink);
  background: #e7ecee;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; }

#app {
  height: 100%; max-width: 480px; margin: 0 auto;
  position: relative; overflow: hidden;
  background: var(--bg);
}

/* Home-screen app on iOS: with a translucent status bar, `height: 100%` comes
   out shorter than the screen (by the status-bar inset), leaving the grey page
   background showing as a strip at the bottom. Pin the app to the full screen. */
@media (display-mode: standalone) {
  html, body { height: 100vh; height: 100lvh; background: var(--bg); }
  #app { position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100lvh; }
}

/* ========== SCREENS + NAVIGATION TRANSITIONS ========== */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  visibility: hidden; pointer-events: none;
  isolation: isolate;
  z-index: 1;
}
.screen.active { visibility: visible; pointer-events: auto; z-index: 2; }
.screen.exiting { visibility: visible; z-index: 1; }
.screen.exiting.on-top { z-index: 3; }

.screen.t-push-in   { animation: push-in 0.44s var(--ease-ios) both; }
.screen.t-push-out  { animation: push-out 0.44s var(--ease-ios) both; }
.screen.t-pop-in    { animation: pop-in 0.44s var(--ease-ios) both; }
.screen.t-pop-out   { animation: pop-out 0.44s var(--ease-ios) both; box-shadow: -1px 0 0 rgba(0, 0, 0, 0.06); }
.screen.t-sheet-in  { animation: sheet-in 0.48s var(--ease-ios) both; }
.screen.t-sheet-out { animation: sheet-out 0.4s var(--ease-ios) both; }
.screen.t-under-out { animation: under-out 0.48s var(--ease-ios) both; }
.screen.t-under-in  { animation: under-in 0.4s var(--ease-ios) both; }
.screen.t-fade-in   { animation: fade-in 0.5s var(--ease-out) both; }
.screen.t-fade-out  { animation: fade-out 0.5s var(--ease-out) both; }

@keyframes push-in   { from { transform: translateX(100%); } to { transform: none; } }
@keyframes push-out  { from { transform: none; } to { transform: translateX(-28%); } }
@keyframes pop-in    { from { transform: translateX(-28%); } to { transform: none; } }
@keyframes pop-out   { from { transform: none; } to { transform: translateX(100%); } }
@keyframes sheet-in  { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { from { transform: none; } to { transform: translateY(100%); } }
@keyframes under-out { from { transform: none; opacity: 1; } to { transform: scale(0.95); opacity: 0.6; } }
@keyframes under-in  { from { transform: scale(0.95); opacity: 0.6; } to { transform: none; opacity: 1; } }
@keyframes fade-in   { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
@keyframes fade-out  { from { opacity: 1; } to { opacity: 0; } }

/* Sky: the teal wash that fades into the page behind the nav bar */
.sky::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: calc(var(--safe-top) + 190px);
  background: linear-gradient(180deg, #66c9e0 0%, #96dbea 28%, #c9ecf2 60%, #e2f2f5 82%, var(--bg) 100%);
  z-index: 0; pointer-events: none;
  transition: height 0.6s var(--ease-out);
}
#main-app[data-tab="home"]::before {
  height: calc(var(--safe-top) + 430px);
  background: linear-gradient(180deg, #63c7de 0%, #83d2e3 24%, #acdee9 55%, #dbeef2 86%, var(--bg) 100%);
}

.scroll {
  position: absolute; inset: 0; z-index: 1;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-top: calc(var(--nav-h) + 8px);
  padding-bottom: calc(var(--safe-bottom) + 28px);
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }

/* ========== NAV BAR + GLASS CONTROLS ========== */
.nav-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: calc(var(--safe-top) + 10px) 19px 10px;
  pointer-events: none;
}
.nav-bar > * { pointer-events: auto; }
/* iOS 26 scroll-edge effect: content blurs out as it slides under the bar */
.nav-bar::before {
  content: ''; position: absolute; inset: 0 0 -14px 0; z-index: -1;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(#000 62%, transparent);
  mask-image: linear-gradient(#000 62%, transparent);
  pointer-events: none;
}
.nav-title {
  position: absolute; left: 76px; right: 76px;
  top: calc(var(--safe-top) + 10px); height: 46px; line-height: 46px;
  font-size: 17px; font-weight: 700; letter-spacing: -0.2px;
  color: var(--ink); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.nav-title.left, #main-app[data-tab="home"] .nav-title { text-align: left; left: 74px; right: 19px; }
#main-app[data-tab="home"] .nav-title { right: 122px; }
.nav-title.swap { animation: title-swap 0.36s var(--ease-out); }
@keyframes title-swap { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Teal liquid-glass circle: flat tint, hairline rim, a single top highlight */
.glass-btn, .glass-pill {
  height: 46px; border-radius: 23px; flex-shrink: 0;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(131, 216, 236, 0.92), rgba(155, 228, 243, 0.92));
  -webkit-backdrop-filter: blur(12px) saturate(1.6); backdrop-filter: blur(12px) saturate(1.6);
  box-shadow:
    inset 0 0 0 1px rgba(84, 184, 208, 0.55),
    inset 0 1.5px 0.5px rgba(255, 255, 255, 0.5),
    inset 0 -2px 3px rgba(255, 255, 255, 0.28);
}
.glass-btn { width: 46px; display: flex; align-items: center; justify-content: center; }
.glass-pill { display: flex; align-items: center; overflow: hidden; }
.glass-pill-btn {
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: width 0.42s var(--ease-out), opacity 0.25s ease, transform 0.42s var(--ease-out);
}
.glass-pill-btn:active { opacity: 0.55; }
.glass-pill-btn.nav-bookmark { width: 0; opacity: 0; transform: scale(0.6); pointer-events: none; }
#main-app[data-tab="home"] .glass-pill-btn.nav-bookmark { width: 44px; margin-left: 3px; opacity: 1; transform: none; pointer-events: auto; }

.pressable { transition: transform 0.3s var(--spring), opacity 0.2s ease; cursor: pointer; }
.pressable:active { transform: scale(0.965); transition-duration: 0.08s; }
.glass-btn.pressable:active, .quiz-close-btn.pressable:active, .quiz-nav-btn.pressable:active { transform: scale(0.9); }

/* ========== SEGMENTED CONTROL (glass capsule, sliding thumb) ========== */
.segmented {
  position: relative; display: flex; align-items: center;
  height: 42px; padding: 3px; border-radius: 21px;
  background: rgba(160, 190, 200, 0.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.5); backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 0 0 0.5px rgba(86, 126, 138, 0.45);
  overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  position: relative; z-index: 1; flex: 1 1 auto;
  height: 36px; padding: 0 13px; border-radius: 18px;
  font-size: 15px; font-weight: 700; letter-spacing: -0.2px;
  color: var(--ink); white-space: nowrap;
  transition: color 0.25s ease;
}
.segmented button.active { color: var(--teal-active); }
.seg-thumb {
  position: absolute; top: 3px; left: 0; height: 36px; width: var(--w, 0px);
  transform: translateX(var(--x, 3px));
  background: #fff; border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: transform 0.45s var(--spring), width 0.45s var(--spring);
}
.segmented.no-anim .seg-thumb { transition: none; }
.nav-bar.has-segmented .segmented { flex: 0 0 calc(100% + 14px); margin: 12px -7px 0; }
.nav-bar.has-segmented + .scroll { padding-top: calc(var(--nav-h) + 62px); }

/* ========== SURFACES ========== */
.card { background: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow-card); overflow: hidden; }
.tile { background: var(--card-bg); border-radius: 5px; box-shadow: var(--shadow-card); }
.hairline { height: 1px; background: var(--hairline); margin: 0 16px; }
.section-label {
  padding: 0 16px 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.3px;
  color: var(--muted); text-transform: uppercase;
}

/* Staggered entrance, applied by JS for one pass only */
.stagger > * { animation: rise 0.55s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 14) * 34ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ========== SPLASH ========== */
#splash-screen {
  background: linear-gradient(168deg, #7fc7dd 0%, #9ed5e6 22%, #c7e7f1 52%, #eef8fb 80%, #fff 100%);
  align-items: center; justify-content: center;
}
.splash-logo { animation: splash-logo 0.9s var(--ease-out) both; }
.splash-tagline {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 44px);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 19px; font-weight: 700; color: #a8def0;
  animation: rise 0.7s 0.35s var(--ease-out) both;
}
.splash-tagline img { animation: heartbeat 1.3s 0.9s ease-in-out infinite; }
@keyframes splash-logo { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes heartbeat { 0%, 40%, 100% { transform: scale(1); } 12% { transform: scale(1.18); } 26% { transform: scale(0.97); } }

/* ========== AUTH ========== */
#auth-screen { background: var(--teal-deep); align-items: center; justify-content: center; }
.auth-content {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; padding: 0 24px calc(var(--safe-bottom) + 96px);
  text-align: center; color: #fff;
}
.screen.active .auth-content > * { animation: rise 0.7s var(--ease-out) both; }
.screen.active .auth-content > :nth-child(1) { animation-delay: 0.1s; }
.screen.active .auth-content > :nth-child(2) { animation-delay: 0.17s; }
.screen.active .auth-content > :nth-child(3) { animation-delay: 0.24s; }
.screen.active .auth-content > :nth-child(4) { animation-delay: 0.31s; }
.screen.active .auth-content > :nth-child(5) { animation-delay: 0.38s; }
.screen.active .auth-content > :nth-child(6) { animation-delay: 0.45s; }
.auth-laurel { margin-bottom: 14px; }
.auth-wordmark { margin-bottom: 52px; }
.auth-subtitle { font-size: 22px; font-weight: 400; line-height: 1.28; letter-spacing: -0.2px; margin-bottom: 46px; }
.btn-signup {
  width: 275px; max-width: 100%; height: 44px;
  background: #fff; color: #000; border-radius: 14px;
  font-size: 16px; font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.auth-login { margin-top: 30px; font-size: 16px; }
.auth-login a { color: #fff; text-decoration: underline; text-underline-offset: 3px; margin-left: 8px; }
.auth-legal { margin-top: 26px; font-size: 14px; line-height: 1.75; }
.auth-legal a { color: #fff; text-decoration: underline; text-underline-offset: 3px; margin: 0 3px; }

/* ========== FORMS ========== */
.form-body { padding-left: 20px; padding-right: 20px; }
.form-body { padding-top: calc(var(--nav-h) + 34px); }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 700; color: var(--slate); margin-bottom: 7px; }
.form-group input, .form-group select {
  width: 100%; height: 48px; padding: 0 14px;
  border: none; border-radius: 5px; outline: none;
  font-size: 16px; color: var(--ink);
  background: #fff; box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease;
  -webkit-appearance: none; appearance: none;
}
.form-group input::placeholder { color: var(--muted); }
.form-group input:focus, .form-group select:focus { box-shadow: var(--shadow-card), 0 0 0 2px var(--primary); }
.btn-primary {
  width: 100%; height: 46px; margin-top: 10px;
  background: var(--primary); color: #fff; border-radius: 5px;
  font-size: 15px; font-weight: 700; letter-spacing: 0.4px;
}
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.form-message {
  margin: -4px 0 4px; padding: 11px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; line-height: 1.4;
  color: var(--incorrect-text); background: #ffeaea;
}
.form-message[data-tone="success"] { color: #4f8a12; background: #eef9df; }
.forgot-password { text-align: center; margin-top: 18px; }
.forgot-password a { color: var(--teal-active); font-size: 14px; font-weight: 600; text-decoration: none; }

/* ========== FLOATING TAB BAR ========== */
.tab-content { padding-bottom: calc(max(20px, var(--safe-bottom)) + 92px); }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: pane-in 0.38s var(--ease-out); }
@keyframes pane-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tab-bar {
  position: absolute; z-index: 20;
  left: 20px; right: 20px; bottom: max(20px, var(--safe-bottom));
  height: 64px; padding: 4px; border-radius: 32px;
  display: flex; align-items: stretch;
  background: rgba(255, 255, 255, 0.66);
  -webkit-backdrop-filter: blur(18px) saturate(1.8); backdrop-filter: blur(18px) saturate(1.8);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.75),
    0 0 0 0.5px rgba(0, 0, 0, 0.16),
    0 6px 20px rgba(0, 0, 0, 0.08);
}
.tab-indicator {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / 4); border-radius: 28px;
  background: rgba(60, 60, 67, 0.11);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.5s var(--spring);
}
.tab-item {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  color: #0f0f0f; font-size: 11px; font-weight: 600; letter-spacing: 0.1px;
  transition: color 0.25s ease;
}
.tab-item svg { transition: transform 0.45s var(--spring); }
.tab-item:active svg { transform: scale(0.86); }
.tab-item.active { color: var(--teal-active); }
.tab-item.active svg { animation: tab-bounce 0.5s var(--spring); }
@keyframes tab-bounce { 0% { transform: scale(0.82); } 100% { transform: none; } }

/* ========== HOME ========== */
.home-hero { display: flex; flex-direction: column; align-items: center; padding: 40px 16px 56px; }
.progress-ring-container { position: relative; width: 104px; height: 104px; margin-bottom: 24px; }
.progress-ring { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 7px rgba(190, 255, 200, 0.85)); }
.progress-ring-fill { stroke-dasharray: 302; stroke-dashoffset: 302; }
.progress-ring.drawn .progress-ring-fill { stroke-dashoffset: 0; transition: stroke-dashoffset 1.3s var(--ease-out) 0.15s; }
.progress-ring-value {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 33px; font-weight: 800; letter-spacing: 0.2px; color: var(--teal-number);
  font-variant-numeric: tabular-nums;
}
.progress-ring-label { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: var(--teal-number); margin-bottom: 24px; }
.go-pro-btn {
  width: 120px; height: 40px; border-radius: 8px;
  background: rgba(98, 200, 223, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 0.4px;
}

/* Pearls card, share link and footer mark (Home) */
.pearls-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  width: calc(100% - 30px); height: 104px; margin: 4px 15px 0; padding: 0 20px;
  background: #fde16b; border-radius: 10px; box-shadow: var(--shadow-card);
  overflow: hidden; text-align: left; color: #3f4446;
}
.pearls-card-title { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; }
.pearls-card-count { margin-top: 6px; font-size: 15px; font-weight: 600; color: #5b5f55; }
.pearls-card-art { position: absolute; right: -6px; top: -8px; width: 112px; height: 100px; color: #f6cf4e; transform: rotate(18deg); opacity: 0.85; }
.share-marrow {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 46px auto 0; padding: 10px 16px;
  font-size: 19px; font-weight: 800; letter-spacing: -0.2px; color: var(--primary);
}
.made-with { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 42px 0 24px; }
.made-with img { display: block; object-fit: contain; }

/* ========== PEARLS ========== */
.pearl-subject-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 72px; padding: 0 26px 0 22px; text-align: left;
  font-size: 18px; font-weight: 600; color: #1d2223;
}
.pearl-subject-row:active { background: rgba(0, 0, 0, 0.04); }
.pearl-subject-row svg { color: #9a9c9c; flex-shrink: 0; width: 9px; height: 16px; }

.pearl-list { padding-left: 0; padding-right: 0; }
.pearl-row { display: flex; align-items: flex-start; gap: 14px; padding: 12px 20px 12px 22px; cursor: pointer; }
.pearl-row:active { background: rgba(0, 0, 0, 0.04); }
.pearl-row-text { flex: 1; min-width: 0; }
.pearl-row-title { font-size: 17px; font-weight: 600; line-height: 1.3; color: #3f4648; overflow-wrap: break-word; }
.pearl-row-meta { margin-top: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.2px; color: #c2c6c6; }
.pearl-row .bm { margin-top: 2px; flex-shrink: 0; width: 28px; height: 28px; }
.pearl-row .bm svg { width: 16px; height: 22px; }

.glass-pill-btn.on { color: var(--teal-active); }
.pearl-search {
  display: none; flex: 0 0 calc(100% + 14px); height: 42px; margin: 12px -7px 0; padding: 0 16px;
  border: none; border-radius: 21px; outline: none;
  background: rgba(255, 255, 255, 0.85); box-shadow: inset 0 0 0 1px rgba(86, 126, 138, 0.25);
  font-size: 16px; font-weight: 500; color: var(--ink);
}
.pearl-search::placeholder { color: var(--muted); }
#pearl-list-screen.searching .segmented { display: none; }
#pearl-list-screen.searching .pearl-search { display: block; }

.pearl-body { padding-bottom: calc(max(12px, var(--safe-bottom)) + 80px); }
.pearl-head { padding: 6px 20px 0; }
.pearl-brand { display: block; height: 24px; width: auto; }
.pearl-title { margin-top: 14px; font-size: 22px; font-weight: 800; line-height: 1.25; letter-spacing: -0.3px; color: #111; overflow-wrap: break-word; }
.pearl-tag { margin-top: 10px; font-size: 15px; font-weight: 700; color: var(--primary); }
.pearl-head + .skeleton { margin-top: 20px; }
.pearl-subject-list .skeleton, .pearl-body .skeleton { margin: 0 15px 10px; }
.pearl-content { padding-top: 18px; }
.pearl-content > * + * { margin-top: 16px; }
.pearl-content p + p, .pearl-content p + ul, .pearl-content ul + p, .pearl-content p + ol, .pearl-content ol + p { margin-top: 10px; }
.pearl-content h4 { font-size: 16px; font-weight: 700; color: #3d4345; }
.pearl-figure { background: #fff; border-radius: 10px; box-shadow: var(--shadow-card); padding: 10px; }
.pearl-figure img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.pearl-table table { display: block; max-width: 100%; overflow-x: auto; }
.pearl-table th p, .pearl-table td p { margin: 0; }
.pearl-table td ul, .pearl-table td ol { padding-left: 18px; }
.pearl-table thead + tbody tr:nth-child(odd) { background: #fff; }
.pearl-table thead + tbody tr:nth-child(even) { background: #effafc; }
.pearl-pager { display: flex; justify-content: space-between; gap: 12px; margin: 20px 20px 0; }
.pearl-pager-btn {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 21px;
  background: #fff; box-shadow: var(--shadow-float); font-size: 14px; font-weight: 700; color: #494d4e;
}
.pearl-pager-btn:disabled { opacity: 0.35; cursor: default; }
.pearl-footer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; }

/* ========== QBANK ========== */
.tracker-row {
  display: flex; align-items: center; gap: 16px;
  height: 52px; margin: 6px 10px 28px; padding: 0 18px 0 13px; border-radius: 17px;
  background: rgba(222, 246, 250, 0.72);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(150, 218, 234, 0.9), inset 0 1.5px 0.5px rgba(255, 255, 255, 0.7);
  font-size: 16px; font-weight: 500; color: var(--slate);
}
.tracker-row span { flex: 1; }
.tracker-icon { color: #8fd6b4; flex-shrink: 0; }
.tracker-chevron { color: #9a9c9c; flex-shrink: 0; }

/* The row is the size container: card padding, gap and type all scale with it,
   reaching the reference sizes (17/12/16px) on a 430pt phone and still fitting
   "Custom Module" at 320px. The 16px icon column keeps both titles on one x. */
.qbank-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 15px 18px; container-type: inline-size; }
.qbank-action-card {
  min-width: 0; height: 76px;
  display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: clamp(7px, 2.8cqi, 12px); align-content: center;
  padding: 0 clamp(6px, 2.4cqi, 10px) 0 clamp(10px, 3.6cqi, 17px); color: var(--primary);
}
.qbank-action-card { text-align: left; }
.qbank-action-card.loading { opacity: 0.6; animation: pulse 0.9s ease-in-out infinite; }
.qbank-action-card svg { justify-self: center; align-self: start; margin-top: 0.15em; font-size: clamp(11px, 4cqi, 16px); }
.qbank-action-title { font-size: clamp(11px, 4cqi, 16px); font-weight: 800; letter-spacing: -0.2px; line-height: 1.25; color: var(--title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qbank-action-sub { font-size: clamp(11px, 3.4cqi, 13px); font-weight: 500; line-height: 1.25; color: var(--slate); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.subject-list { padding: 18px 15px 0; }
.section-label + .subject-list { padding-top: 0; }
.subject-card {
  display: flex; align-items: center;
  min-height: 71px; padding: 8px 14px 8px 12px; margin-bottom: 10px;
  background: #fff; border-radius: 6px; box-shadow: var(--shadow-card);
}
.subject-icon {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.subject-icon img, .subject-icon svg, .subject-icon .icon-mask { width: 19px; height: 19px; object-fit: contain; }
.icon-mask { display: block; background: var(--primary); -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.subject-divider { width: 2px; height: 42px; border-radius: 1px; background: #efefef; margin: 0 16px 0 13px; flex-shrink: 0; }
.subject-info { flex: 1; min-width: 0; }
.subject-name {
  font-size: 20px; font-weight: 800; line-height: 24px; letter-spacing: -0.3px; color: var(--title);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.subject-progress-bar { width: 89%; height: 4px; border-radius: 2px; background: var(--track); margin: 6px 0 7px; overflow: hidden; }
.subject-progress-fill { height: 100%; border-radius: 2px; background: var(--progress); transform-origin: left; }
.stagger .subject-progress-fill { animation: bar-grow 0.9s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 14) * 34ms + 0.25s); }
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: none; } }
.subject-meta { font-size: 13px; font-weight: 700; line-height: 16px; color: #6ccfe3; }

/* ========== TESTS ========== */
#tab-tests .segmented { margin: 6px 12px 22px; }
#tab-tests .segmented button { font-size: 14px; padding: 0 10px; }
.test-list { padding: 0 15px; }
.test-card {
  display: flex; align-items: center; gap: 14px;
  min-height: 71px; padding: 12px 14px 12px 12px; margin-bottom: 10px;
  background: #fff; border-radius: 6px; box-shadow: var(--shadow-card);
}
.test-card-icon {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.test-card-icon img, .test-card-icon svg { width: 19px; height: 19px; object-fit: contain; }
.test-card-body { flex: 1; min-width: 0; }
.test-card-title {
  font-size: 16px; font-weight: 800; line-height: 1.25; letter-spacing: -0.2px; color: var(--title);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.test-card-meta { font-size: 13px; font-weight: 700; color: #6ccfe3; margin-top: 4px; }
.solve-btn {
  flex-shrink: 0; height: 38px; padding: 0 12px; border-radius: 4px;
  background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase;
}
.test-card.loading .solve-btn { opacity: 0.55; animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.empty-state { text-align: center; padding: 56px 24px; font-size: 14px; font-weight: 600; color: var(--muted); }
.empty-state img { display: block; margin: 0 auto 14px; opacity: 0.5; }
.empty-state small { display: block; margin-top: 6px; font-size: 12px; font-weight: 500; }

/* Skeletons (IPA-style placeholder rows) */
.skeleton { height: 71px; margin-bottom: 10px; border-radius: 6px; background: #fff; box-shadow: var(--shadow-card); position: relative; overflow: hidden; }
.skeleton::before {
  content: ''; position: absolute; left: 12px; top: 18px; width: 34px; height: 34px; border-radius: 50%; background: var(--bg);
  box-shadow: 64px -4px 0 -9px var(--track);
}
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background:
    linear-gradient(var(--track), var(--track)) 78px 20px / 46% 14px no-repeat,
    linear-gradient(var(--track), var(--track)) 78px 44px / 24% 10px no-repeat;
  animation: pulse 1.1s ease-in-out infinite;
}
.topic-list .skeleton { margin-left: 57px; margin-right: 10px; height: 87px; margin-bottom: 26px; }

/* ========== SIDE MENU ========== */
.side-menu-overlay {
  position: absolute; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
.side-menu-overlay.open { opacity: 1; visibility: visible; transition-delay: 0s; }
.side-menu {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 91;
  width: min(300px, 80%);
  display: flex; flex-direction: column;
  background: #fff;
  transform: translateX(-102%); visibility: hidden;
  transition: transform 0.46s var(--ease-ios), visibility 0s linear 0.46s;
}
.side-menu.open { transform: none; visibility: visible; transition-delay: 0s; }
.side-menu-header {
  display: flex; align-items: center; gap: 13px;
  padding: calc(var(--safe-top) + 28px) 18px 22px;
  background: var(--teal-deep);
}
.side-menu-avatar {
  width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
}
.side-menu-name { color: #fff; font-size: 18px; font-weight: 800; letter-spacing: -0.2px; }
.side-menu-email { color: rgba(255, 255, 255, 0.78); font-size: 13px; font-weight: 500; margin-top: 2px; }
.side-menu-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.side-menu-item {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  font-size: 16px; font-weight: 600; color: var(--slate);
  cursor: pointer; transition: background 0.15s ease;
}
.side-menu-item:active { background: var(--bg); }
.side-menu-item img { object-fit: contain; }
[hidden] { display: none !important; }
.menu-icon-svg { flex-shrink: 0; fill: none; stroke: #425b61; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.menu-icon-mask { width: 22px; height: 22px; flex-shrink: 0; background: #425b61; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.side-menu.open .side-menu-item { animation: menu-item-in 0.5s var(--ease-out) both; }
.side-menu.open .side-menu-item:nth-child(1) { animation-delay: 0.06s; }
.side-menu.open .side-menu-item:nth-child(2) { animation-delay: 0.09s; }
.side-menu.open .side-menu-item:nth-child(3) { animation-delay: 0.12s; }
.side-menu.open .side-menu-item:nth-child(4) { animation-delay: 0.15s; }
.side-menu.open .side-menu-item:nth-child(5) { animation-delay: 0.18s; }
.side-menu.open .side-menu-item:nth-child(6) { animation-delay: 0.21s; }
.side-menu.open .side-menu-item:nth-child(7) { animation-delay: 0.24s; }
.side-menu.open .side-menu-item:nth-child(8) { animation-delay: 0.27s; }
.side-menu.open .side-menu-item:nth-child(9) { animation-delay: 0.3s; }
@keyframes menu-item-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.side-menu-item.logout { color: var(--incorrect-text); margin-top: 8px; border-top: 1px solid var(--hairline); padding-top: 18px; }
.side-menu-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px calc(var(--safe-bottom) + 16px);
  border-top: 1px solid var(--hairline);
}
.side-menu-version { font-size: 11px; font-weight: 600; color: var(--muted); }

/* ========== SEARCH ========== */
.search-input {
  flex: 1; min-width: 0; height: 46px; margin-left: 10px; padding: 0 18px;
  border: none; outline: none; border-radius: 23px;
  font-size: 16px; font-weight: 500; color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(84, 184, 208, 0.4);
}
.search-input::placeholder { color: var(--muted); }
.search-results { padding-left: 15px; padding-right: 15px; }

/* ========== SUBJECT DETAIL (numbered rail) ========== */
.topic-list .section-label { padding: 8px 15px 14px; font-size: 14px; }
.topic-row { position: relative; padding: 0 10px 26px 57px; cursor: pointer; }
.topic-row::before {
  content: ''; position: absolute; left: 25px; top: 0; bottom: 0; width: 2px;
  background: repeating-linear-gradient(180deg, #c9e9f0 0 6px, transparent 6px 11px);
}
.topic-row:last-child::before { bottom: 50%; }
.topic-num {
  position: absolute; left: 14px; top: 31px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #dff3f8; color: var(--teal-number);
  font-size: 13px; font-weight: 700; line-height: 24px; text-align: center;
  box-shadow: 0 0 0 4px var(--bg);
}
.topic-card {
  display: flex; align-items: flex-start; gap: 11px;
  min-height: 87px; padding: 6px 12px 6px 6px;
  background: #fff; border-radius: 4px; box-shadow: var(--shadow-card);
  transition: transform 0.3s var(--spring);
}
.topic-row:active .topic-card { transform: scale(0.975); transition-duration: 0.08s; }
.topic-thumb { position: relative; width: 75px; height: 75px; flex-shrink: 0; overflow: hidden; background: #dcdcdc; }
.topic-thumb > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topic-pro {
  position: absolute; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 4px;
  height: 14px; padding: 0 6px 0 5px;
  background: rgba(232, 232, 232, 0.94); color: #7b7b7b;
  font-size: 8px; font-weight: 700; letter-spacing: 0.6px;
}
.topic-pro img { width: 6px; height: 7.5px; opacity: 0.75; }
.topic-body { flex: 1; min-width: 0; padding-top: 5px; }
.topic-title { font-size: 16px; font-weight: 800; line-height: 1.2; letter-spacing: -0.2px; color: var(--title); }
.topic-stats { display: flex; align-items: center; flex-wrap: wrap; row-gap: 4px; margin-top: 7px; font-size: 13px; font-weight: 500; color: #979a9a; }
.topic-stats svg { color: #ffc700; margin-right: 7px; }
.topic-stats .sep { width: 1px; height: 15px; background: #e2e2e2; margin: 0 6px 0 7px; }

/* ========== TOPIC DETAIL ========== */
.topic-detail-body { padding: calc(var(--nav-h) + 38px) 30px 40px; }
.topic-detail-body > * { animation: rise 0.55s var(--ease-out) both; }
.topic-detail-body > :nth-child(2) { animation-delay: 0.04s; }
.topic-detail-body > :nth-child(3) { animation-delay: 0.1s; }
.topic-detail-body > :nth-child(4) { animation-delay: 0.16s; }
.topic-detail-body > :nth-child(n+5) { animation-delay: 0.22s; }
.topic-detail-subject { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.topic-detail-name {
  font-size: 20px; font-weight: 800; line-height: 1.25; letter-spacing: -0.3px; color: var(--title);
  padding-bottom: 12px; border-bottom: 1px solid var(--hairline); margin-bottom: 26px;
}
.topic-detail-mcq-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 22px; background: #fff; border-radius: 4px;
}
.topic-detail-mcq-count { font-size: 17px; font-weight: 700; color: var(--title); }
.topic-detail-mcq-sub { font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.topic-detail-mcq-row .solve-btn { width: 68px; padding: 0; }
.topic-bookmarks { display: flex; align-items: center; gap: 7px; margin: 20px 0 36px; font-size: 14px; font-weight: 700; color: #6c7577; }
.topic-bookmarks svg:first-child { color: var(--primary); }
.topic-bookmarks svg:last-child { color: #8a8f91; margin-left: 2px; }
.schema-head { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--high-yield); }
.schema-head img { width: 16px; height: 16px; }
.schema-new { padding: 2px 6px; border-radius: 4px; background: #ffe98a; color: #6d6a3c; font-size: 11px; font-weight: 700; }
.schema-desc { font-size: 12px; font-weight: 500; line-height: 1.35; letter-spacing: 0.1px; color: #869a9d; margin-top: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--hairline); }

/* ========== QUIZ (IPA MCQ player) ========== */
#quiz-screen { background: var(--bg); padding-top: var(--safe-top); }
#quiz-screen::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: calc(var(--safe-top) + 150px);
  background: linear-gradient(180deg, #66c9e0 0%, #96dbea 30%, #c9ecf2 62%, var(--bg) 100%);
  opacity: 0; transition: opacity 0.45s ease; pointer-events: none; z-index: 0;
}
#quiz-screen.answered::before { opacity: 1; }
#quiz-screen > * { position: relative; z-index: 1; }
#quiz-screen > .nav-bar { position: absolute; z-index: 10; }

/* Player chrome collapses once the question is answered; review chrome takes over */
.quiz-player-chrome { flex-shrink: 0; overflow: hidden; max-height: 160px; transition: max-height 0.45s var(--ease-out), opacity 0.3s ease; }
#quiz-screen.answered .quiz-player-chrome { max-height: 66px; opacity: 0; pointer-events: none; }
#quiz-screen .quiz-review-nav, #quiz-screen .quiz-pager, #quiz-screen .quiz-footer-review { display: none; }
#quiz-screen.answered .quiz-review-nav { display: flex; animation: fade-only 0.4s ease both; }
#quiz-screen.answered .quiz-pager { display: flex; animation: rise 0.5s 0.15s var(--ease-out) both; }
#quiz-screen.answered .quiz-footer-review { display: flex; animation: fade-only 0.4s ease both; }
#quiz-screen.answered .quiz-footer-player { display: none; }
@keyframes fade-only { from { opacity: 0; } to { opacity: 1; } }
.nav-actions { display: flex; gap: 10px; }

.quiz-progress-bar { display: none; height: 5px; margin-top: 12px; background: #6e7c7f; }
#quiz-screen.is-test .quiz-progress-bar { display: block; }
.quiz-progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.5s var(--ease-out); }
.quiz-header { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 12px 15px 0 20px; height: 70px; }
.quiz-count { font-size: 16px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.quiz-timer {
  position: absolute; left: 50%; top: 12px; bottom: 0; transform: translateX(-50%); display: flex; align-items: center;
  font-size: 17px; font-weight: 700; letter-spacing: 0.2px; color: #6b7476;
  font-variant-numeric: tabular-nums;
}
.quiz-timer.low { color: var(--incorrect-text); animation: pulse 1s ease-in-out infinite; }
.quiz-close-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: #fff; color: #494d4e; box-shadow: var(--shadow-float);
  display: flex; align-items: center; justify-content: center;
}

.quiz-body { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 20px 0 28px; scrollbar-width: none; }
.quiz-body::-webkit-scrollbar { display: none; }
#quiz-screen.answered .quiz-body { padding: 18px 0 96px; }
.quiz-body.enter-next > * { animation: q-next 0.5s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 8) * 40ms); }
.quiz-body.enter-prev > * { animation: q-prev 0.5s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 8) * 40ms); }
.quiz-body.enter-reveal > * { animation: rise 0.55s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 10) * 45ms); }
@keyframes q-next { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: none; } }
@keyframes q-prev { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: none; } }

.quiz-question-text {
  padding: 0 20px; margin-bottom: 26px;
  font-size: 20px; font-weight: 800; line-height: 1.25; letter-spacing: -0.3px; color: var(--title);
  overflow-wrap: break-word;
}
.quiz-question-text p + p { margin-top: 10px; }
.quiz-image {
  display: block; width: calc(100% - 30px); margin: 0 15px 26px; max-height: 360px;
  object-fit: contain; background: #fff; border-radius: 4px; padding: 12px;
  cursor: zoom-in; transition: transform 0.3s var(--spring);
}
.quiz-image:active { transform: scale(0.98); }
.quiz-option {
  display: flex; align-items: center;
  min-height: 60px; margin: 0 20px 15px; padding: 14px 14px 14px 12px;
  background: #fff; border-radius: 5px; box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.3s var(--spring), background-color 0.3s ease;
}
.quiz-option:active { transform: scale(0.975); transition-duration: 0.08s; }
.quiz-option-label { font-size: 11px; font-weight: 700; color: var(--muted); margin-right: 8px; flex-shrink: 0; transition: color 0.3s ease; }
.quiz-option-text { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; line-height: 1.25; letter-spacing: -0.2px; color: #1b1b1b; overflow-wrap: break-word; }
.quiz-option.selected { background: #e2f5f9; box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--primary); }
.quiz-body.locked .quiz-option { pointer-events: none; }
.quiz-option.correct { background: var(--correct-bg); animation: opt-pop 0.5s var(--spring); }
.quiz-option.incorrect { background: var(--incorrect-bg); animation: opt-shake 0.45s ease; }
.quiz-option.correct .quiz-option-label { color: #5d9a17; }
.quiz-option.incorrect .quiz-option-label { color: #c14545; }
@keyframes opt-pop { 0% { transform: scale(0.97); } 55% { transform: scale(1.025); } 100% { transform: none; } }
@keyframes opt-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

/* ----- Review layout (answered question) ----- */
.rv-question { padding: 0 20px; margin-bottom: 16px; font-size: 17px; font-weight: 700; line-height: 1.25; letter-spacing: -0.2px; color: #1b1b1b; overflow-wrap: break-word; }
.rv-option {
  position: relative; display: flex; gap: 5px;
  padding: 0 22px 0 41px; margin-bottom: 12px;
  font-size: 15.5px; font-weight: 600; line-height: 1.25; letter-spacing: -0.1px; color: #1b1b1b;
}
.rv-option span:last-child { min-width: 0; overflow-wrap: break-word; }
.rv-option.correct { color: var(--correct-text); }
.rv-option.wrong { color: var(--incorrect-text); }
.rv-option .mark { position: absolute; left: 20px; top: 2px; width: 15px; height: 15px; }
.rv-option .tag { font-size: 11px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; opacity: 0.85; white-space: nowrap; }
.rv-verdict {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 0; padding: 11px 20px; background: #fff; box-shadow: var(--shadow-card);
  font-size: 14px; font-weight: 700; color: #1b1b1b;
}
.rv-verdict i { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; background: var(--correct-text); }
.rv-verdict.wrong i { background: var(--incorrect-text); }
.rv-verdict.skipped i { background: #c5d3d6; }
.rv-explanation {
  padding: 22px 20px 0;
  font-size: 16px; line-height: 1.62; letter-spacing: 0.2px; color: #4a4a4c;
  overflow-wrap: break-word;
}
.rv-explanation > * + * { margin-top: 20px; }
.rv-explanation strong, .rv-explanation b { font-weight: 700; color: #3d4345; }
.rv-explanation sup, .rv-explanation sub { font-size: 0.75em; line-height: 0; }
.rv-explanation ul, .rv-explanation ol { padding-left: 26px; }
.rv-explanation li + li { margin-top: 6px; }
.rv-explanation img { max-width: 100%; height: auto; }
.rv-explanation pre { white-space: pre-wrap; word-break: break-word; }
/* Tables — MCQWebViewCSS (ThemeList.plist, Default) */
.rv-explanation table, .quiz-question-text table, .rv-question table {
  display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-collapse: collapse; text-align: left; border: 1px solid #ebf0f1;
  font-weight: 400; letter-spacing: 0; line-height: 1.3125;
}
.rv-explanation td, .rv-explanation th, .quiz-question-text td, .quiz-question-text th, .rv-question td, .rv-question th { padding: 7.5px; font-size: 14px; color: #425b61; }
.rv-explanation th, .quiz-question-text th, .rv-question th { background: var(--primary); color: #fff; font-weight: 600; }
.rv-explanation tr:nth-child(even), .quiz-question-text tr:nth-child(even), .rv-question tr:nth-child(even) { background: #effafc; }
.rv-explanation tr:nth-child(2n+3), .quiz-question-text tr:nth-child(2n+3), .rv-question tr:nth-child(2n+3) { background: #fff; }
.rv-explanation tr:first-child, .quiz-question-text tr:first-child, .rv-question tr:first-child { background: rgba(98, 200, 223, 0.5); }
.rv-explanation td:nth-child(even), .quiz-question-text td:nth-child(even), .rv-question td:nth-child(even) { border-left: 2px solid #ebf0f1; border-right: 2px solid #ebf0f1; }
.rv-images { padding-top: 22px; }
.rv-images .quiz-image { margin-bottom: 14px; }

.rv-id {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 30px 20px 0; padding-bottom: 18px; border-bottom: 1px solid var(--hairline);
  font-size: 15px; font-weight: 700; letter-spacing: 0.1px; color: #111;
}
.rv-copy {
  width: 22px; height: 22px; border-radius: 3px; background: #dbe9ee; color: #557077;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s var(--spring), background-color 0.2s ease;
}
.rv-copy:active { transform: scale(0.85); }
.rv-copy.done { background: var(--correct-bg); }
.rv-meta { margin: 0 20px; padding: 16px 0; border-bottom: 1px solid var(--hairline); font-size: 13px; font-weight: 700; color: var(--high-yield); }
.rv-meta small { display: block; margin-bottom: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.rv-copyright { margin: 0 20px; padding: 22px 0 26px; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.2px; color: #7d8588; }

.quiz-footer {
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
  padding: 10px 20px calc(max(12px, var(--safe-bottom)) + 2px);
}
.quiz-footer-review { height: calc(max(12px, var(--safe-bottom)) + 58px); justify-content: flex-start; gap: 24px; background: var(--bg); box-shadow: 0 -12px 14px -4px var(--bg); }
.quiz-action { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; color: #7d8588; transition: opacity 0.2s ease; }
.quiz-action:active { opacity: 0.5; }
.quiz-action-bookmark { margin-left: auto; }
.quiz-pager { position: absolute !important; right: 16px; bottom: calc(max(12px, var(--safe-bottom)) + 66px); z-index: 5 !important; gap: 10px; }
.quiz-nav-btn {
  min-width: 46px; height: 46px; padding: 0 14px; border-radius: 23px;
  background: #fff; color: #494d4e; box-shadow: var(--shadow-float);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  transition: transform 0.3s var(--spring), opacity 0.25s ease;
}
.quiz-nav-btn:disabled { opacity: 0.35; cursor: default; }
.quiz-nav-btn.primary { background: var(--primary); color: #fff; }
.quiz-footer-player { justify-content: flex-start; gap: 6px; }
.quiz-icon-btn { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: #6b7476; }
.quiz-icon-btn:first-child { margin-left: -10px; }
.quiz-icon-btn .bm-star { color: #6b7476; }
.quiz-step-btn {
  height: 42px; min-width: 70px; padding: 0 18px; border-radius: 6px;
  background: #fff; color: var(--primary); box-shadow: var(--shadow-card);
  font-size: 15px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase;
  transition: transform 0.3s var(--spring), opacity 0.25s ease;
}
.quiz-step-btn.js-prev { margin-left: auto; }
.quiz-step-btn.primary { min-width: 92px; background: var(--primary); color: #fff; margin-left: 8px; }
.quiz-step-btn:disabled { opacity: 0.4; cursor: default; }
.quiz-step-btn.pressable:active { transform: scale(0.94); }

/* Bookmark glyph: pale flag when off, the IPA's red star when on */
.bm { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; color: #c3d6dc; }
.bm img { position: absolute; opacity: 0; transform: scale(0.4) rotate(-30deg); transition: opacity 0.2s ease, transform 0.45s var(--spring); }
.bm svg { transition: opacity 0.2s ease, transform 0.3s ease; }
.active > .bm img, .bm.active img { opacity: 1; transform: none; }
.active > .bm svg, .bm.active svg { opacity: 0; transform: scale(0.5); }

/* ========== RESULT ========== */
#result-screen { background: #f8f8f8; }
.result-body { padding: 0 0 40px; }
.result-close { position: absolute; z-index: 5; top: calc(var(--safe-top) + 46px); right: 30px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: #333; }
.result-top { background: #fff; padding: calc(var(--safe-top) + 78px) 20px 34px; text-align: center; }
.result-solved { font-size: 15px; font-weight: 500; color: #7d8588; }
.result-lead { margin-top: 34px; font-size: 20px; font-weight: 700; letter-spacing: -0.3px; color: var(--title); }
.result-curve { position: relative; width: 184px; height: 120px; margin: 14px auto 12px; }
.result-curve img { width: 100%; height: 100%; display: block; }
.result-curve-value { position: absolute; left: 0; right: 0; top: 46px; font-size: 30px; font-weight: 800; letter-spacing: -0.5px; color: var(--primary); font-variant-numeric: tabular-nums; }
.result-curve-value small { font-size: 14px; font-weight: 700; margin-left: 1px; }
.result-tail { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; color: var(--title); }
.result-marks { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.result-bar { display: flex; height: 14px; margin: 38px 44px 0; background: #dbe3e5; overflow: hidden; }
.result-bar i { display: block; height: 100%; flex: 0 0 auto; width: 0; transition: width 1s var(--ease-out) 0.25s; }
.result-bar .c { background: #b5e370; }
.result-bar .w { background: #f29b8a; }
.result-legend { display: flex; justify-content: space-between; gap: 8px; margin: 10px 44px 0; text-align: left; font-size: 10.5px; font-weight: 600; line-height: 1.2; color: var(--ink); }
.result-legend span { display: flex; gap: 5px; align-items: flex-start; }
.result-legend i { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; background: #d5dee0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.result-legend .c i { background: #a6dd5c; }
.result-legend .w i { background: #ef8d7b; }
.result-actions { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 34px 20px 0; }
.result-btn { width: 232px; max-width: 100%; height: 40px; border-radius: 4px; font-size: 14px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.result-btn.primary { background: var(--primary); color: #fff; }
.result-btn.secondary { background: #fff; color: var(--primary); }
.result-link { margin-top: 4px; font-size: 14px; font-weight: 700; color: #5d7fc4; }

/* ========== REVIEW LIST ========== */
.review-list { padding-left: 15px; padding-right: 15px; }
.review-card {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 17px 14px 17px 9px; margin-bottom: 10px;
  background: #fff; border-radius: 8px; box-shadow: var(--shadow-card);
}
.review-card-body { flex: 1; min-width: 0; }
.review-card-q {
  font-size: 15.5px; font-weight: 600; line-height: 1.27; color: var(--title);
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.review-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; font-weight: 700; color: var(--primary); }
.review-card-meta b { font-weight: 700; color: var(--muted); }
.review-card-meta .ok { color: var(--correct-text); }
.review-card-meta .no { color: var(--incorrect-text); }
.review-card .bm { margin-top: 6px; flex-shrink: 0; }

/* ========== IMAGE VIEWER + TOAST ========== */
.lightbox {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0; visibility: hidden; cursor: zoom-out;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.lightbox.open { opacity: 1; visibility: visible; transition-delay: 0s; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; transform: scale(0.9); transition: transform 0.4s var(--ease-out); }
.lightbox.open img { transform: none; }
.toast {
  position: absolute; z-index: 210; left: 50%; bottom: calc(var(--safe-bottom) + 96px);
  padding: 9px 16px; border-radius: 18px;
  background: rgba(40, 46, 48, 0.9); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap;
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none;
  transition: opacity 0.25s ease, transform 0.4s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Lesson state on the subject rail */
.topic-row.completed .topic-num { background: var(--correct-bg); color: #4d8212; }
.topic-row.paused .topic-num { background: var(--primary); color: #fff; }
.topic-state { display: inline-flex; align-items: center; gap: 4px; flex-basis: 100%; font-size: 12px; font-weight: 700; }
.topic-state img { width: 13px; height: 13px; }
.topic-state.completed { color: var(--correct-text); }
.topic-state.paused { color: var(--teal-active); }

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; transition-delay: 0s !important;
  }
}

@media (max-width: 359px) {
  .subject-name { font-size: 18px; }
  .segmented button { padding: 0 9px; font-size: 14px; }
}

/* ========== TABLET + DESKTOP ==========
   Below 768px the app is the phone layout above. From 768px up it fills the
   window: chrome aligns to a centred content column (--col) and lists become
   grids. --side is the empty margin either side of that column. */
/* ========== MY PERFORMANCE ========== */
.performance-body, .settings-body, .custom-body { padding-left: 15px; padding-right: 15px; }
.performance-body > *, .settings-body > *, .custom-body > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.perf-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; margin-bottom: 12px; }
.perf-stat { padding: 12px 8px; text-align: center; border-radius: 8px; }
.perf-stat b { display: block; font-size: 22px; font-weight: 800; color: var(--teal-number); letter-spacing: -0.4px; }
.perf-stat span { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--muted); }
.perf-chart-card { padding: 14px 14px 8px; margin-bottom: 22px; }
.perf-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.perf-chart-title { font-size: 16px; font-weight: 800; color: var(--ink); }
.perf-chart-sub { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.perf-trend { font-size: 13px; font-weight: 800; padding: 4px 9px; border-radius: 20px; background: var(--bg); color: var(--slate); white-space: nowrap; }
.perf-trend.up { background: #eaf8d6; color: var(--correct-text); }
.perf-trend.down { background: #ffeaea; color: var(--incorrect-text); }
.perf-chart { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; }
.perf-grid { stroke: var(--hairline); stroke-width: 1; }
.perf-axis { font-size: 9.5px; font-weight: 700; fill: var(--muted); }
.perf-line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.perf-dot { fill: #fff; stroke: var(--primary); stroke-width: 2; }
.perf-dot.last { fill: var(--primary); }
.performance-body .section-label { padding-left: 2px; }
.perf-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 10px;
  background: #fff; border-radius: 6px; box-shadow: var(--shadow-card);
}
.perf-row-body { flex: 1; min-width: 0; }
.perf-row-title { font-size: 15px; font-weight: 800; line-height: 1.25; color: var(--title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perf-row-meta { font-size: 12.5px; font-weight: 600; color: #6ccfe3; margin-top: 3px; }
.perf-row-meta + .perf-row-meta { color: var(--muted); }
.perf-score { flex-shrink: 0; min-width: 58px; text-align: right; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.perf-score small { font-size: 13px; margin-left: 1px; }
.perf-score.good { color: var(--correct-text); }
.perf-score.mid { color: #e2a33c; }
.perf-score.low { color: var(--incorrect-text); }

/* ========== SETTINGS ========== */
.settings-body .section-label { padding: 14px 2px 8px; }
.settings-group { border-radius: 10px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  min-height: 50px; padding: 0 16px; text-align: left;
  font-size: 15px; font-weight: 600; color: var(--slate);
  border-bottom: 1px solid var(--hairline);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row b { font-weight: 700; color: var(--title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-row.action { color: var(--teal-active); font-weight: 700; cursor: pointer; }
.settings-row.action:active { background: var(--bg); }
.settings-row.danger { color: var(--incorrect-text); }
.settings-row.note { font-size: 13px; color: var(--muted); padding: 12px 16px; line-height: 1.4; }
.settings-row.note b { color: var(--slate); white-space: normal; }
.settings-note { font-size: 12.5px; font-weight: 500; color: var(--muted); line-height: 1.45; padding: 10px 4px 0; }
.settings-version { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 28px; }

/* ========== MODAL ========== */
.modal { position: absolute; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; visibility: hidden; }
.modal.open { visibility: visible; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); opacity: 0; transition: opacity 0.25s ease; }
.modal.open .modal-scrim { opacity: 1; }
.modal-card {
  position: relative; width: 100%; max-width: 320px; padding: 22px 20px 14px;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  opacity: 0; transform: scale(0.94); transition: opacity 0.25s ease, transform 0.3s var(--spring);
}
.modal.open .modal-card { opacity: 1; transform: none; }
.modal-card h3 { font-size: 18px; font-weight: 800; color: var(--ink); }
.modal-card p { font-size: 14px; font-weight: 500; color: var(--slate); line-height: 1.45; margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-btn { height: 40px; padding: 0 16px; border-radius: 8px; font-size: 15px; font-weight: 700; color: var(--slate); background: var(--bg); }
.modal-btn.danger { color: #fff; background: var(--incorrect-text); }
.modal-btn.primary { color: #fff; background: var(--primary); }
.modal-actions.stacked { flex-direction: column; align-items: stretch; }
.modal-actions.stacked .modal-btn { height: auto; min-height: 44px; padding: 10px 16px; line-height: 1.25; }
.modal-actions.stacked .modal-btn.danger { color: var(--incorrect-text); background: #ffeaea; }

/* ========== CUSTOM MODULE (one page, matching CustomModuleView on iOS) ========== */
.custom-body { padding-bottom: calc(var(--safe-bottom) + 32px); }
.custom-body .section-label { padding: 20px 2px 9px; }
.custom-body .segmented { height: 40px; }
.custom-body .segmented button { height: 34px; font-size: 14px; padding: 0 8px; flex: 1 1 0; }
.custom-body .seg-thumb { height: 34px; }
.custom-body .settings-note { padding: 8px 4px 0; }
.cm-hero { padding: 6px 2px 0; }
.cm-hero h3 { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; color: var(--ink); }
.cm-hero p { font-size: 14px; font-weight: 500; color: var(--slate); line-height: 1.4; margin-top: 4px; }
.cm-progress { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; margin: 4px 0 18px; border-radius: 10px; }
.cm-progress-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.cm-progress-text b { font-size: 15px; font-weight: 800; color: var(--ink); }
.cm-progress-text span { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cm-chip {
  min-height: 34px; padding: 0 14px; border-radius: 17px;
  font-size: 14px; font-weight: 700; color: var(--slate);
  background: #fff; box-shadow: var(--shadow-card);
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.3s var(--spring);
}
.cm-chip.on { background: var(--primary); color: #fff; box-shadow: none; }
.cm-create { margin-top: 26px; height: 48px; }
.cm-code {
  margin-top: 14px; padding: 14px 8px; border-radius: 10px; text-align: center;
  font: 800 22px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1.5px;
  color: var(--teal-number); background: #eef8fb; user-select: all; -webkit-user-select: all;
}
.cm-summary { font-size: 13px !important; color: var(--muted) !important; }

@media (min-width: 768px) {
  #app {
    max-width: none;
    --col: 720px;
    --side: max(0px, (100vw - var(--col)) / 2);
    --qcol: 720px;
    --qside: max(0px, (100vw - var(--qcol)) / 2);
  }

  /* Nav bar + title line up with the content column */
  .nav-bar { padding-left: calc(var(--side) + 19px); padding-right: calc(var(--side) + 19px); }
  .nav-title { left: calc(var(--side) + 76px); right: calc(var(--side) + 76px); }
  .nav-title.left, #main-app[data-tab="home"] .nav-title { left: calc(var(--side) + 74px); right: calc(var(--side) + 19px); }
  #main-app[data-tab="home"] .nav-title { right: calc(var(--side) + 122px); }
  .nav-bar.has-segmented .segmented { flex-basis: calc(100% + 14px); }

  /* Scrolling content sits in the column */
  .scroll { padding-left: var(--side); padding-right: var(--side); }
  .search-results, .review-list { padding-left: calc(var(--side) + 15px); padding-right: calc(var(--side) + 15px); }

  /* Floating tab bar stays a compact capsule */
  .tab-bar { left: max(20px, (100% - 440px) / 2); right: max(20px, (100% - 440px) / 2); }

  /* Lists become two-up */
  .subject-list, .search-results, .review-list {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; align-content: start;
  }
  .search-results > .empty-state, .review-list > .empty-state,
  .search-results > .section-label, .review-list > .section-label { grid-column: 1 / -1; }
  .subject-name { font-size: 18px; }


  #tab-tests .segmented { max-width: 560px; margin-left: auto; margin-right: auto; }
  .test-list { max-width: 720px; margin: 0 auto; }

  /* Subject rail: two columns of modules */
  .topic-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
  .topic-list > .section-label, .topic-list > .empty-state { grid-column: 1 / -1; }
  .topic-row:nth-last-child(2):nth-child(even)::before { bottom: 50%; }

  /* Reading screens: narrower centred column */
  .form-body { padding-left: max(20px, (100% - 440px) / 2); padding-right: max(20px, (100% - 440px) / 2); }
  .topic-detail-body { padding-left: max(30px, (100% - 640px) / 2); padding-right: max(30px, (100% - 640px) / 2); }

  /* Quiz player + review */
  #quiz-screen .nav-bar { padding-left: calc(var(--qside) + 19px); padding-right: calc(var(--qside) + 19px); }
  .quiz-header { padding-left: calc(var(--qside) + 20px); padding-right: calc(var(--qside) + 15px); }
  .quiz-body { padding-left: var(--qside); padding-right: var(--qside); }
  .quiz-footer { padding-left: calc(var(--qside) + 20px); padding-right: calc(var(--qside) + 20px); }
  .quiz-pager { right: calc(var(--qside) + 16px); }
  .quiz-image { max-height: 440px; }

  /* Result: centred card */
  .result-body > * { max-width: 640px; margin-left: auto; margin-right: auto; }
  .result-top { border-radius: 0 0 16px 16px; }
  .result-close { right: calc(max(0px, (100% - 640px) / 2) + 30px); }

  .lightbox img { max-width: 92%; max-height: 92%; }
}

@media (min-width: 1100px) {
  #app { --col: 1040px; --qcol: 780px; }
  .subject-list, .search-results, .review-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #tab-home .home-hero { padding-top: 48px; }
}

/* Short, wide windows (landscape phones, small laptops): tighten vertical chrome */
@media (min-width: 768px) and (max-height: 560px) {
  .home-hero { padding: 16px 16px 28px; }
  .quiz-body { padding-top: 18px; }
}
.dl-bar-row { padding-top: 0; padding-bottom: 12px; }
.dl-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.dl-bar i { display: block; height: 100%; background: var(--teal-active); transition: width .25s; }
