/* ============================================================
   CFO School — warm coffee-shop theme
   ============================================================ */

:root {
  --cream: #FAF5EC;
  --paper: #FFFFFF;
  --espresso: #5D4037;
  --espresso-deep: #4E342E;
  --espresso-darkest: #3E2723;
  --latte: #EFE3D5;
  --tan: #EADCCB;
  --orange: #F08A24;
  --orange-bright: #FFB25E;
  --orange-soft: #FDEBD7;
  --ink: #38271F;
  --muted: #94806F;
  --green: #2E7D32;
  --green-soft: #E8F4E9;
  --red: #C62828;
  --red-soft: #FCE9E7;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(93, 64, 55, 0.08), 0 1px 3px rgba(93, 64, 55, 0.06);
  --shadow-lift: 0 8px 24px rgba(93, 64, 55, 0.14), 0 2px 6px rgba(93, 64, 55, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  background-image: radial-gradient(circle at 15% 0%, #FFFDF8 0%, var(--cream) 55%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.view {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 72px;
}

/* ---------- branded header (renderHeader) ---------- */
.cfo-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 253, 248, 0.86);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--tan);
  box-shadow: 0 1px 0 rgba(93, 64, 55, 0.04);
}
/* No backdrop-filter (file:// / older engines) → solid cream so text stays legible. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .cfo-header { background: var(--cream); }
}
.hdr-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
}
.hdr-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--espresso);
  flex: 0 0 auto;
}
.hdr-logo { display: block; flex: 0 0 auto; }
.hdr-wordmark {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.2px;
  color: var(--espresso-darkest);
  line-height: 1;
  /* Fallback (no Fraunces, e.g. file://) still reads as an intentional display serif. */
  font-feature-settings: "ss01";
}
.hdr-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  flex: 1 1 auto;
}
.hdr-nav-link {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.hdr-nav-link:hover { color: var(--espresso); background: var(--orange-soft); }
.hdr-nav-link.is-active { color: var(--espresso-darkest); background: var(--latte); }

.hdr-account {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
}
.hdr-signin {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #FFF8F0;
  background: var(--espresso);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 2px 8px rgba(93, 64, 55, 0.22);
  transition: background 0.15s ease;
}
.hdr-signin:hover { background: var(--espresso-deep); }
.hdr-dev-chip {
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #CDE6CF;
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}
.hdr-account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--tan);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.hdr-account-btn:hover { box-shadow: var(--shadow-lift); border-color: var(--latte); }
.hdr-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hdr-avatar-initial {
  background: var(--orange);
  color: #FFF8F0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.hdr-account-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--espresso);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-caret { font-size: 11px; color: var(--muted); }

.hdr-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 268px;
  background: var(--paper);
  border: 1px solid var(--tan);
  border-radius: 14px;
  box-shadow: var(--shadow-lift);
  padding: 14px 16px;
  z-index: 60;
  animation: cardIn 0.16s ease both;
}
.hdr-menu[hidden] { display: none; }
.hdr-menu-email {
  font-size: 14px;
  font-weight: 700;
  color: var(--espresso-darkest);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--latte);
}
.hdr-menu-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  padding: 5px 0;
}
.hdr-menu-row span { color: var(--muted); font-weight: 600; }
.hdr-menu-row b {
  color: var(--espresso-darkest);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hdr-plan-full { color: var(--green) !important; }
.hdr-plan-free { color: var(--muted) !important; }
.hdr-exp-amber { color: #B05E0D !important; }
.hdr-exp-red { color: var(--red) !important; }
.hdr-menu-cta {
  display: block;
  text-align: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  color: #FFF8F0;
  background: var(--orange);
  border-radius: 11px;
  padding: 10px 12px;
  margin: 12px 0 4px;
  box-shadow: 0 2px 8px rgba(240, 138, 36, 0.3);
  transition: background 0.15s ease;
}
.hdr-menu-cta:hover { background: #DE7A1B; }
.hdr-menu-signout {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--espresso);
  background: none;
  border: none;
  border-top: 1px solid var(--latte);
  margin-top: 8px;
  padding: 10px 0 0;
  cursor: pointer;
  text-align: left;
}
.hdr-menu-signout:hover { color: var(--espresso-deep); text-decoration: underline; }

/* hamburger — hidden on wide screens, shown on narrow */
.hdr-burger {
  display: none;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--tan);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.hdr-burger span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--espresso);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; }
