/* ============================================
   THEME CONFIGURATION
   Edit this section to retheme the whole app
============================================ */

@font-face {
  font-family: 'Lexend';
src: url('fonts/Lexend-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Lexend';
src: url('fonts/Lexend-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Lexend';
src: url('fonts/Lexend-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Lexend';
src: url('fonts/Lexend-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-body: 'Lexend', Arial, sans-serif;
  --font-display: 'Lexend', Arial, sans-serif;

  --color-primary: #3bc8cd;
  --color-primary-dark: #1a9ba0;
  --color-bg: #f4fefe;
  --color-surface: #e8f9fa;
  --color-surface-2: #d0f0f2;
  --color-surface-3: #f9ffff;
  --color-text: #0d2b2c;
  --color-text-muted: #4a7275;
  --color-text-faint: #729295;
  --color-accent: #ffd166;
  --color-danger: #ff6b6b;
  --color-success: #06d6a0;
  --color-warning: #ffb84d;
  --color-border: #0d2b2c;
  --color-overlay: rgba(13, 43, 44, 0.58);
  --color-white: #ffffff;
--color-danger-hover:  #ff4f4f;
--color-danger-active: #e03a3a;

  --shadow: 4px 4px 0 var(--color-border);
  --shadow-hover: 6px 6px 0 var(--color-border);
  --shadow-press: 2px 2px 0 var(--color-border);
  --shadow-soft: 0 20px 50px rgba(13, 43, 44, 0.16);

  --border-width: 2px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --text-xs: clamp(0.75rem, 0.72rem + 0.12vw, 0.82rem);
  --text-sm: clamp(0.88rem, 0.84rem + 0.18vw, 0.97rem);
  --text-base: clamp(1rem, 0.98rem + 0.2vw, 1.08rem);
  --text-lg: clamp(1.1rem, 1.02rem + 0.35vw, 1.28rem);
  --text-xl: clamp(1.35rem, 1.15rem + 0.7vw, 1.8rem);
  --text-2xl: clamp(1.75rem, 1.45rem + 1.1vw, 2.4rem);

  --topbar-height: 76px;
  --sidebar-width: 272px;
  --bottom-nav-height: 82px;
  --sheet-max-width: 920px;
  --transition-fast: 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-medium: 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-bounce: 340ms cubic-bezier(0.16, 1.25, 0.3, 1);

  --z-base: 1;
  --z-topbar: 20;
  --z-sidebar: 25;
  --z-fab: 30;
  --z-overlay: 60;
  --z-sheet: 70;
  --z-modal: 80;
  --z-toast: 90;
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background:
    radial-gradient(circle at top right, rgba(59, 200, 205, 0.14), transparent 32%),
    linear-gradient(180deg, #faffff 0%, var(--color-bg) 100%);
  overflow-x: hidden;
}

body.is-modal-open,
body.is-sheet-open {
  overflow: hidden;
}

img,
svg,
video,
canvas,
iframe {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

input,
textarea,
select {
  width: 100%;
  max-width: 100%;
}

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

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  white-space: nowrap;
  overflow: hidden;
  clip-path: inset(50%);
}

:focus-visible {
  outline: 3px solid rgba(59, 200, 205, 0.6);
  outline-offset: 2px;
  border-radius: 10px;
}

::selection {
  background: rgba(59, 200, 205, 0.25);
}

/* ============================================
   LAYOUT
============================================ */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 max(var(--space-4), env(safe-area-inset-left)) 0 max(var(--space-4), env(safe-area-inset-right));
  background: rgba(244, 254, 254, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: var(--border-width) solid var(--color-border);
}

.topbar__brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  padding: 8px;
  display: grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 18px;
  background: var(--color-primary);
  box-shadow: var(--shadow);
  color: var(--color-border);
}

.brand-mark__svg {
  width: 100%;
  height: 100%;
}

.brand-copy {
  min-width: 0;
}

.brand-copy__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1;
}

.brand-copy__subtitle {
  margin: 0.2rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.sidebar {
  display: none;
}

.main-content {
  padding: var(--space-5) var(--space-4) calc(var(--bottom-nav-height) + var(--space-6));
}

.dashboard-panel {
  display: none;
  animation: fadeUp 260ms ease;
}

.dashboard-panel.is-active {
  display: block;
}

.hero-strip,
.section-head,
.toolbar-card,
.settings-card,
.stat-card,
.word-card,
.swipe-card,
.quiz-card,
.quiz-mode-card,
.quiz-results-card,
.sidebar-card,
.notice-card,
.modal-card,
.drawer,
.word-sheet,
.filter-panel,
.quiz-locked-card,
.placeholder-card {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.hero-strip,
.section-head,
.toolbar-card,
.filter-panel,
.quiz-locked-card,
.placeholder-card {
  padding: var(--space-5);
}

.settings-card {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.section-title,
.panel-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.1;
}

.section-subtitle,
.settings-card__text,
.placeholder-card p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  max-width: 70ch;
}

.hero-strip,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.hero-strip__copy {
  min-width: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
}

.stat-card__icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border: var(--border-width) solid var(--color-border);
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--color-accent);
  box-shadow: var(--shadow);
}

.stat-card__label {
  margin: 0 0 0.25rem;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.stat-card__value {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.toolbar-card {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--color-surface);
}

.search-bar-wrap,
.toolbar-actions {
  min-width: 0;
}

.search-input-shell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: 0 var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.search-input {
  border: none;
  background: transparent;
  padding: 0;
  min-height: 44px;
}

.search-input::placeholder,
.field-control::placeholder {
  color: var(--color-text-faint);
}

.search-input:focus,
.field-control:focus,
.pill-input:focus {
  outline: none;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
}

.view-toggle {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.words-section {
  position: relative;
}

.word-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.empty-state {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  background: var(--color-surface);
  border: var(--border-width) dashed var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.empty-state__art {
  width: 88px;
  height: 88px;
  margin: 0 auto var(--space-4);
  display: grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 28px;
  background: var(--color-accent);
  box-shadow: var(--shadow);
  animation: floaty 3s ease-in-out infinite;
}

.empty-state__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.empty-state__text {
  margin: 0 auto var(--space-5);
  max-width: 34ch;
  color: var(--color-text-muted);
}

.filter-panel {
  margin-bottom: var(--space-5);
  background: var(--color-surface);
}

.filter-panel__grid,
.settings-grid {
  display: grid;
  gap: var(--space-4);
}

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

.settings-card__title,
.sidebar-card__title {
  margin: 0;
  font-size: var(--text-lg);
}

.sidebar-card {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-card__text {
  margin-bottom: var(--space-4);
}

.settings-card__meta,
.sidebar-card__meta {
  margin: 0;
  color: var(--color-text-muted);
}

.sidebar-card__level {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: 700;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-topbar);
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  align-items: start;
  padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom));
  background: rgba(244, 254, 254, 0.98);
  border-top: var(--border-width) solid var(--color-border);
  backdrop-filter: blur(12px);
}

.bottom-nav__link {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 0.2rem;
  padding: var(--space-2);
  border: var(--border-width) solid transparent;
  border-radius: 16px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.bottom-nav__link.is-active {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: var(--shadow);
}

.fab-add {
  position: fixed;
  right: max(var(--space-4), env(safe-area-inset-right));
  bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom));
  z-index: var(--z-fab);
  width: 62px;
  height: 62px;
  border: var(--border-width) solid var(--color-border);
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--color-primary);
  box-shadow: var(--shadow);
}




/* ============================================
   COMPONENTS
============================================ */

.primary-btn,
.soft-btn,
.view-toggle__btn,
.icon-btn,
.mini-action-btn,
.toggle-pill,
.swipe-arrow,
.nav-link {
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.primary-btn,
.soft-btn,
.view-toggle__btn {
  min-height: 50px;
  padding: 0.78rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: var(--border-width) solid var(--color-border);
  border-radius: 16px;
  font-weight: 700;
  text-decoration: none;
  user-select: none;
}

.primary-btn {
  background: var(--color-primary);
  color: var(--color-border);
  box-shadow: var(--shadow);
}

.primary-btn:hover,
.soft-btn:hover,
.view-toggle__btn:hover,
.icon-btn:hover,
.swipe-arrow:hover,
.nav-link:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hover);
}

