/* ==========================================================================
   Annaphora Design System
   Palette: sky blue primary, green success, purple/coral accents
   Dark mode default (recommended) · light via prefers-color-scheme or [data-theme]
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap");

:root {
  /* Brand (shared) */
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-soft: rgba(14, 165, 233, 0.12);
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.14);
  --coral: #f97316;
  --coral-soft: rgba(249, 115, 22, 0.14);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  /* Light surfaces */
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --ring: rgba(14, 165, 233, 0.35);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --hero-glow-1: rgba(14, 165, 233, 0.18);
  --hero-glow-2: rgba(139, 92, 246, 0.12);
  --hero-glow-3: rgba(34, 197, 94, 0.08);
  --input-bg: #ffffff;
  --code-input-bg: #f8fafc;
  --overlay: rgba(15, 23, 42, 0.4);

  /* Layout */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --space-page: clamp(20px, 4vw, 40px);
  --max-narrow: 440px;
  --max-form: 480px;
  --max-content: 720px;
  --max-wide: 980px;
  --header-h: 64px;
  --transition: 0.18s ease;
}

/* Dark mode — default (highly recommended). Override with data-theme="light". */
html:not([data-theme="light"]) {
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-soft: rgba(56, 189, 248, 0.14);
  --accent: #4ade80;
  --accent-hover: #86efac;
  --accent-soft: rgba(74, 222, 128, 0.14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.16);
  --coral: #fb923c;
  --coral-soft: rgba(251, 146, 60, 0.14);
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);

  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --surface: #1e293b;
  --surface-2: #334155;
  --surface-3: #475569;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
  --ring: rgba(56, 189, 248, 0.4);
  --nav-bg: rgba(15, 23, 42, 0.85);
  --hero-glow-1: rgba(56, 189, 248, 0.16);
  --hero-glow-2: rgba(167, 139, 250, 0.12);
  --hero-glow-3: rgba(74, 222, 128, 0.08);
  --input-bg: #0f172a;
  --code-input-bg: #0f172a;
  --overlay: rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] {
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-soft: rgba(14, 165, 233, 0.12);
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.14);
  --coral: #f97316;
  --coral-soft: rgba(249, 115, 22, 0.14);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --ring: rgba(14, 165, 233, 0.35);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --hero-glow-1: rgba(14, 165, 233, 0.18);
  --hero-glow-2: rgba(139, 92, 246, 0.12);
  --hero-glow-3: rgba(34, 197, 94, 0.08);
  --input-bg: #ffffff;
  --code-input-bg: #f8fafc;
  --overlay: rgba(15, 23, 42, 0.4);
}

/* -------------------------------------------------------------------------- */
/* Reset & base                                                                */
/* -------------------------------------------------------------------------- */

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

html[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--hero-glow-1), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, var(--hero-glow-2), transparent 50%),
    radial-gradient(ellipse 50% 30% at 50% 100%, var(--hero-glow-3), transparent 55%);
  background-attachment: fixed;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

/* -------------------------------------------------------------------------- */
/* Layout shells                                                               */
/* -------------------------------------------------------------------------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  width: 100%;
  max-width: var(--max-content);
  margin: 0 auto;
  padding: calc(var(--header-h) + 28px) var(--space-page) 48px;
}

.page-body--narrow {
  max-width: var(--max-form);
}

.page-body--wide {
  max-width: var(--max-wide);
}

.page-body--center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-top: 48px;
  padding-bottom: 48px;
  min-height: 100vh;
}

/* Legacy container support */
.container {
  width: 100%;
  max-width: var(--max-form);
  margin: 0 auto;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  text-align: center;
}

.container--wide {
  max-width: var(--max-content);
}

.container--flush {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  text-align: left;
  max-width: none;
}

/* -------------------------------------------------------------------------- */
/* Top navigation                                                              */
/* -------------------------------------------------------------------------- */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-h);
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px var(--space-page);
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.app-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.app-nav__brand:hover {
  color: var(--text);
}

.app-nav__mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow: 0 4px 12px var(--primary-soft);
}

.app-nav__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Language dropdown (student pages) */
.lang-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.lang-select__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.lang-select select,
select[data-lang-select] {
  appearance: none;
  -webkit-appearance: none;
  min-width: 118px;
  height: 40px;
  padding: 0 32px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.lang-select select:hover,
select[data-lang-select]:hover {
  border-color: var(--border-strong);
}

html.is-lang-swap .vocab-card__translation,
html.is-lang-swap .vocab-card__example-tr,
html.is-lang-swap .vocab-name-list__tr,
html.is-lang-swap .drill-prompt,
html.is-lang-swap .drill-option {
  animation: annaphora-lang-in 0.2s ease;
}

@keyframes annaphora-lang-in {
  from { opacity: 0.15; }
  to { opacity: 1; }
}

.lang-select select:focus,
select[data-lang-select]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Speech voice picker (Web Speech API) — matches lang-select */
.voice-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  max-width: min(320px, 100%);
  flex-shrink: 0;
}

.voice-select__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.voice-select select,
select[data-voice-select] {
  appearance: none;
  -webkit-appearance: none;
  min-width: 140px;
  max-width: 200px;
  height: 40px;
  padding: 0 32px 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  text-overflow: ellipsis;
}

.voice-select select:hover,
select[data-voice-select]:hover {
  border-color: var(--border-strong);
}

.voice-select select:focus,
select[data-voice-select]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.voice-select__preview {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}

.voice-select__preview:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.voice-select__preview:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.app-nav__link {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.app-nav__link:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* Theme toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* -------------------------------------------------------------------------- */
/* Typography                                                                  */
/* -------------------------------------------------------------------------- */

h1,
.h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 8px;
}

h2,
.h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 6px;
}

h3,
.h3 {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 6px;
}

.lead,
.page-lead {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 28px;
  line-height: 1.55;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header__text {
  flex: 1;
  min-width: 200px;
  text-align: left;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.page-header .lead {
  margin-bottom: 0;
}

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

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

/* -------------------------------------------------------------------------- */
/* Brand / logo                                                                */
/* -------------------------------------------------------------------------- */

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.35rem;
  box-shadow: 0 8px 28px var(--primary-soft);
  letter-spacing: -0.04em;
}

.brand-title {
  font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--text) 30%, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0;
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                     */
/* -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--primary);
  color: #0f172a;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 650;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 2px 12px var(--primary-soft);
  line-height: 1.2;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-soft);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-success,
.btn-accent {
  background: var(--accent);
  color: #052e16;
  box-shadow: 0 2px 12px var(--accent-soft);
}

.btn-success:hover,
.btn-accent:hover {
  background: var(--accent-hover);
  color: #052e16;
}

/* Share: green + upload/share arrow on the right */
.btn-share {
  gap: 6px;
}

.btn-share__icon {
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
  display: block;
}

.btn-purple {
  background: var(--purple);
  color: #1e0a3c;
  box-shadow: 0 2px 12px var(--purple-soft);
}

.btn-purple:hover {
  filter: brightness(1.08);
  color: #1e0a3c;
}

.btn-coral {
  background: var(--coral);
  color: #431407;
  box-shadow: 0 2px 12px var(--coral-soft);
}

.btn-coral:hover {
  filter: brightness(1.06);
  color: #431407;
}

/* ── Teacher create-card: real portrait card, fits the viewport ─ */
.create-card-popup {
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}

.create-card-popup .create-card-panel {
  /* No tall form chrome — just host the card + actions */
  width: auto;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  margin: 0;
  padding: 12px 16px 12px;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: center;
}

.create-card-popup.is-open .create-card-panel {
  transform: none;
}

.create-card-panel__title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.create-card-panel__hint {
  display: none;
}

/*
 * Create-card close: same solid red corner control as My Dictionary reset (−),
 * parked on the card’s top-right (slightly outside the frame).
 */
.create-card-close {
  position: absolute;
  z-index: 12;
  top: -8px;
  right: -8px;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--error);
  color: #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  line-height: 0;
  text-align: center;
}

.create-card-close > span {
  display: block;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  /* Same optical vertical center as My Dictionary − control */
  transform: translateY(-0.12em);
}

.create-card-close:hover {
  background: #dc2626;
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.5);
}

html[data-theme="dark"] .create-card-close:hover,
:root:not([data-theme="light"]) .create-card-close:hover {
  background: #f87171;
  color: #450a0a;
}

.create-card-close:active {
  transform: scale(0.96);
}

.create-card-close:focus-visible {
  outline: 2px solid var(--error);
  outline-offset: 2px;
}

.create-card-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: auto;
  margin: 0;
}

/* Prefer the larger flipped-card size; still clamp to the viewport */
.create-card-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(
    300px,
    calc(100vw - 40px),
    calc((100vh - 110px) * 5 / 9.2)
  );
}

.create-card-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 9.2;
  max-height: calc(100vh - 110px);
  perspective: 1600px;
  perspective-origin: 50% 50%;
  overflow: visible;
  isolation: isolate;
}

.create-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.create-card-inner.is-flipped {
  transform: rotateY(180deg);
}

/* Both faces fill the scene — only one is visible at a time */
.create-card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
}

.create-card-face--front {
  transform: rotateY(0deg);
  z-index: 2;
}

.create-card-face--back {
  transform: rotateY(180deg);
  z-index: 1;
}

.create-card-inner.is-flipped .create-card-face--front {
  z-index: 1;
}

.create-card-inner.is-flipped .create-card-face--back {
  z-index: 2;
}

/* Front + back share the same shell (size, frame, lift) */
.create-card-shell {
  --card-radius: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 16px 14px 18px;
  box-sizing: border-box;
  text-align: left;
  color: var(--text);
  border-radius: var(--card-radius);
  overflow: hidden;
  border: 2px solid rgba(148, 163, 184, 0.35);
  background:
    linear-gradient(
      165deg,
      rgba(56, 189, 248, 0.1) 0%,
      transparent 28%
    ),
    linear-gradient(
      180deg,
      var(--surface) 0%,
      var(--bg-elevated) 55%,
      var(--surface) 100%
    );
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 -10px 18px rgba(0, 0, 0, 0.12) inset,
    0 6px 0 rgba(15, 23, 42, 0.18),
    0 14px 28px rgba(0, 0, 0, 0.28);
  -webkit-user-select: text;
  user-select: text;
  aspect-ratio: unset;
  contain: none;
}

html[data-theme="light"] .create-card-shell {
  border-color: rgba(15, 23, 42, 0.12);
  background:
    linear-gradient(
      165deg,
      rgba(14, 165, 233, 0.12) 0%,
      transparent 30%
    ),
    linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 -8px 14px rgba(15, 23, 42, 0.04) inset,
    0 5px 0 rgba(15, 23, 42, 0.08),
    0 12px 22px rgba(15, 23, 42, 0.1);
}

.create-card-shell__body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.create-card-shell__body--back {
  gap: 8px;
}

.create-card-field {
  display: block;
  margin: 0;
  min-width: 0;
  flex-shrink: 0;
}

/* Input lines on the card */
.create-card-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.2);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.35;
  box-sizing: border-box;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

html[data-theme="light"] .create-card-input {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(15, 23, 42, 0.12);
}

.create-card-input::placeholder {
  color: var(--text-muted);
  opacity: 0.95;
}

.create-card-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--input-bg);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.create-card-input--word {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: lowercase;
  padding: 9px 10px;
  border-width: 1.5px;
}

.create-card-input--pos {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-secondary);
  width: 70%;
  max-width: 12rem;
  padding: 5px 28px 5px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}

/* Placeholder-like look when nothing selected */
.create-card-input--pos:has(option[value=""]:checked) {
  color: var(--text-muted);
}

.create-card-input--pos option {
  color: var(--text);
  background: var(--surface);
}

.create-card-input--pos option[value=""] {
  color: var(--text-muted);
}

.create-card-input--def {
  resize: none;
  min-height: 2.6rem;
  max-height: 4rem;
  font-size: 0.84rem;
  line-height: 1.4;
}

.create-card-input--shake {
  animation: create-card-shake 0.4s ease;
  border-color: var(--error) !important;
  border-style: solid !important;
}

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

/* Actions sit under the card, not inside it */
.create-card-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
  margin: 0;
}

.create-card-actions[hidden] {
  display: none !important;
}

.create-card-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  font-size: 0.78rem;
  padding: 9px 8px;
  white-space: nowrap;
}

