:root {

  /* ── Neutrals / Grays ─────────────────────────────── */
  --black:        #000;
  --near-black:   #111;      /* primary text, input text, labels */
  --charcoal:     #333;      /* secondary text, labels, hover states */
  --mid-gray:     #5f5f5f;      /* muted text, soft borders, placeholders — AA-compliant (~4.95:1 on white) */
  --light-gray:   #bbb;      /* disabled text, separators, placeholders */
  --border:       #CBD5E1;   /* standard border, grammar input resting border */
  --hover-bg:     #E8E8E8;   /* hover state bg, subtle admin border */
  --page-bg:      #eeeeee;   /* main app area / edit tab bg; also subtle border */
  --off-white:    #F0F0F0;   /* section button bg, light dividers */
  --surface:      #FCFCFC;   /* cards, tables, inputs, page bg */
  --white:        #FFF;

  /* ── Green ────────────────────────────────────────── */
  --green:          #115035;   /* forest green — primary accent, headers */
  --medium-green:   #15803D;   /* correct state text, border, score label */
  --mint:           #9AEAC7;   /* correct answer, primary button, language toggle */
  --mint-dark:      #26BA7A;   /* correct answer, primary button, language toggle */
  --badge-green:    #d8fadb;   /* badge-ar/re text */
  --green-xlight:   #C8E6D4;   /* language toggle active bg, badge-ar/re bg */
  --green-light:    #EAF4EF;   /* green section button bg, correct state bg */
  --quiz-correct-bg:rgba(34, 197, 94, 0.1);   /* quiz/gender correct state bg */

  /* ── Red / Coral ──────────────────────────────────── */
  --dark-red:         #e60000;   /* error text, delete button text */
  --coral-dark:       #bd0000;   /* incorrect state text, coral section text */
  --coral:            #F5A0A0;   /* incorrect highlight, section theme */
  --coral-light:      #f7eded;   /* incorrect state bg, danger/delete bg, section button bg */
  --badge-pink-bg:    #fff0f6;   /* badge-ir/la bg */
  --danger-hover-bg:  rgba(192,64,64,0.08);    /* danger button hover bg */

  /* ── Pink / Magenta ───────────────────────────────── */
  --dark-pink:       #710044;   /* glossary section h2, header bg */
  --badge-pink:      #df3c9e;   /* badge-ir/la text */
  --glossary-border: #A12A71;   /* glossary section button border */
  --medium-pink:     #E38EC1;   /* glossary section hover, gender "las" border */
  --magenta-light:   #ffe6f4;   /* glossary section hover, gender "las" border */

  /* ── Yellow / Amber ───────────────────────────────── */
  --dark-amber:   #7A5400;   /* yellow section text, h2 */
  --amber:        #b98700;   /* ghost button border, badge-er text */
  --yellow:       #F6CB4C;   /* yellow — ghost button, section theme */
  --yellow-light: #FEF9C3;   /* yellow section button bg, badge-er bg */

  /* ── Purple / Lavender ────────────────────────────── */
  --dark-lavender:        #5540A3;               /* study tab text, lavender section text */
  --grammar-input-focus:  #6366F1;               /* grammar input focus border */
  --lavender:             #94A3E7;               /* focus rings, study tab border */
  --lavender-border:      #AAA3FC;               /* lavender section button border + hover */
  --lavender-light:       #EEF1FF;               /* study tab bg, lavender section button bg */
  --row-hover:            #EBEFFE;               /* drill table row hover (lavender-tinted) */
  --grammar-focus-ring:   rgba(99,102,241,0.15); /* grammar input focus box-shadow */

  /* ── Blue ─────────────────────────────────────────── */
  --medium-blue:  #1645A2;   /* blue section text/border, header bg, banner text */
  --action-blue:  #2F6ED5;   /* settings buttons, links, badge text, active states */
  --light-blue:   #93C5FD;   /* badge border, banner border */
  --blue-light:   #e6f1ff;   /* badge bg, banner bg, grammar table bg, section button bg */

  /* ── Fonts ─────────────────────────────────────────── */
  /* Google Fonts loaded via <link> in index.html. Fallbacks are system-safe.
     To swap fonts, change the <link> in index.html and update these values. */
  --font-body:    'Quicksand', 'Avenir', 'Avenir Next', 'Century Gothic', Futura, sans-serif;
  --font-heading: 'Young Serif', 'Optima', 'Optima Nova', Candara, 'Gill Sans', serif;
}
/* ── Palette
   var(--black)     black      — text, active states
   var(--green)  forest     — header, primary accent, correct score
   var(--coral)  coral      — incorrect highlights
   var(--yellow)  yellow     — badges
   var(--lavender)  lavender   — focus rings, hover accents
   var(--page-bg)  light gray — page background
──────────────────────────────────────────── */

/* Visually hidden but available to assistive tech (screen readers). */
.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;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--surface);
  color: var(--black);
  min-height: 100vh;
  /* Prevent iOS Safari from auto-enlarging text it heuristically deems
     "small," which scales the whole layout and feels like a slight zoom-in
     on real devices (not reproducible in DevTools emulation). */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ── Header ── */
header {
  /* ── Llama-fur experiment (cream/tan) — confined to header block ── */
  --fur:       #FBF4E9;   /* cream highlight (front tufts) */
  --fur-mid:   #F3E7D4;   /* base fur tone */
  --fur-shade: #E6D2B5;   /* lighter tan (back tufts / shadow) */
  --fur-ink:     #5A4632; /* warm dark brown text */
  --fur-ink-rgb: 90,70,50; /* same brown, for translucent uses */
  /* Solid cream fur (texture experiment removed) */
  background-color: var(--fur);
  color: var(--fur-ink);
  padding: 11px 24px 3px;
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Cloud-like fluffy bottom edge — one mass of heavily-overlapping cream
   puffs at varied sizes AND heights so they merge into a single lumpy
   cloud (not visible rows). Same cream as the header bottom, so there's
   no color seam; soft feathered edges + a drop-shadow give depth. */
header::after {
  content: "";
  position: absolute;
  /* Behind the title/button (which paint above negative-z children) but
     still above the header's own background, so it never overlaps content. */
  z-index: -1;
  left: -20px;
  right: -20px;
  bottom: -11px;
  height: 24px;
  pointer-events: none;
  background-repeat: repeat-x;
  /* Single seamless ~1400px-wide SVG fur strip. Its repeat period is wider
     than nearly any header, so it never visibly tiles; the tile edges are
     spaced to wrap seamlessly for ultrawide screens. */
  background-size: 1400px 24px;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%221400%22%20height%3D%2224%22%20viewBox%3D%220%200%201400%2024%22%3E%3Cg%20fill%3D%22%23FBF4E9%22%3E%3Ccircle%20cx%3D%229.3%22%20cy%3D%227%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%2227.3%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%2243.9%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%2262.1%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%2283.4%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%2299.8%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22118.2%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22136.4%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22157.3%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22175.9%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22193.6%22%20cy%3D%226%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22210.7%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22229.8%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22247.6%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22267.3%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22286.2%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22303.6%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22323.2%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22341%22%20cy%3D%225%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22359%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22377%22%20cy%3D%226%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22396.2%22%20cy%3D%228%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22414%22%20cy%3D%225%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22434.7%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22453.4%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22470.7%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22488.4%22%20cy%3D%228%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22507%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22525.3%22%20cy%3D%227%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22545.1%22%20cy%3D%227%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22563.2%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22582.1%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22599.3%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22617.3%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22636.4%22%20cy%3D%228%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22656.8%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22673%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22692.3%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22710.4%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22728%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22748.9%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22766.3%22%20cy%3D%227%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22783.9%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22802.3%22%20cy%3D%228%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22822%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22840.7%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%22857.8%22%20cy%3D%227%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22876.3%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22896.3%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22913.4%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22932.6%22%20cy%3D%226%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22952.7%22%20cy%3D%226%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%22971%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%22987.9%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221007.8%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221024.5%22%20cy%3D%228%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221044.1%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221061.9%22%20cy%3D%228%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221082.1%22%20cy%3D%228%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221098.2%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221119.2%22%20cy%3D%228%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221136.7%22%20cy%3D%228%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221153.6%22%20cy%3D%227%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221172.5%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221192.3%22%20cy%3D%226%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%221211.8%22%20cy%3D%228%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%221230.3%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221246.4%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221267.5%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221284.7%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221304.2%22%20cy%3D%226%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221322.6%22%20cy%3D%225%22%20r%3D%2214%22%2F%3E%3Ccircle%20cx%3D%221339.7%22%20cy%3D%227%22%20r%3D%2213%22%2F%3E%3Ccircle%20cx%3D%221357.5%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221376%22%20cy%3D%226%22%20r%3D%2215%22%2F%3E%3Ccircle%20cx%3D%221395.1%22%20cy%3D%227%22%20r%3D%2215%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
  filter: drop-shadow(0 2px 1.5px rgba(120,95,60,0.18));
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-username {
  font-size: 0.85rem;
  opacity: 0.85;
}

.header-logout {
  font-size: 0.8rem;
  padding: 5px 12px;
}

/* ── Auth screen ── */
#auth-view {
  position: fixed;
  inset: 0;
  background: var(--page-bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 28px;
  color: var(--green);
}

.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--page-bg);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--mid-gray);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

