/* ============================================
   CSS CUSTOM PROPERTIES & THEMES
   ============================================ */

:root {
  --font-scale: 1;
  --bg: #f9fafb;
  --bg-soft: #ffffff;
  --fg: #0f172a;
  --fg-heading: #020617;
  --muted: #64748b;
  --accent: #facc15; /* Gold — for backgrounds/fills only in light mode */
  --accent-text: #b39100; /* Dark golden yellow — for borders/strokes/fills on light backgrounds */
  --accent-text-readable: #856900; /* Accessible gold — for text on light backgrounds (5.2:1 on white) */
  --accent-soft: rgba(250, 204, 21, 0.12);
  --card-bg: #ffffff;
  --border-subtle: #e5e7eb;
  --shadow-soft: 0 18px 30px rgba(15, 23, 42, 0.07);
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 15px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e1a;
    --bg-soft: #12182B;
    --fg: #e2e8f0;
    --fg-heading: #f1f5f9;
    --muted: #94a3b8;
    --accent: #facc15;
    --accent-text: #facc15; /* Same as accent — gold is legible on dark backgrounds */
    --accent-text-readable: #facc15; /* Same — bright gold readable on dark */
    --accent-soft: rgba(250, 204, 21, 0.16);
    --card-bg: rgba(15, 23, 42, 0.92);
    --border-subtle: #1e293b;
    --shadow-soft: 0 18px 30px rgba(0, 0, 0, 0.5);
  }
}

/* Manual dark mode override */
html.theme-dark {
  --bg: #0a0e1a;
  --bg-soft: #12182B;
  --fg: #e2e8f0;
  --fg-heading: #f1f5f9;
  --muted: #94a3b8;
  --accent: #facc15;
  --accent-text: #facc15;
  --accent-text-readable: #facc15;
  --accent-soft: rgba(250, 204, 21, 0.16);
  --card-bg: rgba(15, 23, 42, 0.92);
  --border-subtle: #1e293b;
  --shadow-soft: 0 18px 30px rgba(0, 0, 0, 0.5);
}

html.theme-light {
  --bg: #f9fafb;
  --bg-soft: #ffffff;
  --fg: #020617;
  --fg-heading: #020617;
  --muted: #6b7280;
  --accent: #facc15;
  --accent-text: #b39100;
  --accent-text-readable: #856900;
  --accent-soft: rgba(250, 204, 21, 0.12);
  --card-bg: #ffffff;
  --border-subtle: #e5e7eb;
  --shadow-soft: 0 18px 30px rgba(15, 23, 42, 0.07);
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: calc(16px * var(--font-scale));
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

/* Prevent text selection on buttons/interactive elements */
button, .book-card, .chapter-square, .category-tab {
  user-select: none;
}

body {
  min-height: 100vh;
  font-family: var(--font-main);
  background: radial-gradient(ellipse at 50% 0%, rgba(250, 204, 21, 0.09) 0%, var(--bg) 55%);
  color: var(--fg);
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  overscroll-behavior-y: none;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  body {
    background: radial-gradient(ellipse at 50% 0%, rgba(250, 204, 21, 0.05) 0%, #0a0e1a 50%);
  }
}

html.theme-dark body {
  background: radial-gradient(ellipse at 50% 0%, rgba(250, 204, 21, 0.05) 0%, #0a0e1a 50%);
}

html.theme-light body {
  background: radial-gradient(ellipse at 50% 0%, rgba(250, 204, 21, 0.09) 0%, var(--bg) 55%);
}

/* ============================================
   APP SHELL
   ============================================ */

.app-shell {
  width: 100%;
  max-width: 840px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Fixed height so flex children are constrained and the chapter
     text area scrolls internally rather than expanding the page */
  height: 90vh;
  max-height: 900px;
}

@media (prefers-color-scheme: dark) {
  .app-shell {
    background: rgba(18, 24, 43, 0.96);
    border-color: rgba(30, 41, 59, 0.6);
  }
}

html.theme-dark .app-shell {
  background: rgba(18, 24, 43, 0.96);
  border-color: rgba(30, 41, 59, 0.6);
}

html.theme-light .app-shell {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(148, 163, 184, 0.35);
}

/* ============================================
   HEADER
   ============================================ */

.app-header {
  padding: 0.5rem 1rem 0.5rem 1.05rem;
  padding-top: calc(0.5rem + env(safe-area-inset-top));
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: #FFF6E8;
  box-shadow: 0 1px 5px rgba(210, 140, 0, 0.18);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Main app header: offset to align with chapter title below
   chapter title left edge = app-main(1rem) + chapter-header(1.05rem) = 2.05rem from shell
   logo left edge = app-header(1rem) + margin(1.05rem) = 2.05rem from shell */
#mainApp .app-header .brand-mark {
  margin-left: 1.05rem;
}

@media (prefers-color-scheme: dark) {
  .brand-mark {
    box-shadow: 0 2px 8px rgba(245, 168, 0, 0.30);
  }
}

/* Dawn glow pool */
.brand-mark::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 68%;
  background: radial-gradient(ellipse at 50% 100%, rgba(251, 191, 36, 0.40) 0%, transparent 65%);
}

/* Rising arc */
.brand-mark::after {
  content: "";
  position: absolute;
  bottom: 44%;
  left: 50%;
  transform: translateX(-50%);
  width: 56%;
  height: 28%;
  background: radial-gradient(ellipse at 50% 20%, #FEE77A, #E9A820 75%);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg-heading);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Tagline is meaningful on the welcome screen but redundant once reading */
#mainApp .brand-sub {
  display: none;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-button {
  background: none;
  border: none;
  color: var(--fg-heading); /* near-black in light mode */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.4rem 0.4rem 0.4rem;
  border-radius: 6px;
  min-width: 36px;
  min-height: 36px;
  justify-content: center;
  /* padding-right pulls the icon leftward so it optically aligns
     with the play button on the right edge of the chapter card */
  padding-right: 1rem;
}

.header-button:hover {
  color: var(--accent-text);
}

.header-button:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  color: var(--fg);
}

.header-button svg,
.header-button img {
  width: 20px;
  height: 20px;
}

/* Dark mode: header-button goes muted gray (inline SVG uses currentColor) */
@media (prefers-color-scheme: dark) {
  .header-button { color: var(--muted); }
  .icon-button img,
  .btn-ghost-danger img {
    filter: brightness(0) saturate(100%) invert(71%) sepia(9%) saturate(628%) hue-rotate(182deg) brightness(92%) contrast(89%);
  }
}

html.theme-dark .header-button { color: var(--muted); }
html.theme-dark .icon-button img,
html.theme-dark .btn-ghost-danger img {
  filter: brightness(0) saturate(100%) invert(71%) sepia(9%) saturate(628%) hue-rotate(182deg) brightness(92%) contrast(89%);
}

/* When user manually picks light mode, reset any dark-mode filters the system media query may have applied */
html.theme-light .header-button img,
html.theme-light .icon-button img,
html.theme-light .btn-ghost-danger img {
  filter: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.app-main {
  padding: 0.85rem 0.9rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1;
  min-height: 0; /* allow flex children to shrink */
}

@media (max-width: 1024px) {
  body {
    min-height: 0;
    padding: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    align-items: stretch;
    justify-content: normal;
  }

  .app-shell {
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    max-width: none;
  }

  /* iOS PWA: 100dvh is not initialized at cold start — 100vh is safe in
     standalone mode because there is no browser toolbar to hide behind */
  html.is-pwa body,
  html.is-pwa .app-shell {
    height: 100vh;
  }

  .app-header {
    padding-inline: 1rem;
  }

  .app-main {
    padding: 0.5rem 0.9rem 0.1rem 1rem;
    gap: 0.4rem;
  }

  .chapter-header {
    padding: 0.3rem 0.95rem 0.25rem 1.05rem;
  }

  .chapter-text {
    padding: 0 0.95rem 0 1.05rem;
  }
}


/* Mobile: body matches app-shell bg so safe-area zone and rounded corners are seamless */
@media (max-width: 1024px) {
  body { background: var(--bg-soft); }
}

/* ============================================
   GREETING & TOP ROW
   ============================================ */

.greeting {
  font-size: 1.4rem;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--muted);
}

.welcome-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg-heading);
  margin-bottom: 1rem;
  margin-top: 0.85rem;
}

.welcome-subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
  line-height: 1.6;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  font-family: inherit;
}