p { margin: 0 0 14px; }
a { color: var(--espresso); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 14px 22px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--espresso);
  color: #FFF8F0;
  box-shadow: 0 3px 10px rgba(93, 64, 55, 0.25);
}
.btn-primary:hover { background: var(--espresso-deep); box-shadow: var(--shadow-lift); }
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn-ghost {
  background: transparent;
  color: var(--espresso);
  border: 2px solid var(--latte);
}
.btn-ghost:hover { border-color: var(--espresso); background: #FFFDF8; }
.btn-block { display: block; width: 100%; margin-top: 18px; }
.btn-row { display: flex; gap: 12px; margin-top: 22px; }
.btn-row .btn { flex: 1; }

.icon-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--espresso);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.18s ease;
}
.icon-btn:hover { transform: translateX(-2px); box-shadow: var(--shadow-lift); }

/* ---------- home: hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--espresso) 0%, var(--espresso-darkest) 100%);
  color: #FFF6EA;
  border-radius: 20px;
  padding: 30px 26px 26px;
  margin-bottom: 30px;
  box-shadow: 0 10px 28px rgba(62, 39, 35, 0.28);
}
.hero h1 {
  font-size: 34px;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
/* When the header sign-in control is present, give the title room to clear it. */
.hero .auth-control ~ h1 { margin-top: 18px; }
.hero .subtitle {
  color: #E8D5C4;
  font-size: 16px;
  margin-bottom: 18px;
}
.pills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.pill {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.pill-xp { background: var(--orange); border-color: var(--orange); color: #FFF8F0; }

.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--orange-bright));
  transition: width 0.25s ease;
}
.progress-label { font-size: 14px; font-weight: 700; color: #E8D5C4; white-space: nowrap; }

/* ---------- home: parts & tiles ---------- */
.part { margin-bottom: 30px; }
.part h2 {
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 14px;
}
.tiles { display: flex; flex-direction: column; gap: 12px; }

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
a.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.tile-emoji {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--orange-soft);
  border-radius: 14px;
}
.tile-body { flex: 1; min-width: 0; }
.tile-title { font-weight: 700; font-size: 17px; }
.tile-short { font-size: 14px; color: var(--muted); }
.tile-state {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.state-start { background: var(--orange-soft); color: #B05E0D; }
.state-resume { background: var(--latte); color: var(--espresso); }
.state-done { background: var(--green-soft); color: var(--green); }
.state-soon { background: #F1ECE5; color: var(--muted); }
.tile-soon { opacity: 0.55; }

.foot {
  margin-top: 44px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- deck player ---------- */
.deck-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 16px;
  background: linear-gradient(var(--cream) 78%, rgba(250, 245, 236, 0));
}
.deck-progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--tan);
  overflow: hidden;
}
.deck-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--orange-bright));
  transition: width 0.25s ease;
}
.deck-count {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  min-width: 54px;
  text-align: right;
}