.auth-field { margin-bottom: 16px; }

.auth-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.auth-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--near-black);
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.auth-input:focus { outline: none; border-color: var(--mint); }

.auth-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-password-wrap .auth-input {
  padding-right: 56px;
}

.auth-pw-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--mid-gray);
  cursor: pointer;
  padding: 2px 4px;
}

.auth-pw-toggle:hover { color: var(--charcoal); }

.auth-error {
  font-size: 0.85rem;
  color: var(--dark-red);
  margin-bottom: 12px;
  min-height: 18px;
}

.auth-message {
  font-size: 0.85rem;
  color: var(--green);
  margin-bottom: 12px;
  min-height: 18px;
}

.auth-lang-btns { display: flex; gap: 8px; }
.auth-lang-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.auth-lang-btn.active { border-color: var(--green); background: var(--green-light); color: var(--green)}

.auth-submit { width: 100%; padding: 12px; font-size: 1rem; }

.auth-reset-intro { margin: 0 0 16px; font-size: 0.9rem; color: var(--charcoal); }
.auth-forgot-wrap { text-align: right; margin-top: 4px; }
.auth-forgot-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--action-blue);
  cursor: pointer;
  text-decoration: underline;
}
.auth-forgot-link:hover { color: var(--medium-blue); }

@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .auth-title { font-size: 1.35rem; }
  .header-username { display: none; }
}

#header-title {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 0.65rem + 1.75vw, 1.35rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
  min-width: 0;
}

/* ── Main layout ── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}
@media (max-width: 640px) {
  main     { padding: 10px 16px 160px; } /* bottom padding for fixed drill bar */
  #landing { padding: 20px 18px; }
}

/* ── Direction button (single click-to-flip control) ── */
.direction-toggle { display: inline-flex; }

.btn-dir {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s;
  white-space: nowrap;
  border: 1px solid;
}
/* Color scheme mirrors the landing-page language-pick buttons: green for the
   default EN→target direction, blue when flipped to target→EN. */
.btn-dir[data-dir="en-to-es"] { background: var(--green-xlight); color: var(--green);       border-color: var(--medium-green); }
.btn-dir[data-dir="es-to-en"] { background: var(--blue-light);    color: var(--action-blue); border-color: var(--medium-blue);  }
.btn-dir:not(:disabled):hover { filter: brightness(0.95); }
.btn-dir:disabled { opacity: 0.35; cursor: default; }

/* ── Drill category title ── */
.drill-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--near-black);
}

/* ── Action buttons bar ── */
.controls-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.4; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(0.93); }
.btn:not(:disabled):active { filter: brightness(0.86); }

.btn-primary   { background: var(--mint); color: var(--green); border: 1px solid var(--green); }
.btn-secondary { background: var(--border); color: var(--black); border: 1px solid var(--mid-gray); }
.btn-ghost     { background: var(--yellow); color: var(--black); border: 1px solid var(--amber); }
.btn-danger    { background: var(--coral-light); color: var(--coral-dark); border: 1px solid var(--dark-red); }

/* ── Score ── */
.score {
  margin-left: auto;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--black);
  white-space: nowrap;
}
.score .correct-count { color: var(--green); }
.score .total-count   { color: var(--mid-gray); }
@media (max-width: 640px) {
  .controls-bottom { gap: 8px; }
  .score        { margin-left: 0; width: 100%; text-align: right; }
  .btn          { padding: 8px 14px; font-size: 0.85rem; }
  .btn-dir      { padding: 8px 14px; font-size: 0.85rem; }
  .btn-category { padding: 10px 14px; font-size: 0.9rem; }
}

/* ── Placeholder ── */
.placeholder {
  text-align: center;
  color: var(--mid-gray);
  padding: 60px 0;
  font-size: 1rem;
}

.conj-mobile-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 60px 24px;
  text-align: center;
  color: var(--mid-gray);
  font-size: 1rem;
}

/* ── Edit / Save tab above table ── */
.table-tab-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding-right: 14px; /* clear the table's rounded corner */
}
.action-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: 6px 6px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid;
  border-bottom: none;
  position: relative;
  bottom: -1px;
  z-index: 1;
  transition: filter 0.15s;
}
.action-tab:hover { filter: brightness(0.93); }
.action-tab:disabled { opacity: 0.4; cursor: default; filter: none; }
.action-tab:disabled:hover { filter: none; }
.edit-tab { background: var(--page-bg); color: var(--charcoal); border-color: var(--mid-gray); }
.save-tab { background: var(--mint); color: var(--green); border-color: var(--green); }
.study-tab        { background: var(--lavender-light); color: var(--dark-lavender); border-color: var(--lavender); }
.study-tab-active { background: var(--lavender-light); color: var(--dark-lavender); border-color: var(--lavender); }

/* Desktop study mode: hide input column, always show answers */
table.study-mode [data-sort-field="answer"] { display: none; }
table.study-mode .col-input { display: none; }
table.study-mode [data-answer],
table.study-mode.hide-answers [data-answer] {
  color: inherit !important;
  user-select: auto !important;
}

/* ── Table wrapper ── */
.table-wrapper {
  overflow: clip; /* clips border-radius corners without creating a scroll container, so sticky thead works */
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--white);
}

/* Inner scroll div used for conjugation tables on mobile */
.table-scroll-inner {
  overflow-x: auto;
}

/* ── Drill table ── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  border-bottom: none;
  /* Match th background so sub-pixel gaps between sticky cells (iOS Safari)
     don't show the page background through. */
  background: var(--medium-blue);
}

th {
  padding: 7px 10px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--white);
  white-space: nowrap;
  background: var(--medium-blue);
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--hover-bg);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

@media (hover: hover) {
  tr:hover td:not(.col-master) { background: var(--row-hover); }
  table tr.row-incorrect:hover td:not(.col-master) { background: rgba(255, 158, 151, 0.4); }
}

/* Row states */
table tr.row-incorrect td:not(.col-master) { background: rgba(255, 158, 151, 0.25); }

/* Brief green flash on the moment a correct answer is entered; fades so the table
   doesn't stay heavy. Triggered transiently from JS — does not re-fire on re-render. */
table tr.row-correct-flash td:not(.col-master) {
  animation: row-correct-flash 700ms ease-out;
}
@keyframes row-correct-flash {
  from { background: rgba(154, 234, 199, 0.55); }
  to   { background: transparent; }
}

/* Mastered row — grayed out, circle stays neutral */
table tr.row-mastered td:not(.col-master) { opacity: 0.35; }


/* Master circle buttons — absolutely positioned just outside the table's
   right edge. The container reserves room for them with padding-right so
   they don't push the page horizontally (which would shorten the sticky
   header). Mobile renders no master column, so the reserve is desktop-only. */
#table-container { position: relative; }
@media (min-width: 641px) {
  #table-container { padding-right: 36px; }
}
.master-btn-col {
  position: absolute;
  pointer-events: none;
  width: 28px;
}
.btn-master {
  position: absolute;
  left: 0;
  width: 28px;
  background: none;
  border: none;
  cursor: pointer;
  pointer-events: all;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
  transition: color 0.15s;
}
.btn-master:hover { color: var(--green); }

/* Badge column */
td.col-badge, th.col-badge-hd {
  width: 60px;
  text-align: center;
}

td.col-flag, th.col-flag {
  width: 32px;
  text-align: center;
  font-size: 1.1rem;
}

/* Number column */
td.col-num {
  width: 40px;
  color: var(--mid-gray);
  font-size: 0.8rem;
  text-align: center;
}

th.col-num {
  width: 40px;
  color: var(--white);
  font-size: 0.8rem;
  text-align: center;
}

/* Answer input */
.answer-input {
  width: 100%;
  min-width: 120px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--white);
  transition: border-color 0.15s;
}

.answer-input:focus {
  outline: none;
  border-color: var(--lavender);
  box-shadow: 0 0 0 2px rgba(163, 180, 252, 0.35);
}

/* ── Sentence-list tables (drill + edit) ───────────────────────────────────
   Sentence lists are a fourth, fully-isolated list type. These rules ONLY
   target table.edit-sentence and table.drill-sentence — vocab, conjugation,
   and grammar tables are untouched. (See feedback_sentence_list_isolation.md
   in user memory.)

   == Overall edit-view width: see #edit-view.is-sentence below ==

   == Column widths — adjust the percentages to taste ==
     Drill (5 cols):  # | English | Your Answer | Translation | result
     Edit  (5 cols):  # | English | Translation | Fragments    | × (delete)
   table-layout: fixed forces these widths; without it the long fragments
   placeholder would push columns past the table edge. */
/* table.drill-sentence intentionally does NOT use table-layout: fixed so that
   study mode can reflow naturally (the same way vocab does) when the answer
   column is hidden. The .col-num default of 40px from the generic rules
   higher up in this file already applies — no per-list override needed.
   table.edit-sentence DOES use fixed because the form table benefits from
   predictable, declared column proportions. */
table.edit-sentence { table-layout: fixed; }

/* Edit-only narrow utility columns. col-num gets a tighter sentence-specific
   width; col-del uses the generic .col-del default (36px) for column width
   but needs its horizontal padding zeroed out — the base td rule's 10px
   padding on each side leaves only 16px of content area inside the 36px
   column, which isn't enough for the ~22px × button. (Vocab edit doesn't
   show this because its table uses table-layout: auto, which lets the
   column grow past 36px; sentence edit uses table-layout: fixed and
   honors 36px strictly.) */