@media (max-width: 640px) {
  .greeting {
    font-size: 1rem;
    font-weight: 500;
  }
}

.top-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1.2rem;
}

@media (max-width: 640px) {
  .top-row {
    padding-left: 1.05rem;
  }

  .top-meta {
    font-size: 1rem;
    letter-spacing: .003em;
  }
}

.top-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  font-size: 1rem;
  letter-spacing: .003em;
  color: var(--muted);
  align-items: center;
}

.dot-separator::before {
  content: "•";
  margin-right: 0.35rem;
  opacity: 0.7;
}

.book-summary {
  margin-top: 0.5rem;
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
  font-family: inherit;
}

.book-summary strong {
  font-weight: 600;
  color: var(--fg);
}

/* ============================================
   CHAPTER CARD
   ============================================ */

.chapter-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  flex: 1;       /* grow to fill app-main space */
  min-height: 0; /* allow shrinking within flex parent */
  overflow: hidden;
}

.chapter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.95rem 0.4rem 1.05rem;
  flex-shrink: 0;
}

.chapter-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--fg-heading);
  flex: 1;
}

.play-button {
  background: none;
  border: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fg-heading); /* near-black in light mode */
  flex-shrink: 0;
  border-radius: 6px;
  padding: 0.3rem;
  transition: background 0.15s, color 0.15s;
}

.play-button:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--accent-text);
}

.play-button:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.play-button.is-reading {
  color: var(--accent-text);
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
}


.chapter-text {
  flex: 1;
  min-height: 0;
  padding: 0 0.95rem 0 1.05rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* momentum scrolling on iOS */
  line-height: 1.7;
  font-size: 0.98rem;
  letter-spacing: 0.003em;
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 2.5rem), transparent 100%);
  mask-image: linear-gradient(to bottom, black calc(100% - 2.5rem), transparent 100%);
}

/* Hide scrollbar visually, keep scroll functional */
.chapter-text {
  scrollbar-width: none; /* Firefox */
}
.chapter-text::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

.chapter-text p {
  margin: 0;
}

.chapter-text p:last-child {
  margin-bottom: 0;
}

.chapter-text strong {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  margin-right: 0.2rem;
}

.chapter-text p.highlighted {
  background: rgba(250, 204, 21, 0.2);
  border-radius: 4px;
}

.chapter-text p.highlighted-continue-top {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.chapter-text p.highlighted-continue-bottom {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* TTS speaking verse highlight */
.chapter-text p.speaking {
  border-left: .3px solid var(--accent);
  background: rgba(250, 204, 21, 0.2);
}

.icon-button {
  display: flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: 6px;
}

.icon-button:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

/* ============================================
   BUTTONS
   ============================================ */

/* .btn-checkin replaced by .bar-checkin in the bottom action bar */

.btn-primary {
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #1f2937;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary:hover {
  background: #f0bf00;
}

.btn-primary:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.btn-primary:active {
  opacity: 0.85;
}

/* Icons inside gold primary buttons need to be dark (same as text color) */
.btn-primary img {
  filter: brightness(0) saturate(100%);
}

.btn-secondary {
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-soft);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.btn-secondary:active {
  opacity: 0.8;
}

.btn-ghost-danger {
  background: none;
  border: none;
  color: #9ca3af;
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.btn-ghost-danger:hover {
  color: #ef4444;
  opacity: 0.9;
}

/* Make the trash img red on hover (color alone doesn't affect img elements) */
.btn-ghost-danger:hover img {
  filter: brightness(0) saturate(100%) invert(27%) sepia(97%) saturate(1903%) hue-rotate(348deg) brightness(96%) contrast(91%);
}

.link-button {
  background: none;
  border: none;
  color: var(--fg);
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  padding: 0.3rem;
  opacity: 0.7;
  text-decoration: none;
  border-radius: 6px;
}

.link-button:hover {
  opacity: 1;
  background: var(--accent-soft);
}

.link-button:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .link-button {
    color: var(--muted);
    opacity: 0.8;
  }

  .link-button:hover {
    opacity: 1;
    color: var(--fg);
  }
}

html.theme-dark .link-button {
  color: var(--muted);
  opacity: 0.8;
}

html.theme-dark .link-button:hover {
  opacity: 1;
  color: var(--fg);
}

.progress-link {
  background: none;
  border: none;
  color: var(--muted);   /* same muted grey as surrounding stats text */
  font-size: inherit;    /* inherits 0.78rem from .stats-row */
  font-weight: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  border-radius: 4px;
}

.progress-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent-text);
  text-underline-offset: 2px;
  color: var(--fg);
}