/* ---------- cards ---------- */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: var(--shadow);
  animation: cardIn 0.22s ease both;
}
.card-kicker {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--orange);
  margin-bottom: 10px;
}
.card-title { font-size: 24px; }
.card-body { color: #4A382E; }

.card-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 6px;
  font-size: 16px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--latte);
}
.card-table th {
  background: var(--latte);
  color: var(--espresso);
  text-align: left;
  font-weight: 700;
  padding: 10px 12px;
}
.card-table td {
  padding: 9px 12px;
  border-top: 1px solid #F2EAE0;
}
.card-table tr:nth-child(even) td { background: #FCF9F4; }

/* formula */
.formula-block {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  background: #FBF3E7;
  border: 1px solid var(--tan);
  border-left: 4px solid var(--orange);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 14px 0 10px;
  overflow-x: auto;
  white-space: nowrap;
}
.formula-example {
  font-family: var(--mono);
  font-size: 14.5px;
  color: var(--muted);
  padding: 0 4px 4px;
  overflow-x: auto;
  white-space: nowrap;
}

/* quiz */
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 16.5px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--latte);
  border-radius: 12px;
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.choice:hover:not(:disabled) { border-color: #D8C5B0; transform: translateY(-1px); }
.choice.selected { border-color: var(--espresso); background: #FAF2E9; }
.choice.correct { border-color: var(--green); background: var(--green-soft); }
.choice.wrong { border-color: var(--red); background: var(--red-soft); }
.choice:disabled { cursor: default; }
.choice.locked:not(.correct):not(.wrong) { opacity: 0.55; }
.choice-key {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  background: #F4EDE3;
  border-radius: 8px;
}
.choice.correct .choice-key { background: var(--green); color: #fff; }
.choice.wrong .choice-key { background: var(--red); color: #fff; }

.explain {
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
  font-size: 16px;
  animation: cardIn 0.2s ease both;
}
.explain-right { background: var(--green-soft); border-left: 4px solid var(--green); }
.explain-wrong { background: var(--red-soft); border-left: 4px solid var(--red); }
.explain-head { font-weight: 800; margin-bottom: 4px; }

/* recap */
.recap-list { list-style: none; padding: 0; margin: 10px 0 0; }
.recap-list li {
  padding: 9px 0;
  border-bottom: 1px solid #F2EAE0;
  font-size: 16.5px;
}
.recap-list li:last-child { border-bottom: none; }

/* widget */
.widget-mount {
  margin-top: 14px;
  border-radius: 12px;
  min-height: 40px;
}
.widget-fallback {
  background: #FBF3E7;
  border: 1px dashed var(--tan);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* XP sparkle */
@keyframes xpPop {
  0%   { opacity: 0; transform: translateY(8px) scale(0.7); }
  20%  { opacity: 1; transform: translateY(0) scale(1.18); }
  100% { opacity: 0; transform: translateY(-36px) scale(1); }
}
.xp-pop {
  position: absolute;
  top: 16px;
  right: 20px;
  color: var(--orange);
  font-weight: 800;
  font-size: 18px;
  pointer-events: none;
  animation: xpPop 1.3s ease forwards;
  text-shadow: 0 1px 0 #fff;
}

/* ---------- celebration ---------- */
.celebrate { text-align: center; padding: 40px 24px; }
@keyframes bigPop {
  0% { transform: scale(0.2); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.celebrate-emoji { font-size: 68px; animation: bigPop 0.5s ease both; }
.celebrate h2 { font-size: 28px; margin-top: 10px; }
.stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 22px 0 6px;
}
.stat {
  background: #FBF3E7;
  border-radius: 14px;
  padding: 14px 18px;
  min-width: 130px;
}
.stat span { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.stat b { font-size: 24px; color: var(--espresso); }

.burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}
@keyframes floatUp {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-115vh) rotate(340deg); opacity: 0; }
}
.burst span {
  position: absolute;
  bottom: -56px;
  animation: floatUp linear forwards;
}

/* ---------- flashcards ---------- */
.flash-scene { perspective: 1200px; margin-bottom: 4px; }
.flash-card {
  position: relative;
  width: 100%;
  height: 300px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.15, 0.2, 1);
}
.flash-card.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
}
.flash-back { transform: rotateY(180deg); background: #FFFBF3; }
.flash-term { font-size: 26px; font-weight: 800; color: var(--espresso); }
.flash-hint { font-size: 14px; color: var(--muted); }
.flash-def { font-size: 18px; }
.flash-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--espresso);
  background: var(--orange-soft);
  border-radius: 999px;
  padding: 5px 12px;
}

/* ---------- exam & misc ---------- */
.center { text-align: center; }
.big-emoji { font-size: 56px; margin-bottom: 8px; animation: bigPop 0.5s ease both; }
.lead { color: #4A382E; }
.note { font-size: 14px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.chip {
  font-size: 14px;
  font-weight: 700;
  color: var(--espresso);
  background: var(--orange-soft);
  border-radius: 999px;
  padding: 6px 13px;
}

.breakdown { list-style: none; padding: 0; margin: 14px 0 0; text-align: left; }
.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #F2EAE0;
  font-size: 15.5px;
}
.breakdown li:last-child { border-bottom: none; }
.breakdown b { color: var(--espresso); white-space: nowrap; }

.review { margin-top: 26px; text-align: left; }
.review h3 { font-size: 17px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.review-item {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 12px;
  font-size: 16px;
}
.review-q { font-weight: 700; margin-bottom: 8px; }
.review-a { margin-bottom: 6px; }
.review-a.wrong-a { color: var(--red); }
.review-a.right-a { color: var(--green); font-weight: 700; }
.review-x { color: #4A382E; font-size: 15px; border-top: 1px solid #F2EAE0; padding-top: 8px; margin-top: 8px; }

/* ---------- deck top-bar extras: Map pill, prev-peek ---------- */
.map-btn {
  width: auto;
  border-radius: 999px;
  padding: 0 14px 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 16px;
  font-weight: 700;
}
.map-btn-label { font-size: 14px; letter-spacing: 0.2px; }
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
  box-shadow: var(--shadow);
}

.peek-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--orange-soft);
  border: 1.5px solid var(--orange-bright);
  color: #B05E0D;
  border-radius: 12px;
  padding: 7px 12px;
  margin-bottom: 14px;
  font-size: 14.5px;
  font-weight: 700;
}
.peek-banner[hidden] { display: none; }
.peek-nav { margin-left: auto; display: flex; gap: 6px; }
.peek-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: var(--espresso);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.peek-nav-btn:hover { box-shadow: var(--shadow-lift); }

/* ---------- review mode ---------- */
.review-top { flex-wrap: wrap; row-gap: 8px; }
.review-head {
  flex: 1 1 120px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.review-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--espresso);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.review-pill {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #B05E0D;
  background: var(--orange-soft);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.pos-btn {
  flex: 0 0 auto;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--espresso);
  background: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 0 14px;
  height: 42px;
  box-shadow: var(--shadow);
  cursor: pointer;
  white-space: nowrap;
}
.pos-btn:hover { box-shadow: var(--shadow-lift); }

.redo-confirm {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--paper);
  border: 1.5px solid var(--orange-bright);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14.5px;
  animation: cardIn 0.18s ease both;
}
.redo-confirm[hidden] { display: none; }
.redo-confirm span { flex: 1 1 220px; }
.redo-confirm .btn { padding: 8px 14px; }

