/* ============================================================
   Polyglens Design System v2.0
   Shared CSS Variables + Component Classes + Animations
   ============================================================ */

/* ── Design Tokens ── */
:root {
  /* Brand Colors */
  --pg-brand:          #4c74ff;
  --pg-brand-dark:     #2841b3;
  --pg-brand-light:    #eef4ff;
  --pg-brand-glow:     rgba(76, 116, 255, 0.18);

  /* Neutral Colors */
  --pg-ink:            #10121a;
  --pg-ink-soft:       #1f2937;
  --pg-muted:          #5c6470;
  --pg-muted-soft:     #94a3b8;
  --pg-border:         #e2e8f0;
  --pg-border-light:   rgba(16, 18, 26, 0.08);
  --pg-surface:        #ffffff;
  --pg-surface-soft:   #f8fafc;
  --pg-body-bg:        #f7f3eb;

  /* Accent Colors */
  --pg-peach:          #ffddc8;
  --pg-mint:           #c7f2e5;
  --pg-success:        #067647;
  --pg-error:          #b42318;
  --pg-warning:        #b45309;

  /* Legacy alias tokens (for backward compatibility) */
  --ink: var(--pg-ink);
  --ink-soft: var(--pg-ink-soft);
  --muted: var(--pg-muted);
  --accent: var(--pg-brand);
  --accent-dark: var(--pg-brand-dark);
  --accent-strong: var(--pg-brand-dark);
  --peach: var(--pg-peach);
  --mint: var(--pg-mint);
  --card: var(--pg-surface);
  --line: var(--pg-border);
  --border: var(--pg-border);
  --danger: var(--pg-error);
  --bg: var(--pg-surface);
  --bg-soft: var(--pg-surface-soft);

  /* Gradients */
  --gradient-brand:    linear-gradient(135deg, #4c74ff, #2841b3);
  --gradient-warm:     linear-gradient(135deg, #ffddc8, #c7f2e5);
  --gradient-body:     linear-gradient(180deg, #f7f3eb 0%, #f4f7ff 40%, #fdf2f0 100%);
  --gradient-danger:   linear-gradient(135deg, #c4322a, #8f1d17);

  /* Shadows */
  --pg-shadow-sm:      0 4px 12px rgba(16, 18, 26, 0.06);
  --pg-shadow-md:      0 12px 28px rgba(16, 18, 26, 0.08);
  --pg-shadow-lg:      0 24px 60px rgba(12, 16, 28, 0.12);
  --pg-shadow-xl:      0 32px 72px rgba(12, 16, 28, 0.16);

  /* Legacy shadow alias */
  --shadow: var(--pg-shadow-lg);

  /* Border Radius */
  --pg-radius-sm:      8px;
  --pg-radius-md:      12px;
  --pg-radius-lg:      16px;
  --pg-radius-xl:      22px;
  --pg-radius-2xl:     32px;
  --pg-radius-full:    9999px;

  /* Legacy radius aliases */
  --radius-sm: var(--pg-radius-lg);
  --radius-md: var(--pg-radius-xl);
  --radius-lg: var(--pg-radius-2xl);

  /* Typography */
  --pg-font-display:   "Sora", "Outfit", "Noto Sans KR", sans-serif;
  --pg-font-body:      "Outfit", "Noto Sans KR", sans-serif;
  --pg-font-mono:      "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Transitions */
  --pg-ease:           0.2s ease;
  --pg-ease-spring:    cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--pg-font-body);
  color: var(--pg-ink);
  background: radial-gradient(1100px 800px at 10% 10%, #f9f4ee 0%, transparent 60%),
              radial-gradient(900px 700px at 90% 0%, #eef4ff 0%, transparent 65%),
              var(--gradient-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--pg-font-display); }

/* ── Page Shell ── */
.page-content {
  animation: fadeInUp 0.35s ease-out;
}

.page-container {
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-12);
}

/* Compound page wrapper (combines container + animation) */
.page {
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-12);
  animation: fadeInUp 0.35s ease-out;
}

/* ── Utilities ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.hidden { display: none !important; }
.font-medium { font-weight: 600; }
.text-center { text-align: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--pg-font-body);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--pg-radius-full);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 20px;
  transition: transform var(--pg-ease), box-shadow var(--pg-ease), background var(--pg-ease), border-color var(--pg-ease);
  text-decoration: none;
  line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible {
  outline: 3px solid var(--pg-brand);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(40, 65, 179, 0.25);
}
.btn-primary:hover { box-shadow: 0 12px 28px rgba(40, 65, 179, 0.32); }

.btn-secondary {
  background: rgba(76, 116, 255, 0.1);
  color: var(--pg-brand-dark);
  border: 1px solid rgba(40, 65, 179, 0.2);
}
.btn-secondary:hover { background: rgba(76, 116, 255, 0.16); }

.btn-outline {
  background: transparent;
  color: var(--pg-brand-dark);
  border: 2px solid var(--pg-brand);
}
.btn-outline:hover { background: var(--pg-brand-light); }

.btn-ghost {
  background: transparent;
  color: var(--pg-muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--pg-surface-soft); color: var(--pg-ink); }

.btn-danger {
  background: var(--gradient-danger);
  color: #fff;
}

.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 1rem; }

/* ── Navigation Bar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--pg-border-light);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.navbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.navbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--pg-font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--pg-ink);
  text-decoration: none;
}
.navbar__brand img { width: 32px; height: 32px; border-radius: var(--pg-radius-full); }
.navbar__nav { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.navbar__link {
  padding: 8px 14px;
  border-radius: var(--pg-radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pg-muted);
  text-decoration: none;
  transition: all var(--pg-ease);
}
.navbar__link:hover { color: var(--pg-brand-dark); background: var(--pg-surface-soft); }
.navbar__link--active { color: var(--pg-brand); }

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

.navbar__lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--pg-radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  transition: all var(--pg-ease);
}
.navbar__lang--en { background: linear-gradient(135deg, #0ea5e9, #4c74ff); }
.navbar__lang--zh { background: linear-gradient(135deg, #f43f5e, #f59e0b); }
.navbar__lang--yue { background: linear-gradient(135deg, #d97706, #ea580c); }
.navbar__lang:hover { transform: translateY(-1px); filter: brightness(1.1); }

/* ── Cards ── */
.card {
  background: var(--pg-surface);
  border-radius: var(--pg-radius-xl);
  box-shadow: var(--pg-shadow-md);
  padding: var(--space-6);
  transition: transform var(--pg-ease), box-shadow var(--pg-ease);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--pg-shadow-lg);
}
.card--interactive { cursor: pointer; }
.card--bordered { border: 1px solid var(--pg-border); }
.card--compact { padding: var(--space-4); }

/* ── Inputs & Forms ── */
.input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--pg-border);
  border-radius: var(--pg-radius-lg);
  font-family: var(--pg-font-body);
  font-size: 0.95rem;
  color: var(--pg-ink);
  background: var(--pg-surface);
  transition: border-color var(--pg-ease), box-shadow var(--pg-ease);
}
.input:focus {
  outline: none;
  border-color: var(--pg-brand);
  box-shadow: 0 0 0 3px var(--pg-brand-light);
}
.input::placeholder { color: var(--pg-muted-soft); }
.input--error { border-color: var(--pg-error); }
.input--error:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.15); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c6470' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pg-muted);
  margin-bottom: 6px;
}

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