.progress-link:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

/* ============================================
   BOTTOM ACTION BAR
   ============================================ */

.bottom-bar {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  flex-shrink: 0;
  overflow: visible;
  /* Bar background fills home indicator zone; capped at 20px so it doesn't over-extend */
  padding-bottom: min(env(safe-area-inset-bottom), 20px);
}

@media (max-width: 1024px) {
  .bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .bottom-bar.bar-hidden {
    transform: translateY(100%);
  }
  /* Pad chapter text so last verse sits above the bar */
  .chapter-text {
    padding-bottom: 110px;
    transition: padding-bottom 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* When bar is hidden, let text scroll to screen edge */
  .chapter-text.bar-hidden {
    padding-bottom: 1rem;
  }
}

/* Icon row — padding directly on the row so it respects the content bounds.
   space-between places outer buttons flush with the padded edges. */
.bar-icon-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0.4rem 1.85rem 0.2rem 1.95rem;
}

/* Highlights (first): icon stays centered, label hugs left to align with strip text.
   Chapters (last): icon stays centered, label hugs right. */
.bar-icon-row > button:first-child {
  padding-left: 0;
}
.bar-icon-row > button:first-child .bar-label {
  align-self: flex-start;
}
.bar-icon-row > button:last-child {
  padding-right: 0;
}
.bar-icon-row > button:last-child .bar-label {
  align-self: flex-end;
}

/* Stats strip: check-ins | progress bar | streak */
.bar-stats-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 1.85rem 0.35rem 1.95rem;
  gap: 0.75rem;
}

/* Mobile: 1rem app-main + 1.05rem chapter indent = 2.05rem to align with verse text */
@media (max-width: 1024px) {
  .bar-icon-row {
    padding-left: 2.05rem;
    padding-bottom: 0.5rem;
  }
  .bar-stats-strip {
    padding-left: 2.05rem;
    padding-top: 0.4rem;
  }
}

@media (min-width: 1025px) {
  .bar-stats-strip {
    padding-bottom: 0.75rem;
  }
}

.strip-stat {
  font-size: 0.57rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--fg-heading);
}

.strip-stat--right {
  text-align: right;
}

.stat-num {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted); /* stays muted until first check-in */
}

.stat-progress-track {
  flex: 1;
  height: 3px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.stat-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--muted);
  width: 0%;
}

.stat-unit {
  font-size: 0.57rem;
  font-weight: 500;
  color: inherit; /* inherits from .strip-stat so theme overrides apply */
}

/* Checked-in state: strip numbers and bar turn gold */
.bar-stats-strip.checked-in .stat-num {
  color: var(--accent-text-readable);
}

.bar-stats-strip.checked-in .stat-progress-fill {
  background: var(--accent-text);
}

/* Icon+label buttons */
.bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-heading); /* near-black in light mode */
  font-family: var(--font-main);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  min-width: 52px;
  min-height: 44px;
  justify-content: center;
}

@media (min-width: 1025px) {
  .bar-item { padding: 0.4rem 1.2rem; }
}

.bar-item:hover {
  color: var(--accent-text);
}

.bar-item:active {
  opacity: 0.7;
}

.bar-item:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.bar-item img {
  width: 22px;
  height: 22px;
}

.bar-item svg,
.bar-checkin svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.bar-label {
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}

/* Check-in bar item */
.bar-checkin {
  position: relative;
  min-width: 52px;
  min-height: 44px;
  justify-content: center;
  color: var(--fg-heading); /* near-black in light mode */
}


.bar-checkin:hover {
  color: var(--accent-text);
}

/* Dot indicator — shows when user hasn't checked in today */
.checkin-dot {
  position: absolute;
  top: 4px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
}

.checkin-dot.hidden {
  display: none;
}

/* Inherits color from .bar-item via currentColor */
.bar-checkin .checkin-icon-unchecked {
  fill: none;
  display: block;
  transition: none; /* snap gold ↔ grey instantly — no fade */
}

.bar-checkin .bar-label {
  transition: none; /* snap label color instantly */
}

/* Hide the second SVG — not used in this approach */
.bar-checkin .checkin-icon-checked {
  display: none;
}

/* Mark Read mode — same appearance as default; color signals unread, not the action */

/* Checked: swap stroke to gold */

.bar-checkin.checked-in .checkin-icon-unchecked {
  stroke: var(--accent-text);
}

.bar-checkin.checked-in .bar-label {
  color: var(--accent-text-readable);
}

/* Dark mode: all bar icons and play button go muted gray, gold on hover */
@media (prefers-color-scheme: dark) {
  .bar-item    { color: var(--muted); }
  .play-button { color: var(--muted); }
  .bar-checkin { color: var(--muted); }
  .stat-unit   { color: var(--muted); }
  .strip-stat  { color: var(--muted); }
}

html.theme-dark .bar-item    { color: var(--muted); }
html.theme-dark .play-button { color: var(--muted); }
html.theme-dark .bar-checkin { color: var(--muted); }
html.theme-dark .stat-unit   { color: var(--muted); }
html.theme-dark .strip-stat  { color: var(--muted); }

/* Light theme explicit override - prevents system dark mode from greying icons when app is set to light */
html.theme-light .bar-item    { color: var(--fg-heading); }
html.theme-light .play-button { color: var(--fg-heading); }
html.theme-light .bar-checkin { color: var(--fg-heading); }
html.theme-light .stat-unit   { color: var(--fg-heading); }
html.theme-light .strip-stat  { color: var(--fg-heading); }



/* ============================================
   BOOKS SECTION (welcome screen / completion modal only)
   ============================================ */

.books-section {
  display: grid;
  gap: 0.9rem;
}

.books-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.books-title {
  font-size: 0.95rem;
  font-weight: 500;
}

.books-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .books-sub {
    display: none;
  }
}

.books-grid {
  display: grid;
  gap: 0.7rem;
}

.book-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: rgba(248, 250, 252, 0.92);
  padding: 0.8rem 0.9rem;
  display: grid;
  gap: 0.35rem;
  cursor: pointer;
  min-height: 44px;
}

@media (hover: hover) {
  .book-card:hover {
    border-color: var(--accent-text);
    background: rgba(250, 204, 21, 0.05);
  }
}

.book-card:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  .book-card {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(30, 41, 59, 0.8);
  }

  @media (hover: hover) {
    .book-card:hover {
      background: rgba(250, 204, 21, 0.08);
    }
  }
}

html.theme-dark .book-card {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(30, 41, 59, 0.8);
}