table.edit-sentence th.col-num,
table.edit-sentence td.col-num {
  width: 32px;
}

table.edit-sentence th.col-del,
table.edit-sentence td.col-del {
  padding-left: 0;
  padding-right: 0;
}

/* Edit column widths.  Fragments gets the largest slice because authored
   fragment strings are usually longer than the source/target sentences. */
table.edit-sentence th.col-sent-en { width: 24%; }
table.edit-sentence th.col-sent-tr { width: 28%; }
table.edit-sentence th.col-sent-fr { width: 42%; }

/* Textareas in the sentence-edit table: column width is fixed by the layout
   above, so the textarea fills 100% of its cell and wraps overflow. */
table.edit-sentence textarea.answer-input {
  resize: none;
  field-sizing: content;
  line-height: 1.4;
  vertical-align: middle;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Textareas in the sentence-drill table: the table uses auto layout (like
   vocab), so the textarea's min-width drives the "Your Answer" column width.
   320px gives plenty of room for typing a sentence without making the table
   overflow on typical desktops. */
table.drill-sentence textarea.answer-input {
  resize: none;
  field-sizing: content;
  line-height: 1.4;
  vertical-align: middle;
  width: 100%;
  min-width: 320px;
  max-width: 100%;
}

/* Widen the edit view's outer container so sentence tables get the same
   roomy treatment conjugation already gets. Matches #edit-view.is-conjugation
   max-width pattern. Set on the parent in buildSentenceEditView. */
#edit-view.is-sentence { max-width: 1040px; }

tr.row-incorrect .answer-input {
  border-color: var(--dark-red);
  background: var(--coral-light);
}

/* Sortable column headers */
th.sortable {
  cursor: pointer;
  user-select: none;
}
@media (hover: hover) {
  th.sortable:hover,
  th.col-num:hover { color: var(--white); background: var(--action-blue); cursor: pointer; }
}

th.sortable .sort-arrow {
  display: inline-block;
  margin-left: 5px;
  font-size: 0.7rem;
  opacity: 0.45;
}
th.sortable.sort-asc .sort-arrow,
th.sortable.sort-desc .sort-arrow { opacity: 1; color: var(--yellow); }

/* Icon buttons inside table headers */
.btn-eye,
.btn-shuffle-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 3px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
  vertical-align: middle;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.btn-eye { margin-left: 6px; }
.btn-eye:hover,
.btn-shuffle-header:hover { color: var(--white); background: rgba(255,255,255,0.2); }
/* Study mode: eye toggle is moot (answers always shown), so dim it and drop
   the hover affordance — still visible so the header doesn't look like it
   lost a control. */
.btn-eye:disabled,
.btn-eye:disabled:hover { color: rgba(255,255,255,0.3); background: none; cursor: default; }

/* Result cell — desktop wide enough to fit "Try Again" without pushing other columns;
   mobile overrides to 28px (just shows ✓/✕) below */
.col-result {
  width: 90px;
  text-align: center;
  font-size: 1rem;
}

/* Answer column */
td[data-answer] {
  font-style: italic;
  color: var(--charcoal);
  font-size: 0.95rem;
}

/* Hidden when answers not revealed, or the row is already correct */
table.hide-answers [data-answer],
[data-answer].answer-locked {
  color: transparent;
  user-select: none;
}

/* Try Again label */
.try-again {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--coral-dark);
  white-space: nowrap;
  cursor: pointer;
}
.try-again:hover { text-decoration: underline; }

/* Input cell with badge */
.input-with-badge { display: flex; align-items: center; gap: 8px; }
.input-with-badge .answer-input { flex: 1; min-width: 0; width: auto; }

/* Tag badges (ending, gender) */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--page-bg);
  color: var(--charcoal);
}

/* Verb ending colors — Spanish */
.badge-ar  { background: var( --badge-green);   color: var(--green); }
.badge-ir  { background: var(--badge-pink-bg);  color: var(--badge-pink); }
.badge-er  { background: var(--yellow-light); color: var(--amber); }

/* Verb ending colors — French */
.badge-re  { background: var(--badge-green);   color: var(--green); }
.badge-oir { background: var(--blue-light);  color: var(--action-blue); }

/* Gender colors — Spanish */
.badge-el  { background: var(--blue-light); color: var(--action-blue); }
.badge-los { background: var(--blue-light); color: var(--action-blue); }
.badge-la  { background: var(--badge-pink-bg); color: var(--badge-pink); }
.badge-las { background: var(--badge-pink-bg); color: var(--badge-pink); }

/* Gender colors — French */
.badge-le  { background: var(--blue-light); color: var(--action-blue); }

@media (max-width: 640px) {
  th, td { padding: 6px 8px; }
  table.drill-vocab td, table.drill-conj td { padding: 3px 8px; }

  /* Vocabulary table layout */
  #table-container { overflow-x: hidden; }
  table.drill-vocab { table-layout: fixed; width: 100%; }
  table.drill-vocab .col-num    { width: 28px; }
  table.drill-vocab .col-result { width: 28px; }
  table.drill-vocab .col-badge  { width: 44px; }
  table.drill-vocab th.col-result .btn-eye { margin-left: -10px; }

  /* Hide correct answer until eye icon is pressed */
  table.drill-vocab.hide-answers .mob-correct,
  table.drill-vocab .mob-correct.answer-locked { display: none; }

  /* Mobile answer cell: typed + correct answer inline, no extra row height */
  .col-mob-answer, .col-prompt { word-break: break-word; overflow-wrap: break-word; }
  .mob-typed   { color: var(--black); font-weight: 500; }
  .mob-correct { font-style: italic; color: var(--charcoal); font-size: 1rem; margin-left: 5px; }

  /* Active row highlight */
  tbody tr.mob-active td               { background: var(--lavender-light) !important; }
  tbody tr.mob-active.row-incorrect td { background: rgba(255,158,151,0.35) !important; }

  /* Result column icons */
  .mob-check { color: var(--green); font-weight: 700; font-size: 1rem; }
  .mob-retry { font-size: 1.1rem; font-weight: 700; }

  /* Font size boost to use space saved by reduced row padding */
  table.drill-vocab .col-prompt,
  table.drill-vocab .mob-typed   { font-size: 1rem; }

  /* Conjugation: compact, horizontally scrollable */
  table.drill-conj th            { padding: 5px 8px; }
  table.drill-conj td            { font-size: 0.88rem; }
  table.drill-conj .answer-input { min-width: 80px; }
}

/* ── Language toggle ── */
#landing { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

.lang-toggle-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.btn-lang {
  padding: 8px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--charcoal);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-lang.active { background: var(--green-xlight); color: var(--green); border-color: var(--medium-green); }
.btn-lang:not(.active):hover { background: var(--off-white); color: var(--charcoal); }
.btn-lang { display: inline-flex; align-items: center; gap: 6px; }
.lang-btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; border: 1.5px solid;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em;
  line-height: 1; font-family: inherit;
}
/* When icon is an emoji, show it without the badge background */
.lang-btn-icon--emoji { background: none !important; border: none !important; padding: 0; min-width: auto; font-size: 1.1rem; }

/* Landing page and admin tabs: compact icon-only on narrow screens, full label when there's space */
@media (max-width: 479px) {
  .lang-toggle-wrap .lang-btn-name,
  .admin-guest-lang-tabs .lang-btn-name,
  .admin-member-lang-tabs .lang-btn-name { display: none; }
  .lang-toggle-wrap .btn-lang,
  .admin-guest-lang-tabs .btn-lang,
  .admin-member-lang-tabs .btn-lang { padding: 6px 10px; }
}
/* Inactive language button — no badge, just muted text */
.btn-lang:not(.active) .lang-btn-icon {
  background: none !important;
  border-color: transparent !important;
  color: var(--mid-gray) !important;
}

/* Settings — language icon inputs */
.settings-lang-icons { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.settings-lang-icon-row { display: flex; align-items: center; gap: 10px; }
.settings-lang-icon-label { font-size: 0.9rem; color: var(--charcoal); width: 80px; }
.settings-lang-icon-input {
  width: 52px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 1rem; text-align: center; font-family: inherit;
}

/* ── Landing page ── */

.landing-section { margin-bottom: 36px; }

.landing-section h2 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green);
  margin-bottom: 12px;
}

.category-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.btn-category {
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--black);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

/* ── Section color themes ── */

/* Lavender — Vocabulary */
.section-lavender h2                    { color: var(--dark-lavender); }
.section-lavender .btn-category         { background: var(--lavender-light); border-color: var(--lavender-border); color: var(--dark-lavender); }
.section-lavender .btn-category:hover   { background: var(--lavender-border); border-color: var(--lavender-border); color: var(--black); box-shadow: 0 2px 10px rgba(163,180,252,0.45); }

/* Green — Verbs */
.section-green h2                       { color: var(--green); }
.section-green .btn-category            { background: var(--green-light); border-color: var(--green); color: var(--green); }
.section-green .btn-category:hover      { background: var(--green); border-color: var(--green); color: var(--white); box-shadow: 0 2px 10px rgba(17,80,53,0.3); }