/* ── Select (standalone class, not just `select.input`) ── */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c6470' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Badges & Chips ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: var(--pg-radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge--brand { background: rgba(76, 116, 255, 0.12); color: var(--pg-brand-dark); }
.badge--success { background: rgba(6, 118, 71, 0.1); color: var(--pg-success); }
.badge--warning { background: rgba(180, 83, 9, 0.1); color: var(--pg-warning); }
.badge--error { background: rgba(180, 35, 24, 0.1); color: var(--pg-error); }
.badge--white { background: rgba(255, 255, 255, 0.9); color: var(--pg-muted); }

/* ── Language Badge Variants ── */
.lang-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--pg-radius-full);
}
.lang-badge--en { background: rgba(14,165,233,0.1); color: #0ea5e9; }
.lang-badge--zh { background: rgba(244,63,94,0.1); color: #f43f5e; }
.lang-badge--yue { background: rgba(217,119,6,0.1); color: #d97706; }
.lang-badge--ca { background: rgba(204,107,44,0.1); color: #8b3718; }

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--pg-border) 25%, #f0eef5 50%, var(--pg-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--pg-radius-sm);
  pointer-events: none;
}

/* Skeleton card pattern (for video/article grids) */
.skeleton-card {
  background: var(--pg-surface);
  border-radius: var(--pg-radius-xl);
  overflow: hidden;
  border: 1px solid var(--pg-border-light);
}
.skeleton-card__thumb {
  aspect-ratio: 16/9;
  background: linear-gradient(90deg, var(--pg-border) 25%, #f0eef5 50%, var(--pg-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}
.skeleton-card__body {
  padding: 14px 16px 16px;
  display: grid;
  gap: 10px;
}
.skeleton-card__line {
  height: 14px;
  border-radius: var(--pg-radius-sm);
  background: linear-gradient(90deg, var(--pg-border) 25%, #f0eef5 50%, var(--pg-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}
.skeleton-card__line--short { width: 55%; }
.skeleton-card__line--medium { width: 80%; }

/* Skeleton text block */
.skeleton-text {
  display: grid;
  gap: 12px;
}
.skeleton-text__line {
  height: 16px;
  border-radius: var(--pg-radius-sm);
  background: linear-gradient(90deg, var(--pg-border) 25%, #f0eef5 50%, var(--pg-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}
.skeleton-text__line--short { width: 35%; }
.skeleton-text__line--medium { width: 65%; }

/* ── State (Empty/Error/Loading) ── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: var(--space-3);
}
.state__icon { font-size: 48px; }
.state__title { font-weight: 700; font-size: 1.1rem; }
.state__desc { color: var(--pg-muted); font-size: 0.9rem; max-width: 400px; line-height: 1.6; }

/* State variant accents */
.state--error .state__icon { color: var(--pg-error); }
.state--error .state__title { color: var(--pg-error); }
.state--warning .state__icon { color: var(--pg-warning); }
.state--warning .state__title { color: var(--pg-warning); }
.state .btn { margin-top: 4px; }

/* ── Progress Bar ── */
.progress {
  width: 100%;
  height: 6px;
  background: var(--pg-border);
  border-radius: var(--pg-radius-full);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: var(--pg-radius-full);
  transition: width 0.6s ease-out;
}

/* ── Video Card (for learn/archive pages) ── */
.video-card {
  width: 100%;
  text-align: left;
  border-radius: var(--pg-radius-xl);
  overflow: hidden;
  background: var(--pg-surface);
  border: 1px solid var(--pg-border-light);
  box-shadow: var(--pg-shadow-md);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}
.video-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--pg-shadow-lg);
}
.video-card:focus-visible {
  outline: 3px solid var(--pg-brand);
  outline-offset: 2px;
}
.video-card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: linear-gradient(135deg, #1e293b, #334155);
}
.video-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-card__badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--pg-radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.9);
  color: var(--pg-muted);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.video-card__body {
  padding: 14px 16px 16px;
}
.video-card__title {
  font-family: var(--pg-font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-card__meta {
  font-size: 0.78rem;
  color: var(--pg-muted-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Language Toggle Buttons (for study page) ── */
.toggle-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--pg-radius-full);
  border: 2px solid var(--pg-border);
  background: var(--pg-surface);
  color: var(--pg-muted);
  font-family: var(--pg-font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--pg-ease);
  -webkit-tap-highlight-color: transparent;
}
.toggle-lang-btn:hover {
  border-color: var(--pg-brand);
  color: var(--pg-brand-dark);
  transform: translateY(-1px);
}
.toggle-lang-btn:focus-visible {
  outline: 3px solid var(--pg-brand);
  outline-offset: 2px;
}
.toggle-lang-btn.is-active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: var(--pg-brand-dark);
  box-shadow: 0 6px 16px rgba(40,65,179,0.25);
}
.toggle-lang-btn.is-active:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(40,65,179,0.32);
}
.toggle-lang-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pg-border);
  transition: background var(--pg-ease);
}
.toggle-lang-btn.is-active .dot { background: #fff; }

/* ── Language Tab Bar ── */
.lang-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--pg-surface-soft);
  border-radius: var(--pg-radius-xl);
  margin-bottom: 24px;
}
.lang-tab {
  flex: 1;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--pg-radius-lg);
  background: transparent;
  color: var(--pg-muted);
  font-family: var(--pg-font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--pg-ease);
}
.lang-tab:hover { color: var(--pg-ink); }
.lang-tab:focus-visible { outline: 3px solid var(--pg-brand); outline-offset: 2px; }
.lang-tab.is-active {
  background: var(--pg-surface);
  color: var(--pg-ink);
  box-shadow: var(--pg-shadow-sm);
}
.lang-tab[data-lang="en"].is-active { color: #0ea5e9; }
.lang-tab[data-lang="zh"].is-active { color: #f43f5e; }
.lang-tab[data-lang="yue"].is-active { color: #d97706; }

/* ── Toggle Group ── */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.toggle-group__label {
  width: 100%;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pg-muted);
  margin-bottom: 2px;
}
.toggle-panel {
  display: grid;
  gap: 16px;
}
.toggle-panel[hidden] { display: none; }

/* ── Mobile Tab Bar ── */
.mobile-tab-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--pg-border-light);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
}
.mobile-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  min-width: 56px;
  text-decoration: none;
  color: var(--pg-muted-soft);
  font-size: 0.6rem;
  font-weight: 600;
  transition: color var(--pg-ease);
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-tab-item:hover { color: var(--pg-muted); }
.mobile-tab-item:focus-visible {
  outline: 3px solid var(--pg-brand);
  outline-offset: 2px;
  border-radius: 8px;
}
.mobile-tab-item.is-active { color: var(--pg-brand); }
.mobile-tab-item__icon { font-size: 1.4rem; line-height: 1; }
.mobile-tab-item__label { font-size: 0.6rem; letter-spacing: 0.03em; }

/* ── Mobile Study: Current Cue Display ── */
.current-cue {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f8fafc;
  padding: 16px 20px;
}
.current-cue__time {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(148,163,184,0.8);
  margin-bottom: 8px;
}
.current-cue__original {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 4px;
}
.current-cue__translation {
  font-size: 0.9rem;
  color: #a5b4fc;
  font-weight: 500;
}
.current-cue__pinyin {
  font-size: 0.85rem;
  color: rgba(226,232,240,0.7);
  font-style: italic;
  margin-top: 2px;
}

/* ── Mobile Study: Compact Nav ── */
.compact-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 16px 10px;
  background: var(--pg-surface-soft);
  border-bottom: 1px solid var(--pg-border-light);
}
.compact-nav__group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.compact-nav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--pg-radius-full);
  border: 1px solid var(--pg-border);
  background: var(--pg-surface);
  color: var(--pg-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--pg-ease);
}
.compact-nav__btn:hover { border-color: var(--pg-brand); color: var(--pg-brand); }
.compact-nav__btn:focus-visible { outline: 3px solid var(--pg-brand); outline-offset: 2px; }
.compact-nav__btn.is-active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: var(--pg-brand-dark);
  box-shadow: 0 4px 12px rgba(40,65,179,0.25);
}
.compact-nav__btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Mobile Study: Toggle Row ── */
.toggle-row {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  background: var(--pg-surface-soft);
  border-bottom: 1px solid var(--pg-border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.toggle-row::-webkit-scrollbar { display: none; }
.toggle-btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: var(--pg-radius-full);
  border: 1px solid var(--pg-border);
  background: var(--pg-surface);
  color: var(--pg-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--pg-ease);
  white-space: nowrap;
}
.toggle-btn:hover { border-color: var(--pg-brand); color: var(--pg-brand-dark); }
.toggle-btn:focus-visible { outline: 3px solid var(--pg-brand); outline-offset: 2px; }
.toggle-btn.is-active {
  background: var(--gradient-brand);
  color: #fff;
  border-color: var(--pg-brand-dark);
  box-shadow: 0 4px 10px rgba(40,65,179,0.2);
}
.toggle-btn.is-pressed {
  background: rgba(76,116,255,0.1);
  color: var(--pg-brand-dark);
  border-color: rgba(76,116,255,0.3);
}

/* ── Mobile Study: Collapsible Transcript ── */
.transcript-collapse {
  border-bottom: 1px solid var(--pg-border-light);
}
.transcript-collapse__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--pg-surface);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.transcript-collapse__header:active { background: var(--pg-surface-soft); }
.transcript-collapse__label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--pg-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.transcript-collapse__count {
  font-size: 0.7rem;
  color: var(--pg-muted-soft);
  font-weight: 600;
  background: var(--pg-surface-soft);
  padding: 2px 8px;
  border-radius: var(--pg-radius-full);
}
.transcript-collapse__icon {
  font-size: 0.8rem;
  color: var(--pg-muted-soft);
  transition: transform 0.25s ease;
}
.transcript-collapse__icon.is-open { transform: rotate(180deg); }
.transcript-collapse__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  opacity: 0;
}
.transcript-collapse__body.is-open {
  max-height: 600px;
  opacity: 1;
}