.primary-btn:active,
.soft-btn:active,
.view-toggle__btn:active,
.icon-btn:active,
.swipe-arrow:active,
.nav-link:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-press);
}

.primary-btn--small {
  min-height: 44px;
  padding: 0.65rem 0.9rem;
}

.soft-btn {
  background: var(--color-surface-3);
  color: var(--color-text);
  box-shadow: var(--shadow);
}

.soft-btn--small,
.soft-btn--label {
  min-height: 44px;
  padding: 0.65rem 0.9rem;
}

.soft-btn--label {
  cursor: pointer;
}

.view-toggle__btn {
  min-height: 46px;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
  color: var(--color-text-muted);
}

.view-toggle__btn.is-active {
  color: var(--color-text);
  background: var(--color-accent);
}

.icon-btn {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: inline-grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.mini-action-btn {
  min-height: 36px;
  padding: 0.45rem 0.8rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: 12px;
  background: var(--color-accent);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  font-weight: 700;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.button-row--wrap {
  flex-wrap: wrap;
}

button.danger-btn {
  min-height: 50px;
  padding: 0.78rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: var(--border-width) solid var(--color-danger);
  border-radius: 16px;
  font-weight: 700;
  user-select: none;
  background: var(--color-danger);
  color: #fff;
  box-shadow: var(--shadow);
  width: 100%;
  margin-top: var(--space-4);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast);
}

button.danger-btn:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  color: #fff;
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hover);
}

button.danger-btn:active {
  background: var(--color-danger-active);
  border-color: var(--color-danger-active);
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-press);
}

.field-group {
  display: grid;
  gap: var(--space-2);
}

.field-group--wide {
  grid-column: 1 / -1;
}

.field-label,
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 700;
}

.field-label--required::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 2px 2px 0 var(--color-border);
}

.field-label__optional {
  color: var(--color-text-muted);
  font-weight: 500;
}

.field-control {
  min-height: 54px;
  padding: 0.95rem 1rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.field-control--textarea {
  min-height: 120px;
  padding-top: 0.9rem;
}

.storage-mode-selector {
  display: grid;
  gap: var(--space-3);
}

.storage-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.storage-option input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.storage-option__title {
  display: block;
  font-weight: 700;
}

.storage-option__desc {
  display: block;
  margin-top: 0.2rem;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.notice-card {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.notice-card--warning {
  background: #fff8ea;
}

.notice-card__icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  display: grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 14px;
  background: var(--color-warning);
  box-shadow: var(--shadow);
}

.notice-card__body h4 {
  margin: 0 0 var(--space-2);
}

.notice-card__body p {
  margin: 0 0 var(--space-3);
  color: var(--color-text-muted);
}

.notice-card--cloud {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary-active);
}

.notice-card--cloud h4 {
  color: var(--color-primary-active);
}

.notice-card--cloud p {
  color: var(--color-primary-hover);
}

.connection-status {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.85rem 1rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.connection-status__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: var(--border-width) solid var(--color-border);
  background: var(--color-danger);
  box-shadow: 2px 2px 0 var(--color-border);
}

.connection-status.is-success .connection-status__dot {
  background: var(--color-success);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.toggle-row__title {
  margin: 0;
  font-weight: 700;
}

.toggle-row__desc {
  margin: 0.2rem 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.toggle-pill {
  width: 68px;
  height: 40px;
  flex: 0 0 68px;
  position: relative;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: #d9ecef;
  box-shadow: var(--shadow);
}

.toggle-pill__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border: var(--border-width) solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface-3);
  box-shadow: 2px 2px 0 var(--color-border);
  transition: transform var(--transition-medium), background-color var(--transition-fast);
}

.toggle-pill.is-on {
  background: var(--color-primary);
}

.toggle-pill.is-on .toggle-pill__thumb {
  transform: translateX(27px);
  background: var(--color-accent);
}

.panel-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.xp-bar,
.mini-progress,
.swipe-progress {
  width: 100%;
  height: 16px;
  overflow: hidden;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: #d7eef0;
  box-shadow: inset 2px 2px 0 rgba(13, 43, 44, 0.1);
}

.mini-progress {
  height: 14px;
}

.mini-progress--wide {
  max-width: 360px;
}

.xp-bar__fill,
.mini-progress__fill,
.swipe-progress__fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, var(--color-primary) 0%, #7ce7eb 55%, var(--color-accent) 100%);
  transition: width 400ms ease;
}