/* Coral — Description */
.section-coral h2                       { color: var(--coral-dark); }
.section-coral .btn-category            { background: var(--coral-light); border-color: var(--coral); color: var(--coral-dark); }
.section-coral .btn-category:hover      { background: var(--coral); border-color: var(--coral); color: var(--black); box-shadow: 0 2px 10px rgba(255,158,151,0.45); }

/* Yellow — Functional Words */
.section-yellow h2                      { color: var(--dark-amber); }
.section-yellow .btn-category           { background: var(--yellow-light); border-color: var(--yellow); color: var(--dark-amber); }
.section-yellow .btn-category:hover     { background: var(--yellow); border-color: var(--yellow); color: var(--black); box-shadow: 0 2px 10px rgba(246,203,76,0.45); }

/* Blue — Conjugation */
.section-blue h2                        { color: var(--medium-blue); }
.section-blue .btn-category             { background: var(--blue-light); border-color: var(--medium-blue); color: var(--medium-blue); }
.section-blue .btn-category:hover       { background: var(--action-blue); border-color: var(--medium-blue); color: var(--white); box-shadow: 0 2px 10px rgba(62,122,243,0.35); }

/* ── Glossary landing section ── */
.section-glossary h2                    { color: var(--dark-pink); }
.section-glossary .btn-category         { background: var(--magenta-light); border-color: var(--glossary-border); color: var(--dark-pink); }
.section-glossary .btn-category:hover   { background: var(--medium-pink); border-color: var(--glossary-border); color: var(--white);box-shadow: 0 2px 10px rgba(91,61,158,0.3); }

/* ── Glossary view ── */
#glossary-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.glossary-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.glossary-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--near-black);
  margin: 0;
}

.glossary-count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--mid-gray);
  white-space: nowrap;
}

.glossary-search {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--white);
  outline: none;
}
.glossary-search:focus { border-color: var(--lavender); box-shadow: 0 0 0 2px rgba(163,180,252,0.3); }

.glossary-table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: clip;
}

.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.glossary-table thead th {
  background: var(--dark-pink);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--white);
  border-bottom: none;
}

.glossary-table tbody tr:not(:last-child) td { border-bottom: 1px solid var(--page-bg); }
.glossary-table tbody td { padding: 8px 16px; }
.glossary-table tbody tr:nth-child(even) { background: var(--surface); }

@media (max-width: 640px) {
  #glossary-view { padding: 16px 16px 48px; }
  .glossary-title { font-size: 1.1rem; }
  .glossary-table tbody td { padding: 7px 10px; }
}

/* ── Your Lists section ── */
.section-black h2                     { color: var(--black); }
.section-black .btn-category          { background: var(--off-white); border-color: var(--mid-gray); color: var(--black); }
.section-black .btn-category:hover    { background: var(--black); color: var(--white); border-color: var(--black); box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.btn-new-list          { background: transparent; border-style: dashed; border-color: var(--mid-gray); color: var(--charcoal); }
.btn-new-list:hover    { border-style: solid; }
.section-black .btn-new-list          { border-color: var(--mid-gray); color: var(--charcoal); }
.section-black .btn-new-list:hover    { background: var(--black); color: var(--white); border-color: var(--black); }

/* ── Drag and drop ── */
.btn-category[draggable="true"] { cursor: grab; }
.btn-category.dragging          { opacity: 0.4; cursor: grabbing; }
.landing-section.drag-over      { outline: 2px dashed rgba(0,0,0,0.25); outline-offset: -6px; border-radius: 12px; }
.section-drag-hint              { color: rgba(0,0,0,0.3); font-style: italic; font-size: 0.85rem; padding: 8px 4px; }
.landing-add-section            { margin-bottom: 36px; }

.btn-add-section-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--black);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.btn-add-section-label:hover { color: var(--charcoal); }

.custom-list-btn-group                { display: flex; align-items: stretch; }
.custom-list-btn-group .btn-category  { border-radius: 10px 0 0 10px; }
.btn-edit-list {
  display: flex; align-items: center; justify-content: center;
  padding: 0 10px;
  background: var(--off-white); border: 1px solid var(--mid-gray); border-left: none;
  border-radius: 0 10px 10px 0;
  cursor: pointer; color: var(--mid-gray);
  transition: color 0.15s, background 0.15s;
}
.btn-edit-list:hover { color: var(--black); background: var(--hover-bg); }

/* ── Edit view ── */
#edit-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}
/* Conjugation edit table has 5 input columns + #/× — needs more room than
   the vocab edit (which has 3 input cols + 2 narrow) to keep the × visible. */
#edit-view.is-conjugation { max-width: 1040px; }
table.edit-conj .answer-input { min-width: 80px; }

.edit-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.edit-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--black);
}

.edit-name-row { margin-bottom: 20px; }

.edit-name-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edit-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.edit-name-input {
  width: 100%;
  max-width: 420px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
}
.edit-name-input:focus {
  outline: none;
  border-color: var(--lavender);
  box-shadow: 0 0 0 2px rgba(163,180,252,0.35);
}

.edit-table-wrapper { margin-bottom: 12px; }

/* Editable column label input inside a th — looks like a header label until focused */
.edit-col-header-input {
  background: white;
  border: white;
  border-radius: 4px;
  color: black;
  font: inherit;
  width: 100%;
  text-align: left;
  outline: none;
  cursor: text;
  padding: 5px;
}

/* Narrow columns in edit table (Ending, Gender) */
.col-edit-narrow { width: 80px; }
.col-edit-narrow .answer-input { min-width: 0; text-align: center; }

/* Delete row button */
.col-del { width: 36px; text-align: center; }
.btn-del-row {
  background: none; border: none;
  color: var(--border); font-size: 1.1rem;
  cursor: pointer; 
  padding: 2px 6px; 
  border-radius: 4px;
  line-height: 1;
}
.btn-del-row:hover { color: var(--coral-dark); background: var(--danger-hover-bg); }

.edit-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.btn-delete {
  margin-left: auto;
  background: var(--coral-light);
  color: var(--dark-red);
  border: 1px solid var(--dark-red);
}
.btn-delete:not(:disabled):hover { filter: brightness(0.93); }

/* Library section management (Settings Admin box, Phase 4) */
.admin-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-section-header[draggable="true"] { cursor: grab; }
.admin-section-header .admin-guest-section-title {
  cursor: text;
  margin: 0;
}
.admin-section-rename-input {
  font: inherit;
  font-weight: 600;
  padding: 2px 6px;
  border: 1px solid var(--mid-gray);
  border-radius: 4px;
  min-width: 0;
}
.admin-new-section-btn {
  display: block;
  margin-top: 10px;
  padding: 4px 10px;
  font: inherit;
  font-weight: 600;
  color: var(--mid-gray);
  background: none;
  border: 1px dashed var(--mid-gray);
  border-radius: 6px;
  cursor: pointer;
}
.admin-new-section-btn:hover { color: var(--action-blue); border-color: var(--action-blue); }
.admin-guest-section.drag-over {
  outline: 2px dashed var(--action-blue);
  outline-offset: 2px;
  border-radius: 6px;
}
.admin-guest-row.dragging,
.admin-section-header.section-dragging { opacity: 0.5; }

/* Library list affordances on landing buttons (admins only) */
.btn-template {
  /* Promotion is still tracked (class applied by decorateAdminListButton) and
     the dot still anchors here — but no visual weight difference for now.
     Re-add a distinguishing style here when deciding how to mark promoted lists. */
  position: relative;   /* anchors the corner dot */
}
.admin-draft-dot {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--action-blue);
  border: 2px solid var(--white);   /* sits cleanly on the button border */
}

/* Stacked equal-width buttons in chooser modals (e.g. the library delete
   chooser) — overrides the edit-row margin-left:auto on btn-delete/promote */
.modal-choice-btn {
  margin: 0;
  width: 100%;
}

/* "Promote to Library" — admin action in edit mode (Template Library) */
.btn-promote {
  margin-left: auto;
  background: var(--action-blue);
  color: var(--white);
  border: 1px solid var(--action-blue);
}
.btn-promote:not(:disabled):hover { filter: brightness(0.93); }
.btn-promote:disabled { opacity: 0.4; cursor: not-allowed; }
/* When promote sits before delete in the row, only the first pushes right */
.btn-promote + .btn-delete { margin-left: 8px; }

/* Grammar page button color variants — button shape, tab color palette */
.btn-clr-edit  { background: var(--page-bg); color: var(--charcoal); border: 1px solid var(--mid-gray); }
.btn-clr-study { background: var(--lavender-light); color: var(--dark-lavender); border: 1px solid var(--lavender); }
.btn-clr-study-active { background: var(--lavender-light); color: var(--dark-lavender); border-color: var(--dark-lavender); }

.edit-error {
  color: var(--coral-dark);
  font-size: 0.9rem;
  margin-top: 12px;
}
@media (max-width: 640px) {
  #edit-view { padding: 16px 18px 260px; }
  .edit-table-wrapper { overflow: clip; }
  .col-edit-narrow { width: 60px; }
}

/* ── Mobile drill bar (fixed, always visible during drill) ── */
#mobile-drill-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 2px solid var(--lavender);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
  transition: border-top-color 0.2s, background 0.2s;
}
#mobile-drill-bar[data-result="correct"]   { border-top-color: var(--green); background: var(--green-light); }
#mobile-drill-bar[data-result="incorrect"] { border-top-color: var(--coral); background: var(--blue-light); }