@media (hover: hover) {
  html.theme-dark .book-card:hover {
    background: rgba(250, 204, 21, 0.08);
  }

  html.theme-light .book-card:hover {
    background: rgba(250, 204, 21, 0.05);
  }
}

html.theme-light .book-card {
  background: rgba(248, 250, 252, 0.92);
  border-color: rgba(148, 163, 184, 0.2);
}

.book-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.book-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.book-status {
  font-size: 0.78rem;
  color: var(--muted);
}

.book-progress-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.book-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), rgba(250, 204, 21, 0.2));
  transition: width 0.5s ease;
}

.book-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  gap: 0.5rem;
  flex-wrap: wrap;
}

.book-pill-current {
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  background: var(--accent-soft);
  font-size: 0.75rem;
  color: #92400e;
}

@media (prefers-color-scheme: dark) {
  .book-pill-current {
    color: #fef3c7;
  }
}

html.theme-dark .book-pill-current {
  color: #fef3c7;
}

html.theme-light .book-pill-current {
  color: #92400e;
}

/* ============================================
   MODALS
   ============================================ */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45); /* lightened — dark themes add their own weight */
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 200; /* must be above fixed bottom bar (100) */
  overscroll-behavior: contain;
  overflow: hidden; /* prevent modal content from bleeding past viewport edge */
}

/* Restore darker overlay in dark mode */
@media (prefers-color-scheme: dark) {
  .scrim { background: rgba(15, 23, 42, 0.75); }
}
html.theme-dark  .scrim { background: rgba(15, 23, 42, 0.75); }
html.theme-light .scrim { background: rgba(15, 23, 42, 0.4); }

.scrim.is-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 640px) {
  .scrim {
    padding: 1rem;
  }
}

.modal {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 2rem 1.5rem 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow:
    0 20px 60px rgba(15, 23, 42, 0.18),
    0 6px 16px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
  display: grid;
  gap: 1rem;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  opacity: 0;
}

.scrim.is-visible .modal {
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .modal {
    box-shadow:
      0 24px 64px rgba(0, 0, 0, 0.5),
      0 8px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.08);
  }
}

html.theme-dark .modal {
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.5),
    0 8px 20px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 640px) {
  .modal {
    max-height: 85dvh;
    border-radius: 18px;
  }


}

/* ============================================
   MOBILE BOTTOM SHEET (Browse & Chapters)
   Desktop: unchanged centered modal
   Mobile (≤640px): slides up from bottom
   ============================================ */

@media (max-width: 640px) {
  /* Anchor scrim to bottom edge */
  .scrim.mobile-sheet {
    align-items: flex-end;
    padding: 0;
  }

  /* Sheet panel */
  .scrim.mobile-sheet .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    height: 85dvh;
    max-height: none;
    align-content: start;
    touch-action: pan-y;
    padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom));
    /* Use transform instead of opacity for show/hide */
    opacity: 1;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .scrim.mobile-sheet.is-visible .modal {
    transform: translateY(0);
  }

  /* Drag handle via pseudo-element — no HTML change needed */
  .scrim.mobile-sheet .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    margin: 0 auto 0.5rem;
  }

  /* Progress: restore its tighter side padding */
  #progressModal.mobile-sheet .modal {
    padding: 1.25rem 0.85rem calc(1rem + env(safe-area-inset-bottom));
  }

}

#progressModal .modal {
  padding: 1rem 0.85rem 1rem;
  width: 100%;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg-heading);
  text-align: center;
  padding: 0.25rem 2.5rem;
  line-height: 1.3;
}

.modal-back {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  background: rgba(148, 163, 184, 0.08);
  border: none;
  color: var(--fg-heading);
  cursor: pointer;
  padding: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.modal-back:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--accent-text);
}

.modal-back:active {
  opacity: 0.7;
}

.modal-back:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(148, 163, 184, 0.08);
  border: none;
  color: var(--fg-heading);
  cursor: pointer;
  padding: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.modal-close:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--accent-text);
}

.modal-close:active {
  opacity: 0.7;
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  .modal-back, .modal-close { color: var(--muted); }
  .modal-back:hover, .modal-close:hover { color: var(--accent-text); }
  .play-button:hover { color: var(--accent-text); }
}
html.theme-dark .modal-back,
html.theme-dark .modal-close { color: var(--muted); }
html.theme-dark .modal-back:hover,
html.theme-dark .modal-close:hover { color: var(--accent-text); }
html.theme-dark .play-button:hover { color: var(--accent-text); }

.modal-body {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0.25rem 0;
}

.modal-actions button {
  min-width: 120px;
}

.modal-actions.yearly-progress-actions {
  flex-direction: column;
}

.sign-in-email-section {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}


.sign-in-email-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  color: var(--fg);
  font-size: max(16px, 0.85rem); /* 16px floor prevents iOS auto-zoom on tap */
  min-height: 44px;
  box-sizing: border-box;
  font-family: inherit;
}

.sign-in-email-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sign-in-email-input::placeholder {
  color: var(--muted);
}

/* Override browser autofill yellow in light mode */
.sign-in-email-input:-webkit-autofill,
.sign-in-email-input:-webkit-autofill:hover,
.sign-in-email-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #f9fafb inset;
  -webkit-text-fill-color: #0f172a;
  transition: background-color 5000s ease-in-out 0s;
}

@media (prefers-color-scheme: dark) {
  .sign-in-email-input:-webkit-autofill,
  .sign-in-email-input:-webkit-autofill:hover,
  .sign-in-email-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #0a0e1a inset;
    -webkit-text-fill-color: #e2e8f0;
  }
}

html.theme-dark .sign-in-email-input:-webkit-autofill,
html.theme-dark .sign-in-email-input:-webkit-autofill:hover,
html.theme-dark .sign-in-email-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0a0e1a inset;
  -webkit-text-fill-color: #e2e8f0;
}

/* Pro lock icons on translation buttons */
.pro-lock-icon {
  opacity: 0.45;
  vertical-align: middle;
  margin-left: 0.15rem;
  flex-shrink: 0;
}

.is-pro .pro-lock-icon {
  display: none;
}

.sign-in-footer-links {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.sign-in-text-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: inherit;
}

.sign-in-text-link:hover {
  color: var(--fg);
}

.confirm-modal {
  max-width: 360px;
  text-align: center;
}

#signInSheet .modal {
  gap: 0.4rem;
}

.confirm-modal .modal-title {
  font-size: 1.2rem;
  padding: 0 2rem;
  margin-bottom: 0.75rem;
}