/* ── Mobile Transcript List ── */
.transcript-list-mobile {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cue-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--pg-radius-md);
  border: 1px solid var(--pg-border);
  background: var(--pg-surface);
  cursor: pointer;
  transition: all var(--pg-ease);
}
.cue-item:hover { border-color: rgba(76,116,255,0.3); }
.cue-item:focus-visible { outline: 3px solid var(--pg-brand); outline-offset: 2px; }
.cue-item.is-active {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border-color: rgba(76,116,255,0.45);
  color: #f8fafc;
}
.cue-item__index {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--pg-radius-full);
  background: var(--pg-surface-soft);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--pg-muted);
}
.cue-item.is-active .cue-item__index {
  background: rgba(76,116,255,0.25);
  color: #e2e8f0;
}
.cue-item__body { flex: 1; min-width: 0; }
.cue-item__time {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--pg-muted-soft);
  margin-bottom: 4px;
}
.cue-item.is-active .cue-item__time { color: rgba(226,232,240,0.6); }
.cue-item__orig {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 2px;
}
.cue-item.is-active .cue-item__orig { color: #f8fafc; }
.cue-item__trans {
  font-size: 0.82rem;
  color: var(--pg-muted);
  line-height: 1.4;
}
.cue-item.is-active .cue-item__trans { color: #a5b4fc; }
.cue-item__pinyin {
  font-size: 0.78rem;
  color: var(--pg-muted-soft);
  font-style: italic;
}
.cue-item.is-active .cue-item__pinyin { color: rgba(226,232,240,0.6); }

/* ── Mobile Study: Summary Section ── */
.summary-section-mobile {
  margin-top: 4px;
  padding: 16px;
  background: var(--pg-surface);
  border-top: 1px solid var(--pg-border-light);
}
.summary-section__title {
  font-family: var(--pg-font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary-section__title .icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--pg-radius-full);
  background: rgba(76,116,255,0.1);
  color: var(--pg-brand-dark);
  font-size: 0.75rem;
}
.summary-section__body {
  font-size: 0.88rem;
  color: var(--pg-muted);
  line-height: 1.7;
  white-space: pre-line;
}

/* ── Bottom Sheet (for mobile transcript) ── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.bottom-sheet-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background: var(--pg-surface);
  border-top-left-radius: var(--pg-radius-2xl);
  border-top-right-radius: var(--pg-radius-2xl);
  box-shadow: 0 -8px 40px rgba(12,16,28,0.15);
  z-index: 110;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bottom-sheet--visible {
  transform: translateY(0);
}
.bottom-sheet__handle {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
  cursor: grab;
}
.bottom-sheet__handle-bar {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--pg-border);
}
.bottom-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 8px;
}
.bottom-sheet__title {
  font-size: 0.95rem;
  font-weight: 700;
}
.bottom-sheet__count {
  font-size: 0.75rem;
  color: var(--pg-muted);
}
.bottom-sheet__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.05);
  color: var(--pg-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.bottom-sheet__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 20px;
  -webkit-overflow-scrolling: touch;
}

/* ── Study Meta Bar (mobile) ── */
.study-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--pg-surface);
  border-bottom: 1px solid var(--pg-border-light);
}
.study-meta-bar__title {
  font-family: var(--pg-font-display);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.study-meta-bar__badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--pg-radius-full);
  background: rgba(76,116,255,0.12);
  color: var(--pg-brand-dark);
  flex-shrink: 0;
}