.mob-bar-prompt {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--black);
}
.mob-bar-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mob-bar-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--lavender);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: var(--white);
  outline: none;
}
.mob-bar-input:focus {
  border-color: var(--grammar-input-focus);
  box-shadow: 0 0 0 2px rgba(163,180,252,0.35);
}
.mob-bar-submit {
  padding: 10px 16px;
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.mob-bar-submit:active { filter: brightness(0.85); }

/* ── Mobile edit bar (fixed, always visible in edit view on mobile) ── */
#mobile-edit-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--white);
  border-top: 2px solid var(--lavender);
  padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
}

.mob-edit-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mob-edit-row-num {
  flex: 1;
  font-size: 0.8rem;
  color: var(--mid-gray);
}

.mob-edit-action-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.mob-edit-action-btn:not(.mob-edit-del-btn):not(.mob-edit-save-btn) { background: var(--mint); color: var(--green); border: 1px solid var(--green); }
.mob-edit-save-btn { background: var(--yellow); color: var(--black); border: 1px solid var(--amber); }
.mob-edit-del-btn  { background: var(--coral-light); color: var(--dark-red); border: 1px solid var(--dark-red); }
.mob-edit-action-btn:active { filter: brightness(0.88); }

.mob-edit-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mob-edit-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mob-edit-label {
  width: 44px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mid-gray);
}

.mob-edit-input {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 16px;
  font-family: inherit;
  background: var(--white);
  outline: none;
}
.mob-edit-input:focus { border-color: var(--lavender); box-shadow: 0 0 0 2px rgba(163,180,252,0.3); }
.mob-edit-badge-input { max-width: 90px; flex: none; }
.mob-edit-flag-input  { max-width: 60px; flex: none; text-transform: uppercase; }

.flag-info-btn {
  background: none; border: none; padding: 0 0 0 4px;
  cursor: pointer; font-size: 0.85rem; color: var(--white);
  opacity: 0.7; line-height: 1; vertical-align: middle;
}
.flag-info-btn:hover { opacity: 1; }

.flag-info-popover {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 900;
  background: var(--white);
  border: 1px solid var(--mid-gray);
  border-radius: 8px;
  padding: 14px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  min-width: 200px;
  max-height: 75vh;
  overflow-y: auto;
}
.flag-info-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--charcoal);
  margin-bottom: 8px;
}
.flag-info-table { border-collapse: collapse; width: 100%; }
.flag-info-table td { padding: 3px 6px; font-size: 0.9rem; white-space: nowrap; }
.flag-info-code { font-family: monospace; font-weight: 600; color: var(--charcoal); }

.mob-edit-placeholder { color: var(--border); font-style: italic; }

/* ── Quiz mode ── */
#quiz-view {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 48px;
}

.quiz-progress {
  font-size: 0.9rem;
  color: var(--mid-gray);
  font-weight: 500;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
}

.quiz-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--near-black);
  line-height: 1.2;
}

.quiz-context {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--mid-gray);
}

.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 480px;
}

.quiz-btn {
  padding: 20px 16px;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  color: var(--near-black);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

@media (hover: hover) {
  .quiz-btn:hover:not(:disabled) {
    border-color: var(--lavender);
    background: var(--lavender-light);
  }
}

.quiz-btn:disabled { cursor: default; }

.quiz-btn.quiz-correct {
  border-color: var(--mint-dark);
  background: var(--badge-green);
  color: var(--medium-green);
}

.quiz-btn.quiz-wrong {
  border-color: var(--dark-red);
  background: var(--coral-light);
  color: var(--dark-red);
}

.quiz-icon { font-weight: 700; margin-left: 4px; }

/* Completion screen */
.quiz-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 60px;
  text-align: center;
}

.quiz-complete-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green);
}

.quiz-complete-score {
  font-size: 1.15rem;
  color: var(--charcoal);
}

.quiz-complete-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}
.quiz-retry-wrap {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.quiz-review {
  width: 100%;
  max-width: 480px;
  margin: 32px auto 0;
}

.quiz-review-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dark-red);
  margin-bottom: 10px;
}

.quiz-review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.quiz-review-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--coral-light);
  color: var(--charcoal);
  vertical-align: top;
}

.quiz-review-table td:first-child {
  color: var(--charcoal);
  width: 50%;
}

.quiz-review-table td:last-child {
  font-weight: 600;
  color: var(--near-black);
}

.quiz-review-table tr:last-child td {
  border-bottom: none;
}

.quiz-review-ctx {
  font-size: 0.8em;
  color: var(--mid-gray);
  margin-left: 4px;
}

@media (max-width: 640px) {
  #quiz-view { padding: 16px 18px 48px; }
  .quiz-header { margin-bottom: 32px; }
  .quiz-prompt { font-size: 1.7rem; }
  .quiz-btn { padding: 16px 12px; font-size: 0.95rem; }
}

/* ── Quiz dropdown menu ── */
.quiz-menu {
  position: relative;
}

.quiz-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  min-width: 160px;
  overflow: hidden;
}

.quiz-drop-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--near-black);
}

.quiz-drop-item:hover:not(:disabled) { background: var(--off-white); }
.quiz-drop-item:disabled { opacity: 0.4; cursor: default; }

/* ── Gender drill buttons ── */
.gender-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 480px;
}

.gender-btn {
  padding: 20px 16px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  text-align: center;
  line-height: 1.3;
}

/* default: neutral background, colored text + outline to signal gender */
.gender-btn { background: var(--white); }
.gender-btn-el,
.gender-btn-los,
.gender-btn-le  { color: var(--action-blue); border-color: var(--light-blue); }

.gender-btn-la,
.gender-btn-las { color: var(--badge-pink); border-color: var(--medium-pink); }

.gender-btn-les { color: var(--near-black); border-color: var(--border); }

.gender-btn:disabled { cursor: default; }

.gender-btn.gender-correct {
  border-color: var(--medium-green);
  background: var(--badge-green);
  color: var(--medium-green);
}
.gender-btn.gender-wrong {
  border-color: var(--dark-red);
  background: var(--coral-light);
  color: var(--dark-red);
}

@media (max-width: 640px) {
  .gender-btn { padding: 16px 12px; font-size: 0.95rem; }
}

/* ── Word Builder ── */
.wb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.wb-btn {
  padding: 12px 6px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--near-black);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  text-align: center;
  word-break: break-all;
}

@media (hover: hover) {
  .wb-btn:not(.wb-selected):hover:not(:disabled) {
    border-color: var(--lavender);
    background: var(--lavender-light);
  }
}

.wb-btn:disabled { cursor: default; }

.wb-btn.wb-selected {
  background: var(--blue-light);
  border-color: var(--medium-blue);
  color: var(--medium-blue);
}

.wb-word-display {
  /* min-height sized to fit one row of chips without growth — keeps the
     underline from shifting when the first chip is added or a new word/sentence
     loads. Chip ≈ 30px (1rem text + 1.2 line-height + 4px padding + 1.5px
     border); container padding 8+8 = 16; 52 - 16 = 36px content room. */
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  padding: 8px 0;
  border-bottom: 2px solid var(--border);
}

.wb-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 5px;
  border-radius: 10px;
  background: var(--blue-light);
  border: 1.5px solid var(--medium-blue);
  color: var(--medium-blue);
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.wb-word-display.wb-correct .wb-chip {
  background: var(--badge-green);
  border-color: var(--mint-dark);
  color: var(--medium-green);
}

.wb-skip-row {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

/* ── Sentence Builder ── */
/* Matches Word Builder's visual language: 4-column grid of equal-size buttons
   and a built-sentence display that's just text above a horizontal underline
   (no boxed background). */
.sb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 560px;
}

.sb-btn {
  padding: 12px 6px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--near-black);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  text-align: center;
  word-break: break-word;  /* allow long fragments to wrap inside the button */
  min-width: 0;            /* let grid 1fr cell decide width, not content */
}

@media (hover: hover) {
  .sb-btn:not(.sb-selected):hover:not(:disabled) {
    border-color: var(--lavender);
    background: var(--lavender-light);
  }
}

.sb-btn:disabled { cursor: default; }

.sb-btn.sb-selected {
  background: var(--blue-light);
  border-color: var(--medium-blue);
  color: var(--medium-blue);
}

.sb-built-display {
  /* min-height sized to fit one row of chips without growth — see the same
     comment on .wb-word-display above. */
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  padding: 8px 0;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
  transition: border-color 0.2s;
}

/* Chip styles mirror .wb-chip (Word Builder). Each selected fragment renders
   as a chip; chips that begin a new word-group (i.e. follow a || in the
   answer's fragment string) get an extra left margin so word boundaries
   read as visual spaces. */
.sb-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 5px;
  border-radius: 10px;
  background: var(--blue-light);
  border: 1.5px solid var(--medium-blue);
  color: var(--medium-blue);
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.sb-chip.sb-chip-newword { margin-left: 0.45em; }

.sb-built-display.sb-correct .sb-chip {
  background: var(--badge-green);
  border-color: var(--mint-dark);
  color: var(--medium-green);
}