.confirm-modal .modal-body {
  margin-top: 0;
  margin-bottom: 1rem;
  text-align: center;
  line-height: 1.6;
  font-size: 0.95rem;
}

.confirm-modal .modal-actions {
  margin-top: 0;
  padding: 0;
  gap: 0.75rem;
  flex-direction: column-reverse;
}

.confirm-modal .modal-actions button {
  min-width: 100%;
  width: 100%;
}

/* ============================================
   SEARCH INPUT
   ============================================ */

.search-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  color: var(--fg);
  font-size: 16px;
  font-family: var(--font-main);
  margin-bottom: 0.75rem;
  min-height: 44px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-text);
}

.search-input:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-color: var(--accent-text);
}

.search-input::placeholder {
  color: var(--muted);
}

#welcomeLevel1 .search-input-welcome {
  margin-top: 0.75rem;
  margin-bottom: 0;
}

/* ============================================
   WELCOME SCREEN
   ============================================ */

.welcome-container {
  padding: 1rem;
  text-align: left;
  flex: 1;
}

.welcome-tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.75rem;
  grid-auto-rows: minmax(72px, auto);
}

.welcome-tile {
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
  font-family: var(--font-main);
  min-height: 44px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

@media (hover: hover) {
  .welcome-tile:hover {
    border-color: var(--accent-text);
    background: rgba(250, 204, 21, 0.06);
  }
}

.welcome-tile:active { transform: scale(0.97); }

.welcome-tile.welcome-tile-wide {
  grid-column: 1 / -1;
}

.welcome-tile-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.2;
}

.welcome-tile-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.welcome-level2-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
  padding-left: .1rem;
  margin-left: .6rem;
}

#welcomeLevel1 .greeting,
#welcomeLevel1 .welcome-title {
  padding-left: .1rem;
  margin-left: .6rem;
  text-align: center;
}

.welcome-back-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-main);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  min-height: 44px;
  transition: color 0.15s;
  white-space: nowrap;
}

.welcome-back-btn:hover { color: var(--fg); }


/* ============================================
   CATEGORY TABS
   ============================================ */

.category-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 1rem;
  font-weight: 600;
}


/* Welcome screen: scrollable book list */
#welcomeScreen .app-main {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-width: thin;
  padding-bottom: env(safe-area-inset-bottom);
}

.category-tab {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  opacity: 0.8;
  letter-spacing: 0.03em;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.category-tab:hover {
  border-color: var(--accent-text);
  opacity: 1;
}

.category-tab:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.category-tab:focus:not(:focus-visible) {
  outline: none;
}

.category-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1f2937;
  font-weight: 600;
  opacity: 1;
}

/* ============================================
   CHAPTER GRID (Progress Modal)
   ============================================ */

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.4rem;
}

@media (max-width: 500px) {
  .chapter-grid {
    gap: 0.4rem;
  }
}

.chapter-square {
  aspect-ratio: 1;
  border: 1.5px solid var(--border-subtle);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chapter-square:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}


.chapter-square:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.chapter-square.read {
  background: var(--accent);
  border-color: var(--accent);
  color: #1f2937;
}

.chapter-square.read:hover {
  opacity: 0.9;
}

.chapter-square.today {
  border-color: var(--accent);
  border-width: 2px;
}

.progress-summary {
  text-align: center;
  color: var(--fg);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.6;
  margin-bottom: 0;
  padding: 0.3rem 0;
  background: transparent;
  border-radius: var(--radius);
}

#progressModal .modal {
  gap: 0.5rem;
}

#progressModal .chapter-grid {
  margin-bottom: 1.5rem;
}

/* ============================================
   YEARLY PROGRESS HEATMAP
   ============================================ */

.year-heatmap {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 0.5rem;
}

.heatmap-note {
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  margin: 0.35rem 0 0;
}

.month-section {
  display: grid;
  gap: 0.3rem;
}

.month-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1.5px;
  max-width: 180px;
}

.day-square {
  aspect-ratio: 1;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.15);
  cursor: pointer;
  position: relative;
  font-size: 0;
}

.day-square.checked {
  background: var(--accent);
}

.day-square.today {
  border: 1.5px solid var(--fg);
}

/* Day squares use ::after for their tooltip — suppress the global ::before system */
.day-square[data-tooltip]::before { display: none !important; }

.day-square.checked:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: pre;
  max-width: 120px;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.year-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.year-stat {
  text-align: center;
}

.year-stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--muted); /* goes gold once user has check-ins */
}

.has-checkins .year-stat-value {
  color: var(--accent-text-readable);
}

.year-stat-label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.share-message {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  font-weight: 500;
  padding: 0.5rem;
  animation: fadeIn 0.3s ease;
}

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

/* ============================================
   HIGHLIGHTS
   ============================================ */

#highlightsList {
  max-height: 60vh;
  min-height: 200px;
  overflow-y: auto;
  display: grid;
  gap: 0.65rem;
  padding-right: 0.25rem;
  scrollbar-width: none; /* Firefox */
}

#highlightsList::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

#highlightsList h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  margin-left: 0.9rem;
  color: var(--fg);
  font-weight: 600;
}

.highlight-card {
  position: relative;
  min-height: 110px;
  padding: 0.85rem 0.9rem 1.2rem;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
  margin-bottom: 0.65rem;
  touch-action: pan-y;
}

.highlight-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.highlight-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--fg);
  padding-right: 2.5rem;
  position: relative;
  overflow: hidden;
}

@media (hover: none) and (pointer: coarse), (max-width: 640px) {
  .highlight-text {
    padding-right: 0;
  }
}

.highlight-text.collapsed {
  max-height: 5.5em;
}

.highlight-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.8em;
  background: linear-gradient(180deg, rgba(255,255,255,0), var(--card-bg));
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  .highlight-fade {
    background: linear-gradient(180deg, rgba(0,0,0,0), var(--card-bg));
  }
}

.highlight-toggle {
  margin-top: 0.35rem;
  background: none;
  border: none;
  color: var(--fg-heading);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0;
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  .highlight-toggle { color: var(--muted); }
}
html.theme-dark  .highlight-toggle { color: var(--muted); }
html.theme-light .highlight-toggle { color: var(--fg-heading); }

.highlight-skeleton {
  display: grid;
  gap: 0.35rem;
}