/* ── Note boxes ── */
.note {
  background: rgba(16, 18, 26, 0.04);
  border-radius: var(--pg-radius-lg);
  padding: 14px;
  color: var(--pg-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}
.note--accent {
  background: rgba(76, 116, 255, 0.08);
  border: 1px solid rgba(76, 116, 255, 0.2);
}

/* ── Font utilities ── */
.font-medium { font-weight: 600; }

/* ── Auth Mount (used across pages) ── */
.auth-mount {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.auth-user-shell,
.auth-user-shell--compact {
  position: relative;
}
.auth-avatar-btn,
.auth-avatar-btn--compact {
  border: 1px solid var(--pg-border-light);
  background: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--pg-radius-full);
  font-weight: 700;
  color: var(--pg-brand-dark);
  cursor: pointer;
  font-size: 0.95rem;
}
.auth-avatar-btn--compact {
  width: 36px;
  height: 36px;
  font-size: 0.85rem;
}
.auth-menu,
.auth-menu--compact {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--pg-border-light);
  border-radius: 14px;
  box-shadow: var(--pg-shadow-lg);
  padding: 8px;
  display: grid;
  gap: 6px;
  z-index: 40;
}
.auth-menu-header {
  font-size: 0.8rem;
  color: var(--pg-muted);
  padding: 8px 10px;
}
.auth-menu-link {
  text-decoration: none;
  color: var(--pg-ink);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.auth-menu-link:hover {
  background: rgba(76, 116, 255, 0.12);
}
.auth-menu-logout {
  color: var(--pg-error);
}

/* ── Dividers ── */
.divider {
  margin: 22px 0;
  border-top: 1px solid var(--pg-border-light);
}

/* ── Site Footer ── */
.site-footer {
  width: 100%;
  border-top: 1px solid var(--pg-border-light);
  background: rgba(255, 255, 255, 0.75);
}
.site-footer__inner {
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: var(--space-4) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  color: var(--pg-muted);
  font-size: 0.9rem;
}
.site-footer__link {
  color: var(--pg-brand-dark);
  text-decoration: none;
  font-weight: 600;
}
.site-footer__link:hover {
  text-decoration: underline;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════════ */
/* RESPONSIVE BREAKPOINTS                   */
/* ════════════════════════════════════════ */

/* Mobile tab bar visible on small screens */
@media (max-width: 720px) {
  .mobile-tab-bar { display: flex; }
}

/* Navbar collapses on small screens */
@media (max-width: 680px) {
  .navbar__inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .navbar__actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Small mobile (< 480px) */
@media (max-width: 480px) {
  .nav-actions-demo .nav-lang-pill { font-size: 0.72rem; padding: 6px 10px; }
}