.sb-skip-row {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

@media (max-width: 640px) {
  .sb-btn { padding: 10px 6px; font-size: 0.92rem; min-height: 44px; }
  .sb-grid { max-width: 100%; }
  .sb-built-display { font-size: 1rem; max-width: 100%; }
}

@media (max-width: 640px) {
  .wb-btn { padding: 12px 8px; font-size: 0.9rem; min-height: 44px; }
}

/* ── Header gear icon ── */
.header-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(var(--fur-ink-rgb), 0.75);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.header-gear:hover {
  color: var(--fur-ink);
  background: rgba(var(--fur-ink-rgb), 0.12);
}
.header-gear { position: relative; }
.gear-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--action-blue);
  border: 1.5px solid var(--white);
}

/* ── Update banner ── */
/* Compound selector (.settings-section.update-banner-settings) so the blue
   fill + border beat the later, equal-specificity .settings-section base rule. */
.settings-section.update-banner-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--near-black);
  background: var(--blue-light);
  border: 1px solid var(--action-blue);
}
.update-banner-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--action-blue);
}
.update-banner-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--near-black);
}
.update-banner-lang { font-weight: 700; color: var(--action-blue); }
.update-banner-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.9rem;
}
.update-banner-list li {
  margin: 2px 0;
}
.update-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.update-banner-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: var(--action-blue);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.update-banner-btn:hover { filter: brightness(0.93); }
.update-banner-btn:disabled { opacity: 0.6; cursor: default; }
.update-banner-btn-secondary {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--mid-gray);
  background: var(--off-white);
  color: var(--charcoal);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s;
}
.update-banner-btn-secondary:hover { filter: brightness(0.95); }
.update-banner-btn-secondary:disabled { opacity: 0.6; cursor: default; }

/* ── Shared with you (pending list shares) ── */
/* Styled like the other settings sections: uppercase dark-green title (via
   .settings-section-title), neutral body text — not the blue updates banner. */
.share-inbox-section { display: flex; flex-direction: column; gap: 12px; }
.share-inbox-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.share-inbox-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.share-inbox-text { font-size: 0.9rem; color: var(--near-black); }
.share-inbox-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-inbox-links { font-size: 0.8rem; }
.share-inbox-links a { color: var(--mid-gray); text-decoration: underline; cursor: pointer; }
.share-inbox-links a:hover { color: var(--charcoal); }
.share-inbox-sep { color: var(--light-gray); margin: 0 4px; }

/* Privacy & Notifications */
.settings-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--near-black);
  margin: 6px 0;
  cursor: pointer;
}
.settings-checkbox-row input { cursor: pointer; }
.blocked-list { list-style: none; padding: 0; margin: 6px 0; font-size: 0.85rem; color: var(--charcoal); }
.blocked-list li { padding: 2px 0; }

/* Admin Reports subsection */
.report-row { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.report-row:last-of-type { border-bottom: none; }
.report-meta { color: var(--near-black); }
.report-reason { color: var(--mid-gray); font-style: italic; margin: 4px 0; }
.report-links { font-size: 0.8rem; margin-top: 2px; }
.report-view-link, .report-resolve-link { font-size: 0.8rem; text-decoration: underline; color: var(--action-blue); cursor: pointer; }
.report-content {
  margin: 8px 0 0;
  padding: 10px;
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: pre;
  overflow-x: auto;
}

/* ── Guest mode ── */
.auth-guest-row {
  margin-top: 16px;
  text-align: center;
}
.auth-guest-btn {
  font-size: 0.85rem;
  color: var(--black);
}
.auth-guest-btn:hover { 
  color: var(--black);
  background: var(--yellow);
 }

.guest-cta {
  text-align: center;
  padding: 20px;
  background: var(--blue-light);
  border-radius: 12px;
  border: 1px solid var(--light-blue);
}
.guest-cta-text {
  margin: 0 0 12px;
  color: var(--near-black);
  font-size: 0.95rem;
}
.guest-cta-btn {
  background: var(--action-blue);
  color: var(--white);
  border: 1px solid var(--medium-blue);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
}
.guest-cta-btn:hover { filter: brightness(0.93); }

/* ── Settings view ── */
#settings-view {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 24px 64px;
}

/* Anchored scroll offset so a clicked TOC link clears the sticky header. */
.settings-section { scroll-margin-top: 70px; }

/* Sticky settings section nav — hidden by default; only appears on wide enough
   screens where it fits in the left gutter of the 680px-centered content, so it
   never reflows the page. Anchored to the content's left edge via calc. */
#settings-toc { display: none; }
@media (min-width: 1200px) {
  #settings-toc {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: fixed;
    top: 96px;
    left: calc((100vw - 680px) / 2 - 204px);  /* 180px width + 24px gap to content */
    width: 180px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    z-index: 50;
  }
  .settings-toc-link {
    display: block;
    padding: 6px 10px;
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--charcoal);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 6px 6px 0;
  }
  .settings-toc-link:hover { background: var(--off-white); }
  .settings-toc-link.active {
    color: var(--action-blue);
    font-weight: 700;
    border-left-color: var(--action-blue);
    background: var(--blue-light);
  }
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.settings-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--near-black);
  margin: 0;
}

.settings-section {
  background: var(--white);
  border: 1px solid var(--hover-bg);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.settings-section-admin {
  border-color: var(--action-blue);
  background: var(--blue-light);
}
.settings-section-admin .settings-section-title { color: var(--action-blue); }

/* Admin: public lists toggles */
.settings-hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--mid-gray);
}
.admin-guest-lang-tabs,
.admin-member-lang-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.admin-guest-section {
  margin-bottom: 10px;
}
.admin-guest-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--mid-gray);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.admin-guest-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 0.9rem;
}
.admin-list-dirty-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--coral-dark);
  background: var(--coral-light);
  padding: 2px 6px;
  border: 1px solid var(--coral-dark);
  border-radius: 4px;
  white-space: nowrap;
}
.admin-guest-toggle {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--action-blue);
}

.settings-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--green);
  margin: 0 0 8px;
}

.settings-section-subtitle {
  font-size: 0.85rem;
  color: var(--mid-gray);
  margin: 0 0 20px;
}

.settings-section-title + .settings-field,
.settings-section-title + .settings-section-subtitle + .settings-field,
.settings-section-title:not(:has(+ .settings-section-subtitle)) {
  margin-top: 16px;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--off-white);
  margin: 20px 0;
}

.settings-field {
  margin-bottom: 16px;
}

.settings-field:last-child { margin-bottom: 0; }

.settings-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.settings-input {
  width: 100%;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--near-black);
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.settings-input:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 2px rgba(154,234,199,0.3);
}

.settings-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.settings-btn:disabled { opacity: 0.4; cursor: default; }
.settings-btn:not(:disabled):hover { filter: brightness(0.93); }

.settings-btn-primary {
  background: var(--mint);
  color: var(--green);
  border: 1px solid var(--green);
}

.settings-btn-secondary {
  background: var(--action-blue);
  color: var(--white);
  border: 1px solid var(--action-blue);
}

.settings-btn-restore {
  background: var(--page-bg);
  color: var(--charcoal);
  border: 1px solid var(--mid-gray);
}

.settings-region-lang-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
#settings-region-checkboxes { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.region-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  min-height: 44px; /* full-row tap target so the small checkbox isn't the only hit area */
  font-size: 0.95rem;
  color: var(--charcoal);
  cursor: pointer;
}
.region-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--action-blue);
  flex-shrink: 0;
}

.settings-btn-danger {
  background: var(--coral-light);
  color: var(--coral-dark);
  border: 1px solid var(--dark-red);
}
.settings-btn-danger:not(:disabled):hover {
  filter: none;
  background: var(--danger-hover-bg);
}

.settings-message {
  font-size: 0.85rem;
  color: var(--green);
  margin-top: 8px;
  min-height: 18px;
}

.settings-error {
  font-size: 0.85rem;
  color: var(--dark-red);
  margin-top: 8px;
  min-height: 18px;
}
/* Empty message/error placeholders shouldn't reserve height — otherwise a
   trailing empty one (e.g. Account's delete error) adds uneven space at the
   bottom of a section, making the gap above the next header look inconsistent. */
.settings-message:empty, .settings-error:empty { min-height: 0; margin-top: 0; }
/* Muted empty-state line ("No reports pending", etc.). */
.settings-empty { font-size: 0.85rem; color: var(--mid-gray); font-style: italic; margin: 8px 0 0; }

/* File input for CSV import */
.settings-file-input {
  display: none;
}

.settings-file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--action-blue);
  color: var(--white);
  border: 1px solid var(--action-blue);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s;
}
.settings-file-label:hover { filter: brightness(0.93); }

.settings-file-name {
  font-size: 0.85rem;
  color: var(--charcoal);
  font-style: italic;
}

/* Import progress bar */
.import-progress-wrap {
  width: 100%;
  height: 18px;
  border-radius: 9px;
  background: var(--border);
  overflow: hidden;
  margin-top: 10px;
}

.import-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 9px;
  background: repeating-linear-gradient(
    -45deg,
    var(--action-blue) 0px,
    var(--action-blue) 10px,
    var(--white)    10px,
    var(--white)    20px
  );
  background-size: 28px 28px;
  animation: import-stripes 0.6s linear infinite;
  transition: width 0.15s ease;
}

@keyframes import-stripes {
  from { background-position: 0 0; }
  to   { background-position: 28px 0; }
}

/* Backups */
.backup-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--off-white);
}
.backup-item:last-child { border-bottom: none; padding-bottom: 0; }
.backup-item:first-child { padding-top: 0; }