.show-answer {
  display: block;
  margin: 12px auto 0;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}
.show-answer:hover { color: var(--espresso); }

.jump-overlay {
  position: fixed;
  inset: 0;
  z-index: 9989;
  background: rgba(62, 39, 35, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.jump-panel {
  background: var(--cream);
  border-radius: 18px;
  box-shadow: var(--shadow-lift);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cardIn 0.18s ease both;
}
.jump-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  font-weight: 800;
  color: var(--espresso);
}
.jump-head .icon-btn { width: 34px; height: 34px; font-size: 15px; }
.jump-list { overflow-y: auto; padding: 0 12px 14px; }
.jump-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.jump-item:hover { box-shadow: var(--shadow-lift); }
.jump-item.current { outline: 2px solid var(--orange); }
.jump-idx { flex: 0 0 auto; width: 24px; font-weight: 800; color: var(--muted); font-size: 13px; }
.jump-type { flex: 0 0 auto; }
.jump-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jump-here {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #B05E0D;
  background: var(--orange-soft);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---------- notes & highlights ---------- */
mark.hl {
  background: rgba(255, 193, 94, 0.5);
  box-shadow: 0 0 0 1.5px rgba(255, 193, 94, 0.25);
  border-radius: 3px;
  color: inherit;
  padding: 0;
  cursor: pointer;
}
.note-quote mark.hl,
.note-sheet-quote mark.hl {
  cursor: inherit;
  box-shadow: none;
  padding: 1px 4px;
}

.note-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
  z-index: 2;
}
.note-btn:hover { opacity: 1; background: var(--orange-soft); transform: scale(1.08); }

.sel-toolbar {
  position: absolute;
  z-index: 9980;
  display: flex;
  gap: 6px;
  background: var(--espresso-darkest);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow-lift);
}
.sel-toolbar button {
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: #FFF6EA;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.sel-toolbar button:hover { background: rgba(255, 255, 255, 0.2); }

.mark-pop {
  position: absolute;
  z-index: 9981;
  max-width: 300px;
  background: var(--paper);
  border-radius: 12px;
  box-shadow: var(--shadow-lift);
  padding: 10px 12px;
  font-size: 14.5px;
  animation: cardIn 0.15s ease both;
}
.mark-pop-note { margin-bottom: 8px; white-space: pre-wrap; overflow-wrap: break-word; }
.mark-pop-actions { display: flex; gap: 14px; }
.mark-pop-actions button {
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  border: none;
  background: none;
  color: var(--espresso);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.mark-pop-actions .mark-pop-remove { color: var(--red); }

.note-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(62, 39, 35, 0.35);
  z-index: 9992;
}
@keyframes sheetUp {
  from { transform: translate(-50%, 30%); opacity: 0.4; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}
.note-sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 680px;
  background: var(--cream);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 36px rgba(62, 39, 35, 0.28);
  z-index: 9993;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: sheetUp 0.22s ease both;
}
.note-sheet-ctx { font-size: 13.5px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.note-sheet-quote { font-size: 15px; margin-bottom: 10px; }
.note-sheet textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  padding: 12px;
  border: 1.5px solid var(--tan);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
.note-sheet textarea:focus { outline: none; border-color: var(--espresso); }
.note-sheet .btn-row { margin-top: 12px; }

.app-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  background: var(--espresso-darkest);
  color: #FFF6EA;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14.5px;
  font-weight: 700;
  box-shadow: var(--shadow-lift);
  z-index: 9995;
  display: flex;
  gap: 14px;
  align-items: center;
  white-space: nowrap;
  animation: cardIn 0.2s ease both;
}
.app-toast button {
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--orange-bright);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ---------- my notes screen ---------- */
.notes-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.notes-top h1 { margin: 0; font-size: 26px; }
.notes-search {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 11px 14px;
  border: 1.5px solid var(--tan);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  margin-bottom: 10px;
}
.notes-search:focus { outline: none; border-color: var(--espresso); }
.notes-group-head { font-size: 15px; font-weight: 800; color: var(--espresso); margin: 18px 0 10px; }
.notes-none { text-align: center; margin-top: 20px; }
.note-entry {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.note-entry-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 6px;
}
.note-kind { flex: 0 0 auto; }
.note-ref { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-date { flex: 0 0 auto; }
.note-quote { font-size: 15px; margin: 0 0 6px; }
.note-body { font-size: 15.5px; margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: break-word; }
.note-actions { display: flex; align-items: center; gap: 10px; }
.note-open {
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--espresso);
  background: var(--latte);
  border: none;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
}
.note-open:hover { background: var(--tan); }
.note-del {
  font: inherit;
  font-size: 15px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.55;
  padding: 4px 6px;
}
.note-del:hover { opacity: 1; }
.notes-empty { text-align: center; padding: 36px 24px; }

/* ---------- auth control (header sign-in) ---------- */
.auth-control {
  position: absolute;
  left: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}
.auth-user {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: #FFF6EA;
  opacity: 0.92;
}
.auth-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
  padding: 6px 14px;
  border: 1.5px solid rgba(255, 246, 234, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #FFF6EA;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.auth-btn:hover { background: rgba(255, 255, 255, 0.22); border-color: #FFF6EA; }
.auth-signout {
  padding: 4px 10px;
  font-size: 12px;
}

/* ---------- paywall: locked tiles + unlock screen ---------- */
.tile-locked { position: relative; }
.tile-locked .tile-title,
.tile-locked .tile-short { opacity: 0.85; }
.state-locked {
  background: #F1E4D0;
  color: var(--espresso);
  border: 1px solid var(--tan);
}
.unlock-top {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 18px;
}
.unlock-top .auth-control {
  position: static;
  margin-left: auto;
}
.unlock-top .auth-user { color: var(--espresso); }
.unlock-top .auth-btn {
  color: var(--espresso);
  border-color: var(--latte);
  background: var(--paper);
}
.unlock-top .auth-btn:hover { background: #FFFDF8; border-color: var(--espresso); }
.unlock-card { text-align: center; }
.unlock-cols {
  display: flex;
  gap: 14px;
  margin: 18px 0 6px;
  text-align: left;
}
.unlock-col {
  flex: 1;
  background: var(--cream);
  border: 1.5px solid var(--latte);
  border-radius: 14px;
  padding: 14px 16px;
}
.unlock-col-head { font-weight: 800; color: var(--espresso); margin-bottom: 8px; }
.unlock-col ul { list-style: none; margin: 0; padding: 0; }
.unlock-col li { font-size: 14px; color: var(--ink); padding: 4px 0; }
.unlock-signin-note { margin-top: 8px; }
.unlock-buy { margin-top: 16px; }
.unlock-fineprint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- responsive: header nav collapses to a hamburger ---------- */
@media (max-width: 560px) {
  .hdr-burger { display: flex; }
  .hdr-brand { margin-right: auto; }
  .hdr-account { margin-left: 0; }
  /* The nav drops into a panel under the bar, toggled by the hamburger. */
  .hdr-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 8px 12px 12px;
    background: var(--cream);
    border-bottom: 1px solid var(--tan);
    box-shadow: var(--shadow-lift);
    display: none;
  }
  .hdr-nav.is-open { display: flex; }
  .hdr-nav-link { padding: 11px 12px; font-size: 16px; }
  .hdr-inner { position: relative; gap: 10px; }
  .hdr-account-name { max-width: 78px; }
}

/* ---------- responsive ---------- */
@media (max-width: 480px) {
  .hdr-wordmark { font-size: 20px; }
  .hdr-menu { width: min(268px, calc(100vw - 24px)); }
  body { font-size: 17px; }
  .view { padding: 16px 12px 64px; }
  .hero { padding: 24px 20px 22px; }
  .hero h1 { font-size: 28px; }
  .card { padding: 22px 18px; }
  .card-title { font-size: 21px; }
  .stats { flex-direction: column; align-items: stretch; }
  .btn-row { flex-direction: column; }
  .tile-state { font-size: 12px; padding: 5px 9px; }
  .flash-card { height: 320px; }
  .map-btn-label { display: none; }
  .map-btn { padding: 0 13px; }
  .review-title { font-size: 14px; }
  .app-toast { white-space: normal; width: max-content; max-width: 92vw; }
  .unlock-cols { flex-direction: column; }
  .auth-user { max-width: 120px; }
}