.highlight-skeleton div {
  height: 10px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.25);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.highlight-actions {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  display: flex;
  gap: 0.35rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.highlight-share {
  position: absolute;
  bottom: 0.35rem;
  right: 0.35rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .highlight-card:hover .highlight-actions,
  .highlight-card:hover .highlight-share {
    opacity: 1;
  }
}

@media (hover: none) and (pointer: coarse), (max-width: 640px) {
  .highlight-actions,
  .highlight-share {
    display: none !important;
  }
}

.highlight-hint {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin: -0.25rem 0 0.75rem;
  display: none;
}

/* Only show swipe hint on touch devices (mobile/tablet) */
@media (hover: none) and (pointer: coarse) {
  .highlight-hint {
    display: block;
  }
}

/* Or on small screens regardless of input type */
@media (max-width: 640px) {
  .highlight-hint {
    display: block;
  }
}

/* ============================================
   BADGE SYSTEM
   ============================================ */

.badge-section {
  margin-bottom: 2rem;
}

.badge-section:last-child {
  margin-bottom: 0;
}

.badge-section-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--fg);
}

#badgeFilterTabs {
  justify-content: center;
}

#badgeFilterTabs .category-tab {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--fg);
  opacity: 0.7;
}

#badgeFilterTabs .category-tab:hover {
  border-color: var(--accent-text);
  opacity: 1;
}

#badgeFilterTabs .category-tab.active {
  background: var(--accent);
  color: #1f2937;
  border-color: var(--accent-text);
  opacity: 1;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

@media (max-width: 500px) {
  .badges-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
  }
}

.badge-card {
  background: var(--card-bg);
  border: 2px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.badge-card.earned {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 2px 8px rgba(250, 204, 21, 0.2);
}

.badge-card.locked {
  opacity: 0.4;
  filter: grayscale(0.8);
}

.badge-card.earned:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(250, 204, 21, 0.35);
}

.badge-card.earned:hover .badge-emoji {
  transform: scale(1.1) rotate(5deg);
}

.badge-card.locked:hover {
  opacity: 0.6;
}

/* Tap-to-zoom state for earned badge cards */
.badge-card.zoomed {
  transform: scale(1.08);
  z-index: 10;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.badge-card.zoomed .badge-emoji {
  transform: scale(1.15) rotate(5deg);
}

@media (prefers-color-scheme: dark) {
  .badge-card.earned {
    background: rgba(250, 204, 21, 0.12);
    box-shadow: 0 2px 8px rgba(250, 204, 21, 0.15);
  }

  .badge-card.earned:hover {
    box-shadow: 0 4px 12px rgba(250, 204, 21, 0.25);
  }
}

html.theme-dark .badge-card.earned {
  background: rgba(250, 204, 21, 0.12);
  box-shadow: 0 2px 8px rgba(250, 204, 21, 0.15);
}

html.theme-dark .badge-card.earned:hover {
  box-shadow: 0 4px 12px rgba(250, 204, 21, 0.25);
}

.badge-emoji {
  font-size: 1.75rem;
  margin-bottom: 0.3rem;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.badge-card.locked .badge-emoji {
  filter: grayscale(1);
}

.badge-desc {
  font-size: 0.8rem;
  color: var(--fg);
  line-height: 1.4;
  font-weight: 500;
}

.badge-card.locked .badge-desc {
  color: var(--muted);
}

.badge-earned-date {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.3rem;
  font-style: italic;
}

/* Badge unlock animation */
.badge-card.unlocking {
  animation: badge-unlock 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-unlock {
  0% {
    transform: scale(0.8) rotate(-5deg);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.15) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.badge-card.unlocking .badge-emoji {
  animation: emoji-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emoji-pop {
  0% {
    transform: scale(0);
    filter: grayscale(1);
  }
  60% {
    transform: scale(1.3);
    filter: grayscale(0);
  }
  100% {
    transform: scale(1);
    filter: grayscale(0);
  }
}

/* Transparent backdrop — sits behind notification, tap to dismiss */
.badge-notif-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
}

.badge-notification {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom) + 12px);
  right: max(20px, env(safe-area-inset-right) + 12px);
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 280px;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.badge-notification.show {
  transform: translateY(0);
  opacity: 1;
}

.badge-notification-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge-notification-emoji {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.badge-notification-text {
  flex: 1;
}

.badge-notification-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-text-readable);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.15rem;
}

.badge-notification-desc {
  font-size: 0.8rem;
  color: var(--fg);
  line-height: 1.3;
}

.badge-notif-view {
  background: none;
  border: 1px solid var(--accent-text);
  color: var(--accent-text-readable);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font-main);
  white-space: nowrap;
}

html.theme-dark .badge-notif-view {
  color: var(--accent-text);
}

@media (prefers-color-scheme: dark) {
  .badge-notif-view {
    color: var(--accent-text);
  }
}

@media (max-width: 500px) {
  .badge-notification {
    right: 16px;
    left: 16px;
    max-width: none;
    bottom: calc(env(safe-area-inset-bottom) + 72px);
  }

  .badge-notification-emoji {
    font-size: 1.5rem;
  }

  .badge-notification-content {
    gap: 0.65rem;
  }
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-group {
  display: grid;
  gap: 0.65rem;
}

.settings-note {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0.75rem 0 0.25rem;
}
.settings-note + .settings-note {
  margin-top: 0.25rem;
}

/* Hide Data section on mobile */
@media (max-width: 768px) {
  #dataSettingsGroup {
    display: none;
  }
}

/* Hide local storage warning for Pro users on desktop */
@media (min-width: 769px) {
  #appSettingsModal[data-plan="pro"] .data-warning {
    display: none;
  }
}

.settings-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
}

.settings-segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

html.theme-dark .settings-segmented {
  background: rgba(148, 163, 184, 0.15);
}

.settings-segmented button {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem 0.4rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.settings-segmented button svg {
  color: var(--muted);
  transition: color 0.2s ease;
}

.settings-segmented button:nth-child(1) svg {
  color: #f59e0b;
}

.settings-segmented button:nth-child(2) svg {
  color: #f59e0b;
}

.settings-segmented button:nth-child(3) svg {
  color: #3b82f6;
}

.settings-segmented button.active {
  background: var(--bg-soft);
  color: var(--fg);
}

.settings-segmented button.active svg {
  color: inherit;
}

html.theme-dark .settings-segmented button.active {
  background: #1f2937;
  color: #e5e7eb;
}

html.theme-dark .settings-segmented button:nth-child(1) svg {
  color: #fbbf24;
}

html.theme-dark .settings-segmented button:nth-child(2) svg {
  color: #fbbf24;
}

html.theme-dark .settings-segmented button:nth-child(3) svg {
  color: #60a5fa;
}

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


/* Inline settings rows (label left, control right) */
.settings-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.5rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
  min-height: 44px;
  overflow: hidden; /* prevent font-scale L from breaking row layout */
  transition: background 0.12s ease;
}