.create-card-back__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.create-card-back__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.create-card-extra-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.create-card-extra-empty {
  margin: 12px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.create-card-extra {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.2);
}

html[data-theme="light"] .create-card-extra {
  background: rgba(255, 255, 255, 0.65);
}

.create-card-extra__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--purple);
}

.create-card-extra__remove {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.create-card-extra__remove:hover {
  background: var(--error-soft);
  color: var(--error);
}

.create-card-add-extra {
  align-self: center;
  flex-shrink: 0;
}

.vocab-name-list__band--custom {
  /* Same grey chip look as band labels; wider shape for the word “Custom” */
  color: var(--text-muted);
  background: var(--surface-2, var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 16px;
  min-width: 5.25rem;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
  box-sizing: border-box;
  max-width: none;
  overflow: visible;
  text-align: center;
  line-height: 1.2;
  opacity: 0.95;
}

.vocab-name-list__item--custom .vocab-name-list__word {
  font-weight: 750;
}

.btn-danger,
.btn-delete,
.logout-btn {
  background: var(--error);
  color: #fff;
  box-shadow: 0 2px 12px var(--error-soft);
  border: none;
  cursor: pointer;
  font-weight: 650;
}

.btn-danger:hover,
.btn-delete:hover,
.logout-btn:hover {
  filter: brightness(1.08);
  color: #fff;
}

.logout-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.btn-warning,
.btn-edit {
  background: var(--warning);
  color: #422006;
  border: none;
  cursor: pointer;
  font-weight: 650;
}

.btn-warning:hover,
.btn-edit:hover {
  filter: brightness(1.05);
}

.btn-save {
  background: var(--accent);
  color: #052e16;
  border: none;
  cursor: pointer;
  font-weight: 650;
}

.btn-cancel {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
}

.btn-view {
  background: var(--primary);
  color: #0f172a;
}

.btn-row,
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.btn-row--start {
  justify-content: flex-start;
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.action-stack .btn {
  margin: 0 !important;
}

/* -------------------------------------------------------------------------- */
/* Cards                                                                       */
/* -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  border-color: var(--border-strong);
}

.card h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.card p {
  color: var(--text-secondary);
  margin-bottom: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  text-align: left;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.feature-card__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 14px;
  background: var(--primary-soft);
}

.feature-card__icon--green {
  background: var(--accent-soft);
}

.feature-card__icon--purple {
  background: var(--purple-soft);
}

.feature-card__icon--coral {
  background: var(--coral-soft);
}

.feature-card h3 {
  margin-bottom: 6px;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

/* -------------------------------------------------------------------------- */
/* Forms                                                                       */
/* -------------------------------------------------------------------------- */

.form-group {
  margin-bottom: 18px;
  text-align: left;
}

label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 3.5L11.5 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

.input-code {
  font-size: 1.35rem !important;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  text-align: center;
  font-weight: 700;
  background: var(--code-input-bg);
  padding: 16px !important;
}

.input-otp {
  font-size: 1.5rem !important;
  letter-spacing: 0.4em;
  text-align: center;
  font-weight: 700;
}

.link {
  display: inline-block;
  margin-top: 16px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}

.link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.link-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.link-row .link {
  margin-top: 0;
}

/* -------------------------------------------------------------------------- */
/* Badges & chips                                                              */
/* -------------------------------------------------------------------------- */

.role-badge,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 650;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.badge--success {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--purple {
  background: var(--purple-soft);
  color: var(--purple);
}

.badge--coral {
  background: var(--coral-soft);
  color: var(--coral);
}

.badge--error {
  background: var(--error-soft);
  color: var(--error);
}

.status-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* -------------------------------------------------------------------------- */
/* Dashboard                                                                   */
/* -------------------------------------------------------------------------- */

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  text-align: left;
}

.dashboard-header h1 {
  margin-bottom: 4px;
}

.dashboard-header p {
  color: var(--text-secondary);
  margin: 0;
  word-break: break-all;
}

/* Dev role switcher */
.dev-card {
  background: var(--warning-soft);
  border: 1.5px dashed var(--coral);
}

.dev-card h3 {
  color: var(--coral);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dev-badge {
  display: inline-block;
  background: var(--coral);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.dev-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.role-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.role-switcher button {
  border: 1.5px solid var(--coral);
  background: var(--surface);
  color: var(--coral);
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.role-switcher button:hover {
  background: var(--coral-soft);
}

.role-switcher button.active {
  background: var(--coral);
  color: #fff;
}

.role-switcher button:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* -------------------------------------------------------------------------- */
/* Classes / students / results                                                */
/* -------------------------------------------------------------------------- */

.class-card,
.student-card,
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 14px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
  transition: transform var(--transition), box-shadow var(--transition);
}

.class-card:hover,
.student-card:hover,
.result-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.student-card {
  border-left-color: var(--accent);
}

.class-name,
.student-email {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.student-email--with-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.student-email__name {
  min-width: 0;
  word-break: break-word;
}

.student-stats-btn {
  flex-shrink: 0;
  font-weight: 650;
}

.class-meta,
.student-meta,
.result-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.class-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.class-actions .btn,
.class-actions button,
.class-actions a {
  padding: 8px 14px;
  font-size: 0.88rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  color: inherit;
}

.class-actions .btn-view {
  color: #0f172a;
}

.class-actions .btn-edit {
  color: #422006;
}

.class-actions .btn-delete {
  color: #fff;
}

.class-actions .btn-save {
  color: #052e16;
}

.class-actions .btn-cancel {
  color: var(--text-secondary);
}

.edit-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--warning);
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  background: var(--input-bg);
  box-sizing: border-box;
}

.class-card.busy {
  opacity: 0.65;
  pointer-events: none;
}

.result-score {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin: 8px 0;
}

.band-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.band-row:last-child {
  border-bottom: none;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  padding: 40px 28px;
  text-align: center;
  line-height: 1.6;
}

.empty-state strong {
  color: var(--text);
}

/* -------------------------------------------------------------------------- */
/* Vocab test                                                                  */
/* -------------------------------------------------------------------------- */

#testArea {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.progress {
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  text-align: left;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.word {
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.context {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-style: italic;
  line-height: 1.5;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  padding: 14px 18px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
  font-weight: 500;
  text-align: left;
}

.option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--ring);
}

.option.disabled {
  pointer-events: none;
  opacity: 0.85;
}

#results {
  display: none;
}

.score-big {
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 12px 0 20px;
  letter-spacing: -0.03em;
}

.word-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  text-align: left;
  border-left: 4px solid var(--accent);
}

.word-card__word {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.word-card__def {
  color: var(--text-secondary);
  margin-top: 4px;
}

.word-card__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* -------------------------------------------------------------------------- */
/* Dictionary page — vertical vocab cards                                      */
/* -------------------------------------------------------------------------- */

.dict-page {
  max-width: min(1610px, 100%); /* ~15% wider than 1400 → larger 8-col cards */
  margin: 0 auto;
  padding: calc(var(--header-h) + 24px) var(--space-page) 80px;
  text-align: left;
}

.dict-shell {
  background: transparent;
  box-shadow: none;
  padding: 0;
  max-width: none;
  margin: 0;
  text-align: left;
  border: none;
}

.dict-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.dict-topbar h1 {
  margin-bottom: 6px;
}

.dict-topbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.dict-topbar__actions .voice-select {
  max-width: min(320px, 100%);
}

.unknown-dict-hint {
  margin: -8px 0 18px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.45;
}

/* Unknown cards: allow + to stick out past the frame */
.vocab-card.vocab-card--unknown {
  position: relative;
  overflow: visible;
}

.unknown-dict-grid {
  margin-top: 4px;
  /* Room for + buttons and bottom-edge level chips that stick past the card */
  padding-top: 0.55rem;
  padding-right: 0.55rem;
  padding-bottom: 0.85rem;
  overflow: visible;
}

/* -------------------------------------------------------------------------- */
/* My Dictionary — mastery popup (all words at 20/20)                          */
/* -------------------------------------------------------------------------- */

body.dict-popup-open {
  overflow: hidden;
}

.dict-popup {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.dict-popup[hidden] {
  display: none !important;
}

.dict-popup.is-open {
  opacity: 1;
  pointer-events: auto;
}

.dict-popup__backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay, rgba(15, 23, 42, 0.55));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: none;
  cursor: pointer;
}

.dict-popup__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  padding: 28px 24px 22px;
  border-radius: var(--radius-lg, 16px);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg, 0 16px 48px rgba(0, 0, 0, 0.28));
  text-align: center;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.dict-popup.is-open .dict-popup__panel {
  transform: translateY(0) scale(1);
}

.dict-popup__panel--wide {
  width: min(100%, 520px);
  text-align: left;
}

.dict-popup__panel--wide .dict-popup__title,
.dict-popup__panel--wide .dict-popup__icon {
  text-align: center;
}

.dict-popup__panel--wide .dict-popup__text {
  text-align: center;
}