.xp-max-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-3);
  background: linear-gradient(
    135deg,
    color-mix(in oklch, var(--color-gold) 30%, var(--color-primary-highlight)),
    var(--color-primary-highlight)
  );
  color: var(--color-primary);
  border: 1px solid color-mix(in oklch, var(--color-gold) 40%, var(--color-border));
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  animation: xp-badge-glow 2.5s ease-in-out infinite alternate;
}

@keyframes xp-badge-glow {
  from { box-shadow: 0 0 4px color-mix(in oklch, var(--color-gold) 30%, transparent); }
  to   { box-shadow: 0 0 10px color-mix(in oklch, var(--color-gold) 60%, transparent); }
}

.nav-panel {
  display: grid;
  gap: var(--space-3);
}

.nav-link {
  min-height: 52px;
  width: 100%;
  padding: 0.75rem var(--space-4);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: 18px;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
  font-weight: 700;
  text-align: left;
  box-sizing: border-box;
  min-width: 0;
  overflow: visible;
  position: relative;
}

.nav-link.is-active {
  background: var(--color-accent);
}

.nav-link__badge {
  margin-left: auto;
  padding: 0.25rem 0.55rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: #fff1cc;
  box-shadow: 2px 2px 0 var(--color-border);
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.word-card {
  overflow: hidden;
  background: var(--color-surface-3);
  border-radius: var(--radius-lg);
  min-width: 0;
  width: 100%;
}

.word-card__body {
  width: 100%;
  display: block;
  text-align: left;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.word-card__media {
  aspect-ratio: 16 / 9;
  border-bottom: var(--border-width) solid var(--color-border);
  background: linear-gradient(135deg, rgba(59, 200, 205, 0.16), rgba(255, 209, 102, 0.26));
  overflow: hidden;
  position: relative;
  border-radius: calc(var(--radius-lg) - 2px) calc(var(--radius-lg) - 2px) 0 0;
}

.word-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  margin: 0;
  padding: 0;
}
.image-preview img {
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-lg);
}

.image-preview {
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface-offset);
  margin-top: var(--space-3);
  max-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-card__content {
  padding: var(--space-3) var(--space-4) var(--space-4) var(--space-4);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.word-card__content > * {
  max-width: 100%;
  min-width: 0;
}

.word-card__topline {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  justify-content: space-between;
  width: 100%;
  min-width: 0;
}

.word-card__title {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.2;
  min-width: 0;
  flex: 1;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.word-card__star-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  margin-top: 2px;
}

.word-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
  min-width: 0;
}

.word-card__definition {
  margin: 0;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-left: 0;
  width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.word-card__date {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}

.chip {
  min-height: 32px;
  padding: 0.35rem 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: 2px 2px 0 var(--color-border);
  font-size: var(--text-xs);
  font-weight: 700;
}

.chip--difficulty {
  background: #fff7d8;
}

.swipe-section {
  display: grid;
  gap: var(--space-4);
}

.swipe-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.swipe-progress-wrap {
  flex: 1;
  min-width: 0;
}

.swipe-progress__count {
  margin: 0 0 var(--space-2);
  font-weight: 700;
}

.swipe-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.swipe-stage {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-4);
  align-items: center;
}

.swipe-deck {
  min-height: 440px;
  position: relative;
  display: grid;
  place-items: center;
}

.swipe-card {
  width: min(100%, 520px);
  min-height: 440px;
  padding: var(--space-5);
  background: var(--color-surface-3);
  transform-style: preserve-3d;
  perspective: 1000px;
  user-select: none;
  touch-action: pan-y;
  will-change: transform;
}

.swipe-card__inner {
  position: relative;
  width: 100%;
  min-height: 380px;
  transition: transform 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-style: preserve-3d;
}

.swipe-card.is-flipped .swipe-card__inner {
  transform: rotateY(180deg);
}

.swipe-card__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: grid;
  align-content: start;
  gap: var(--space-4);
}

.swipe-card__face--back {
  transform: rotateY(180deg);
}

.swipe-card__hero {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-bottom: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(135deg, rgba(59, 200, 205, 0.18), rgba(255, 209, 102, 0.25));
}

.swipe-card__hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.swipe-card__word {
  margin: 0;
  font-size: var(--text-2xl);
  line-height: 1.05;
}

.swipe-card__hint,
.swipe-card__definition,
.swipe-card__context,
.swipe-card__extra {
  margin: 0;
  color: var(--color-text-muted);
}