.settings-inline-row:hover {
  background: var(--bg);
}

.settings-inline-row-last {
  border-bottom: none;
}

.settings-inline-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  flex-shrink: 0;
}

/* Compact segmented control for inline rows */
.settings-segmented-compact {
  display: flex;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

html.theme-dark .settings-segmented-compact {
  background: rgba(148, 163, 184, 0.15);
}

.settings-segmented-compact button {
  border: none;
  background: transparent;
  border-radius: 5px;
  padding: 0.3rem 0.6rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px; /* px intentional — must not scale with --font-scale */
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}

.settings-segmented-compact button.active {
  background: var(--bg-soft);
  color: var(--fg);
}

html.theme-dark .settings-segmented-compact button.active {
  background: #1f2937;
  color: #e5e7eb;
}

/* Inline install button */
.install-button-settings-inline {
  min-height: unset;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
}

/* Settings nav rows (Badges / Highlights quick links) */
.settings-nav-group {
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
}

.settings-nav-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0rem 0rem;
  background: var(--bg-soft);
  border: none;
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
}

.settings-nav-row:hover,
.settings-inline-row:hover {
  background: var(--accent-soft);
}

.settings-nav-chevron {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .settings-nav-chevron { color: var(--muted); }
}
html.theme-dark .settings-nav-chevron { color: var(--muted); }

.settings-nav-row:hover .settings-nav-chevron,
.settings-inline-row:hover .settings-nav-chevron {
  color: var(--accent-text);
}

/* Dark mode filter for settings nav row icons — match header/bottom bar grey */
@media (prefers-color-scheme: dark) {
  .settings-nav-row img {
    filter: brightness(0) saturate(100%) invert(71%) sepia(9%) saturate(628%) hue-rotate(182deg) brightness(92%) contrast(89%);
  }
}

html.theme-dark .settings-nav-row img {
  filter: brightness(0) saturate(100%) invert(71%) sepia(9%) saturate(628%) hue-rotate(182deg) brightness(92%) contrast(89%);
}

/* Danger / destructive settings row (e.g. Reset All Data) */
.settings-nav-row.danger-row {
  color: #ef4444;
}

/* Red filter for danger icon — same in light and dark mode */
.settings-nav-row.danger-row img {
  filter: brightness(0) saturate(100%) invert(40%) sepia(80%) saturate(500%) hue-rotate(330deg) brightness(1.1);
}

@media (prefers-color-scheme: dark) {
  .settings-nav-row.danger-row img {
    filter: brightness(0) saturate(100%) invert(40%) sepia(80%) saturate(500%) hue-rotate(330deg) brightness(1.1);
  }
}

html.theme-dark .settings-nav-row.danger-row img {
  filter: brightness(0) saturate(100%) invert(40%) sepia(80%) saturate(500%) hue-rotate(330deg) brightness(1.1);
}

html.theme-light .settings-nav-row.danger-row img {
  filter: brightness(0) saturate(100%) invert(40%) sepia(80%) saturate(500%) hue-rotate(330deg) brightness(1.1);
}

/* Hairline dividers between bordered nav groups only */
.modal > .settings-nav-group + .settings-nav-group {
  /* 1rem grid gap on .modal already separates groups — no border needed */
}

/* ── Menu (settingsModal): borderless nav rows ───────────────────────────── */
/* The only border in the Menu should be on the account info card             */
#settingsModal .settings-nav-group {
  border: none;
  border-radius: 0;
  overflow: visible;
}
#settingsModal .settings-nav-row {
  border-bottom: none;
  border-radius: 8px;
  padding: 0.85rem 0.25rem;
}

/* ── Menu: responsive scaling for narrow phones (SE, 12 Pro ≤ 390px) ──────── */
@media (max-width: 390px) {
  #settingsModal .modal {
    padding: 1.5rem 1.1rem 1rem;
    gap: 0.65rem;
  }
  #settingsModal .account-info-card {
    padding: 0.75rem;
  }
  #settingsModal .account-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }
  #settingsModal .account-user-name {
    font-size: 0.82rem;
  }
  #settingsModal .account-user-email {
    font-size: 0.72rem;
  }
  #settingsModal .account-plan-status {
    font-size: 0.72rem;
    margin-bottom: 0.5rem;
  }
  #settingsModal .settings-nav-row {
    padding: 0.65rem 0.25rem;
    font-size: 0.85rem;
  }
}

.settings-version-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.5;
  padding: 1rem 0 0.25rem;
}


/* ============================================
   FOOTER
   ============================================ */

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */

.scroll-to-top {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: 20px;
  background: var(--accent);
  color: #1f2937;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  z-index: 100;
  opacity: 0;
  transform: scale(0.8);
}

.scroll-to-top.show {
  opacity: 1;
  transform: scale(1);
}

.scroll-to-top:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.scroll-to-top:active {
  transform: scale(0.95);
}

/* Scroll-to-top arrow: sits on gold bg, needs dark fill in both modes */
.scroll-to-top img {
  filter: brightness(0) saturate(100%);
}

/* ============================================
   TOOLTIPS
   ============================================ */

/* chapter-header has overflow:hidden — tooltips inside it are always clipped */
.chapter-header [data-tooltip]::before {
  display: none;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  color: var(--fg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}

[data-tooltip]:hover::before {
  opacity: 1;
}

[data-tooltip]:last-child::before {
  left: auto;
  right: 0;
  transform: none;
}

[data-tooltip]:first-child::before {
  left: 0;
  transform: none;
}

/* Bottom bar tooltips appear above — below is clipped by app-shell overflow:hidden */
.bar-item[data-tooltip]::before {
  top: auto;
  bottom: calc(100% + 8px);
}

/* Modal-actions tooltips appear above the button, not below into the modal footer */
.modal-actions [data-tooltip]::before {
  top: auto;
  bottom: calc(100% + 8px);
}

@media (max-width: 768px) {
  [data-tooltip]::before {
    display: none;
  }

  .keyboard-shortcuts-group {
    display: none;
  }
}

/* ============================================
   KEYBOARD SHORTCUTS
   ============================================ */

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
}