.dict-popup__panel--xl {
  width: min(100%, 560px);
  max-height: min(90vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
  text-align: left;
  box-sizing: border-box;
}

.dict-popup__panel--xl .dict-popup__title,
.dict-popup__panel--xl .dict-popup__icon {
  text-align: center;
}

.dict-popup__panel--xl .dict-popup__text {
  text-align: center;
}

/* Assign set → class */
.assign-set-current {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.assign-set-current strong {
  color: var(--text);
}

.assign-set-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 6px 0 0;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 650;
}

.assign-set-chip__undo {
  margin: 0;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.assign-set-chip__undo:hover {
  color: var(--error, #dc2626);
}

.assign-set-class-list {
  margin: 0 0 12px;
  max-height: 280px;
  overflow: auto;
}

.assign-set-classes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assign-set-class-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.assign-set-class-row.is-assigned {
  border-color: var(--purple, #a78bfa);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.25);
}

.assign-set-class-row__info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.assign-set-class-row__name {
  font-weight: 700;
  color: var(--text);
}

.assign-set-class-row__code {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.assign-set-class-row__badge {
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--purple, #a78bfa);
}

.sets-card__assign-meta {
  margin: 6px 0 0;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--purple, #a78bfa);
}

.sets-card__share-meta {
  margin: 4px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Share set with teacher */
.share-set-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  text-align: left;
}

.share-set-form__actions {
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 4px;
}

.share-set-form__actions .btn {
  width: auto;
  flex: 1 1 auto;
  min-width: 120px;
}

.share-set-success {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 650;
  text-align: left;
}

.share-contacts {
  margin: 0;
}

.share-contacts__label {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.share-contacts__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}

.share-contacts__item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.share-contacts__pick {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 4px 6px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-contacts__pick:hover {
  color: var(--primary);
}

.share-contacts__send {
  flex: 0 0 auto;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.share-contacts__send:hover {
  border-color: var(--purple, #a78bfa);
  color: var(--purple, #a78bfa);
}

.share-contacts__remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.share-contacts__remove:hover {
  color: var(--error, #dc2626);
  background: rgba(220, 38, 38, 0.12);
}

/* Student: teacher set assignment popup */
.set-assign-recv-summary {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Graded deadline on receive-popup (date + same thin chip as dictionary cards) */
.set-assign-recv-deadline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2, var(--surface));
}

.set-assign-recv-deadline__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px 10px;
  text-align: center;
}

.set-assign-recv-deadline__label {
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.set-assign-recv-deadline__date {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Reuse card chip look; position static inside the popup (not absolute) */
.set-assign-recv-deadline__chip.vocab-card__deadline {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  pointer-events: auto;
  box-shadow: none;
}

/* Teacher: assign words to one student — selected basket */
.assign-picked-panel {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.assign-picked-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.assign-picked-panel__head strong {
  font-size: 0.92rem;
  font-weight: 750;
  color: var(--text);
}

.assign-picked-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 140px;
  overflow-x: hidden;
  overflow-y: auto;
}

.assign-picked-chips__item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 4px 4px 10px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
}

.assign-picked-chips__word {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.assign-picked-chips__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.assign-picked-chips__remove:hover {
  color: var(--error, #dc2626);
  background: rgba(220, 38, 38, 0.12);
}

.set-assign-recv-section {
  margin: 0 0 16px;
  min-width: 0;
}

.set-assign-recv-section__title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--text);
  text-align: left;
}

.set-assign-recv-section__hint {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-secondary);
  text-align: left;
}

.set-assign-recv-section__hint strong {
  color: var(--accent);
  font-weight: 700;
}

/* New words: wrapping chips — no horizontal scroll */
.set-assign-recv-words {
  list-style: none;
  margin: 0;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 200px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-sizing: border-box;
}

.set-assign-recv-words__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.set-assign-recv-words__word {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.set-assign-recv-words__band {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
}

/* Already-known: clear checkbox rows (no sideways clip / slider) */
.set-assign-recv-check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-sizing: border-box;
}

.set-assign-recv-check {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.set-assign-recv-check:last-child {
  border-bottom: none;
}

.set-assign-recv-check__label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.set-assign-recv-check__label:hover {
  background: var(--surface-3, rgba(255, 255, 255, 0.04));
}

.set-assign-recv-check__input {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.15rem 0 0;
  accent-color: var(--primary);
}

.set-assign-recv-check__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.set-assign-recv-check__word {
  display: block;
  width: 100%;
  font-size: 0.98rem;
  font-weight: 750;
  line-height: 1.3;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.set-assign-recv-check__meta {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-secondary);
  white-space: normal;
  word-break: break-word;
}

.dict-popup__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dict-popup__close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.dict-popup__icon {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 10px;
}

.dict-popup__title {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.dict-popup__text {
  margin: 0 0 20px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.dict-popup__text strong {
  color: var(--accent);
  font-weight: 700;
}

.dict-popup__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dict-popup__actions .btn {
  width: 100%;
  justify-content: center;
}

.dict-summary {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.98rem;
}

.dict-summary strong {
  color: var(--text);
  font-weight: 700;
}

/* Mastery / band progress (same bar design as drilling) */
.dict-progress-chrome {
  margin: 0 0 20px;
}

.dict-progress-chrome__top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dict-progress-chrome__top--toggle {
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  outline: none;
}

.dict-progress-chrome__top--toggle:hover .dict-progress-label,
.dict-progress-chrome__top--toggle:hover .drill-counter {
  color: var(--text);
}

.dict-progress-chrome__top--toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--ring);
}

.dict-progress-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
}

.dict-progress-chrome .drill-counter {
  display: inline-block;
}

/* Instant prefix search (above band sections) */
.dict-search {
  margin: 0 0 18px;
  width: 100%;
  max-width: 23vw; /* 20vw + 15% */
}

@media (max-width: 900px) {
  .dict-search {
    max-width: 40vw;
  }
}

@media (max-width: 640px) {
  .dict-search {
    max-width: 100%;
  }
}

.dict-search__label {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0;
  width: 100%;
}

.dict-search__icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.dict-search__input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.dict-search__input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.dict-search__input:hover {
  border-color: var(--border-strong);
}

.dict-search__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.dict-search__clear {
  position: absolute;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.dict-search__clear:hover {
  background: var(--surface-3);
  color: var(--text);
}

.dict-search__clear[hidden] {
  display: none;
}

.band-section {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: 32px;
}

.band-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  width: 100%;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  flex-wrap: wrap;
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    margin 0.2s ease-out;
}

.band-section__header:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

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

.band-section__header-end {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.band-section__chevron {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.band-section.is-collapsed .band-section__chevron {
  transform: rotate(-45deg);
  margin-top: 4px;
}

.band-section.is-collapsed .band-section__header {
  margin-bottom: 0;
}

/* Snappy collapse: height in px via JS (avoids laggy grid-template-rows) */
.band-section__body {
  overflow: hidden;
  transition: height 0.2s ease-out;
}

.band-section.is-collapsed .band-section__body {
  pointer-events: none;
}

.band-section.is-collapsed .band-section__body:not([style*="height"]) {
  height: 0;
}

.band-section__title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.band-section__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.band-section__title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 700;
}

.band-section__subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.band-section__count {
  font-size: 0.88rem;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-weight: 600;
}

/* Window-scroll virtualization shell (only visible rows/cards are mounted) */
.dict-virtual {
  position: relative;
  width: 100%;
  min-height: 0;
}

.dict-virtual__spacer {
  display: block;
  margin: 0;
  padding: 0;
  border: 0 !important;
  list-style: none;
  pointer-events: none;
  visibility: hidden;
}

/* Full-width row in the card grid so column tracks (and card size) stay unchanged */
.dict-virtual__spacer--grid {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Dense Hearthstone-style portrait tiles — 8 cards per desktop row */
.band-section__grid,
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 16px 14px;
  align-items: stretch;
  /* Room for top deadline chip + bottom level chip / corner − past the card */
  padding-top: 0.9rem;
  padding-bottom: 0.85rem;
  padding-right: 0.45rem;
}

@media (max-width: 1200px) {
  .band-section__grid,
  .vocab-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .band-section__grid,
  .vocab-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .band-section__grid,
  .vocab-grid {
    grid-template-columns: 1fr;
  }
}

.band-section[data-band="1000"] .band-section__badge {
  background: var(--accent-soft);
  color: var(--accent);
}
.band-section[data-band="2000"] .band-section__badge {
  background: var(--primary-soft);
  color: var(--primary);
}
.band-section[data-band="3000"] .band-section__badge {
  background: var(--purple-soft);
  color: var(--purple);
}
.band-section[data-band="4000"] .band-section__badge {
  background: var(--coral-soft);
  color: var(--coral);
}
.band-section[data-band="5000"] .band-section__badge {
  background: var(--error-soft);
  color: var(--error);
}
.band-section[data-band="6000"] .band-section__badge {
  background: var(--warning-soft);
  color: var(--warning);
}

/*
 * Portrait “trading card” tiles — tall rounded rectangles,
 * framed edge, soft 3D lift (Hearthstone-adjacent, not a clone).
 */
.vocab-card {
  --card-radius: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  /* Taller than 5/8 so examples fit; ~15% larger overall via wider page */
  aspect-ratio: 5 / 9.2;
  /* layout/style only — do NOT use paint/content-visibility (clips +/− and level chip) */
  contain: layout style;
  width: 100%;
  min-height: 0;
  height: auto;
  /* Extra bottom padding so content clears the upper half of the level chip */
  padding: 13px 12px 18px;
  text-align: left;
  /* Visible so corner +/− and bottom-edge level chip can stick out past the frame */
  overflow: visible;
  color: var(--text);
  border-radius: var(--card-radius);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  border: 2px solid rgba(148, 163, 184, 0.35);
  background:
    linear-gradient(
      165deg,
      rgba(56, 189, 248, 0.1) 0%,
      transparent 28%
    ),
    linear-gradient(
      180deg,
      var(--surface) 0%,
      var(--bg-elevated) 55%,
      var(--surface) 100%
    );
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 -10px 18px rgba(0, 0, 0, 0.12) inset,
    0 6px 0 rgba(15, 23, 42, 0.18),
    0 14px 28px rgba(0, 0, 0, 0.28);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease;
}

/*
 * Hide text until JS fit pins a stable size. Prevents the “font pops while
 * scrolling” effect when virtual lists remount cards at CSS defaults.
 */
.vocab-card:not([data-fit="1"]) .vocab-card__word,
.vocab-card:not([data-fit="1"]) .vocab-card__pos,
.vocab-card:not([data-fit="1"]) .vocab-card__definition,
.vocab-card:not([data-fit="1"]) .vocab-card__translation,
.vocab-card:not([data-fit="1"]) .vocab-card__example-en,
.vocab-card:not([data-fit="1"]) .vocab-card__example-tr,
.vocab-card:not([data-fit="1"]) .vocab-card__missing {
  opacity: 0;
}

.vocab-card[data-fit="1"] .vocab-card__word,
.vocab-card[data-fit="1"] .vocab-card__pos,
.vocab-card[data-fit="1"] .vocab-card__definition,
.vocab-card[data-fit="1"] .vocab-card__translation,
.vocab-card[data-fit="1"] .vocab-card__example-en,
.vocab-card[data-fit="1"] .vocab-card__example-tr,
.vocab-card[data-fit="1"] .vocab-card__missing {
  opacity: 1;
  /* Never animate size — remounts must appear already final */
  transition: none;
}

html[data-theme="light"] .vocab-card {
  border-color: rgba(15, 23, 42, 0.12);
  background:
    linear-gradient(
      165deg,
      rgba(14, 165, 233, 0.12) 0%,
      transparent 30%
    ),
    linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 -8px 14px rgba(15, 23, 42, 0.04) inset,
    0 5px 0 rgba(15, 23, 42, 0.08),
    0 12px 22px rgba(15, 23, 42, 0.1);
}

.vocab-card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: calc(var(--card-radius) - 5px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  pointer-events: none;
  z-index: 0;
}

html[data-theme="light"] .vocab-card::before {
  border-color: rgba(15, 23, 42, 0.08);
}

/* Stack content above the card frame; keep corner buttons + level chip free for position:absolute */
.vocab-card > *:not(.vocab-card__add-btn):not(.vocab-card__reset-btn):not(.vocab-card__chip--level):not(.vocab-card__deadline) {
  position: relative;
  z-index: 1;
}

/* 24h progress freeze at 10/20 — timer under example, above related-form meta */
.vocab-card__freeze {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  margin-left: auto;
  margin-right: auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warning, #f59e0b) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 40%, transparent);
  color: var(--warning, #f59e0b);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  width: fit-content;
  max-width: 100%;
  /* Centered under card content (not left-skewed) */
  align-self: center;
  transform-origin: center center;
}

/*
 * Graded assignment deadline — same height/size as Frozen chip, with ⏳ only
 * (no “Frozen” label). Straddles the top edge like the level chip on the bottom.
 */
.vocab-card__deadline {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 50%;
  /* Same straddle pattern as .vocab-card__chip--level (bottom: translateY(50%)) */
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Match .vocab-card__freeze metrics for equal height */
  gap: 6px;
  margin: 0;
  padding: 4px 8px;
  min-height: 0;
  height: auto;
  border-radius: 999px;
  /* Solid-enough fill (was ~16% transparent wash) */
  background: color-mix(in srgb, var(--warning, #f59e0b) 42%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 70%, transparent);
  color: var(--warning, #f59e0b);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 2px 8px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] .vocab-card__deadline {
  background: color-mix(in srgb, var(--warning, #f59e0b) 28%, #ffffff);
  border-color: color-mix(in srgb, var(--warning, #f59e0b) 55%, transparent);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 2px 6px rgba(15, 23, 42, 0.14);
}

.vocab-card__deadline-icon {
  /* Same as .vocab-card__freeze-icon */
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
  opacity: 1;
}

.vocab-card__deadline-clock {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: inherit;
  font-weight: 700;
  line-height: 1.2;
  opacity: 1;
}

html[data-theme="light"] .vocab-card__deadline-clock {
  color: var(--text);
}

.vocab-card.vocab-card--deadline {
  /* Room so the straddling top chip isn’t clipped */
  overflow: visible;
  /* contain:layout can clip abspos children that stick out of the card box */
  contain: none;
}

/* Expanded list-view cards: don’t clip the top deadline chip */
.vocab-name-list__item.is-expanded .vocab-name-list__expand-inner {
  overflow: visible;
  padding-top: 0.75rem;
}

/* Open band: don’t clip deadline chips that straddle card tops */
.band-section:not(.is-collapsed) > .band-section__body {
  overflow: visible;
}

/* Collapsed band still needs clip for the height animation */
.band-section.is-collapsed > .band-section__body {
  overflow: hidden;
}

/* Hidden until outline transition finishes, then pop into final place */
.vocab-card__freeze.vocab-card__freeze--await-pop {
  opacity: 0;
  transform: scale(0.35) translateY(10px);
  pointer-events: none;
}
.vocab-card__freeze.vocab-card__freeze--pop {
  animation: vocab-freeze-timer-pop 0.55s ease-out forwards;
}
@keyframes vocab-freeze-timer-pop {
  0% {
    opacity: 0;
    transform: scale(0.35) translateY(10px);
  }
  68% {
    opacity: 1;
    transform: scale(1.1) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.vocab-card__freeze-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.vocab-card__freeze-text {
  opacity: 0.9;
}

.vocab-card__freeze-clock {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

html[data-theme="light"] .vocab-card__freeze-clock {
  color: var(--text);
}

.vocab-card.vocab-card--frozen {
  /* Subtle pause cue without fighting level outline colors */
  opacity: 0.98;
}

/* Shared round corner control (green + / red −) */
.vocab-card__add-btn,
.vocab-card__reset-btn {
  position: absolute;
  z-index: 10;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  line-height: 0;
  text-align: center;
}

.vocab-card__add-btn > span,
.vocab-card__reset-btn > span {
  display: block;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

/* Unknown-card + : TOP-RIGHT corner, slightly outside the card */
.vocab-card.vocab-card--unknown > .vocab-card__add-btn {
  top: -8px;
  right: -8px;
  left: auto;
  bottom: auto;
  background: var(--accent);
  color: #052e16;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
}

.vocab-card.vocab-card--unknown > .vocab-card__add-btn > span {
  /* Nudge up so the glyph reads centered in the circle */
  transform: translateY(-0.14em);
}

.vocab-card.vocab-card--unknown > .vocab-card__add-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(34, 197, 94, 0.5);
}

.vocab-card.vocab-card--unknown > .vocab-card__add-btn:active {
  transform: scale(0.96);
}

.vocab-card.vocab-card--unknown > .vocab-card__add-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vocab-card.vocab-card--unknown > .vocab-card__add-btn.is-busy,
.vocab-card.vocab-card--unknown > .vocab-card__add-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

/* Interpolatable level outline tokens (mastery celebration animation) */
@property --level-color {
  syntax: "<color>";
  inherits: true;
  initial-value: #64748b;
}
@property --level-glow {
  syntax: "<number>";
  inherits: true;
  initial-value: 0.28;
}
@property --level-glow-core {
  syntax: "<number>";
  inherits: true;
  initial-value: 0.38;
}
@property --level-glow-spread {
  syntax: "<length>";
  inherits: true;
  initial-value: 12px;
}
@property --level-glow-spread-core {
  syntax: "<length>";
  inherits: true;
  initial-value: 4px;
}

/* My Dictionary cards: thick glowing level outline */
.vocab-card.vocab-card--mine {
  position: relative;
  overflow: visible;
  /* Thicker frame than default 2px cards */
  border-width: 4px;
  border-style: solid;
  border-color: var(--level-color, rgba(148, 163, 184, 0.45));
  /* Gentle glow; mastery only nudges intensity (see data-level rules) */
  --level-glow: 0.28;
  --level-glow-core: 0.38;
  --level-glow-spread: 12px;
  --level-glow-spread-core: 4px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 -10px 18px rgba(0, 0, 0, 0.12) inset,
    0 6px 0 rgba(15, 23, 42, 0.18),
    0 14px 28px rgba(0, 0, 0, 0.28),
    0 0 0 1px color-mix(
      in srgb,
      var(--level-color, #94a3b8) 40%,
      transparent
    ),
    0 0 var(--level-glow-spread-core)
      color-mix(
        in srgb,
        var(--level-color, #94a3b8) calc(var(--level-glow-core) * 100%),
        transparent
      ),
    0 0 var(--level-glow-spread)
      color-mix(
        in srgb,
        var(--level-color, #94a3b8) calc(var(--level-glow) * 100%),
        transparent
      );
}

html[data-theme="light"] .vocab-card.vocab-card--mine {
  border-color: var(--level-color, rgba(15, 23, 42, 0.18));
  --level-glow: 0.24;
  --level-glow-core: 0.32;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 -8px 14px rgba(15, 23, 42, 0.04) inset,
    0 5px 0 rgba(15, 23, 42, 0.08),
    0 12px 22px rgba(15, 23, 42, 0.1),
    0 0 0 1px color-mix(
      in srgb,
      var(--level-color, #64748b) 36%,
      transparent
    ),
    0 0 var(--level-glow-spread-core)
      color-mix(
        in srgb,
        var(--level-color, #64748b) calc(var(--level-glow-core) * 100%),
        transparent
      ),
    0 0 var(--level-glow-spread)
      color-mix(
        in srgb,
        var(--level-color, #64748b) calc(var(--level-glow) * 100%),
        transparent
      );
}

.vocab-card.vocab-card--mine::before {
  inset: 5px;
  border-width: 1.5px;
  border-color: color-mix(
    in srgb,
    var(--level-color, rgba(148, 163, 184, 0.5)) 55%,
    transparent
  );
  box-shadow: 0 0 6px
    color-mix(
      in srgb,
      var(--level-color, #94a3b8) 18%,
      transparent
    );
}

/*
 * Knowledge-level outline palette (1 = least attractive → 20 = amber-gold).
 * Level 0 = not practiced yet (cooler slate than level 1).
 * Glow rises only a little with mastery so 20/20 stays calm.
 */
.vocab-card.vocab-card--mine[data-level="0"] {
  --level-color: #64748b;
  --level-glow: 0.2;
  --level-glow-core: 0.28;
  --level-glow-spread: 10px;
  --level-glow-spread-core: 3px;
}
.vocab-card.vocab-card--mine[data-level="1"] {
  --level-color: #7f8994;
  --level-glow: 0.21;
  --level-glow-core: 0.29;
  --level-glow-spread: 10px;
  --level-glow-spread-core: 3px;
}
.vocab-card.vocab-card--mine[data-level="2"] {
  --level-color: #758b9a;
  --level-glow: 0.22;
  --level-glow-core: 0.3;
  --level-glow-spread: 10px;
  --level-glow-spread-core: 3px;
}
.vocab-card.vocab-card--mine[data-level="3"] {
  --level-color: #6a91a4;
  --level-glow: 0.23;
  --level-glow-core: 0.31;
  --level-glow-spread: 11px;
  --level-glow-spread-core: 3px;
}
.vocab-card.vocab-card--mine[data-level="4"] {
  --level-color: #5c9bb0;
  --level-glow: 0.24;
  --level-glow-core: 0.32;
  --level-glow-spread: 11px;
  --level-glow-spread-core: 4px;
}
.vocab-card.vocab-card--mine[data-level="5"] {
  --level-color: #4aa8be;
  --level-glow: 0.25;
  --level-glow-core: 0.33;
  --level-glow-spread: 11px;
  --level-glow-spread-core: 4px;
}
.vocab-card.vocab-card--mine[data-level="6"] {
  --level-color: #38b8c5;
  --level-glow: 0.26;
  --level-glow-core: 0.34;
  --level-glow-spread: 12px;
  --level-glow-spread-core: 4px;
}
.vocab-card.vocab-card--mine[data-level="7"] {
  --level-color: #28c6b8;
  --level-glow: 0.27;
  --level-glow-core: 0.35;
  --level-glow-spread: 12px;
  --level-glow-spread-core: 4px;
}
.vocab-card.vocab-card--mine[data-level="8"] {
  --level-color: #1ed4a0;
  --level-glow: 0.28;
  --level-glow-core: 0.36;
  --level-glow-spread: 12px;
  --level-glow-spread-core: 4px;
}
.vocab-card.vocab-card--mine[data-level="9"] {
  --level-color: #1cde80;
  --level-glow: 0.29;
  --level-glow-core: 0.37;
  --level-glow-spread: 12px;
  --level-glow-spread-core: 4px;
}
.vocab-card.vocab-card--mine[data-level="10"] {
  --level-color: #22e65c;
  --level-glow: 0.3;
  --level-glow-core: 0.38;
  --level-glow-spread: 13px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="11"] {
  --level-color: #3aee3a;
  --level-glow: 0.31;
  --level-glow-core: 0.39;
  --level-glow-spread: 13px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="12"] {
  --level-color: #5ff22a;
  --level-glow: 0.32;
  --level-glow-core: 0.4;
  --level-glow-spread: 13px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="13"] {
  --level-color: #85f625;
  --level-glow: 0.33;
  --level-glow-core: 0.41;
  --level-glow-spread: 14px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="14"] {
  --level-color: #a9f82e;
  --level-glow: 0.34;
  --level-glow-core: 0.42;
  --level-glow-spread: 14px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="15"] {
  --level-color: #c9f93c;
  --level-glow: 0.35;
  --level-glow-core: 0.43;
  --level-glow-spread: 14px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="16"] {
  --level-color: #e2f84c;
  --level-glow: 0.36;
  --level-glow-core: 0.44;
  --level-glow-spread: 15px;
  --level-glow-spread-core: 5px;
}
.vocab-card.vocab-card--mine[data-level="17"] {
  --level-color: #f3f35a;
  --level-glow: 0.37;
  --level-glow-core: 0.45;
  --level-glow-spread: 15px;
  --level-glow-spread-core: 6px;
}
.vocab-card.vocab-card--mine[data-level="18"] {
  --level-color: #f9e34a;
  --level-glow: 0.38;
  --level-glow-core: 0.46;
  --level-glow-spread: 15px;
  --level-glow-spread-core: 6px;
}
.vocab-card.vocab-card--mine[data-level="19"] {
  --level-color: #fbd23a;
  --level-glow: 0.4;
  --level-glow-core: 0.48;
  --level-glow-spread: 16px;
  --level-glow-spread-core: 6px;
}
.vocab-card.vocab-card--mine[data-level="20"] {
  --level-color: #fbbf24;
  --level-glow: 0.42;
  --level-glow-core: 0.5;
  --level-glow-spread: 16px;
  --level-glow-spread-core: 6px;
}

/* After drilling: previous outline → gold peak → settle at 20/20 */
.vocab-card.vocab-card--mine.vocab-card--mastery-animating {
  /* Continuous rise (no ease-in-out reverse feel); longer than freeze */
  transition:
    border-color 3.15s ease-out,
    box-shadow 3.15s ease-out;
  z-index: 6;
}
.vocab-card.vocab-card--mine.vocab-card--mastery-peak {
  --level-color: #fbbf24;
  /* ~20% stronger peak than previous 0.78 / 34px */
  --level-glow: 0.94;
  --level-glow-core: 1;
  --level-glow-spread: 41px;
  --level-glow-spread-core: 17px;
}

/* After drilling: previous outline → level-10 color (with brief brighter peak) */
.vocab-card.vocab-card--mine.vocab-card--freeze-animating {
  transition:
    border-color 1.15s ease-in-out,
    box-shadow 1.15s ease-in-out;
  z-index: 6;
}
.vocab-card.vocab-card--mine.vocab-card--freeze-peak {
  --level-color: #22e65c;
  --level-glow: 0.72;
  --level-glow-core: 0.86;
  --level-glow-spread: 30px;
  --level-glow-spread-core: 12px;
}

/* My Dictionary − : BOTTOM-RIGHT corner, slightly outside the card */
.vocab-card.vocab-card--mine > .vocab-card__reset-btn {
  top: auto;
  right: -8px;
  left: auto;
  bottom: -8px;
  background: var(--error);
  color: #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.vocab-card.vocab-card--mine > .vocab-card__reset-btn > span {
  /* Minus glyph optical center */
  transform: translateY(-0.12em);
  font-size: 1.05rem;
  font-weight: 900;
}

.vocab-card.vocab-card--mine > .vocab-card__reset-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.5);
}

html[data-theme="dark"] .vocab-card.vocab-card--mine > .vocab-card__reset-btn:hover,
:root:not([data-theme="light"]) .vocab-card.vocab-card--mine > .vocab-card__reset-btn:hover {
  background: #f87171;
  color: #450a0a;
}

.vocab-card.vocab-card--mine > .vocab-card__reset-btn:active {
  transform: scale(0.96);
}

.vocab-card.vocab-card--mine > .vocab-card__reset-btn:focus-visible {
  outline: 2px solid var(--error);
  outline-offset: 2px;
}

.vocab-card:hover {
  transform: translateY(-6px) scale(1.02);
  /* Keep knowledge-level outline when present; otherwise primary */
  border-color: var(--level-color, var(--primary));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 -10px 18px rgba(0, 0, 0, 0.14) inset,
    0 10px 0 rgba(15, 23, 42, 0.2),
    0 22px 36px color-mix(
      in srgb,
      var(--level-color, rgb(56, 189, 248)) 22%,
      transparent
    );
  z-index: 2;
}

/* Hover: lift + slight level-glow boost (My Dictionary) */
.vocab-card.vocab-card--mine:hover {
  border-color: var(--level-color, var(--primary));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 -10px 18px rgba(0, 0, 0, 0.14) inset,
    0 10px 0 rgba(15, 23, 42, 0.2),
    0 22px 36px rgba(0, 0, 0, 0.3),
    0 0 0 1px color-mix(
      in srgb,
      var(--level-color, #94a3b8) 50%,
      transparent
    ),
    0 0 calc(var(--level-glow-spread-core, 4px) + 2px)
      color-mix(
        in srgb,
        var(--level-color, #94a3b8)
          calc((var(--level-glow-core, 0.38) + 0.06) * 100%),
        transparent
      ),
    0 0 calc(var(--level-glow-spread, 12px) + 4px)
      color-mix(
        in srgb,
        var(--level-color, #94a3b8)
          calc((var(--level-glow, 0.28) + 0.06) * 100%),
        transparent
      );
}

html[data-theme="light"] .vocab-card:hover {
  box-shadow:
    0 1px 0 #fff inset,
    0 10px 0 rgba(15, 23, 42, 0.08),
    0 20px 32px color-mix(
      in srgb,
      var(--level-color, rgb(14, 165, 233)) 20%,
      transparent
    );
}

html[data-theme="light"] .vocab-card.vocab-card--mine:hover {
  box-shadow:
    0 1px 0 #fff inset,
    0 10px 0 rgba(15, 23, 42, 0.08),
    0 20px 32px rgba(15, 23, 42, 0.12),
    0 0 0 1px color-mix(
      in srgb,
      var(--level-color, #64748b) 45%,
      transparent
    ),
    0 0 calc(var(--level-glow-spread-core, 4px) + 2px)
      color-mix(
        in srgb,
        var(--level-color, #64748b)
          calc((var(--level-glow-core, 0.32) + 0.05) * 100%),
        transparent
      ),
    0 0 calc(var(--level-glow-spread, 12px) + 3px)
      color-mix(
        in srgb,
        var(--level-color, #64748b)
          calc((var(--level-glow, 0.24) + 0.05) * 100%),
        transparent
      );
}

.vocab-card__top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.vocab-card__word {
  margin: 0;
  /* one type step smaller than 1.5–1.75rem */
  font-size: clamp(1.35rem, 1.5vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  /* Click-to-speak (AnnaphoraSpeech) — same affordance as student dictionary */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /*
   * Line-height 1.2 + overflow:hidden was clipping descenders (g, y, p, q, j)
   * on bold display sizes. Slightly taller line box + a little padding keeps
   * tails visible while still clipping long words horizontally via fit JS.
   */
  line-height: 1.35;
  padding-top: 0.06em;
  padding-bottom: 0.14em;
  color: var(--text);
  text-transform: lowercase;
  text-align: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* Single line; JS shrinks font (or scaleX) so the full word fits — no ellipsis */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
}

.vocab-card__pos {
  align-self: center;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pos-color, var(--purple));
  background: var(--pos-bg, var(--purple-soft));
  border-radius: 999px;
  padding: 2px 8px;
  max-width: 100%;
  overflow: hidden;
  /* JS may shrink font to fully fit long POS labels */
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
}

/* POS color coding (palette: primary, purple, coral, accent, error, warning) */
.vocab-card__pos[data-pos="noun"] {
  --pos-color: var(--primary);
  --pos-bg: var(--primary-soft);
}
.vocab-card__pos[data-pos="verb"] {
  --pos-color: var(--accent);
  --pos-bg: var(--accent-soft);
}
.vocab-card__pos[data-pos="adjective"],
.vocab-card__pos[data-pos="adj"] {
  --pos-color: var(--purple);
  --pos-bg: var(--purple-soft);
}
.vocab-card__pos[data-pos="adverb"],
.vocab-card__pos[data-pos="adv"] {
  --pos-color: var(--coral);
  --pos-bg: var(--coral-soft);
}
.vocab-card__pos[data-pos="preposition"],
.vocab-card__pos[data-pos="prep"] {
  --pos-color: var(--warning);
  --pos-bg: var(--warning-soft);
}
.vocab-card__pos[data-pos="pronoun"] {
  --pos-color: #38bdf8;
  --pos-bg: rgba(56, 189, 248, 0.16);
}
.vocab-card__pos[data-pos="conjunction"],
.vocab-card__pos[data-pos="conj"] {
  --pos-color: var(--error);
  --pos-bg: var(--error-soft);
}
.vocab-card__pos[data-pos="determiner"],
.vocab-card__pos[data-pos="article"],
.vocab-card__pos[data-pos="det"] {
  --pos-color: #94a3b8;
  --pos-bg: rgba(148, 163, 184, 0.18);
}
.vocab-card__pos[data-pos="interjection"],
.vocab-card__pos[data-pos="exclamation"] {
  --pos-color: var(--coral);
  --pos-bg: var(--coral-soft);
}
.vocab-card__pos[data-pos="number"],
.vocab-card__pos[data-pos="numeral"] {
  --pos-color: var(--warning);
  --pos-bg: var(--warning-soft);
}
.vocab-card__pos[data-pos="phrase"],
.vocab-card__pos[data-pos="idiom"] {
  --pos-color: var(--purple);
  --pos-bg: var(--purple-soft);
}

.vocab-card__block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vocab-card__definition {
  margin: 0;
  color: var(--coral);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.2;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  /* Wrap long sentences; JS shrinks font / scales so full text shows */
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: manual;
}

.vocab-card__translation {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 750;
  color: var(--primary);
  line-height: 1.2;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: manual;
}

.vocab-card__translation[dir="rtl"],
.vocab-card__example-tr[dir="rtl"] {
  text-align: center;
  font-weight: 700;
}

.vocab-card__example {
  margin-top: auto;
  padding: 8px 7px 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
  min-height: 0;
  background: rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

html[data-theme="light"] .vocab-card__example {
  background: rgba(15, 23, 42, 0.04);
}

.vocab-card__example-en {
  margin: 0;
  font-size: 0.86rem; /* +1 type step */
  line-height: 1.2;
  color: var(--text);
  font-style: italic;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  /* Long example sentences: wrap + JS fit so full text stays on the card */
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: manual;
  /* Click-to-speak (AnnaphoraSpeech) */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.vocab-card__word:focus-visible,
.vocab-card__example-en:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.vocab-card__example-tr {
  margin: 0;
  font-size: 0.84rem; /* +1 type step */
  line-height: 1.2;
  color: var(--text-secondary);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: manual;
}

.vocab-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: auto;
  justify-content: center;
}

.vocab-card__meta:empty {
  display: none;
}

/*
 * Knowledge level sits on the card’s bottom border, centered:
 * half the chip above the edge, half below it.
 */
.vocab-card__chip--level {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 6;
  transform: translate(-50%, 50%);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.01em;
  min-width: 2.6rem;
  justify-content: center;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 2px 6px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.35);
  pointer-events: none;
}

html[data-theme="light"] .vocab-card__chip--level {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 2px 5px rgba(15, 23, 42, 0.12);
  border-color: rgba(15, 23, 42, 0.1);
}

.vocab-card__chip--level-low {
  background: var(--error-soft);
  color: var(--error);
  border-color: transparent;
}

.vocab-card__chip--level-mid {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

.vocab-card__chip--level-high {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.vocab-card__chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 2px 6px;
}

.vocab-card__missing {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-style: italic;
  text-align: center;
}

/* Band jump links + view toggle (List / Cards) */
.dict-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin-bottom: 22px;
}

.band-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.band-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.band-nav__link:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.band-nav__link span {
  color: var(--text-muted);
  font-weight: 700;
}

.dict-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

.dict-view-toggle:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.dict-view-toggle[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.dict-view-toggle__icon {
  font-size: 1rem;
  line-height: 1;
}

/* Collapsed list view — one word name per line; click expands to full card */
.band-section--list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px 14px;
  box-shadow: var(--shadow-sm);
}

.band-section--list .band-section__header {
  background: transparent;
  border-color: transparent;
  padding: 6px 4px;
  margin-bottom: 8px;
}

.band-section--list .band-section__header:hover {
  background: var(--primary-soft);
  border-color: transparent;
}

.band-section--list.is-collapsed .band-section__header {
  margin-bottom: 0;
}

.vocab-name-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.vocab-name-list__item {
  margin: 0;
  padding: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.vocab-name-list__item:last-child {
  border-bottom: none;
}

.vocab-name-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 6px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 48px;
  opacity: 1;
  transform: translateY(0);
  transition:
    background 0.2s ease,
    max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease,
    padding 0.35s ease,
    transform 0.3s ease;
}

/*
 * Dictionary / Unknown list: English | L1 translation | chevron
 * Each row is its own grid, so the English column MUST be a fixed width —
 * minmax(a, b) still sized per-row to content and misaligned translations.
 */
.vocab-name-list__row--with-tr {
  --dict-list-word-col: 11.5rem;
  --dict-list-chevron-col: 1.35rem;
  --dict-list-col-gap: 1.25rem;
  display: grid;
  grid-template-columns:
    var(--dict-list-word-col)
    minmax(0, 1fr)
    var(--dict-list-chevron-col);
  column-gap: var(--dict-list-col-gap);
  align-items: center;
  justify-content: stretch;
  gap: 0;
  overflow: hidden;
  max-height: none;
  padding-top: 11px;
  padding-bottom: 11px;
  padding-inline: 10px 8px;
}

.vocab-name-list__row:hover {
  background: var(--primary-soft);
}

/* Expanded: name row stays in place so the user can click it again to collapse */
.vocab-name-list__item.is-expanded .vocab-name-list__row {
  background: var(--primary-soft);
}

.vocab-name-list__word {
  font-size: 1.05rem;
  font-weight: 650;
  color: inherit;
  text-transform: lowercase;
  letter-spacing: -0.01em;
  line-height: 1.3;
  transition: opacity 0.25s ease, transform 0.3s ease;
}

.vocab-name-list__row--with-tr .vocab-name-list__word {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-self: stretch;
  text-align: left;
}

/* L1 column: every row starts at the same x (after fixed English col + gap) */
.vocab-name-list__tr {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-muted);
  /* Physical left of the L1 column — same for RU and HE so both sit near English */
  text-align: left;
  justify-self: stretch;
}

/*
 * Hebrew: still dir=rtl for correct glyph order, but left-edge of the cell
 * (not right-aligned into the chevron). Matches Russian’s left margin and
 * leaves the same free space on the right before the chevron.
 */
.vocab-name-list__tr[dir="rtl"] {
  text-align: left;
  font-weight: 550;
  unicode-bidi: plaintext;
  direction: rtl;
}

.vocab-name-list__tr--empty::before {
  content: "\00a0";
}

.vocab-name-list__tr--empty {
  visibility: hidden;
}

.vocab-name-list__row--with-tr .vocab-name-list__chevron {
  justify-self: center;
  margin-right: 0;
  margin-bottom: 2px;
}

.vocab-name-list__chevron {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.3s ease, border-color 0.2s ease, opacity 0.2s ease;
  margin-right: 6px;
  margin-bottom: 2px;
}

/* Slightly wider English column on larger panels so long lemmas don't feel cramped */
@media (min-width: 720px) {
  .vocab-name-list__row--with-tr {
    --dict-list-word-col: 13rem;
    --dict-list-col-gap: 1.5rem;
    padding-inline: 12px 10px;
  }
}

@media (max-width: 520px) {
  .vocab-name-list__row--with-tr {
    --dict-list-word-col: 7.25rem;
    --dict-list-chevron-col: 1.1rem;
    --dict-list-col-gap: 0.65rem;
    padding-inline: 6px 4px;
  }

  .vocab-name-list__tr {
    font-size: 0.92rem;
  }

  .vocab-name-list__word {
    font-size: 1rem;
  }
}

.vocab-name-list__item.is-expanded .vocab-name-list__chevron {
  transform: rotate(225deg);
  margin-bottom: -2px;
  border-color: var(--primary);
}

/* Height animation: siblings push down as this opens */
.vocab-name-list__expand {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.vocab-name-list__item.is-expanded .vocab-name-list__expand {
  grid-template-rows: 1fr;
}

.vocab-name-list__expand-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transition:
    opacity 0.35s ease 0.05s,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.02s;
}

.vocab-name-list__item.is-expanded .vocab-name-list__expand-inner {
  opacity: 1;
  transform: translateY(0) scale(1);
  padding: 4px 6px 16px;
}

/* Unknown Words list: room for corner + and bottom-edge level chip */
.unknown-dict-list .vocab-name-list__item.is-expanded .vocab-name-list__expand-inner {
  overflow: visible;
  padding: 12px 12px 20px;
}

/* Full card when revealed from list */
.vocab-card--from-list {
  aspect-ratio: 5 / 9.2;
  width: min(220px, 100%);
  max-width: 240px;
  margin: 0 auto;
  /* Collapse by re-clicking the name row — card itself is not a toggle control */
  cursor: default;
  animation: vocab-card-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes vocab-card-pop {
  from {
    opacity: 0.4;
    transform: translateY(-10px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .dict-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .dict-view-toggle {
    align-self: flex-end;
  }

  .vocab-card--from-list {
    width: min(260px, 100%);
  }
}

@media (max-width: 640px) {
  .band-section__grid,
  .vocab-grid,
  .unknown-dict-grid {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-inline: 0;
    gap: 12px 0;
  }

  .vocab-card {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 5 / 9.2;
  }

  /*
   * Dictionary cards on a phone: one full-width horizontal bar.
   * Word and part of speech share the top line; the sentences stack
   * under it and the card grows only as tall as that text.
   */
  .band-section__grid > .vocab-card,
  .vocab-grid > .vocab-card,
  .unknown-dict-grid > .vocab-card,
  .vocab-card.vocab-card--from-list {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    aspect-ratio: auto;
    height: auto;
    min-height: 0;
    gap: 3px;
    padding: 8px 12px 14px;
  }

  .band-section__grid > .vocab-card > *,
  .vocab-grid > .vocab-card > *,
  .unknown-dict-grid > .vocab-card > *,
  .vocab-card.vocab-card--from-list > * {
    min-width: 0;
    max-width: 100%;
  }

  .band-section__grid > .vocab-card > .vocab-card__top,
  .vocab-grid > .vocab-card > .vocab-card__top,
  .unknown-dict-grid > .vocab-card > .vocab-card__top,
  .vocab-card.vocab-card--from-list > .vocab-card__top {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    padding: 0 0 4px;
    min-width: 0;
    overflow: hidden;
  }

  .band-section__grid > .vocab-card .vocab-card__word,
  .vocab-grid > .vocab-card .vocab-card__word,
  .unknown-dict-grid > .vocab-card .vocab-card__word,
  .vocab-card.vocab-card--from-list .vocab-card__word {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    text-align: start;
    font-size: 1.28rem;
  }

  .band-section__grid > .vocab-card .vocab-card__pos,
  .vocab-grid > .vocab-card .vocab-card__pos,
  .unknown-dict-grid > .vocab-card .vocab-card__pos,
  .vocab-card.vocab-card--from-list .vocab-card__pos {
    flex: 0 0 auto;
  }

  .band-section__grid > .vocab-card .vocab-card__definition,
  .vocab-grid > .vocab-card .vocab-card__definition,
  .unknown-dict-grid > .vocab-card .vocab-card__definition,
  .vocab-card.vocab-card--from-list .vocab-card__definition,
  .band-section__grid > .vocab-card .vocab-card__translation,
  .vocab-grid > .vocab-card .vocab-card__translation,
  .unknown-dict-grid > .vocab-card .vocab-card__translation,
  .vocab-card.vocab-card--from-list .vocab-card__translation,
  .band-section__grid > .vocab-card .vocab-card__example-en,
  .vocab-grid > .vocab-card .vocab-card__example-en,
  .unknown-dict-grid > .vocab-card .vocab-card__example-en,
  .vocab-card.vocab-card--from-list .vocab-card__example-en,
  .band-section__grid > .vocab-card .vocab-card__example-tr,
  .vocab-grid > .vocab-card .vocab-card__example-tr,
  .unknown-dict-grid > .vocab-card .vocab-card__example-tr,
  .vocab-card.vocab-card--from-list .vocab-card__example-tr {
    text-align: start;
    white-space: normal;
    overflow-wrap: break-word;
    height: auto;
    max-height: none;
  }

  .band-section__grid > .vocab-card .vocab-card__translation,
  .vocab-grid > .vocab-card .vocab-card__translation,
  .unknown-dict-grid > .vocab-card .vocab-card__translation,
  .vocab-card.vocab-card--from-list .vocab-card__translation {
    font-size: 1.05rem;
  }

  .band-section__grid > .vocab-card > .vocab-card__example,
  .vocab-grid > .vocab-card > .vocab-card__example,
  .unknown-dict-grid > .vocab-card > .vocab-card__example,
  .vocab-card.vocab-card--from-list > .vocab-card__example,
  .band-section__grid > .vocab-card > .vocab-card__freeze,
  .vocab-grid > .vocab-card > .vocab-card__freeze,
  .unknown-dict-grid > .vocab-card > .vocab-card__freeze,
  .vocab-card.vocab-card--from-list > .vocab-card__freeze,
  .band-section__grid > .vocab-card > .vocab-card__meta,
  .vocab-grid > .vocab-card > .vocab-card__meta,
  .unknown-dict-grid > .vocab-card > .vocab-card__meta,
  .vocab-card.vocab-card--from-list > .vocab-card__meta {
    margin-top: 0;
    flex: 0 0 auto;
  }

  .band-section__grid > .vocab-card > .vocab-card__example,
  .vocab-grid > .vocab-card > .vocab-card__example,
  .unknown-dict-grid > .vocab-card > .vocab-card__example,
  .vocab-card.vocab-card--from-list > .vocab-card__example {
    padding: 5px 8px 4px;
  }

  .lang-select__label {
    display: none;
  }

  .voice-select__label {
    display: none;
  }

  .voice-select select,
  select[data-voice-select] {
    min-width: 120px;
    max-width: 46vw;
  }
}

/* -------------------------------------------------------------------------- */
/* Landing (index)                                                             */
/* -------------------------------------------------------------------------- */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px var(--space-page) 64px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 650;
  margin-bottom: 24px;
  border: 1px solid transparent;
}

.landing-title {
  font-size: clamp(2.4rem, 7vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.1;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text) 20%, var(--primary) 70%, var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.landing-sub {
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 32px;
  line-height: 1.55;
}

.landing-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 48px;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 640px;
}

.landing-feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.landing-feature__icon {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.landing-feature strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.landing-feature span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.landing-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* Auth shell */
.auth-card {
  width: 100%;
  max-width: var(--max-form);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 32px;
  text-align: center;
}

.auth-card h1 {
  margin-bottom: 6px;
}

.auth-card > .lead {
  margin-bottom: 28px;
}

/* -------------------------------------------------------------------------- */
/* Utilities                                                                   */
/* -------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-left { text-align: left; }
.text-center { text-align: center; }

/* -------------------------------------------------------------------------- */
/* Responsive                                                                  */
/* -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .container,
  .auth-card {
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }

  .landing-features {
    grid-template-columns: 1fr;
  }

  .page-body {
    padding-top: calc(var(--header-h) + 20px);
  }

  .dict-page {
    margin-top: 0;
  }

  .band-section {
    padding: 16px;
  }

  .dashboard-header {
    flex-direction: column;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------------------- */
/* Drilling                                                                    */
/* -------------------------------------------------------------------------- */

/* Entire drilling webpage: no text selection (prompts, nav, options, etc.) */
body.drill-session,
body.drill-session * {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none;
}

.drill-page {
  max-width: 720px;
}

.drill-chrome {
  margin-bottom: 20px;
}

.drill-chrome__top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.drill-title {
  margin: 0 0 4px;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.drill-stage-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
}

.drill-counter {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Continuous session progress (single fill line; Safari-friendly scaleX) */
.drill-progress {
  position: relative;
  height: 10px;
  width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.drill-progress__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--coral), var(--primary));
  /* scaleX is more reliable than width % on Safari */
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transform-origin: left center;
  transform-origin: left center;
  -webkit-transition: -webkit-transform 0.28s ease;
  transition: transform 0.28s ease;
  will-change: transform;
  pointer-events: none;
}

.drill-stage {
  min-height: 320px;
}

.drill-stage.is-stage-in {
  animation: drill-stage-in 0.22s ease;
}

@keyframes drill-stage-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.is-lang-swap .vocab-card__translation,
  html.is-lang-swap .vocab-card__example-tr,
  html.is-lang-swap .vocab-name-list__tr,
  html.is-lang-swap .drill-prompt,
  html.is-lang-swap .drill-option,
  .drill-stage.is-stage-in {
    animation: none;
  }
}

.drill-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.drill-panel--quiz {
  text-align: center;
}

.drill-panel h2 {
  margin: 0 0 10px;
}

.drill-flow-list {
  margin: 0 0 22px;
  padding-left: 1.25rem;
  color: var(--text-secondary);
  text-align: left;
  line-height: 1.55;
}

.drill-flow-list li {
  margin-bottom: 6px;
}

.drill-hint {
  margin: 0 0 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drill-prompt {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 22px;
  word-break: break-word;
}

.drill-prompt--l1 {
  color: var(--primary);
}

/* EN→L1 English target: click to re-hear (no layout change) */
.drill-prompt--speakable {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.drill-prompt--speakable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
  border-radius: 4px;
}

.drill-options {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 560px) {
  .drill-options {
    grid-template-columns: 1fr 1fr;
  }
}

.drill-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    background 0.12s ease,
    transform 0.12s ease;
}

.drill-option:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.drill-option:disabled {
  cursor: default;
  opacity: 0.95;
}

.drill-option.is-correct {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.drill-option.is-wrong {
  border-color: var(--error);
  background: var(--error-soft);
  color: var(--error);
}

.drill-xp-list {
  margin: 10px 0 0;
  padding-left: 1.2em;
  text-align: left;
  list-style: disc;
}

.drill-xp-list li {
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.drill-feedback {
  margin: 0 0 14px;
  font-weight: 700;
  font-size: 0.98rem;
}

.drill-feedback--ok {
  color: var(--accent);
}

.drill-feedback--bad {
  color: var(--error);
}

.drill-type-input {
  width: 100%;
  max-width: 360px;
  margin: 0 auto 16px;
  display: block;
  padding: 14px 16px;
  font-size: 1.15rem;
  font-weight: 650;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
}

.drill-type-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.drill-type-input.is-correct {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.drill-type-input.is-wrong {
  border-color: var(--error);
  background: var(--error-soft);
  color: var(--error);
  box-shadow: 0 0 0 3px var(--error-soft);
}

.drill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* Intro fly stage */
.drill-intro-stage {
  position: relative;
  min-height: min(70vh, 560px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-lg, 16px);
  background:
    radial-gradient(ellipse at center, var(--primary-soft) 0%, transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
}

.drill-intro-card {
  position: absolute;
  /* Intro card — 50% larger than the compact tile */
  width: min(222px, 57vw);
  max-width: 240px;
  aspect-ratio: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: 320px;
  padding: 15px 15px 18px !important;
  gap: 8px !important;
  z-index: 2;
  /* Allow click-to-speak on the word while card is visible */
  pointer-events: auto;
  opacity: 0;
  transform: translate(var(--fly-in-x, -100vw), var(--fly-in-y, 0)) scale(0.88);
  will-change: transform, opacity;
  overflow: hidden;
}

.drill-intro-card .vocab-card__word {
  font-size: 1.58rem !important;
  line-height: 1.15;
}

.drill-intro-card .vocab-card__pos {
  font-size: 0.87rem;
  padding: 2px 7px;
}

.drill-intro-card .vocab-card__definition,
.drill-intro-card .vocab-card__translation {
  font-size: 1.08rem !important;
  line-height: 1.25;
}

.drill-intro-card .vocab-card__meta {
  margin-top: auto;
}

.drill-intro-card .vocab-card__chip {
  font-size: 0.82rem;
  padding: 3px 8px;
}

.drill-intro-card .vocab-card__chip--level {
  /* Keep straddling bottom edge; slightly larger for intro */
  font-size: 0.82rem;
  padding: 3px 8px;
}

.drill-intro-card.is-in {
  /* 40% slower again relative to previous pacing */
  animation: drill-fly-in 0.74s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.drill-intro-card.is-out {
  animation: drill-fly-out 0.63s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Celebrate stage reuses intro stage layout */
.drill-intro-card .vocab-card__freeze {
  margin-top: 8px;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.75rem;
  align-self: center;
  transform-origin: center center;
}
.drill-intro-card .vocab-card__freeze.vocab-card__freeze--await-pop {
  opacity: 0;
  transform: scale(0.35) translateY(10px);
}
.drill-intro-card .vocab-card__freeze.vocab-card__freeze--pop {
  animation: vocab-freeze-timer-pop 0.55s ease-out forwards;
}
.drill-intro-card.vocab-card--freeze-animating {
  transition:
    border-color 1.05s ease-in-out,
    box-shadow 1.05s ease-in-out;
}
/* 20/20: glow ramps continuously upward (no fade-back) */
.drill-intro-card.vocab-card--mastery-animating {
  transition:
    border-color 3.15s ease-out,
    box-shadow 3.15s ease-out;
}
.drill-intro-card.vocab-card--mastery-peak {
  --level-color: #fbbf24;
  --level-glow: 0.94;
  --level-glow-core: 1;
  --level-glow-spread: 41px;
  --level-glow-spread-core: 17px;
}
.drill-intro-card.vocab-card--freeze-peak {
  --level-color: #22e65c;
  --level-glow: 0.72;
  --level-glow-core: 0.86;
  --level-glow-spread: 30px;
  --level-glow-spread-core: 12px;
}

@keyframes drill-fly-in {
  from {
    opacity: 0;
    transform: translate(var(--fly-in-x, -100vw), var(--fly-in-y, 0)) scale(0.82);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
}

@keyframes drill-fly-out {
  from {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(var(--fly-out-x, 100vw), var(--fly-out-y, 0)) scale(0.88);
  }
}

/* Gaps */
.drill-panel--gaps {
  text-align: left;
}

.drill-bank-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
}

.drill-word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}

.drill-word-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-full, 999px);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
}

.drill-word-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.drill-word-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.drill-gaps-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drill-gap-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid transparent;
  cursor: pointer;
}

.drill-gap-item .drill-gap-input {
  cursor: text;
}

.drill-gap-item.is-correct {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drill-gap-item.is-wrong {
  border-color: var(--error);
  background: var(--error-soft);
}

.drill-gap-num {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  margin-top: 2px;
}

.drill-gap-sentence {
  margin: 0;
  flex: 1;
  line-height: 1.55;
  font-size: 1rem;
  color: var(--text);
}

.drill-gap-input {
  display: inline-block;
  min-width: 5.5rem;
  max-width: 10rem;
  width: 7rem;
  margin: 0 4px;
  padding: 4px 8px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  border: none;
  border-bottom: 2px solid var(--primary);
  border-radius: 4px 4px 0 0;
  background: var(--input-bg);
  color: var(--text);
  vertical-align: baseline;
}

.drill-gap-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  background: var(--primary-soft);
}

.drill-gap-item.is-wrong .drill-gap-input {
  border-bottom-color: var(--error);
}

.drill-gap-item.is-correct .drill-gap-input {
  border-bottom-color: var(--accent);
}

@media (max-width: 560px) {
  .drill-page {
    max-width: 100%;
  }

  .drill-panel {
    padding: 20px 16px;
  }

  .drill-intro-stage {
    min-height: 55vh;
  }
}

/* Print-friendly */
@media print {
  body {
    background: white;
    color: black;
  }
  .app-nav,
  .theme-toggle {
    display: none;
  }
}

/* -------------------------------------------------------------------------- */
/* Teacher: My Sets                                                            */
/* -------------------------------------------------------------------------- */

.sets-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform 0.12s ease;
}

a.sets-back-link {
  color: var(--text);
  text-decoration: none;
}

.sets-back-link:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sets-back-link:active {
  transform: translateY(0);
  box-shadow: none;
}

.sets-back-link:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.sets-in-count {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Shared-set offer: new custom cards → My Words */
.shared-cards-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: min(40vh, 280px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}

.shared-cards-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.shared-cards-list__item:last-child {
  border-bottom: none;
}

.shared-cards-list__word {
  grid-column: 1;
  font-weight: 750;
  font-size: 0.98rem;
  color: var(--text);
  text-transform: lowercase;
}

.shared-cards-list__pos {
  grid-column: 2;
  justify-self: end;
  align-self: start;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: lowercase;
}

.shared-cards-list__def {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Sets | My Words segment control */
.sets-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  border-radius: var(--radius-full, 999px);
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
}

.sets-tabs__btn {
  margin: 0;
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-full, 999px);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.sets-tabs__btn:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.12);
}

.sets-tabs__btn.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent);
}

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

.my-words-list .vocab-name-list__row {
  cursor: pointer;
}

.sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 8px;
}

.sets-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform 0.15s ease;
}

.sets-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.sets-card__title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.25;
  word-break: break-word;
}

.sets-card__meta {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.sets-card__meta strong {
  color: var(--text);
  font-weight: 700;
}

.sets-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sets-create-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  margin-top: 4px;
}

.sets-create-form__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--text-secondary);
  text-align: left;
}

.sets-create-form__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.sets-create-form__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.sets-create-form__error {
  margin: 0;
  color: #dc2626;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
}

.sets-band-toolbar {
  margin-bottom: 12px;
}

.band-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.band-nav__btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.band-nav__btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* List row: name + optional related hint + band + chevron | + button.
   Stays visible when expanded so the user can click the word again to collapse. */
.vocab-name-list__line {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
}

.vocab-name-list__line .vocab-name-list__row {
  flex: 1 1 auto;
  min-width: 0;
}

/* ── My Sets table layout: Word | Related to | Band | ▾ | actions ─ */
.sets-word-list {
  --sets-col-related: 9.5rem;
  /* Room for the wider “Custom” type pill (min 5.25rem + padding) */
  --sets-col-band: 6.25rem;
  --sets-col-chevron: 18px;
  --sets-col-action: 1.75rem;
  --sets-col-actions: 3.1rem;
  --sets-table-gap: 12px;
}

.my-words-list {
  --sets-col-related: 8.5rem;
  --sets-col-band: 6.25rem;
}

.sets-table-header {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    var(--sets-col-related)
    var(--sets-col-band)
    var(--sets-col-chevron)
    var(--sets-col-actions);
  column-gap: var(--sets-table-gap);
  align-items: center;
  padding: 4px 6px 10px;
  margin: 0 0 2px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sets-table-header__related {
  text-align: left;
  padding-inline: 2px;
}

.sets-table-header__band {
  text-align: center;
  justify-self: center;
}

.sets-table-header__action {
  /* matches actions column (edit / remove / +) */
}

.sets-word-list .vocab-name-list__line.sets-table-line {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    var(--sets-col-related)
    var(--sets-col-band)
    var(--sets-col-chevron)
    var(--sets-col-actions);
  column-gap: var(--sets-table-gap);
  align-items: center;
  padding-inline: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

/* Full-line hover / expanded highlight (includes action buttons) */
.sets-word-list .vocab-name-list__line.sets-table-line:hover {
  background: var(--primary-soft);
}

.sets-word-list .vocab-name-list__item.is-expanded .vocab-name-list__line.sets-table-line {
  background: var(--primary-soft);
}

.sets-word-list .vocab-name-list__row.sets-table-row {
  grid-column: 1 / span 4;
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    var(--sets-col-related)
    var(--sets-col-band)
    var(--sets-col-chevron);
  column-gap: var(--sets-table-gap);
  align-items: center;
  justify-content: stretch;
  width: auto;
  min-width: 0;
  max-width: none;
  padding-top: 12px;
  padding-bottom: 12px;
  padding-inline: 0;
  overflow: visible;
  max-height: none;
}

/* Row itself is transparent — line owns the highlight */
.sets-word-list .vocab-name-list__row.sets-table-row:hover,
.sets-word-list .vocab-name-list__item.is-expanded .vocab-name-list__row.sets-table-row {
  background: transparent;
}

.sets-word-list .vocab-name-list__actions {
  grid-column: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.sets-word-list .vocab-name-list__band {
  justify-self: center;
  width: max-content;
  max-width: 100%;
}

.sets-word-list .vocab-name-list__chevron {
  justify-self: center;
  margin-right: 0;
  margin-bottom: 0;
  width: 9px;
  height: 9px;
  box-sizing: border-box;
}

.sets-word-list .vocab-name-list__word {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Related forms are flat A–Z peers — fixed column keeps families aligned */
.sets-word-list .vocab-name-list__related {
  display: block;
  min-width: 0;
  max-width: none;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.95;
  text-align: left;
  line-height: 1.3;
}

.sets-word-list .vocab-name-list__related.is-empty {
  visibility: hidden;
}

.vocab-name-list__item--related .vocab-name-list__word {
  /* Same weight/indent as headwords — not nested under thousands or families */
  font-weight: 650;
}

/* Band K labels — fixed column, centered pill */
.sets-word-list .vocab-name-list__band {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: 100%;
  min-width: 0;
  max-width: 2.5rem;
  margin: 0 auto;
  padding: 2px 0;
  border-radius: 999px;
  background: var(--surface-2, var(--bg));
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.95;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* “Custom” is longer than “1K”/“6K” — must not inherit the 2.5rem band cap */
.sets-word-list .vocab-name-list__band--custom {
  width: auto;
  min-width: 5.25rem;
  max-width: none;
  padding: 4px 16px;
  margin: 0;
  color: var(--text-muted);
  background: var(--surface-2, var(--bg));
  border: 1px solid var(--border);
  font-variant-numeric: normal;
  letter-spacing: 0.02em;
  opacity: 0.95;
}

.sets-word-list .vocab-name-list__band.is-empty {
  visibility: hidden;
  border-color: transparent;
  background: transparent;
}

.sets-word-list .vocab-name-list__chevron {
  justify-self: end;
  margin-right: 0;
  margin-bottom: 2px;
}

.sets-word-list .vocab-name-list__chevron-spacer {
  display: block;
  width: 8px;
  height: 8px;
}

/* Keep + / − aligned in the action column */
.sets-word-list .vocab-name-list__add-btn {
  flex: 0 0 1.15rem;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
}

/* Remove matches My Dictionary size (1.15rem) */
.sets-word-list .vocab-name-list__remove-btn {
  flex: 0 0 1.15rem;
  width: 1.15rem;
  height: 1.15rem;
  align-self: center;
  margin: 0;
  box-sizing: border-box;
}

/* Edit custom card (My Words + set detail) */
.vocab-name-list__edit-btn {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0 4px 0 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--warning);
  color: #422006;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  line-height: 0;
  text-align: center;
}

.vocab-name-list__edit-btn > span {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-0.04em);
}

.vocab-name-list__edit-btn:hover {
  filter: brightness(1.06);
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(245, 158, 11, 0.5);
}

.vocab-name-list__edit-btn:active {
  transform: scale(0.96);
}

.vocab-name-list__edit-btn:focus-visible {
  outline: 2px solid var(--warning);
  outline-offset: 2px;
}

.sets-word-list .vocab-name-list__edit-btn {
  flex: 0 0 1.15rem;
  width: 1.15rem;
  height: 1.15rem;
  align-self: center;
  margin: 0;
  box-sizing: border-box;
}

/* Expanded chevron: keep fully visible (no clip from row overflow) */
.sets-word-list .vocab-name-list__item.is-expanded .vocab-name-list__chevron {
  margin-bottom: 0;
  transform: rotate(225deg) translateY(1px);
}

/* Fallback (non–My Sets pages) if classes are reused */
.vocab-name-list__related {
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 26%;
  opacity: 0.9;
}

.vocab-name-list__band {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2, var(--bg));
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

@media (max-width: 640px) {
  .sets-word-list {
    --sets-col-related: 5.5rem;
    --sets-col-band: 6rem;
    --sets-col-actions: 2.9rem;
    --sets-table-gap: 8px;
  }

  .my-words-list {
    --sets-col-related: 5.25rem;
    --sets-col-band: 6rem;
  }

  .sets-table-header {
    font-size: 0.65rem;
    padding-inline: 4px;
  }

  .sets-word-list .vocab-name-list__line.sets-table-line {
    padding-inline: 4px;
  }

  .sets-word-list .vocab-name-list__related {
    font-size: 0.72rem;
  }
}

.vocab-name-list__add-btn {
  flex-shrink: 0;
  width: 1.55rem;
  height: 1.55rem;
  margin: 0 4px 0 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #052e16;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.35);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease,
    opacity 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  line-height: 0;
}

.vocab-name-list__add-btn > span {
  display: block;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-0.06em);
}

.vocab-name-list__add-btn:hover:not(:disabled):not(.is-in-set) {
  background: var(--accent-hover);
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(34, 197, 94, 0.5);
}

.vocab-name-list__add-btn:active:not(:disabled):not(.is-in-set) {
  transform: scale(0.96);
}

.vocab-name-list__add-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.vocab-name-list__add-btn.is-in-set,
.vocab-name-list__add-btn:disabled.is-in-set {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
  cursor: default;
  opacity: 1;
}

.vocab-name-list__add-btn.is-busy {
  opacity: 0.55;
  cursor: wait;
}

/* Set detail: non-interactive name row + remove control */
.sets-detail-row {
  cursor: default;
}

.sets-detail-row:hover {
  background: transparent;
}

/* Set remove: same solid red circle as My Dictionary reset (−) */
.vocab-name-list__remove-btn {
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0 4px 0 0;
  padding: 0;
  border: none;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--error);
  color: #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  line-height: 0;
  text-align: center;
}

.vocab-name-list__remove-btn > span {
  display: block;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  /* Same optical center as .vocab-card__reset-btn */
  transform: translateY(-0.12em);
}

.vocab-name-list__remove-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.5);
}

html[data-theme="dark"] .vocab-name-list__remove-btn:hover,
:root:not([data-theme="light"]) .vocab-name-list__remove-btn:hover {
  background: #f87171;
  color: #450a0a;
}

.vocab-name-list__remove-btn:active {
  transform: scale(0.96);
}

.vocab-name-list__remove-btn:focus-visible {
  outline: 2px solid var(--error);
  outline-offset: 2px;
}

/* ── Graded assignment options (assign set popup) ── */
.assign-grade-opts {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2, var(--surface));
  text-align: left;
}

.assign-grade-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.assign-grade-toggle input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--purple);
  cursor: pointer;
}

.assign-grade-hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.assign-deadline-wrap {
  margin-top: 12px;
}

.assign-deadline-wrap .sets-create-form__input {
  margin-top: 6px;
}

.assign-set-chip--graded {
  border-color: color-mix(in srgb, var(--purple) 40%, var(--border));
  background: var(--purple-soft);
}

/* Grades / performance tables */
.grades-table,
.performance-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.grades-table th,
.grades-table td,
.performance-table th,
.performance-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.grades-table th,
.performance-table th {
  background: var(--surface-2, var(--bg));
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.grades-table tr:last-child td,
.performance-table tr:last-child td {
  border-bottom: none;
}

.grade-pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.grade-pct.is-missing {
  color: var(--text-muted);
  font-weight: 600;
}

.grade-pending {
  color: var(--warning);
  font-weight: 650;
  font-size: 0.88rem;
}

/* Student statistics (teacher view) */
.stats-summary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 640px) {
  .stats-summary-row {
    grid-template-columns: 1fr;
  }
}

.stats-avg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}

.stats-avg-card--secondary {
  border-left-color: var(--purple);
}

.stats-avg-card__label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stats-avg-card__value {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stats-avg-card__value.is-empty {
  color: var(--text-muted);
  font-weight: 700;
}

.stats-avg-card__value--sm {
  font-size: 1.25rem;
  color: var(--text);
}

.stats-avg-card__hint {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.stats-param-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.stats-param-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition);
}

.stats-param-tab:hover {
  border-color: var(--primary);
  color: var(--text);
}

.stats-param-tab.is-active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.stats-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 16px 12px;
  box-shadow: var(--shadow-sm);
}

.stats-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stats-chart-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
}

.stats-chart-max {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.stats-chart-empty {
  margin: 8px 0 4px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.stats-bar-chart__plot {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 220px;
  padding: 8px 2px 0;
  overflow-x: auto;
}

.stats-bar-chart__col {
  flex: 1 1 0;
  min-width: 28px;
  max-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stats-bar-chart__value {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-height: 1em;
  line-height: 1;
}

.stats-bar-chart__bar-wrap {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.stats-bar-chart__bar {
  width: 70%;
  min-width: 10px;
  max-width: 28px;
  border-radius: 6px 6px 3px 3px;
  background: var(--primary);
  box-shadow: 0 2px 8px var(--primary-soft);
  transition: height 0.25s ease;
}

.stats-bar-chart__bar.is-zero {
  height: 2px !important;
  opacity: 0.35;
  background: var(--border-strong);
  box-shadow: none;
}

/* Stacked mastered-by-band bar (total height = overall mastered) */
.stats-bar-chart__stack {
  width: 70%;
  min-width: 10px;
  max-width: 28px;
  border-radius: 6px 6px 3px 3px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse; /* 1k at bottom */
  box-shadow: 0 2px 8px var(--primary-soft);
  transition: height 0.25s ease;
}

.stats-bar-chart__seg {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  flex-shrink: 0;
  min-height: 0;
  display: block;
  cursor: pointer;
  transition: filter 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.stats-bar-chart__seg:hover,
.stats-bar-chart__seg:focus-visible {
  filter: brightness(1.12);
  outline: none;
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.stats-bar-chart__seg.is-selected {
  filter: brightness(1.18);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
  z-index: 2;
}

.stats-chart-detail {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2, var(--bg));
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 2.5rem;
}

.stats-chart-detail.is-hint {
  color: var(--text-secondary);
  font-weight: 550;
  font-size: 0.86rem;
}

.stats-chart-detail--list {
  padding: 12px 14px;
}

.stats-band-detail {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  min-height: 0;
  font: inherit;
  color: inherit;
}

.stats-band-detail.is-hint {
  color: var(--text-secondary);
  font-weight: 550;
  font-size: 0.86rem;
}

.stats-bar-chart__bar--clickable {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  display: block;
  cursor: pointer;
  background: var(--coral);
  box-shadow: 0 2px 8px var(--coral-soft);
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.stats-bar-chart__bar--clickable:hover,
.stats-bar-chart__bar--clickable:focus-visible {
  filter: brightness(1.1);
  outline: none;
  box-shadow: 0 2px 10px var(--coral-soft), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.stats-bar-chart__bar--clickable.is-selected {
  filter: brightness(1.16);
  box-shadow: 0 2px 12px var(--coral-soft), inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.stats-mistakes-detail__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.stats-mistakes-detail__title {
  font-weight: 750;
  color: var(--text);
}

.stats-mistakes-detail__total {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--coral);
  font-variant-numeric: tabular-nums;
}

.stats-mistakes-detail__empty {
  margin: 0;
  color: var(--text-secondary);
  font-weight: 550;
  font-size: 0.88rem;
}

.stats-mistakes-detail__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.stats-mistakes-detail__item {
  margin: 0;
}

.stats-mistakes-detail__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.stats-mistakes-detail__word {
  font-weight: 750;
  color: var(--text);
  word-break: break-word;
}

.stats-mistakes-detail__count {
  font-size: 0.84rem;
  font-weight: 650;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-mistakes-detail__bar {
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

.stats-mistakes-detail__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  min-width: 4px;
}

.stats-mistakes-detail__note {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-muted);
}

/* Class statistics — student ranking */
.class-rank-header {
  margin-bottom: 12px;
}

.class-rank-tabs {
  margin-bottom: 14px;
}

.class-rank-list__ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.class-rank-list__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.class-rank-list__place {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.85rem;
}

.class-rank-list__item:nth-child(1) .class-rank-list__place {
  background: var(--warning-soft);
  color: var(--warning);
}

.class-rank-list__item:nth-child(2) .class-rank-list__place {
  background: var(--surface-2);
  color: var(--text-secondary);
}

.class-rank-list__item:nth-child(3) .class-rank-list__place {
  background: var(--coral-soft);
  color: var(--coral);
}

.class-rank-list__body {
  flex: 1;
  min-width: 0;
}

.class-rank-list__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.class-rank-list__name {
  font-weight: 750;
  color: var(--text);
  text-decoration: none;
  word-break: break-word;
}

.class-rank-list__name:hover {
  color: var(--primary);
  text-decoration: underline;
}

.class-rank-list__score {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.class-rank-list__bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  overflow: hidden;
}

.class-rank-list__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  min-width: 4px;
}

/* Class statistics — clickable sets + detail panel */
.set-stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.set-stats-card {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition),
    transform var(--transition);
}

.set-stats-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.set-stats-card:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.set-stats-card__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.set-stats-card__name {
  font-weight: 750;
  font-size: 1.02rem;
  color: var(--text);
}

.set-stats-card__meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.set-stats-card__side {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.set-stats-card__chevron {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
}

/* Must stay display:none when closed — plain `display:flex` overrides HTML [hidden]. */
.set-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--overlay, rgba(15, 23, 42, 0.45));
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.set-detail-overlay[hidden] {
  display: none !important;
}

.set-detail-overlay.is-open {
  display: flex !important;
}

@media (min-width: 720px) {
  .set-detail-overlay.is-open {
    align-items: center;
    padding: 24px;
  }
}

.set-detail-panel {
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: var(--bg-elevated, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px 18px 22px;
}

.set-detail-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: var(--bg-elevated, var(--surface));
  z-index: 1;
  padding-bottom: 8px;
}

.set-detail-panel__title {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.set-detail-panel__sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.set-detail-section {
  margin-bottom: 22px;
}

.set-detail-section__title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 750;
}

.set-detail-table tr.is-current-class td {
  background: var(--primary-soft);
}

.set-detail-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 750;
  vertical-align: middle;
}

.set-detail-avg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 640px) {
  .set-detail-avg-grid {
    grid-template-columns: 1fr;
  }
}

.set-detail-avg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.set-detail-avg__label {
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.set-detail-avg__value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}

.set-detail-avg__hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.set-detail-student-link {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  word-break: break-word;
}

.set-detail-student-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

body.set-detail-open {
  overflow: hidden;
}

.stats-band-detail__swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.stats-band-detail__text {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
}

.stats-band-detail__date {
  color: var(--text-muted);
  font-weight: 650;
  font-size: 0.82rem;
  margin-right: 4px;
}

.stats-band-detail__date::after {
  content: "·";
  margin-left: 6px;
  color: var(--text-muted);
}

.stats-band-detail__k {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.stats-band-detail__n {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--primary);
}

.stats-band-seg--1000 {
  background: var(--accent);
}
.stats-band-seg--2000 {
  background: var(--primary);
}
.stats-band-seg--3000 {
  background: var(--purple);
}
.stats-band-seg--4000 {
  background: var(--coral);
}
.stats-band-seg--5000 {
  background: var(--error);
}
.stats-band-seg--6000 {
  background: var(--warning);
}
.stats-band-seg--other {
  background: var(--text-muted);
}

.stats-band-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-secondary);
}

.stats-band-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stats-band-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.stats-bar-chart__label {
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-top-words__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-top-words__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.stats-top-words__rank {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--coral-soft);
  color: var(--coral);
  font-weight: 800;
  font-size: 0.85rem;
}

.stats-top-words__body {
  flex: 1;
  min-width: 0;
}

.stats-top-words__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.stats-top-words__word {
  font-weight: 750;
  color: var(--text);
  word-break: break-word;
}

.stats-top-words__count {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-top-words__bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  overflow: hidden;
}

.stats-top-words__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  min-width: 4px;
}

#btnReturnToSet {
  white-space: nowrap;
  /* Primary-style so "return to set" is easy to spot while adding words */
  background: var(--primary);
  color: #0f172a;
  border: 1px solid transparent;
  box-shadow: 0 2px 12px var(--primary-soft);
  font-weight: 700;
}

#btnReturnToSet:hover {
  background: var(--primary-hover);
  color: #0f172a;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-soft);
}

.sets-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.sets-title--editable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  outline: none;
  transition: color var(--transition), background var(--transition);
}

.sets-title--editable:hover {
  color: var(--primary);
}

.sets-title--editable:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Expanded list cards in My Sets: room for corner + */
.sets-word-list .vocab-name-list__item.is-expanded .vocab-name-list__expand-inner {
  overflow: visible;
  padding: 12px 12px 20px;
}

/* Set picker cards (expanded) — green + like Unknown Words */
.vocab-card.vocab-card--set {
  position: relative;
}

.vocab-card.vocab-card--set > .vocab-card__add-btn {
  top: -8px;
  right: -8px;
  left: auto;
  bottom: auto;
  background: var(--accent);
  color: #052e16;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
}

.vocab-card.vocab-card--set > .vocab-card__add-btn > span {
  transform: translateY(-0.14em);
}

.vocab-card.vocab-card--set > .vocab-card__add-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.1);
}

.vocab-card.vocab-card--set > .vocab-card__add-btn.is-in-set,
.vocab-card.vocab-card--set > .vocab-card__add-btn:disabled {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
  cursor: default;
  opacity: 1;
  transform: none;
}

.vocab-card.vocab-card--set.vocab-card--in-set {
  border-color: var(--primary);
}