.swipe-arrow {
  width: 56px;
  height: 56px;
  border: var(--border-width) solid var(--color-border);
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.swipe-card--flat {
  cursor: default;
  overflow-y: auto;
  max-height: calc(100dvh - 220px);
}

.swipe-card--flat:hover {
  transform: none;
}

.swipe-card__flat-body {
  display: flex;
  flex-direction: column;
}

.swipe-card__content {
  padding: var(--space-5) var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.swipe-card__title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.swipe-card__stars {
  margin-left: auto;
}

.swipe-card__extra {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.swipe-card__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-2);
}

.swipe-card__actions .soft-btn {
  flex: 1;
  justify-content: center;
}

.swipe-card--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  gap: var(--space-3);
  cursor: default;
}

.quiz-mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.quiz-mode-card,
.quiz-results-card {
  padding: var(--space-5);
  background: var(--color-surface-3);
}

.quiz-mode-card__header,
.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.quiz-mode-card__title {
  margin: 0;
  font-size: var(--text-lg);
}

.quiz-mode-card__desc,
.quiz-progress-label {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.quiz-topbar {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.quiz-card {
  padding: var(--space-5);
  background: var(--color-surface-3);
}

.quiz-card h3,
.quiz-card p {
  margin-top: 0;
}

.quiz-options {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.quiz-option {
  width: 100%;
  min-height: 58px;
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow);
  text-align: left;
  font-weight: 600;
}

.quiz-option.is-correct {
  background: #d8fff2;
}

.quiz-option.is-wrong {
  background: #ffe5e5;
}

.quiz-results {
  margin-top: var(--space-5);
}

.quiz-locked-card {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.quiz-locked-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
}

.quiz-locked-card__icon {
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  display: grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 22px;
  background: #fce8cc;
  box-shadow: var(--shadow);
}

.quiz-locked-card__body h3 {
  margin: 0 0 var(--space-2);
}

.word-sheet,
.modal-card {
  overflow: hidden;
}

.drawer {
  overflow: visible;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--color-overlay);
  backdrop-filter: blur(3px);
}

body.is-modal-open,
body.is-sheet-open,
body.is-drawer-open {
  overflow: hidden;
  touch-action: none;
}

.word-sheet,
.drawer {
  position: fixed;
  z-index: var(--z-sheet);
  background: var(--color-surface-3);
  display: flex;
  flex-direction: column;
}

.word-sheet {
  left: 0;
  right: 0;
  top: calc(var(--topbar-height) + env(safe-area-inset-top));
  bottom: 0;
  max-height: none;
  height: auto;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  box-shadow: 0 -16px 40px rgba(13, 43, 44, 0.28);
  transform: translateY(110%);
  transition: transform var(--transition-medium);
}

.word-sheet.is-open {
  transform: translateY(0);
}

.word-sheet__handle {
  width: 84px;
  height: 8px;
  margin: var(--space-3) auto var(--space-2);
  border-radius: var(--radius-pill);
  background: #b7d9db;
  border: var(--border-width) solid var(--color-border);
  box-shadow: 2px 2px 0 var(--color-border);
  flex-shrink: 0;
}

.word-sheet__header,
.drawer__header,
.modal-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.word-sheet__body,
.drawer__body,
.modal-card__body {
  padding: var(--space-4);
  overflow-x: hidden;
}

.drawer__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.word-sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.word-sheet__footer,
.modal-card__footer {
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  border-top: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.helper-toolbar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.word-form__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

.pill-input-shell {
  min-height: 54px;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.pill-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pill-input {
  flex: 1 1 150px;
  min-width: 120px;
  border: none;
  background: transparent;
  padding: 0.2rem 0;
}

.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.35rem 0.65rem;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: 2px 2px 0 var(--color-border);
  font-size: var(--text-sm);
  font-weight: 600;
}

.pill-tag__remove {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface-3);
  box-shadow: 1px 1px 0 var(--color-border);
  font-size: 0.82rem;
  line-height: 1;
}

.star-picker {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.star-picker__btn {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: var(--border-width) solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
}

.star-picker__btn.is-active {
  background: var(--color-accent);
}

.image-preview {
  margin-top: var(--space-3);
  min-height: 180px;
  overflow: hidden;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.image-preview img,
.image-preview video {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

.drawer {
  left: 0;
  right: 0;
  top: calc(var(--topbar-height) + env(safe-area-inset-top));
  bottom: 0;
  max-height: none;
  transform: translateY(102%);
  transition: transform var(--transition-medium);
  border-left: none;
  border-right: none;
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: 0 -14px 34px rgba(13, 43, 44, 0.28);
}

.drawer.is-open {
  transform: translateY(0);
}

.drawer__header-actions {
  display: flex;
  gap: var(--space-2);
}

.dictionary-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.dictionary-results {
  display: grid;
  gap: var(--space-4);
}

.dictionary-card,
.detail-block,
.qa-card {
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.dictionary-card h3,
.detail-block h3,
.qa-card h4 {
  margin: 0 0 var(--space-2);
}

.dictionary-card p,
.detail-block p,
.qa-card p {
  margin: 0;
  color: var(--color-text-muted);
}

.detail-grid {
  display: grid;
  gap: var(--space-4);
}

.detail-media {
  overflow: hidden;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  background: var(--color-surface);
  aspect-ratio: 16 / 9;
}

.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-media iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(13, 43, 44, 0.62);
  backdrop-filter: blur(5px);
}

.modal-card {
  width: min(100%, 720px);
  max-height: min(90vh, 860px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-card--large {
  width: min(100%, 920px);
}

.modal-card__body {
  flex: 1;
}

/* ── SETUP GUIDE ──────────────────────────────────────────── */

.setup-guide {
  display: grid;
  gap: var(--space-5);
}

.setup-guide__intro {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin: 0;
}

/* ── Step row ── */
.setup-step {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

/* Circle number badge */
.setup-step__num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  font-weight: 700;
  font-size: var(--text-sm);
  display: grid;
  place-items: center;
  /* Prevent text/emoji from stretching the circle */
  overflow: hidden;
  line-height: 1;
  /* For the ⚙ pre-step symbol — scale it down to fit */
  font-size: 0.9rem;
}

.setup-step__body {
  flex: 1;
  min-width: 0;
}

.setup-step__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.setup-step__list {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-5);
  font-size: var(--text-sm);
  line-height: 2;
  color: var(--color-text);
}

.setup-step__list li {
  margin-bottom: var(--space-1);
}

.setup-step__list li:last-child {
  margin-bottom: 0;
}

.setup-step__list code {
  font-size: var(--text-xs);
  background: var(--color-surface-offset);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
}

/* ── Notice / info boxes ── */
.setup-notice {
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
  line-height: 1.6;
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}

.setup-notice--info {
  background: var(--color-primary-highlight);
  color: var(--color-primary-active);
}

.setup-notice--warn {
  background: var(--color-warning-highlight);
  color: var(--color-warning);
}

.setup-notice--success {
  background: var(--color-success-highlight);
  color: var(--color-success);
  font-weight: 600;
}

/* ── Thumbnail "View example" buttons ── */
.setup-thumb-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-2);
  margin-top: var(--space-1);
  padding: 3px var(--space-3);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  border: 1px solid color-mix(in oklch, var(--color-primary) 25%, transparent);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-interactive),
              color var(--transition-interactive),
              border-color var(--transition-interactive);
  white-space: nowrap;
  vertical-align: middle;
}

.setup-thumb-btn:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.setup-thumb-btn:active {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* ── Collapsible sections ── */
.setup-details {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
}

.setup-details[open] {
  border-color: var(--color-primary-highlight);
}

.setup-details__summary {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
  background: var(--color-surface);
  transition: background var(--transition-interactive);
}

.setup-details__summary:hover {
  background: var(--color-surface-offset);
}

.setup-details__summary::after {
  content: '›';
  margin-left: auto;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  transition: transform var(--transition-interactive);
  display: inline-block;
}

.setup-details[open] .setup-details__summary::after {
  transform: rotate(90deg);
}

/* ── Column reference table ── */
.setup-table-wrap {
  overflow-x: auto;
  padding: 0 var(--space-4);
}

.setup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.setup-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.setup-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  vertical-align: top;
  line-height: 1.5;
}

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

.setup-table tr:hover td {
  background: var(--color-surface-offset);
}

/* ── Troubleshooting cards ── */
.setup-troubleshoot {
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--color-border);
}

.setup-troubleshoot__q {
  font-size: var(--text-sm);
  font-weight: 700;
  margin: 0 0 var(--space-1);
  color: var(--color-text);
}

.setup-troubleshoot__a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.65;
}