.backup-date {
  flex: 1;
  font-size: 0.9rem;
  color: var(--charcoal);
}

.backup-empty {
  font-size: 0.9rem;
  color: var(--mid-gray);
  font-style: italic;
}

@media (max-width: 640px) {
  #settings-view { padding: 16px 14px 64px; }
  .settings-section { padding: 18px 16px; }
  .settings-input { max-width: 100%; }
}

/* ── Add Section inline form ─────────────────────────────────────────── */
.add-section-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  margin-bottom: 10px;
}

.add-section-input {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  width: 280px;
  max-width: 100%;
  transition: border-color 0.15s;
}

.add-section-input:focus {
  border-color: var(--grammar-input-focus);
  box-shadow: 0 0 0 2px var(--grammar-focus-ring);
}

.add-section-input.input-error {
  border-color: var(--coral-dark);
  animation: shake 0.25s;
}

/* Phase F: color swatch inside the rename form. Click cycles palette. */
.section-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, border-color 0.15s;
}
.section-color-swatch:hover { transform: scale(1.1); }
.section-color-swatch.swatch-lavender { background: var(--lavender-light); border-color: var(--lavender-border);}
.section-color-swatch.swatch-green    { background: var(--green-light); border-color: var(--green);}
.section-color-swatch.swatch-coral    { background: var(--coral-light); border-color: var(--coral);}
.section-color-swatch.swatch-yellow   { background: var(--yellow-light); border-color: var(--yellow);}
.section-color-swatch.swatch-blue     { background: var(--blue-light); border-color: var(--medium-blue); }

/* Phase F: section drag affordances. Header is the drag handle. */
.landing-section h2 { cursor: grab; }
.landing-section h2:active { cursor: grabbing; }
.landing-section.section-dragging,
.landing-section h2.section-dragging { opacity: 0.5; }
.landing-section.section-drop-over {
  outline: 2px dashed var(--lavender);
  outline-offset: -2px;
}
/* Don't let "Your Lists" / "List Search" / "Glossary" headers look draggable —
   only editable section headers in the unified loop are reorderable. */
.section-black h2,
.landing-list-search h2,
.section-glossary h2,
.landing-add-section h2 { cursor: default; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* ── Grammar drill ────────────────────────────────────────────────────── */
.grammar-drill-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 4px 0 32px;
}

/* Grammar tab row: mirrors controls-bottom — same btn sizes, same layout */
.grammar-tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

/* Grammar group: plain container, title sits above the table-wrapper */
/* Spacing between groups is handled by .grammar-drill-container gap: 32px */

/* Title outside the bordered box, matches section headings */
/* Proportional widths for fewer-column grammar tables — desktop only */
@media (min-width: 641px) {
  .grammar-group-2col { max-width: 67%; }
  .grammar-group-1col { max-width: 34%; }
}

.grammar-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--near-black);
  margin: 0 0 6px 0;
  padding: 0;
  letter-spacing: 0.01em;
}

/* Table inherits global th (blue) and td styles; only add grammar-specific overrides */
.grammar-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Response column headers: centered */
.grammar-table th.grammar-col-header {
  text-align: center;
}

/* Color swatch in edit-form column headers */
.grammar-edit-col-th {
  position: relative;
  padding-right: 22px !important; /* room for swatch at right edge */
}
.grammar-col-color-swatch {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--mid-gray);
  cursor: pointer;
  display: block;
  flex-shrink: 0;
}
.grammar-col-color-swatch input[type="color"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* Pronoun column header: narrower, left-aligned (inherits global th) */
.grammar-table th.grammar-pronoun-col {
  width: 90px;
}

/* Pronoun data cells: left-aligned, bold, no input */
.grammar-table td.grammar-pronoun {
  font-weight: 500;
  white-space: nowrap;
  width: 90px;
}

/* Response cells: centered, compact padding */
.grammar-table td.grammar-cell {
  text-align: center;
  padding: 5px 8px;
}

.grammar-input {
  width: 100%;
  min-width: 70px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 1rem;
  font-family: inherit;
  text-align: center;
  background: var(--white);
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}

.grammar-input:focus {
  border-color: var(--grammar-input-focus);
  box-shadow: 0 0 0 2px var(--grammar-focus-ring);
}

.grammar-input.grammar-correct {
  background: var(--green-light);
  border-color: var(--mint);
  color: var(--medium-green);
}

.grammar-input.grammar-incorrect {
  background: var(--coral-light);
  border-color: var(--coral);
  color: var(--coral-dark);
}

/* Revealed (empty cells shown after Check): no border, no bg — plain readable text */
.grammar-input.grammar-revealed {
  background: transparent;
  border-color: transparent;
  color: var(--near-black);
}

/* Study mode: correct answers shown in plain black, no border */
.grammar-input.grammar-study {
  background: transparent;
  border-color: transparent;
  color: var(--near-black);
}

/* Footer: outside the table-wrapper, score + action button */
.grammar-group-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 2px 0;
  flex-wrap: wrap;
}

.grammar-score-perfect {
  font-size: 0.85rem;
  color: var(--medium-green);
  font-weight: 600;
}

.grammar-score-partial {
  font-size: 0.85rem;
  color: var(--mid-gray);
}

.grammar-action-btn {
  margin-left: auto;
  font-size: 0.85rem;
  padding: 5px 14px;
}

/* ── Grammar edit view ────────────────────────────────────────────────── */
.grammar-edit-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 24px;
  overflow: hidden;
}

.grammar-edit-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--medium-blue);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.grammar-edit-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
}

.grammar-delete-table {
  font-size: 0.8rem;
  padding: 3px 8px;
  white-space: nowrap;
}

.grammar-edit-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.grammar-edit-table {
  width: max-content; /* shrink to content, scroll if needed */
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.grammar-edit-table th,
.grammar-edit-table td {
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.grammar-edit-table .btn-del-row { color: var(--mid-gray); }
/* Global .answer-input has min-width: 120px which pushes the table wider than
   needed (pronouns are 2–4 chars), shoving the col-del × past the scroll edge.
   Let cells shrink to content; the cell's own min-width: 48px is the floor. */
.grammar-edit-table .answer-input { min-width: 0; }

.grammar-edit-table thead th {
  background: var(--blue-light);
  color: var(--near-black); /* override global th white — headers sit on near-white background */
}

/* Pronoun column stays narrow */
.grammar-edit-table .grammar-pronoun-col {
  width: 1px; /* shrink-wrap to content */
  white-space: nowrap;
}

/* Response/header columns: no fixed width, just a small minimum */
.grammar-edit-table td,
.grammar-edit-table th:not(.grammar-pronoun-col) {
  min-width: 48px;
}

.grammar-header-input {
  width: 100%;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  min-width: 60px;
}

.grammar-edit-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
}

.grammar-edit-block .grammar-add-row {
  margin: 8px 12px;
  font-size: 0.85rem;
}

/* ── Sentence edit view ───────────────────────────────────────────────── */
/* Tabular layout matching vocab/conjugation edit tables — # | English |
   Translation | Fragments | × on desktop; mobile collapses to 4 read-only
   cells (# | English | Translation | Frags preview) with the floating
   mobile-edit-bar handling input. */
table.edit-sentence { width: 100%; }

/* table.edit-sentence .edit-th-hint {
  font-weight: 400;
  color: var(--white);
  font-size: 0.78rem;
}
table.edit-sentence .edit-th-hint code {
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  color: var(--white);
} */


.mob-edit-frags-cell {
  font-size: 0.85rem;
  color: var(--charcoal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

@media (max-width: 640px) {
  .grammar-table th { padding: 6px 6px; font-size: 0.85rem; white-space: normal; word-break: break-word; }
  .grammar-table td { padding: 3px 6px; font-size: 1rem; }
  .grammar-input    { font-size: 1rem; min-width: 50px; padding: 1px 8px; }
  .grammar-table .grammar-pronoun-col { width: 70px; }

  /* Edit table: compact on mobile, scrolls horizontally if needed */
  .grammar-edit-table th,
  .grammar-edit-table td { padding: 4px 4px; font-size: 0.8rem; }
  .grammar-edit-table td,
  .grammar-edit-table th:not(.grammar-pronoun-col) { min-width: 0; }
  .grammar-header-input,
  .grammar-edit-pronoun,
  .grammar-edit-resp { font-size: 0.8rem; padding: 4px 4px; min-width: 0; width: 100%; }
}

/* ── App footer ── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  margin-top: 32px;
  border-top: 1px solid var(--page-bg);
  font-size: 0.8rem;
  color: var(--mid-gray);
}

.footer-link {
  color: var(--mid-gray);
  text-decoration: none;
}
.footer-link:hover { color: var(--charcoal); text-decoration: underline; }

.footer-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

.footer-sep { user-select: none; }

/* ── Feedback modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal-card {
  background: var(--white);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--action-blue);
  margin: 0;
}
.modal-title--danger { color: var(--coral-dark); }
.modal-confirm-text { margin: 0 0 20px; line-height: 1.5; }

.feedback-success {
  text-align: center;
  color: var(--green);
  font-size: 1rem;
  padding: 20px 0;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--mid-gray);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--charcoal); background: var(--hover-bg); }

.modal-body { display: flex; flex-direction: column; gap: 14px; }

.modal-field { display: flex; flex-direction: column; gap: 4px; }

.modal-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--charcoal);
}

.modal-input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--near-black);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}
.modal-input:focus { border-color: var(--action-blue); box-shadow: 0 0 0 3px rgba(47,110,213,0.1); }

.modal-textarea { resize: vertical; min-height: 100px; }

.modal-error {
  font-size: 0.85rem;
  color: var(--dark-red);
  min-height: 1.2em;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-submit { padding: 10px 24px; }

/* Short explanatory line under a modal title (e.g. share-list modal). */
.modal-subtitle { color: var(--mid-gray); font-size: 0.9rem; margin: 0 0 14px; }

/* Share-this-list button below the drill table — right edge aligns with the
   table. #table-container reserves 36px on the right (desktop) for the mastery
   overlay; match that here so flex-end lands on the table edge, not the buttons. */
#share-list-bar { display: flex; justify-content: flex-end; margin: 12px 0 4px; }
@media (min-width: 641px) { #share-list-bar { padding-right: 36px; } }
.drill-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--white);
  background: var(--action-blue);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s;
}
.drill-share-btn:hover { filter: brightness(0.93); }
.drill-share-btn svg { display: block; }

@media (max-width: 640px) {
  .modal-card { padding: 24px 20px; }
}

/* ── Modal content helpers ── */
.modal-content { padding: 1.5rem; font-size: 0.95rem; line-height: 1.6; }
.modal-list { margin: 1rem 0; padding-left: 1.5rem; }
.modal-list li { margin-bottom: 0.5rem; }
.modal-section-title { margin-top: 1.5rem; margin-bottom: 0.5rem; font-weight: 600; }
.modal-note { margin-top: 1rem; font-size: 0.85rem; color: var(--charcoal); }

/* ── Fragments info modal specific ── */
.fragments-example-code {
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
}
.fragments-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 560px;
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
}
.fragments-preview-button {
  padding: 12px 6px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--black);
  cursor: pointer;
  text-align: center;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
  max-width: 90vw;
}
.toast {
  padding: 10px 16px;
  border: 1px solid var(--medium-blue);
  border-radius: 8px;
  background: var(--blue-light);   /* default = general info (light blue, dark blue border) */
  color: var(--medium-blue);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: auto;
  animation: toast-slide-in 200ms ease-out;
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.toast-error   { background: var(--coral-dark); color: var(--white); border-color: var(--coral-dark); }  /* warnings / errors (red) */
.toast-success { background: var(--green); color: var(--white); border-color: var(--green); }            /* positive confirmations (green) */
.toast-leaving { opacity: 0; transform: translateY(-8px); }
@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading spinner overlay ── */
.app-spinner-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.5);
  z-index: 1500;
}
.app-spinner-inner {
  width: 36px; height: 36px;
  border: 3px solid rgba(85, 64, 163, 0.15);
  border-top-color: var(--dark-lavender);
  border-radius: 50%;
  animation: app-spinner-spin 800ms linear infinite;
}
@keyframes app-spinner-spin { to { transform: rotate(360deg); } }