.shortcuts-grid .shortcut-row {
  display: grid;
  grid-template-columns: 4rem 1fr;
  align-items: center;
  gap: 0 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.shortcuts-grid .shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  max-width: 4rem;
  padding: 0.1rem 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}

.shortcuts-grid .shortcut-row span {
  color: var(--muted);
}

.shortcut-row--last {
  grid-column: 2;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
  display: none;
}


/* .app-footer install / footer-text rules removed — install button is now
   only in the App Settings modal (.install-button-settings-inline) */

.category-tabs.badge-filter-tabs {
  margin-bottom: 0.5rem;
}

.category-tabs.highlight-filter-tabs {
  margin-bottom: 1rem;
  display: none;
}

/* ============================================
   INSTALL CARD (first-visit nudge above bottom bar)
   ============================================ */

.install-card {
  position: fixed;
  bottom: calc(64px + 0.75rem);
  left: 1rem;
  right: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.14);
  z-index: 150;
  animation: slideUpFade 0.3s ease;
  touch-action: pan-y;
  user-select: none;
  will-change: transform, opacity;
}

.install-card-body {
  flex: 1;
  min-width: 0;
}

.install-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: var(--text);
}

.install-card-text {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.install-card-text svg {
  vertical-align: middle;
  margin: 0 1px;
}

.install-card-step {
  display: block;
  line-height: 1.5;
}

.install-card-step + .install-card-step {
  margin-top: 0.2rem;
}

.install-card-dismiss {
  /* Match .modal-close style */
  background: rgba(148, 163, 184, 0.08);
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  width: 28px;
  height: 28px;
}
.install-card-dismiss:hover {
  background: rgba(148, 163, 184, 0.18);
  color: var(--fg);
}
.install-card-dismiss:active { opacity: 0.7; }

.install-card-install-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.3rem 0.85rem;
  background: var(--accent);
  color: #1f2937;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

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

.shortcuts-grid.shortcuts-grid-styled {
  padding: 0.75rem;
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.settings-group .data-warning {
  padding: 0.75rem;
  background: var(--accent-soft);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.settings-group .data-warning-text {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.settings-group .data-warning-text strong {
  color: var(--fg);
}

.support-body-text {
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--fg);
  padding: 0.25rem 0 0.5rem;
}

.support-body-text .secondary {
  color: var(--muted);
}

.install-steps {
  padding: 0 0 0 1.1rem;
  margin: 0.85rem 0 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.install-steps li {
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.install-steps li strong {
  color: var(--fg);
}

.settings-group .backup-button-primary {
  width: 100%;
  margin-bottom: 0.5rem;
}

.settings-group .backup-button-secondary {
  width: 100%;
}

.settings-group .backup-message {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: center;
  display: none;
}

/* ============================================
   ACCOUNT / PLAN SECTION
   ============================================ */

.account-info-card {
  padding: 1rem;
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

html.theme-dark .account-info-card {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.15);
}

/* Pro upgrade card — Option A: heading + feature list */
#accountSignedOut .account-info-card {
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

@media (prefers-color-scheme: dark) {
  #accountSignedOut .account-info-card {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(30, 41, 59, 0.8);
  }
}

html.theme-dark #accountSignedOut .account-info-card {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(30, 41, 59, 0.8);
}

html.theme-light #accountSignedOut .account-info-card {
  background: rgba(248, 250, 252, 0.92);
  border-color: rgba(148, 163, 184, 0.2);
}

/* Top row: heading left, Free badge right */
.pro-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.pro-card-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-heading);
  letter-spacing: -0.01em;
}

.pro-card-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* Feature bullet list */
.pro-feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0;
  margin: 0;
}

.pro-feature-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--fg);
}

.pro-feature-list li::before {
  content: '';
  width: 14px;
  height: 14px;
  background: var(--accent-soft);
  border-radius: 50%;
  flex-shrink: 0;
  /* checkmark via background-image */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 7l3 3 5-5' stroke='%2392400e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px 10px;
}

html.theme-dark .pro-feature-list li::before {
  background-color: rgba(250, 204, 21, 0.15);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 7l3 3 5-5' stroke='%23fbbf24' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  .pro-feature-list li::before {
    background-color: rgba(250, 204, 21, 0.15);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 7l3 3 5-5' stroke='%23fbbf24' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

.account-plan-badge {
  display: inline-block;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.account-plan-badge.free {
  color: #475569;
}

html.theme-dark .account-plan-badge.free {
  color: #94a3b8;
}

.account-plan-badge.pro {
  background: transparent;
  color: var(--accent-text-readable);
  /* border: 1px solid var(--accent-text); */
}

html.theme-dark .account-plan-badge.pro {
  background: transparent;
  color: #fbbf24;
  /* border: 1px solid rgba(251, 191, 36, 0.5); */
}

.account-plan-badge + .account-description {
  margin-top: 0.6rem;
}

.account-description {
  margin: 0.75rem 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.account-upgrade-btn {
  width: 100%;
  margin-top: 0.25rem;
}

.account-user-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.account-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

html.theme-dark .account-avatar {
  background: rgba(148, 163, 184, 0.15);
}

.account-user-details {
  min-width: 0;
  flex: 1;
}

.account-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-user-email {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-plan-status {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.account-plan-status:empty {
  display: none;
}

.account-signout-btn {
  width: 100%;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 3rem;
  font-style: italic;
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.empty-state-message {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 320px;
  margin: 0 auto;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--fg);
}

.toast-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--accent-text); /* gold in both light and dark mode */
}

@media (prefers-color-scheme: dark) {
  .toast {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  }
}

@media (max-width: 640px) {
  .toast {
    bottom: 20px;
    left: 20px;
    right: 20px;
    transform: translateY(100px);
    min-width: auto;
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* ============================================
   CHECK-IN CELEBRATION
   ============================================ */

/* Sparkle emoji particles ✨ */
.checkin-sparkle {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  user-select: none;
  animation: sparkle-float 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes sparkle-float {
  0% {
    opacity: 1;
    transform: translate(-10px, -10px) scale(0.5) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: translate(calc(var(--tx) - 10px), calc(var(--ty) - 10px)) scale(1.2) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--tx) * 1.5 - 10px), calc(var(--ty) * 1.5 - 10px)) scale(0.5) rotate(360deg);
  }
}

/* ============================================
   PWA STANDALONE OVERRIDES
   Browser mode keeps the styles above.
   In standalone PWA mode, revert toolbar and
   scroll-to-top to the old working behaviour.
   ============================================ */

html.is-pwa .scroll-to-top {
  bottom: 20px;
}
