* {
  font-family: 'Nunito', sans-serif;
}

:root {
  --ink: #1f2a2e;
  --ink-muted: #5a6570;
  --paper: #f2f3f4;
  --paper-soft: #ffffff;
  --accent: #b4327c;
  --accent-deep: #8f255f;
  --accent-soft: #f3d7e7;
  --mist: #e7ece8;
  --shadow: 0 18px 38px rgba(31, 42, 46, 0.12);
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  --color-grammar: #1a73e8;
  --color-grammar-bg: #e8f4fd;
  --color-grammar-border: #d2e8f9;
  --color-vocab: #1e8e3e;
  --color-vocab-bg: #e6f4ea;
  --color-vocab-border: #ceead6;
  --color-function: #b06000;
  --color-function-bg: #fef7e0;
  --color-function-border: #fdecc8;
  --color-correct: #1e8e3e;
  --color-correct-bg: #e6f4ea;
  --color-incorrect: #d93025;
  --color-incorrect-bg: #fce8e6;
}

html {
  scroll-behavior: smooth;
}

::selection {
  background: var(--accent);
  color: #fff;
}

h1 {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.text-secondary {
  color: var(--ink-muted) !important;
}

.nav-link {
  font-weight: 700;
  color: var(--ink) !important;
}

.nav-link-active {
  color: var(--accent) !important;
}

body {
  background-color: var(--paper);
  color: var(--ink);
}

.bg-navbar {
  background-color: var(--paper-soft);
}

.navbar {
  background: color-mix(in srgb, var(--paper-soft) 92%, transparent) !important;
  backdrop-filter: blur(14px);
}

.navbar-brand img {
  filter: drop-shadow(0 6px 10px rgba(31, 42, 46, 0.15));
}

.navbar-toggler {
  border: none;
}

.navbar-toggler:focus {
  box-shadow: 0 0 0 3px rgba(180, 50, 124, 0.2);
  outline: none;
}

/* Global focus-visible for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Footer */
.site-footer {
  margin-top: 4rem;
  padding: 3rem 0 1.5rem;
  border-top: 1px solid var(--mist);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 767.98px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}

.footer-brand img {
  margin-bottom: 0.6rem;
}

.footer-tagline {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.5;
  max-width: 200px;
}

.footer-heading {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 0.45rem;
}

.footer-links a {
  font-size: 0.88rem;
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.12s;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-bottom {
  padding-top: 1.5rem;
  border-top: 1px solid var(--mist);
  font-size: 0.78rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.footer-dot {
  color: var(--mist);
}

[data-theme="dark"] .site-footer {
  border-top-color: var(--mist);
}

[data-theme="dark"] .footer-links a {
  color: var(--ink-muted);
}

[data-theme="dark"] .footer-links a:hover {
  color: var(--accent);
}


.section-title {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-subtitle {
  color: var(--ink-muted);
  max-width: 40rem;
}

.book-card {
  border-radius: 16px;
  background: var(--paper-soft);
  border: 1px solid var(--mist);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(31, 42, 46, 0.1);
  border-color: var(--accent);
}

.book-card__cover {
  overflow: hidden;
  background: var(--paper);
}

.book-card__cover img {
  width: 100%;
  display: block;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.book-card:hover .book-card__cover img {
  transform: scale(1.03);
}

.book-card__body {
  padding: 0.65rem 0.7rem 0.7rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-card__title {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.2rem;
}

.book-card__author {
  font-size: 0.7rem;
  color: var(--ink-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card__footer {
  margin-top: auto;
  padding-top: 0.4rem;
}

.book-card__chapters {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
}

a.book-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}

a.book-card-link:hover {
  text-decoration: none;
  color: inherit;
}

.section-wrap {
  padding: 2.5rem 0 1.5rem;
}

.breadcrumb-nav {
  font-size: 0.85rem;
  padding: 0.75rem 0;
}

.breadcrumb-nav a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb-nav a:hover {
  text-decoration: underline;
}

.breadcrumb-nav .separator {
  margin: 0 0.4rem;
  color: var(--ink-muted);
}

.breadcrumb-nav .current {
  color: var(--ink-muted);
}

/* === Shared exercise page styles === */

.content-card {
  background: var(--paper-soft);
  border: 1px solid var(--mist);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.content-card .card-body {
  padding: 1.25rem;
}

.content-card-accent {
  border-color: var(--accent);
  border-width: 2px;
}

.content-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
}

.cover-img {
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chapter-select {
  border-radius: 12px;
  border: 1px solid var(--mist);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  background: var(--paper-soft);
}

.chapter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(180, 50, 124, 0.1);
  outline: none;
}

/* Ad slots — visually distinct from content cards.
   The "Sponsored" label and dotted border are deliberate: when ads
   look like content, accidental clicks happen and AdSense's invalid-
   click filter kicks in (which is what tanked our CTR in Feb 2026).
   Clear ad framing → fewer mis-clicks → higher legitimate CTR and RPM. */
.ad-slot {
  text-align: center;
  padding: 1.5rem 0.75rem 1rem;
  border: 1px dashed var(--mist);
  border-radius: 8px;
  background: var(--paper-soft, #fafbfc);
  margin: 1.5rem 0;
  overflow: hidden;
  position: relative;
  min-height: 120px;
  z-index: 0;
}

.ad-slot::before {
  content: 'Sponsored';
  position: absolute;
  top: 0.4rem;
  left: 0.75rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7a8c);
  opacity: 0.8;
}

.tag-pill {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.tag-pill:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.tag-level { background: var(--accent); color: #fff; }
.tag-skill { background: var(--accent-soft); color: var(--accent-deep); }
.tag-grammar { background: var(--color-grammar-bg); color: var(--color-grammar); border: 1px solid var(--color-grammar-border); }
.tag-grammar:hover { background: var(--color-grammar-border); color: var(--color-grammar); }
.tag-vocab { background: var(--color-vocab-bg); color: var(--color-vocab); border: 1px solid var(--color-vocab-border); }
.tag-vocab:hover { background: var(--color-vocab-border); color: var(--color-vocab); }
.tag-function { background: var(--color-function-bg); color: var(--color-function); border: 1px solid var(--color-function-border); }

.tag-sm {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
}

.tag-sm-level { background: var(--accent); color: #fff; }
.tag-sm-skill { background: var(--accent-soft); color: var(--accent-deep); }
.tag-sm-grammar { background: var(--color-grammar-bg); color: var(--color-grammar); }
.tag-sm-vocab { background: var(--color-vocab-bg); color: var(--color-vocab); }

.word-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
}

.word-link:hover { text-decoration: underline; }
.word-link + .word-link::before {
  content: '\00b7';
  margin: 0 0.3rem;
  color: var(--ink-muted);
  font-weight: 400;
}

.nav-btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: var(--paper-soft);
  border: 1px solid var(--mist);
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.nav-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

.exercise-grid-link {
  display: block;
  padding: 0.6rem 0.7rem;
  background: var(--paper-soft);
  border: 1px solid var(--mist);
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.15s ease;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.exercise-grid-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

.view-answer-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.85rem 2.5rem;
  border-radius: var(--radius-lg);
  text-decoration: none;
  font-size: 1.05rem;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(180, 50, 124, 0.3);
}

.view-answer-btn:hover {
  background: var(--accent-deep);
  color: #fff;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(180, 50, 124, 0.4);
}

/* Quill editor content styles */
.ql-content p:last-child,
.ql-content ol:last-child,
.ql-content ul:last-child { margin-bottom: 0; }
.ql-content ol li, .ql-content ul li { margin-bottom: 0.5rem; }
.ql-content ol li:last-child, .ql-content ul li:last-child { margin-bottom: 0; }
.ql-content .ql-indent-1 { list-style-type: lower-alpha; }
.ql-content .ql-indent-2 { list-style-type: lower-roman; }
.ql-content .ql-align-center { text-align: center; margin-bottom: 1rem; }
.ql-content blockquote { display: block; margin: 1em 40px; }
.ql-content .ql-video { width: 100%; height: 230px; }
@media (max-width: 991.98px) { .ql-content img { max-width: 100%; } }

/* Utility classes */
.border-mist-top { border-top: 1px solid var(--mist); }
.text-sm { font-size: 0.9rem; }
.text-xs { font-size: 0.85rem; }
.text-accent { color: var(--accent); }
.text-ink-muted { color: var(--ink-muted); }

/* Utility: flex gap */
.flex-gap-sm { gap: 0.4rem; }
.flex-gap-md { gap: 0.45rem; }

/* Practice-in-Learn callout shown after the answer card on solution
   pages. The funnel from textbook traffic into the Learn feature —
   without this, Learn is invisible to the readers landing on textbook
   solution pages from search. Three module cards in a responsive grid;
   each links straight to /learn/<pack>/<module>. */
.learn-callout {
  margin-bottom: 1.5rem;
}

.learn-callout-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  background: var(--paper-soft, #fafbfc);
  border: 1px solid var(--mist, #e7ece8);
  border-radius: 12px;
  text-decoration: none;
  color: var(--ink, #1f2a37);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  height: 100%;
}

.learn-callout-card:hover {
  text-decoration: none;
  color: var(--ink, #1f2a37);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(31, 42, 55, 0.08);
  border-color: var(--accent, #b4327c);
}

.learn-callout-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.learn-callout-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.learn-callout-pack {
  display: flex;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted, #6b7a8c);
}

/* Mobile sticky ad — responsive format. Cap to 100px so it never
   takes more than ~12% of a typical mobile viewport (AdSense ad
   density policy). The spacer matches the cap so content above
   doesn't get covered. */
.mobile-sticky-ad {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  text-align: center;
  background: var(--paper-soft);
  border-top: 1px solid var(--mist);
  padding: 4px 0;
  max-height: 100px;
  overflow: hidden;
}

.mobile-sticky-ad ins.adsbygoogle {
  max-height: 100px;
}

.mobile-sticky-spacer {
  height: 108px;
}

/* Homepage pack cards */
.pack-card-home {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--paper-soft);
  border: 1px solid var(--mist);
  border-radius: 14px;
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s ease;
}

.pack-card-home:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
  color: var(--ink);
  transform: translateY(-2px);
}

.pack-card-home__emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.pack-card-home__title {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
}

.pack-card-home__meta {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  margin-top: 0.1rem;
}

/* Activity icon backgrounds */
.activity-icon-vocabulary_cards { background: #fef7e0; }
.activity-icon-phrase_builder { background: #e8f4fd; }
.activity-icon-quick_test { background: #fce4ec; }
.activity-icon-mistake_fixer { background: #fff3e0; }
.activity-icon-dialogue_sim { background: #f3e5f5; }
.activity-icon-matching_pairs { background: #e6f4ea; }
.activity-icon-listening_exercise { background: #e0f2f1; }
.activity-icon-word_scramble { background: #e8eaf6; }

[data-theme="dark"] .activity-icon-vocabulary_cards { background: #2d2a1a; }
[data-theme="dark"] .activity-icon-phrase_builder { background: #1a2d3d; }
[data-theme="dark"] .activity-icon-quick_test { background: #2d1a22; }
[data-theme="dark"] .activity-icon-mistake_fixer { background: #2d251a; }
[data-theme="dark"] .activity-icon-dialogue_sim { background: #2a1a2d; }
[data-theme="dark"] .activity-icon-matching_pairs { background: #1a2d1f; }
[data-theme="dark"] .activity-icon-listening_exercise { background: #1a2d2a; }
[data-theme="dark"] .activity-icon-word_scramble { background: #1a1e2d; }

/* Streak badge */
.streak-badge {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.3rem 0.65rem;
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  color: #e65100;
}

[data-theme="dark"] .streak-badge {
  background: #2d251a;
  border-color: #3d3525;
  color: #ffab40;
}

.streak-fire { font-size: 1rem; }
.streak-count { line-height: 1; }

.streak-badge-mini {
  font-size: 0.75rem;
  font-weight: 700;
  color: #e65100;
}

[data-theme="dark"] .streak-badge-mini {
  color: #ffab40;
}

/* Visible language switcher in the navbar. Pulled out of the profile
   dropdown because non-English readers landing on /en pages weren't
   opening the profile menu — the localized catalog was effectively
   hidden. The flag-first design works as a recognizable trigger across
   16 languages without needing localized button copy. */
.lang-switch-btn {
  background: none;
  border: 1px solid var(--mist);
  border-radius: 10px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-muted);
  transition: all 0.15s ease;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  gap: 0.1rem;
}
.lang-switch-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.lang-switch-flag {
  font-size: 1.1rem;
  line-height: 1;
}
.lang-switch-code {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.78rem;
}
.lang-switch-menu {
  border-radius: 14px;
  border: 1px solid var(--mist);
  background: var(--paper-soft);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.35rem;
  min-width: 200px;
  max-height: 70vh;
  overflow-y: auto;
}
.lang-switch-menu .dropdown-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 0.5rem 0.75rem 0.4rem;
}
.lang-switch-item {
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
}
.lang-switch-item:hover {
  background: var(--accent-soft, #fff0f7);
  color: var(--accent);
}
.lang-switch-item .theme-check {
  color: var(--accent);
  font-weight: 700;
}

/* Profile dropdown */
.profile-btn {
  background: none;
  border: 1px solid var(--mist);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-muted);
  transition: all 0.15s ease;
  padding: 0;
}

.profile-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.profile-dropdown {
  border-radius: 14px;
  border: 1px solid var(--mist);
  background: var(--paper-soft);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.35rem;
  min-width: 180px;
}

.profile-dropdown .dropdown-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 0.5rem 0.75rem 0.25rem;
}

.profile-dropdown .dropdown-item {
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
}

.profile-dropdown .dropdown-item:hover {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.theme-check {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 700;
}

/* === Dark mode palette === */
[data-theme="dark"] {
  --ink: #e4e8eb;
  --ink-muted: #8e959c;
  --paper: #13181b;
  --paper-soft: #1a2025;
  --accent: #d64e9a;
  --accent-deep: #e877b5;
  --accent-soft: #2d1a25;
  --mist: #2a3036;
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] body {
  background-color: var(--paper);
  color: var(--ink);
}


[data-theme="dark"] .book-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Dark tag pills — override the color variables */
[data-theme="dark"] {
  --color-grammar: #6db3f2;
  --color-grammar-bg: #1a2d3d;
  --color-grammar-border: #253d52;
  --color-vocab: #6dd68a;
  --color-vocab-bg: #1a2d1f;
  --color-vocab-border: #253d2a;
  --color-function: #d6a86d;
  --color-function-bg: #2d2a1a;
  --color-function-border: #3d3525;
  --color-correct: #6dd68a;
  --color-correct-bg: #1a2d1f;
  --color-incorrect: #f28b82;
  --color-incorrect-bg: #2d1a1a;
}

/* Dark mode footer */
[data-theme="dark"] footer a {
  color: var(--ink) !important;
}

/* Dark mode text overrides */
[data-theme="dark"] .text-dark {
  color: var(--ink) !important;
}

[data-theme="dark"] .text-secondary {
  color: var(--ink-muted) !important;
}

[data-theme="dark"] .text-muted {
  color: var(--ink-muted) !important;
}

/* Dark mode cover image */
[data-theme="dark"] .cover-img {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Dark mode book card cover placeholder */
[data-theme="dark"] .book-card__cover {
  background: var(--mist);
}