/* ── List Search (Phase D.3) ── */
.landing-list-search { color: var(--black); }
.landing-list-search h2 { color: var(--black); }
.list-search-subtitle {
  margin: 4px 0 12px;
  font-size: 0.9rem;
  color: var(--black);
}
.list-search-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.list-search-input {
  flex: 0 1 280px;
  max-width: 280px;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--white);
}
.list-search-input:focus {
  outline: 2px solid var(--lavender);
  outline-offset: -1px;
}
.list-search-btn { flex-shrink: 0; }
.list-search-clear-btn { flex-shrink: 0; }
.list-search-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Utility classes ── */
/* Empty-state messaging — centered block used by quizzes, glossary, and any
   other view that needs a "nothing here yet" placeholder. */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}
.empty-state-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.empty-state-message {
  color: var(--mid-gray);
}
/* Result cards mirror .btn-category sizing/shape so they sit visually with
   the user's own lists. Dashed border signals "addable"; solid border once
   added; lavender-tinted for "apply updates?". */
.list-search-result {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--white);
  border: 2px dashed var(--lavender-border);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, filter 0.15s;
}
.list-search-result:hover:not(:disabled) {
  background: var(--lavender-light);
  filter: brightness(0.97);
}
.list-search-result:disabled { cursor: default; }
.list-search-result-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--black);
}
.list-search-result-meta {
  font-size: 0.75rem;
  color: var(--mid-gray);
}
.list-search-result-updates {
  border-color: var(--dark-lavender);
}
.list-search-result-added {
  border-style: solid;
  border-color: var(--border);
  opacity: 0.65;
}
.list-search-empty {
  margin: 8px 0;
  font-size: 0.9rem;
  color: var(--mid-gray);
  font-style: italic;
}

/* ── Welcome tour modal ────────────────────────────────────────────────── */
.welcome-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.welcome-modal {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.welcome-modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--mid-gray);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.welcome-modal-close:hover { color: var(--charcoal); background: var(--hover-bg); }
.welcome-modal-body {
  padding: 36px 32px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  /* Keep this scroll area from chaining to the page (iOS rubber-band bounce). */
  overscroll-behavior: contain;
}
.welcome-modal-body--centered {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}
.welcome-modal-image-wrap:empty { display: none; }
.welcome-modal-title {
  margin: 0 0 16px;
  font-size: 1.4rem;
  color: var(--charcoal);
  font-weight: 700;
}
.welcome-modal-image-wrap {
  margin: 0 0 16px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.welcome-modal-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.welcome-modal-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--charcoal);
}
.welcome-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--light-gray);
  gap: 12px;
  flex-wrap: wrap;
}
.welcome-modal-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.welcome-modal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.15s;
}
.welcome-modal-dot.active { background: var(--green); }
.welcome-modal-nav {
  display: flex;
  gap: 8px;
}
.welcome-modal-nav button { min-width: 72px; }

@media (max-width: 640px) {
  .welcome-modal-image-wrap { height: 220px; }
  .welcome-modal-body { min-height: 380px; }
}
@media (min-width: 641px) {
  .welcome-modal-body { min-height: 460px; }
}

/* ── Conjugation MC quiz filter screen ─────────────────────────────────── */
.cqf-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}
.cqf-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0.5rem 0 0.5rem;
}
.cqf-subtitle {
  margin: 0 0 1.5rem;
  color: var(--mid-gray);
  font-size: 0.95rem;
}
.cqf-section {
  margin-bottom: 1.5rem;
}
.cqf-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
/* Match .landing-section h2 — small green uppercase label */
.cqf-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
}
.cqf-toggle-all {
  background: transparent;
  border: none;
  color: var(--action-blue);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
  text-decoration: underline;
}
.cqf-toggle-all:hover { color: var(--medium-blue); }
.cqf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
/* Toggle-buttons: action-blue when selected, blue-light when not */
.cqf-item {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: center;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.cqf-item[aria-pressed="true"] {
  background: var(--action-blue);
  color: var(--white);
  border-color: var(--action-blue);
}
.cqf-item[aria-pressed="false"] {
  background: var(--blue-light);
  color: var(--action-blue);
  border-color: var(--blue-light);
}
.cqf-item[aria-pressed="true"]:hover  { background: var(--medium-blue); border-color: var(--medium-blue); }
.cqf-item[aria-pressed="false"]:hover { border-color: var(--action-blue); }
/* Grammar MC filter: pronouns/columns not reachable via the current table
   selection look like normal unselected items but ignore mouse interaction. */
.cqf-item.cqf-disabled,
.cqf-item.cqf-disabled:hover {
  pointer-events: none;
  border-color: var(--blue-light);
  cursor: default;
}
.cqf-actions {
  margin-top: 1.5rem;
  text-align: center;
}
.cqf-actions .btn-primary { min-width: 140px; }

/* ── Legal pages (Privacy Policy / Code of Conduct) ─────────────────────────
   Shared by the standalone privacy.html / code-of-conduct.html pages and the
   in-app legal views (app-legal.js). */
.privacy-wrap {
  max-width: 680px;
  margin: 48px auto;
  padding: 0 24px 64px;
}
.privacy-wrap h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--green);
  margin-bottom: 8px;
}
.privacy-wrap .updated {
  font-size: 0.85rem;
  color: var(--mid-gray);
  margin-bottom: 32px;
}
.privacy-wrap h2 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--green);
  margin: 28px 0 8px;
}
.privacy-wrap p, .privacy-wrap li {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--charcoal);
}
.privacy-wrap ul { padding-left: 20px; }
.privacy-wrap li { margin-bottom: 4px; }
.privacy-back {
  display: inline-block;
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--action-blue);
  text-decoration: none;
}
.privacy-back:hover { text-decoration: underline; }
/* In-app back button sits inside the centered .privacy-wrap column. */
.legal-back { margin-bottom: 16px; }

.settings-hint .link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--action-blue);
  text-decoration: underline;
  cursor: pointer;
}

/* These containers receive programmatic focus on view-switch (for screen-reader
   announcement). They are not interactive, so hide the focus ring; real controls
   keep theirs. */
#landing:focus, #edit-view:focus, #drill-view:focus, #quiz-view:focus,
#glossary-view:focus, #settings-view:focus, #privacy-view:focus,
#code-of-conduct-view:focus, #auth-view:focus {
  outline: none;
}