.setup-troubleshoot__a code {
  font-size: var(--text-xs);
  background: var(--color-surface-dynamic);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: var(--text-xs);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body, monospace);
}

.toast-stack {
  position: fixed;
  right: max(var(--space-4), env(safe-area-inset-right));
  bottom: calc(var(--bottom-nav-height) + var(--space-4) + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: grid;
  gap: var(--space-3);
  width: min(92vw, 380px);
}

.toast {
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-3);
  box-shadow: var(--shadow);
  animation: toastIn 260ms ease;
}

.toast--success {
  background: #e3fff6;
}

.toast--error {
  background: #ffe7e7;
}

.toast__title {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.toast__text {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ============================================
   ICONS
============================================ */

.icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-block;
  position: relative;
  color: currentColor;
}

.icon::before,
.icon::after {
  content: '';
  position: absolute;
  box-sizing: border-box;
}

.icon-plus::before,
.icon-plus::after {
  background: currentColor;
  border-radius: 999px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.icon-plus::before { width: 1rem; height: 0.18rem; }
.icon-plus::after { width: 0.18rem; height: 1rem; }

.icon-menu::before {
  left: 0.12rem;
  top: 0.22rem;
  width: 1rem;
  height: 0.16rem;
  background: currentColor;
  border-radius: 999px;
  box-shadow: 0 0.32rem 0 currentColor, 0 0.64rem 0 currentColor;
}
.icon-home::before {
  left: 0.18rem;
  top: 0.22rem;
  width: 0.9rem;
  height: 0.75rem;
  border: 0.16rem solid currentColor;
  border-top: none;
  border-radius: 0.12rem;
}
.icon-home::after {
  left: 0.18rem;
  top: 0.05rem;
  width: 0.9rem;
  height: 0.9rem;
  border-left: 0.16rem solid currentColor;
  border-top: 0.16rem solid currentColor;
  transform: rotate(45deg);
}

.icon-settings::before {
  inset: 0.22rem;
  border: 0.16rem solid currentColor;
  border-radius: 50%;
}
.icon-settings::after {
  inset: 0;
  border-radius: 50%;
  box-shadow:
    0 -0.52rem 0 -0.42rem currentColor,
    0 0.52rem 0 -0.42rem currentColor,
    0.52rem 0 0 -0.42rem currentColor,
    -0.52rem 0 0 -0.42rem currentColor,
    0.37rem 0.37rem 0 -0.42rem currentColor,
    -0.37rem 0.37rem 0 -0.42rem currentColor,
    0.37rem -0.37rem 0 -0.42rem currentColor,
    -0.37rem -0.37rem 0 -0.42rem currentColor;
}

.icon-book::before,
.icon-book-open::before {
  left: 0.14rem;
  top: 0.18rem;
  width: 0.45rem;
  height: 0.88rem;
  border: 0.16rem solid currentColor;
  border-right: 0.08rem solid currentColor;
  border-radius: 0.12rem 0 0 0.12rem;
}
.icon-book::after,
.icon-book-open::after {
  right: 0.14rem;
  top: 0.18rem;
  width: 0.45rem;
  height: 0.88rem;
  border: 0.16rem solid currentColor;
  border-left: 0.08rem solid currentColor;
  border-radius: 0 0.12rem 0.12rem 0;
}

.icon-search::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9 7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-search::after { display: none; }
.icon-filter::before {
  left: 0.15rem;
  top: 0.15rem;
  width: 0.95rem;
  height: 0.16rem;
  background: currentColor;
  border-radius: 999px;
  box-shadow: 0 0.38rem 0 currentColor, 0 0.76rem 0 currentColor;
}
.icon-filter::after {
  left: 0.28rem;
  top: 0.06rem;
  width: 0.2rem;
  height: 0.34rem;
  border: 0.16rem solid currentColor;
  border-radius: 999px;
  background: var(--color-surface-3);
  box-shadow: 0.35rem 0.38rem 0 -0.02rem var(--color-surface-3), 0.68rem 0.76rem 0 -0.02rem var(--color-surface-3);
}

.icon-grid::before {
  inset: 0.1rem;
  border-radius: 0.1rem;
  box-shadow:
    0 0 0 0.16rem currentColor inset,
    0.48rem 0 0 0 currentColor inset,
    0 0.48rem 0 0 currentColor inset,
    0.48rem 0.48rem 0 0 currentColor inset;
}

.icon-swipe::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M7.5 16L2 12l5.5-4v2.5h9V8L22 12l-5.5 4v-2.5h-9V16z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M7.5 16L2 12l5.5-4v2.5h9V8L22 12l-5.5 4v-2.5h-9V16z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-swipe::after { display: none; }

.icon-quiz::before {
  left: 0.14rem;
  top: 0.12rem;
  width: 0.96rem;
  height: 0.78rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.14rem;
}
.icon-quiz::after {
  left: 0.4rem;
  top: 0.34rem;
  width: 0.16rem;
  height: 0.16rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0.22rem 0 0 currentColor, 0.44rem 0 0 currentColor, 0.2rem 0.42rem 0 0 currentColor;
}

.icon-flame::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2C10 5 7 8 7 12a5 5 0 0 0 10 0c0-3-2-5-3-6 0 0 0 2.5-1.5 3-.8.3-1.5-.3-1.5-1C11 7 12 2 12 2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2C10 5 7 8 7 12a5 5 0 0 0 10 0c0-3-2-5-3-6 0 0 0 2.5-1.5 3-.8.3-1.5-.3-1.5-1C11 7 12 2 12 2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-flame::after { display: none; }

.icon-badge::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle fill='black' cx='12' cy='8' r='5'/%3E%3Cpath fill='black' d='M9.5 13a6 6 0 0 0 5 0L17 21l-5-2.5L7 21l2.5-8z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle fill='black' cx='12' cy='8' r='5'/%3E%3Cpath fill='black' d='M9.5 13a6 6 0 0 0 5 0L17 21l-5-2.5L7 21l2.5-8z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-badge::after { display: none; }

.icon-calendar::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Crect fill='black' x='3' y='4' width='18' height='18' rx='2'/%3E%3Crect fill='white' x='3' y='9' width='18' height='1'/%3E%3Crect fill='white' x='8' y='2' width='2' height='4' rx='1'/%3E%3Crect fill='white' x='14' y='2' width='2' height='4' rx='1'/%3E%3Ccircle fill='white' cx='8' cy='14' r='1.5'/%3E%3Ccircle fill='white' cx='12' cy='14' r='1.5'/%3E%3Ccircle fill='white' cx='16' cy='14' r='1.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Crect fill='black' x='3' y='4' width='18' height='18' rx='2'/%3E%3Crect fill='white' x='3' y='9' width='18' height='1'/%3E%3Crect fill='white' x='8' y='2' width='2' height='4' rx='1'/%3E%3Crect fill='white' x='14' y='2' width='2' height='4' rx='1'/%3E%3Ccircle fill='white' cx='8' cy='14' r='1.5'/%3E%3Ccircle fill='white' cx='12' cy='14' r='1.5'/%3E%3Ccircle fill='white' cx='16' cy='14' r='1.5'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-calendar::after { display: none; }

.icon-image::before {
  left: 0.12rem;
  top: 0.16rem;
  width: 1rem;
  height: 0.86rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.12rem;
}
.icon-image::after {
  left: 0.24rem;
  bottom: 0.2rem;
  width: 0.66rem;
  height: 0.34rem;
  background: currentColor;
  clip-path: polygon(0 100%, 35% 35%, 55% 62%, 100% 0, 100% 100%);
}

.icon-camera::before {
  left: 0.12rem;
  top: 0.28rem;
  width: 1rem;
  height: 0.62rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.14rem;
}
.icon-camera::after {
  left: 0.42rem;
  top: 0.42rem;
  width: 0.36rem;
  height: 0.36rem;
  border: 0.16rem solid currentColor;
  border-radius: 50%;
  box-shadow: -0.24rem -0.22rem 0 -0.08rem currentColor;
}

.icon-pdf::before {
  left: 0.22rem;
  top: 0.12rem;
  width: 0.72rem;
  height: 0.96rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.1rem;
}
.icon-pdf::after {
  left: 0.34rem;
  top: 0.34rem;
  width: 0.42rem;
  height: 0.14rem;
  background: currentColor;
  box-shadow: 0 0.24rem 0 currentColor, 0 0.48rem 0 currentColor;
}

.icon-download::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 16l-6-6h4V4h4v6h4l-6 6zM4 20h16v-2H4v2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 16l-6-6h4V4h4v6h4l-6 6zM4 20h16v-2H4v2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-download::after { display: none; }

.icon-upload::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 4l6 6h-4v6h-4v-6H6l6-6zM4 20h16v-2H4v2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 4l6 6h-4v6h-4v-6H6l6-6zM4 20h16v-2H4v2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-upload::after { display: none; }

.icon-share::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M14 3h7v7l-2.5-2.5-8.5 8.5-1.5-1.5 8.5-8.5L14 3zM10 5H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5h-2v5H5V7h5V5z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M14 3h7v7l-2.5-2.5-8.5 8.5-1.5-1.5 8.5-8.5L14 3zM10 5H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5h-2v5H5V7h5V5z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-share::after { display: none; }

.icon-guide::before {
  left: 0.18rem;
  top: 0.12rem;
  width: 0.86rem;
  height: 0.96rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.12rem;
}
.icon-guide::after {
  left: 0.34rem;
  top: 0.34rem;
  width: 0.34rem;
  height: 0.34rem;
  border: 0.16rem solid currentColor;
  border-radius: 50%;
  box-shadow: 0 0.4rem 0 -0.04rem currentColor;
}

.icon-columns::before {
  left: 0.12rem;
  top: 0.16rem;
  width: 1rem;
  height: 0.88rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.12rem;
}
.icon-columns::after {
  left: 0.48rem;
  top: 0.16rem;
  width: 0.16rem;
  height: 0.88rem;
  background: currentColor;
}

.icon-close::before,
.icon-close::after {
  left: 0.5rem;
  top: 0.12rem;
  width: 0.16rem;
  height: 1rem;
  background: currentColor;
  border-radius: 999px;
}
.icon-close::before { transform: rotate(45deg); }
.icon-close::after { transform: rotate(-45deg); }

.icon-edit::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a1 1 0 0 0 0-1.41l-2.34-2.34a1 1 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-edit::after { display: none; }

.icon-star::before {
  left: 0.14rem;
  top: 0.08rem;
  width: 0.96rem;
  height: 0.96rem;
  background: currentColor;
  clip-path: polygon(50% 0%, 61% 36%, 100% 38%, 70% 60%, 82% 100%, 50% 76%, 18% 100%, 30% 60%, 0 38%, 39% 36%);
}

.icon-arrow-left::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-arrow-left::after { display: none; }

.icon-arrow-right::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M4 11h12.17l-5.59-5.59L12 4l8 8-8 8-1.41-1.41L16.17 13H4v-2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M4 11h12.17l-5.59-5.59L12 4l8 8-8 8-1.41-1.41L16.17 13H4v-2z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-arrow-right::after { display: none; }
.icon-warning::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2L1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V9h2v4z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 2L1 21h22L12 2zm1 15h-2v-2h2v2zm0-4h-2V9h2v4z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-warning::after { display: none; }

.icon-lock::before {
  left: 0.26rem;
  top: 0.48rem;
  width: 0.64rem;
  height: 0.46rem;
  border: 0.16rem solid currentColor;
  border-radius: 0.1rem;
}
.icon-lock::after {
  left: 0.34rem;
  top: 0.12rem;
  width: 0.46rem;
  height: 0.5rem;
  border: 0.16rem solid currentColor;
  border-bottom: none;
  border-radius: 0.42rem 0.42rem 0 0;
}

/* Sound / Pronounce icon */
.icon-sound-on {
  position: relative;
  display: inline-block;
  width: 1rem;
  height: 1rem;
}

.icon-sound-on::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.18rem;
  width: 0.38rem;
  height: 0.64rem;
  background: currentColor;
  border-radius: 0 0.06rem 0.06rem 0;
  clip-path: polygon(0 25%, 100% 0%, 100% 100%, 0 75%);
}

.icon-sound-on::after {
  content: '';
  position: absolute;
  left: 0.52rem;
  top: 0.1rem;
  width: 0.44rem;
  height: 0.8rem;
  border-right: 0.15rem solid currentColor;
  border-top: 0.15rem solid currentColor;
  border-bottom: 0.15rem solid currentColor;
  border-radius: 0 0.4rem 0.4rem 0;
  border-left: none;
}

.icon-shuffle::before {
  inset: 0;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M16 4l4 4-4 4V9H8L6 7l2-2h8V4zM8 20l-4-4 4-4v3h8l2 2-2 2H8v1z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M16 4l4 4-4 4V9H8L6 7l2-2h8V4zM8 20l-4-4 4-4v3h8l2 2-2 2H8v1z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.icon-shuffle::after { display: none; }

/* ============================================
   RESPONSIVE
============================================ */

@media (min-width: 640px) {
  .main-content {
    padding-inline: var(--space-5);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .word-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel__grid,
  .settings-grid,
  .word-form__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quiz-mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawer,
  .word-sheet {
    left: auto;
    right: 0;
    top: var(--topbar-height);
    bottom: calc(var(--bottom-nav-height) + var(--space-3));
    width: min(560px, 92vw);
    max-height: none;
    height: auto;
    border-radius: 24px 0 0 24px;
    border-right: none;
    border-bottom: var(--border-width) solid var(--color-border);
    transform: translateX(105%);
  }

  .drawer.is-open,
  .word-sheet.is-open {
    transform: translateX(0);
  }

  .word-sheet__handle {
    display: none;
  }

  .word-sheet__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .modal-shell {
    padding: var(--space-6);
  }
}

/* ── BASE SIDEBAR (all screen sizes) ───────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-6) var(--space-5) var(--space-4);
  background: rgba(244, 254, 254, 0.96);
  border-right: var(--border-width) solid var(--color-border);
  transform: translateX(-110%);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
}


.sidebar__close-row {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 var(--space-2) 0;
  flex-shrink: 0;
}

.sidebar__inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-top: var(--space-2);
}

.storage-indicator {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.storage-bar-track {
  width: 100%;
  height: 0.5rem;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
}

.storage-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--color-primary);
  transition: width 600ms ease, background-color 400ms ease;
}

.storage-bar-fill.storage-warn {
  background: var(--color-gold);
}

.storage-bar-fill.storage-danger {
  background: var(--color-notification);
}

.storage-bar-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
}

/* ── TABLET AND SMALL DESKTOP (1024px+) ─────────────────── */
@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .toolbar-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .word-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-strip {
    align-items: center;
  }

  .word-sheet {
    top: var(--space-5);
    right: var(--space-5);
    bottom: var(--space-5);
    left: var(--space-5);
    width: auto;
    max-height: none;
    height: auto;
    border-radius: 24px;
    border-right: var(--border-width) solid var(--color-border);
    transform: scale(0.96);
    opacity: 0;
    pointer-events: none;
  }

  .word-sheet.is-open {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
  }

  .word-sheet__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .drawer {
    top: var(--space-5);
    bottom: var(--space-5);
    right: var(--space-5);
    left: auto;
    width: min(640px, calc(100vw - var(--space-10)));
    max-height: none;
    border-radius: var(--radius-lg);
  }

  .swipe-card {
    min-height: 520px;
  }

  .word-form__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── DESKTOP (1200px+) — permanent sidebar ──────────────── */
@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
  }
  .sidebar__close-row {
    display: none;
  }
  .topbar {
    padding-left: calc(var(--sidebar-width) + var(--space-5));
  }
  .topbar__menu-btn {
    display: none;
  }
  .main-content {
    margin-left: var(--sidebar-width);
    padding: var(--space-5) var(--space-5) var(--space-6);
  }
  .bottom-nav,
  .fab-add {
    display: none;
  }
  .word-sheet {
    left: calc(var(--sidebar-width) + var(--space-5));
  }
  .drawer {
    width: min(640px, calc(100vw - var(--sidebar-width) - var(--space-10)));
  }
  .word-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ============================================
   ANIMATIONS
============================================ */

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

@keyframes floaty {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulseSoft {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.is-pulsing {
  animation: pulseSoft 700ms ease;
}

.is-wiggle {
  animation: wiggle 400ms ease;
}

@keyframes wiggle {
  0% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.word-card__body[role="button"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}

/* ── FAQ Modal ── */


.faq-group {
  margin-bottom: var(--space-5);
}

.faq-group__title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  margin: 0 0 var(--space-2);
}

.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  overflow: hidden;
  background: var(--color-surface);
}

.faq-item__question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  text-align: left;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-interactive);
}

.faq-item__question:hover {
  background: var(--color-surface-offset);
}

.faq-item__chevron {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  display: inline-block;
  position: relative;
  transition: transform 260ms ease;
  color: var(--color-text-muted);
}

.faq-item__chevron::before {
  content: '';
  position: absolute;
  left: 0.15rem;
  top: 0.28rem;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 0.14rem solid currentColor;
  border-bottom: 0.14rem solid currentColor;
  transform: rotate(45deg);
}

.faq-item.is-open .faq-item__chevron {
  transform: rotate(180deg);
}

.faq-item__answer {
  display: none;
  padding: 0 var(--space-4) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.65;
  border-top: 1px solid var(--color-border);
}

.faq-item.is-open .faq-item__answer {
  display: block;
}

/* FAQ modal — safe spacing on all devices */
#faqModal {
  padding: var(--space-4);
  padding-top: calc(var(--space-4) + env(safe-area-inset-top));
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  align-items: center;
}

