:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --ink: #18212a;
  --muted: #758292;
  --line: rgba(24, 33, 42, 0.09);
  --brand: #2f6df6;
  --brand-soft: rgba(47, 109, 246, 0.08);
  --success: #3b7a57;
  --amber: #c58a2b;
  --shadow-soft: 0 18px 50px rgba(26, 41, 68, 0.08);
  --shadow-card: 0 10px 30px rgba(26, 41, 68, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
strong, b, th { font-weight: 500; }

.app-shell {
  width: min(900px, calc(100% - 48px));
  margin: 0 auto 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  width: min(900px, calc(100% - 48px));
  margin: 0 auto;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 0;
}
.brand-block h1, .view-header h2, .deck-group h3, .practice-card-inner h3, .text-card h3 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 300;
}
.brand-block h1 {
  letter-spacing: -0.04em;
  font-size: 1.72rem;
}
.eyebrow, .label {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: .64rem;
}
.main-nav {
  display: flex;
  gap: 22px;
  flex: 1;
  overflow-x: auto;
  justify-content: flex-start;
  align-self: stretch;
}
.nav-link {
  padding: 12px 0 13px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 400;
  border-bottom: 3px solid transparent;
  transition: color .18s ease, border-color .18s ease;
  white-space: nowrap;
}
.nav-link.active, .nav-link:hover { color: var(--brand); border-bottom-color: var(--brand); }
.topbar-stats { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.streak-pill, .ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  font-size: .84rem;
}
.streak-icon { color: #e65100; }
.main-panel {
  padding: 32px 0 0;
  max-width: 100%;
  margin: 0 auto;
}
.view-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.section-subtle, .reader-info, .reader-tip, .flashcard-progress, .practice-feedback, .empty-card, .text-card p {
  color: var(--muted);
  font-size: .93rem;
}
.filter-row, .practice-controls, .practice-actions, .deck-pill-row, .deck-chip-row { display: flex; gap: 12px; flex-wrap: wrap; }
.filter-row label, .practice-controls label { display: grid; gap: 8px; font-weight: 400; }
select, input {
  min-width: 170px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  appearance: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  font-size: .9rem;
}
.action-button, .ghost-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  padding: 9px 15px;
  font-weight: 400;
  font-size: .88rem;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.action-button:hover, .ghost-button:hover { transform: translateY(-1px); }
.action-button.primary {
  background: var(--brand);
  color: #fff;
  border-color: rgba(47, 109, 246, 0.24);
  box-shadow: 0 10px 20px rgba(47, 109, 246, 0.14);
}
.action-button.secondary, .ghost-button { background: rgba(255, 255, 255, 0.92); color: var(--ink); }
.text-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.text-card, .reader-card, .feedback-card, .practice-card, .deck-chip, .auth-card, .vocab-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}
.text-card { padding: 24px; backdrop-filter: blur(12px); }
.text-card-link { display: block; color: inherit; text-decoration: none; }
.text-card-image-wrap {
  margin: -24px -24px 18px;
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  border-bottom: 1px solid rgba(24, 33, 42, 0.06);
  aspect-ratio: 16 / 9;
  background: rgba(24, 33, 42, 0.05);
}
.text-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.text-card--clickable {
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.text-card--clickable:hover {
  transform: translateY(-4px);
  border-color: rgba(47,109,246,.18);
  box-shadow: 0 18px 36px rgba(26, 41, 68, 0.1);
}
.text-card-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}
.text-card h3 {
  font-size: 1.38rem;
}
.text-card-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; color: var(--muted); font-size: .78rem; padding-top: 14px; border-top: 1px solid rgba(24,33,42,.06); }
.badge, .meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  font-weight: 400;
  font-size: .79rem;
}
.library-view {
  display: grid;
  gap: 18px;
}
.library-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: end;
  padding: 2px 2px 0;
}
.library-hero-copy h2 {
  font-size: clamp(1.72rem, 3.4vw, 2.8rem);
  line-height: .96;
  margin-bottom: 10px;
  max-width: 22ch;
  font-weight: 300;
  letter-spacing: -0.035em;
}
.library-hero-copy .section-subtle {
  max-width: 62ch;
  font-size: .96rem;
  line-height: 1.65;
}
.text-grid--airy {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.reader-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) 320px; gap: 20px; }
.reader-card, .feedback-card, .practice-card { padding: 28px; }
.reader-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.reader-audio { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.reader-audio-btn {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1.5px solid rgba(24,33,42,.18);
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease;
}
.reader-audio-btn:hover { border-color: var(--ink); }
.reader-audio-icon { width: 14px; height: 14px; fill: var(--ink); }
.reader-audio-play { display: block; }
.reader-audio-pause { display: none; }
.reader-audio-btn.is-playing .reader-audio-play { display: none; }
.reader-audio-btn.is-playing .reader-audio-pause { display: block; }
.reader-audio-meta { display: flex; align-items: center; gap: 6px; }
.reader-audio-label { font-weight: 600; font-size: .93rem; color: var(--ink); }
.reader-audio-duration { color: var(--muted); font-size: .93rem; }
.reader-content { position: relative; font-size: .99rem; line-height: 1.95; }
.reader-content > *:first-child { margin-top: 0; }
.reader-content > *:last-child { margin-bottom: 0; }
.reader-content p,
.reader-content ul,
.reader-content ol,
.reader-content blockquote,
.reader-content h2,
.reader-content h3,
.reader-content h4,
.reader-content figure {
  margin: 0 0 1.15em;
}
.reader-content h2,
.reader-content h3,
.reader-content h4 {
  font-family: "Fraunces", serif;
  font-weight: 300;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.reader-content h2 { font-size: 1.62rem; margin-top: 1.8em; }
.reader-content h3 { font-size: 1.3rem; margin-top: 1.5em; }
.reader-content h4 { font-size: 1.1rem; margin-top: 1.35em; }
.reader-content ul,
.reader-content ol {
  padding-left: 1.4em;
}
.reader-content li + li {
  margin-top: 0.45em;
}
.reader-content blockquote {
  padding: 0.2em 0 0.2em 1em;
  border-left: 3px solid rgba(55, 109, 161, 0.22);
  color: #5e6875;
}
.reader-content code {
  padding: 0.12em 0.34em;
  border-radius: 6px;
  background: rgba(24, 33, 42, 0.06);
  font-size: 0.92em;
}
.reader-link {
  color: #376da1;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}
.reader-figure {
  margin: 1.5em 0;
}
.reader-image {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(24, 33, 42, 0.08);
}
.reader-figure figcaption {
  margin-top: 0.55em;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}
.word-token {
  border-radius: 6px;
  cursor: pointer;
  padding: 1px 3px;
  transition: background .16s ease, box-shadow .16s ease;
}
.word-token:hover, .word-token.active { background: rgba(43,95,142,.14); }
.word-token.saved { box-shadow: inset 0 -2.5px 0 var(--amber); }
.word-token.session-saved { box-shadow: inset 0 -2.5px 0 var(--success); }
.reader-sidebar-stack, .session-words-list, .deck-groups { display: grid; gap: 18px; }
.reader-sidebar-thumb {
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(24, 33, 42, 0.08);
  background: rgba(24, 33, 42, 0.04);
}
.reader-sidebar-thumb-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.session-word-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
}
.reader-sidebar-action {
  margin-top: -4px;
}
.reader-sidebar-action form {
  margin: 0;
}
.reader-sidebar-action-button {
  width: 100%;
  justify-content: center;
}
.deck-groups { margin-bottom: 20px; }
.deck-chip { padding: 14px 16px; }
.vocab-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.vocab-table th, .vocab-table td { padding: 13px 18px; text-align: left; border-bottom: 1px solid rgba(28,26,21,.06); font-size: .88rem; }
.vocab-table th { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 400; }
.vocab-cell-word { font-weight: 500; }
.vocab-cell-translation { color: #376da1; font-style: italic; }
.strength-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.strength-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}
.strength-strong { color: #51916a; }
.strength-building { color: #a67f2d; }
.strength-new { color: #d36a35; }
.empty-table { text-align: center; color: var(--muted); }
.deck-browser { display: grid; gap: 14px; margin-bottom: 22px; }
.deck-pill {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 400;
  font-size: .84rem;
}
.deck-pill.active { color: #fff; background: #376da1; border-color: #376da1; }
.vocab-deck-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.study-summary-card {
  margin-bottom: 32px;
  padding: 20px 22px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-card);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}
.study-summary-copy h3 {
  margin: 0 0 6px;
  font-family: "Fraunces", serif;
  font-size: 1.02rem;
  font-weight: 300;
}
.study-summary-copy p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
}
.study-summary-actions {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}
.study-summary-actions .action-button {
  white-space: nowrap;
}
.vocab-deck-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px 16px;
  align-items: center;
  padding: 20px 22px 18px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}
.vocab-deck-icon {
  font-size: 1.45rem;
  line-height: 1;
}
.vocab-deck-copy h3 {
  margin: 0 0 6px;
  font-family: "Fraunces", serif;
  font-size: 1.02rem;
  font-weight: 300;
}
.vocab-deck-copy p {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
}
.deck-practice-link {
  align-self: start;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(47, 109, 246, 0.14);
  background: rgba(47, 109, 246, 0.06);
  color: #376da1;
  font-size: .78rem;
  white-space: nowrap;
}
.deck-progress-track {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: rgba(24, 33, 42, 0.06);
  overflow: hidden;
}
.deck-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #376da1;
}
.tone-warm .deck-progress-fill { background: #d36a35; }
.tone-blue .deck-progress-fill { background: #376da1; }
.tone-green .deck-progress-fill { background: #51916a; }
.tone-gold .deck-progress-fill { background: #a67f2d; }
.tone-teal .deck-progress-fill { background: #447b80; }
.tone-rose .deck-progress-fill { background: #b24f66; }
.tone-slate .deck-progress-fill { background: #5f7188; }
.practice-card--centered { max-width: 720px; margin: 0 auto; }
.practice-card-inner { min-height: 280px; display: grid; align-content: center; gap: 16px; text-align: center; }
.practice-card-inner h3 {
  font-size: 1.48rem;
}
.flashcards-stage {
  display: grid;
  gap: 20px;
  justify-items: center;
}
.flashcards-track {
  width: min(720px, 100%);
  height: 6px;
  border-radius: 999px;
  background: rgba(24, 33, 42, 0.12);
  overflow: hidden;
  margin-top: 4px;
}
.flashcards-track-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #376da1;
  min-width: 12%;
}
.flashcards-count,
.flashcard-progress {
  color: #7b7266;
  font-size: .88rem;
  text-align: center;
}
.flashcard-shell {
  width: min(720px, 100%);
}
.flashcard-stage-card {
  width: 100%;
  min-height: 370px;
  padding: 32px 40px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-card);
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
}
.flashcard-complete-card {
  position: relative;
  width: 100%;
  min-height: 370px;
  padding: 40px 40px 36px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 18px;
  place-items: center;
  text-align: center;
  overflow: hidden;
}
.completion-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 12px;
  height: 24px;
  margin-left: -6px;
  margin-top: -12px;
  border-radius: 3px;
  background: var(--hue, #376da1);
  opacity: 0;
  transform: translate(0, 0) rotate(0deg) scale(.4);
  animation: confetti-burst 1.9s cubic-bezier(.15,.8,.24,1) forwards;
  animation-delay: var(--delay, 0s);
}
.confetti-piece:nth-child(3n) {
  width: 8px;
  height: 18px;
}
.confetti-piece:nth-child(4n) {
  border-radius: 999px;
}
@keyframes confetti-burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(.2);
  }
  12% {
    opacity: 1;
  }
  58% {
    opacity: 1;
    transform: translate(calc(var(--x) * .86), calc(var(--y) * .86)) rotate(calc(var(--r) * .7)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), calc(var(--y) + 120px)) rotate(var(--r)) scale(.88);
  }
}
.flashcard-stage-card.is-revealed {
  cursor: default;
}
.flashcard-face {
  display: grid;
  gap: 16px;
  justify-items: center;
}
.flashcards-stage[data-flashcard-stage="hidden"] .flashcard-face-back {
  display: none;
}
.flashcards-stage[data-flashcard-stage="revealed"] .flashcard-face-front {
  display: none;
}
.flashcard-kicker {
  margin: 0;
  color: #7b7266;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .72rem;
}
.flashcard-answer-word {
  color: #376da1;
}
.flashcards-track-fill.is-complete {
  animation: bloom-fill .7s ease-out forwards;
}
@keyframes bloom-fill {
  0% { box-shadow: 0 0 0 rgba(55, 109, 161, 0); }
  100% { box-shadow: 0 0 0 10px rgba(55, 109, 161, 0.08); }
}
.flashcard-context {
  margin: 0;
  max-width: 26ch;
  color: #7b7266;
  font-size: .98rem;
  line-height: 1.55;
  font-style: italic;
}
.flashcard-context-wide {
  max-width: 34ch;
}
.streak-celebration {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 247, 234, 0.92);
  border: 1px solid rgba(230, 152, 54, 0.18);
  animation: streak-pop .45s ease-out;
}
.streak-celebration-icon {
  font-size: 1.45rem;
  line-height: 1;
}
.streak-celebration-label,
.streak-celebration-value {
  margin: 0;
}
.streak-celebration-label {
  color: #9a7a3c;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.streak-celebration-value {
  font-family: "Fraunces", serif;
  font-size: 1.28rem;
  color: #513d1f;
}
@keyframes streak-pop {
  0% { transform: scale(.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.completion-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.flashcard-review-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.flashcards-stage[data-flashcard-stage="hidden"] .flashcard-review-bar {
  display: none;
}
.flashcard-rating {
  min-width: 150px;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  display: grid;
  gap: 4px;
  text-align: center;
  cursor: pointer;
}
.flashcard-rating span {
  font-size: .96rem;
}
.flashcard-rating small {
  font-size: .74rem;
  color: inherit;
}
.flashcard-rating.review-again {
  color: #c84a54;
  border-color: rgba(200, 74, 84, 0.28);
  background: rgba(200, 74, 84, 0.06);
}
.flashcard-rating.review-hard {
  color: #dc6a24;
  border-color: rgba(220, 106, 36, 0.28);
  background: rgba(220, 106, 36, 0.06);
}
.flashcard-rating.review-good {
  color: #4c865a;
  border-color: rgba(76, 134, 90, 0.28);
  background: rgba(76, 134, 90, 0.08);
}
.flashcard-rating.review-easy {
  color: #4b7cac;
  border-color: rgba(75, 124, 172, 0.28);
  background: rgba(75, 124, 172, 0.08);
}
.prompt-word { margin: 0; font-family: "Fraunces", serif; font-size: clamp(1.82rem, 4.2vw, 2.9rem); font-weight: 300; }
.cloze-sentence { padding: 16px; border-radius: 16px; background: rgba(28,26,21,.04); font-family: "Fraunces", serif; line-height: 1.8; }
.practice-actions--centered, .practice-feedback--centered { justify-content: center; text-align: center; }
.flashcard-answer { margin-top: 16px; display: grid; gap: 12px; }
.word-modal { position: absolute; top: 0; left: 0; width: 310px; z-index: 30; }
.word-modal.hidden { display: none; }
.word-modal-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
.word-modal-card h3 { font-size: 1.02rem; }
.word-modal-translation { margin: 0 0 8px; color: var(--brand); font-style: italic; font-size: .9rem; }
.word-modal-type { display: inline-block; margin: 0 0 12px; padding: 2px 7px; border-radius: 6px; background: #fff; color: var(--muted); font-size: .66rem; }
.word-modal-actions { display: flex; gap: 10px; }
.word-modal-actions .action-button { flex: 1 1 0; justify-content: center; }
.auth-card { max-width: 480px; margin: 0 auto; padding: 24px; }
.auth-form { display: grid; gap: 12px; }
.auth-form p { display: grid; gap: 6px; }

/* ---------------------------------------------------------------------------
   Star icon (shared shape)
--------------------------------------------------------------------------- */
.star-icon {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: fill .15s, stroke .15s;
}

/* ---------------------------------------------------------------------------
   Library filter bar
--------------------------------------------------------------------------- */
.library-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

/* Select-style filter dropdowns */
.filter-select {
  position: relative;
}

/* The trigger looks like a <select> form control */
.filter-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 7px 10px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  font-size: .88rem;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  min-width: 130px;
  transition: border-color .15s, box-shadow .15s;
}
.filter-select-trigger::-webkit-details-marker { display: none; }
.filter-select-trigger::marker { display: none; }
.filter-select-trigger:hover {
  border-color: rgba(24, 33, 42, 0.22);
}
.filter-select[open] .filter-select-trigger {
  border-color: var(--brand);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.filter-select-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-chevron {
  width: 10px;
  height: 6px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform .2s ease;
}
.filter-select[open] .filter-chevron {
  transform: rotate(180deg);
}

/* Dropdown panel — width driven by content, not by the trigger */
.filter-select-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  background: var(--panel-strong);
  border: 1px solid var(--brand);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 4px;
  width: max-content;
  min-width: 100%;
  box-shadow: 0 8px 24px rgba(26, 41, 68, 0.12);
}

/* Select all / Clear all button */
.filter-select-all-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: .82rem;
  font-weight: 500;
  color: var(--brand);
  cursor: pointer;
  transition: background .12s;
}
.filter-select-all-btn:hover {
  background: var(--brand-soft);
}
.filter-select-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

/* Individual option rows — label itself is the flex container */
.filter-option {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .88rem;
  white-space: nowrap;
  transition: background .12s;
}
.filter-option:hover {
  background: var(--brand-soft);
}
.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
  appearance: checkbox;
  -webkit-appearance: checkbox;
  accent-color: var(--brand);
  width: 14px;
  height: 14px;
  cursor: pointer;
  margin: 0;
}
.filter-option input[type="radio"] {
  appearance: radio;
  -webkit-appearance: radio;
}

/* Starred filter toggle — matches the select trigger height */
.filter-star-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  cursor: pointer;
  color: var(--muted);
  font-size: .88rem;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.filter-star-btn:hover {
  border-color: rgba(24, 33, 42, 0.22);
  color: var(--ink);
}
.filter-star-btn.is-active {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(197, 138, 43, 0.07);
}
.filter-star-icon {
  width: 13px;
  height: 13px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: fill .15s, stroke .15s;
}
.filter-star-btn.is-active .filter-star-icon {
  fill: var(--amber);
  stroke: var(--amber);
}

/* ---------------------------------------------------------------------------
   Text card — layout adjusted for star button overlay
--------------------------------------------------------------------------- */
.text-card {
  position: relative;
}
.text-card-star-form {
  position: absolute;
  top: 14px;
  right: 14px;
  margin: 0;
}
.card-star-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  cursor: pointer;
  color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.card-star-btn:hover,
.card-star-btn.is-starred {
  color: var(--amber);
  border-color: var(--amber);
}
.card-star-btn.is-starred .star-icon {
  fill: var(--amber);
  stroke: var(--amber);
}

/* Read badge */
.badge--read {
  background: rgba(59, 122, 87, 0.10);
  color: var(--success);
  border: 1px solid rgba(59, 122, 87, 0.18);
}
.text-card.is-read .text-card-link h3 {
  color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Reader header — star button + actions row
--------------------------------------------------------------------------- */
.view-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.reader-star-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
.reader-star-btn:hover,
.reader-star-btn.is-starred {
  color: var(--amber);
  border-color: var(--amber);
}
.reader-star-btn.is-starred .star-icon {
  fill: var(--amber);
  stroke: var(--amber);
}

/* ---------------------------------------------------------------------------
   Streak dashboard
--------------------------------------------------------------------------- */
.streak-stat-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.streak-stat-card {
  flex: 1 1 100px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.streak-stat-card--hero {
  flex: 1 1 140px;
  background: var(--panel-strong);
  border-color: rgba(47, 109, 246, 0.15);
}
.streak-stat-flame {
  font-size: 1.6rem;
  line-height: 1;
  display: block;
  margin-bottom: 4px;
}
.streak-stat-number {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 300;
  line-height: 1;
  color: var(--ink);
}
.streak-stat-card--hero .streak-stat-number {
  color: var(--brand);
}
.streak-stat-label {
  margin: 6px 0 0;
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Heatmap card */
.streak-heatmap-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
  overflow-x: auto;
}
.streak-heatmap {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-top: 14px;
}
.streak-heatmap-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 1px;
  flex-shrink: 0;
}
.streak-day-label {
  font-size: .68rem;
  color: var(--muted);
  height: 14px;
  line-height: 14px;
  width: 12px;
  text-align: right;
}
.streak-heatmap-grid {
  display: flex;
  gap: 3px;
}
.streak-heatmap-week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.streak-heatmap-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Cell levels — 0 = inactive, 1–5 = streak depth (light → dark green) */
.streak-heatmap-cell--0 { background: rgba(24, 33, 42, 0.07); }
.streak-heatmap-cell--1 { background: #c8ead4; }
.streak-heatmap-cell--2 { background: #84cda0; }
.streak-heatmap-cell--3 { background: #4caf72; }
.streak-heatmap-cell--4 { background: #2d8a4e; }
.streak-heatmap-cell--5 { background: #1a5c34; }
.streak-heatmap-cell.is-future { background: rgba(24, 33, 42, 0.03); }
.streak-heatmap-cell.is-today {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

/* Legend */
.streak-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.streak-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--muted);
}
.streak-legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Nudge message */
.streak-nudge {
  text-align: center;
  color: var(--muted);
  font-size: .92rem;
  margin: 8px 0 0;
}

/* ---------------------------------------------------------------------------
   Reader — mark as read button + confetti
--------------------------------------------------------------------------- */
.reader-read-action {
  display: flex;
  justify-content: center;
  padding: 32px 0 8px;
}

/* The wrapper is the confetti origin point */
.reader-read-wrap {
  position: relative;
  display: inline-flex;
}

/* Green "mark as read" state */
.action-button.read-done {
  background: #2d8a4e;
  border-color: #2d8a4e;
  color: #fff;
}
.action-button.read-done:hover {
  background: #246b3d;
  border-color: #246b3d;
}

/* ---------------------------------------------------------------------------
   Read confetti — 12 particles launched from the button centre
--------------------------------------------------------------------------- */
.read-confetti-piece {
  position: absolute;
  /* centre on the button — JS nudges these via top/left after layout */
  top: 50%;
  left: 50%;
  width: var(--w, 8px);
  height: var(--h, 14px);
  border-radius: var(--br, 3px);
  background: var(--col, #2d8a4e);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) rotate(0deg) scale(0);
  animation: read-particle var(--dur, 0.9s) cubic-bezier(.2,.8,.3,1) var(--delay, 0s) forwards;
}

@keyframes read-particle {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.2);
  }
  20% {
    opacity: 1;
    transform:
      translate(calc(-50% + var(--tx) * 0.3), calc(-50% + var(--ty) * 0.3))
      rotate(calc(var(--rot) * 0.3))
      scale(1);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(-50% + var(--tx)), calc(-50% + var(--ty)))
      rotate(var(--rot))
      scale(0.6);
  }
}

@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; }
  .app-shell {
    width: min(100% - 24px, 1360px);
    margin: 12px auto;
  }
  .topbar-inner {
    width: min(100% - 24px, 1360px);
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .topbar-stats { width: 100%; justify-content: flex-start; }
  .library-hero {
    padding: 0;
  }
  .text-grid--airy {
    grid-template-columns: 1fr;
  }
  .vocab-deck-grid {
    grid-template-columns: 1fr;
  }
  .study-summary-card {
    grid-template-columns: 1fr;
  }
  .study-summary-actions {
    justify-content: flex-start;
  }
  .main-nav {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .main-panel {
    padding: 20px 4px 4px;
  }
  .flashcard-stage-card {
    min-height: 300px;
    padding: 28px 22px;
    border-radius: 18px;
  }
  .flashcard-complete-card {
    min-height: 300px;
    padding: 32px 22px 28px;
    border-radius: 18px;
  }
  .flashcard-rating {
    min-width: 132px;
    flex: 1 1 calc(50% - 10px);
  }
  .text-card,
  .reader-card,
  .feedback-card,
  .practice-card,
  .deck-chip,
  .auth-card,
  .vocab-table-wrap {
    border-radius: 16px;
  }
}