#faqModal .modal-card {
  max-height: calc(90dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  width: min(100%, 640px);
}

@media (max-width: 600px) {
  #faqModal .modal-card {
    max-height: calc(85dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

.field-required {
  color: var(--color-error);
  margin-left: 2px;
}

/* ═══════════════════════════════════════════
   TEACHER VIEW — scoped button styles
   All selectors start with #teacherView
   so they never affect other pages
════════════════════════════════════════════ */

/* Primary action buttons (Add Student, Open Sheet) */
#teacherView .tv-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: var(--color-text) !important;
  font-size: var(--text-sm);
  font-weight: 600;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  white-space: nowrap;
}
#teacherView .tv-btn-primary:hover {
  background: var(--color-primary) !important;
  color: var(--color-text) !important;
  box-shadow: var(--shadow-hover) !important;
  transform: translate(-1px, -1px);
}
#teacherView .tv-btn-primary:hover * {
  color: var(--color-text) !important;
}
#teacherView .tv-btn-primary:active {
  box-shadow: var(--shadow-press) !important;
  transform: translate(2px, 2px);
}

/* Secondary buttons (Export PDF, Export JSON, Import JSON) */
#teacherView .tv-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 100ms ease;
  white-space: nowrap;
}
#teacherView .tv-btn-secondary:hover  { background: var(--color-surface-offset); border-color: var(--color-primary); }
#teacherView .tv-btn-secondary:active { transform: scale(0.97); }

/* Row buttons (Edit) */
#teacherView .tv-btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}
#teacherView .tv-btn-edit:hover { background: var(--color-surface-offset); border-color: var(--color-primary); color: var(--color-primary); }

/* Row buttons (Delete) */
#teacherView .tv-btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--color-surface);
  color: var(--color-error);
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}
#teacherView .tv-btn-delete:hover { background: var(--color-error-highlight); border-color: var(--color-error); }

/* Ghost utility buttons (Change PIN, Lock) */
#teacherView .tv-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
  text-decoration: none;
}
#teacherView .tv-btn-ghost:hover { background: var(--color-surface-offset); border-color: var(--color-primary); color: var(--color-primary); }

