/* ==========================================================================
   Korean Part-Time 700 Sentences Online Course Platform Stylesheet
   Modern LMS with Two-Stage AI Verification
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-glow: rgba(79, 70, 229, 0.25);
  
  --success: #10b981;
  --success-hover: #059669;
  --success-light: #d1fae5;
  
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  
  --danger: #ef4444;
  --danger-light: #fee2e2;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-input: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border: #e2e8f0;
  --border-light: #edf2f7;
  
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Bengali", "Kalpurush", "SolaimanLipi", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-card: #151c2c;
  --bg-sidebar: #111726;
  --bg-input: #1e293b;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border: #1e293b;
  --border-light: #182234;
  
  --primary-light: rgba(79, 70, 229, 0.2);
  --success-light: rgba(16, 185, 129, 0.2);
  --warning-light: rgba(245, 158, 11, 0.2);

  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --card-hover-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

/* Mobile Slim App Bar (Active on <= 1024px) */
.mobile-app-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 0.85rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: 100%;
}

.mab-day-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.mab-day-trigger:active {
  transform: scale(0.95);
}

.mab-flag {
  font-size: 1rem;
}

.mab-chevron {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Duolingo-style Segmented Progress Bar */
.mab-segmented-progress {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-input);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.mab-track {
  display: flex;
  gap: 4px;
  align-items: center;
}

.mab-seg {
  width: 14px;
  height: 7px;
  border-radius: 4px;
  background: var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mab-seg.filled {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.mab-counter {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  font-family: inherit;
  letter-spacing: 0.5px;
}

.mab-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.mab-token-pill {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1.5px solid rgba(245, 158, 11, 0.35);
  color: #d97706;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.mab-token-pill:active {
  transform: scale(0.94);
}

.mab-profile-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.mab-profile-btn:active {
  transform: scale(0.92);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  padding: 0.25rem;
  border-radius: var(--radius-full);
}

.nav-tab {
  border: none;
  background: transparent;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-tab.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 700;
}

.btn-icon {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}

.btn-icon:hover {
  background: var(--border);
}

/* ==========================================================================
   Course Layout (Sidebar + Stage)
   ========================================================================== */

.app-body {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  display: flex;
  padding: 1.5rem;
  gap: 1.5rem;
  position: relative;
}

/* Mobile Curriculum Toggle Bar (Shown on <= 1024px) */
.mobile-curriculum-bar {
  display: none;
  width: 100%;
}

.btn-mobile-curriculum-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: var(--transition);
}

.btn-mobile-curriculum-toggle:hover {
  border-color: var(--primary);
  background: var(--bg-input);
}

.mct-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mct-icon {
  font-size: 1.15rem;
}

.mct-title {
  font-weight: 700;
}

.mct-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mct-day-pill {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.mct-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.25s ease;
  display: inline-block;
}

.btn-mobile-curriculum-toggle.active .mct-chevron {
  transform: rotate(180deg);
}

/* Curriculum Sidebar */
.curriculum-sidebar {
  width: 360px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 110px);
  position: sticky;
  top: 80px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: var(--transition);
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.course-progress-box {
  margin-top: 0.75rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
}

.progress-track {
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.curriculum-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0.75rem;
}

/* Module Accordion */
.module-group {
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
}

.module-toggle {
  width: 100%;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text-main);
  transition: var(--transition);
}

.module-toggle:hover {
  background: var(--bg-input);
}

.module-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.module-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.module-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.module-chevron {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  color: var(--text-light);
}

.module-group.open .module-chevron {
  transform: rotate(180deg);
}

.module-days-list {
  display: none;
  padding: 0.35rem 0.5rem 0.6rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-main);
  flex-direction: column;
  gap: 0.25rem;
}

.module-group.open .module-days-list {
  display: flex;
}

/* Day item in sidebar */
.day-btn {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.day-btn:hover:not(.locked) {
  background: var(--bg-card);
  color: var(--text-main);
}

.day-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  border-left: 3px solid var(--primary);
}

.day-btn.completed {
  color: var(--success);
}

.day-btn.locked {
  cursor: not-allowed;
  opacity: 0.55;
}

.day-status-icon {
  font-size: 0.85rem;
}

/* ==========================================================================
   Main Stage (Active Lesson View)
   ========================================================================== */

.course-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.lesson-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--card-shadow);
  flex-wrap: wrap;
  gap: 1rem;
}

.lesson-banner-text h2 {
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lesson-banner-text p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.lesson-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* OpenAI Real-time AI Status Pill */
.openai-status-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.85rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.3);
  transition: var(--transition);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-indicator-dot.active {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

/* OpenAI Real-time Token Usage Badge */
.token-usage-badge {
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: var(--transition);
}

.token-badge-top-row {
  display: contents;
}

.token-badge-title {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.token-badge-icon {
  font-size: 0.95rem;
}

.token-badge-details {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.token-badge-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.token-stat-pill {
  background: var(--bg-input);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.token-stat-pill strong {
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.token-stat-pill.highlight {
  background: rgba(79, 70, 229, 0.1);
  border-color: rgba(79, 70, 229, 0.25);
  color: var(--primary);
}

.token-stat-pill.highlight strong {
  color: var(--primary);
}

.token-stat-pill.cost-highlight {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #065f46;
}

.token-stat-pill.cost-highlight strong {
  color: #059669;
}

[data-theme="dark"] .token-stat-pill.cost-highlight {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

[data-theme="dark"] .token-stat-pill.cost-highlight strong {
  color: #10b981;
}

.token-rate-pill {
  background: var(--bg-input);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.token-rate-pill strong {
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.btn-token-logs {
  background: rgba(79, 70, 229, 0.12);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.3);
  border-radius: var(--radius-full);
  padding: 0.2rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-token-logs:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translateY(-1px);
}

/* In-Card Split Token Badge & Pills */
.token-split-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  background: transparent;
  border: none;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
  padding: 0.5rem 0 0;
  margin-top: 0.25rem;
  width: 100%;
  box-sizing: border-box;
}

[data-theme="dark"] .token-split-badge {
  border-top-color: rgba(255, 255, 255, 0.15);
}

.token-split-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.55rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}

[data-theme="dark"] .token-split-pill {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.12);
}

.token-split-pill.input-split {
  color: #1d4ed8;
}

.token-split-pill.output-split {
  color: #6d28d9;
}

.token-split-pill.total-split {
  color: #b45309;
  font-weight: 700;
}

.token-split-pill.cost-split {
  color: #047857;
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
  font-weight: 700;
  margin-left: auto;
}

[data-theme="dark"] .token-split-pill.cost-split {
  color: #34d399;
  background: rgba(16, 185, 129, 0.2);
}

.btn-secondary {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-input);
}

/* ==========================================================================
   AI Two-Stage Interactive Sentence Card
   ========================================================================== */

.sentences-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sentence-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: relative;
}

.sentence-card.is-locked {
  opacity: 0.5;
  pointer-events: none;
  border-style: dashed;
}

.sentence-card.is-mastered {
  border-color: var(--success);
  background: linear-gradient(to bottom, var(--bg-card), rgba(16, 185, 129, 0.03));
}

/* Focus Mode: Active Sentence Card Glow */
.sentence-card.is-active-focus {
  border-color: var(--primary) !important;
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.16), 0 0 0 2px rgba(79, 70, 229, 0.2) !important;
  position: relative;
}

/* Inline Structured Focus Pill inside card-top */
.focus-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* Locked Cards: Muted, Minimal & Distraction-Free */
.sentence-card.is-locked {
  opacity: 0.65;
  background: var(--bg-card);
  border: 1.5px dashed var(--border);
  box-shadow: none !important;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  margin: 0;
}
.sentence-card.is-locked .card-actions,
.sentence-card.is-locked .audio-btn {
  display: none !important;
}
.sentence-card.is-locked .korean-headline span {
  color: var(--text-muted);
  font-size: 1.15rem;
}

/* Collapsible Achievement Row for Completed Sentences on Mobile */
.sentence-card.is-mastered.is-collapsed {
  padding: 0.75rem 1rem !important;
  cursor: pointer;
  border-radius: 16px !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
  background: var(--bg-card) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03) !important;
  transition: all 0.2s ease;
  margin: 0 !important;
}

.sentence-card.is-mastered.is-collapsed:hover {
  background: rgba(16, 185, 129, 0.04) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
}

.sentence-card.is-mastered.is-collapsed .card-top,
.sentence-card.is-mastered.is-collapsed .korean-headline,
.sentence-card.is-mastered.is-collapsed .card-dynamic-stage {
  display: none !important;
}

.completed-summary-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.sentence-card.is-mastered.is-collapsed .completed-summary-bar {
  display: flex;
}

.csb-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.csb-check {
  font-size: 1.15rem;
  line-height: 1;
}

.csb-num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.csb-korean {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csb-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.csb-status {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.csb-expand-icon {
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  transition: transform 0.2s ease;
}

/* Audio Ripple Pulse Animation */
@keyframes audioWavePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.6);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(79, 70, 229, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
  }
}

.audio-btn.playing-audio {
  animation: audioWavePulse 1.1s infinite;
  background: var(--primary) !important;
  color: #fff !important;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-top-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.card-top-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.sentence-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
}

.phase-indicator {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.phase-indicator.phase-1 {
  background: var(--warning-light);
  color: #b45309;
}

.phase-indicator.phase-2 {
  background: var(--primary-light);
  color: var(--primary);
}

.phase-indicator.phase-complete {
  background: var(--success-light);
  color: var(--success);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.action-btn {
  background: var(--bg-input);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.action-btn:hover {
  background: var(--border);
  color: var(--text-main);
}

.action-btn.bookmarked {
  color: var(--warning);
}

/* Korean Headline */
.korean-headline {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.korean-headline .audio-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}

.korean-headline .audio-btn:hover {
  transform: scale(1.08);
}

/* Interactive Input Steps */
.step-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: transparent;
  padding: 0.75rem 0 0;
  border: none;
  border-top: 1px dashed var(--border-light);
  margin-top: 0.75rem;
  transition: var(--transition);
}

.step-label {
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-main);
}

.input-row {
  display: flex;
  gap: 0.6rem;
  width: 100%;
}

.step-input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 0.85rem 1.15rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
  box-sizing: border-box;
}

.step-input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.btn-ai-verify {
  padding: 0.85rem 1.35rem;
  border-radius: 16px;
  border: none;
  background: linear-gradient(180deg, #5b51f5 0%, #4338ca 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
  box-shadow: 0 4px 0 #312e81, 0 8px 18px rgba(79, 70, 229, 0.28);
  -webkit-tap-highlight-color: transparent;
}

.btn-ai-verify:hover:not(:disabled) {
  background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
}

.btn-ai-verify:active:not(:disabled) {
  transform: translateY(3px) !important;
  box-shadow: 0 1px 0 #312e81, 0 3px 8px rgba(79, 70, 229, 0.2) !important;
}

.btn-ai-verify:disabled {
  opacity: 0.65;
  box-shadow: none;
  cursor: not-allowed;
}

/* AI Feedback Box */
.ai-feedback {
  padding: 0.95rem 1.15rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: feedbackSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

@keyframes feedbackSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-feedback.success {
  background: #f0fdf4;
  color: #14532d;
  border: 1.5px solid #86efac;
}

[data-theme="dark"] .ai-feedback.success {
  background: rgba(20, 83, 45, 0.25);
  color: #a7f3d0;
  border-color: rgba(52, 211, 153, 0.35);
}

.ai-feedback.error {
  background: #fef2f2;
  color: #7f1d1d;
  border: 1.5px solid #fca5a5;
}

[data-theme="dark"] .ai-feedback.error {
  background: rgba(127, 29, 29, 0.25);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.ai-feedback-header {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
}

.ai-feedback-icon {
  font-size: 1.15rem;
  line-height: 1.3;
  flex-shrink: 0;
}

.ai-feedback-text {
  flex: 1;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

/* Vocabulary Clues Box (Step 2) */
.vocab-clues-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: rgba(79, 70, 229, 0.04);
  border: 1px solid rgba(79, 70, 229, 0.14);
  padding: 0.85rem 1rem;
  border-radius: 16px;
}

.vocab-clues-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.vocab-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vocab-chip {
  background: var(--bg-card);
  border: 1.5px solid rgba(79, 70, 229, 0.18);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.vocab-chip:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.12);
}

.vocab-chip .kr-word {
  font-weight: 800;
  color: var(--primary);
  font-size: 0.92rem;
}

.vocab-sep {
  color: var(--primary);
  opacity: 0.45;
  font-weight: 700;
  font-size: 0.75rem;
  margin: 0 1px;
}

.vocab-chip .bn-word {
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
}

/* Mastered Complete Card View */
.mastered-summary {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 1.25rem;
  border-radius: var(--radius-md);
}

.mastered-summary .row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
}

.mastered-summary .tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.mastered-summary .val {
  font-weight: 600;
  color: var(--text-main);
}

.btn-next-sentence {
  margin-top: 0.5rem;
  align-self: flex-end;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-next-sentence:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.4);
}

/* ==========================================================================
   Complete & Unlock Footer
   ========================================================================== */

.lesson-footer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-nav-btns {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
}

.btn-nav {
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-nav:hover:not(:disabled) {
  background: var(--border);
  transform: translateY(-1px);
}

.btn-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ==========================================================================
   Reference Library View (All 700 Sentences)
   ========================================================================== */

.library-view {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.library-view.active {
  display: flex;
}

.course-view {
  display: flex;
  gap: 1.5rem;
  width: 100%;
  align-items: flex-start;
}

.course-view.hidden {
  display: none;
}

.library-controls {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-bar-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-pills-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.cat-pill {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.cat-pill:hover {
  color: var(--text-main);
}

.cat-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.library-stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1rem;
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--modal-shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: modalEnter 0.2s ease-out;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.close-btn,
.btn-close-modal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  line-height: 1;
}

.close-btn:hover,
.btn-close-modal:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  transform: scale(1.05);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.setting-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.setting-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover {
  background: #dc2626;
}

/* ==========================================================================
   Multi-User SQLite Header Badge & Switch Button
   ========================================================================== */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.65rem;
  transition: var(--transition);
}

.user-badge:hover {
  border-color: var(--primary);
}

.user-avatar-icon {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.user-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-handle {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.btn-switch-user {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.btn-switch-user:hover {
  background: var(--primary);
  color: #ffffff;
  transform: scale(1.03);
}

/* ==========================================================================
   Multi-User Onboarding & Login Modals
   ========================================================================== */
.user-auth-box {
  max-width: 460px;
  padding: 1.75rem;
}

.auth-header-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.auth-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.auth-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.auth-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-description {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-description code {
  background: var(--bg-input);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--primary);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  text-align: left;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.input-with-prefix {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.input-with-prefix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-prefix {
  padding-left: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.65rem 0.75rem;
  font-size: 0.92rem;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
}

.form-group > .form-input {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.form-group > .form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-help {
  font-size: 0.74rem;
  color: var(--text-light);
  margin-top: 0.2rem;
}

.username-pill-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
}

.username-pill {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}

.auth-msg-box {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
  margin-bottom: 0.85rem;
  display: none;
}

.auth-msg-box.error {
  display: block;
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.auth-msg-box.success {
  display: block;
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.auth-actions {
  display: flex;
  justify-content: stretch;
  margin-top: 0.5rem;
}

.auth-actions .btn-auth-primary {
  width: 100%;
}

.auth-actions-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn-auth-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.7rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-auth-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-auth-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-auth-secondary:hover {
  background: var(--bg-input);
  color: var(--text-main);
}

/* ==========================================================================
   Token Logs Modal Box & Audit Table
   ========================================================================== */
.token-logs-modal-box {
  max-width: 920px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.token-logs-body {
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

/* Summary Grid */
.token-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.token-summary-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.token-summary-card.highlight {
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.35);
}

.token-summary-card.cost-card {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.35);
}

.token-summary-card.cost-card .token-summary-val {
  color: #059669;
}

[data-theme="dark"] .token-summary-card.cost-card .token-summary-val {
  color: #10b981;
}

.token-summary-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.token-summary-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.token-summary-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.token-logs-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.log-file-pill {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.log-file-pill code {
  background: var(--bg-input);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-refresh-logs {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-refresh-logs:hover {
  background: var(--bg-input);
  color: var(--text-main);
}

/* Scrollable Token Logs Table */
.token-table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-height: 420px;
}

.token-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.token-table th {
  background: var(--bg-input);
  padding: 0.65rem 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

.token-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

.token-table tr:hover {
  background: rgba(79, 70, 229, 0.04);
}

.token-badge-pass {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
}

.token-badge-fail {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .token-summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .token-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Confetti Canvas
   ========================================================================== */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.6s linear infinite;
}

/* ==========================================================================
   Bottom Navigation Dock (PWA Standard)
   ========================================================================== */
.bottom-app-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  align-items: center;
  justify-content: space-evenly;
  z-index: 900;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

[data-theme="dark"] .bottom-app-dock {
  background: rgba(17, 24, 39, 0.94);
  border-top-color: rgba(255, 255, 255, 0.08);
}

.dock-item {
  flex: 1;
  max-width: 74px;
  min-width: 0;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 2px 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.dock-item:active {
  transform: scale(0.92);
}

.dock-icon {
  width: 48px;
  height: 28px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dock-item.active .dock-icon {
  background: rgba(79, 70, 229, 0.14);
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.15);
}

.dock-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
  text-align: center;
  transition: color 0.18s ease, font-weight 0.18s ease;
  white-space: nowrap;
}

.dock-item.active .dock-label {
  color: var(--primary);
  font-weight: 700;
}

/* Bottom Sheet Backdrop */
.curriculum-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.curriculum-backdrop.open,
.curriculum-backdrop.active {
  display: block !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.sheet-grab-bar {
  display: none;
}

.btn-close-sheet {
  display: none;
}

/* ==========================================================================
   Responsive Breakpoints & Native Mobile App Experience
   ========================================================================== */

/* Tablet & Smaller Screens (<= 1024px) */
@media (max-width: 1024px) {
  /* Toggle headers: show slim mobile app bar, hide crowded desktop header */
  .desktop-header-container {
    display: none !important;
  }

  .mobile-app-bar {
    display: flex !important;
  }

  /* Show fixed bottom navigation dock */
  .bottom-app-dock {
    display: flex !important;
  }

  /* Main body spacing to prevent bottom dock overlap */
  .app-body {
    flex-direction: column;
    padding: 0.85rem;
    padding-bottom: 84px !important;
    width: 100%;
  }

  .course-view {
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
  }

  .mobile-curriculum-bar {
    display: none !important;
  }

  /* Transform Curriculum into an iOS-Style Slide-Up Bottom Sheet */
  .curriculum-backdrop {
    display: block;
  }

  .curriculum-sidebar.mobile-sheet {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-height: 82vh !important;
    border-top-left-radius: 24px !important;
    border-top-right-radius: 24px !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-bottom: none !important;
    z-index: 1000 !important;
    box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.35) !important;
    transform: translateY(105%) !important;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .curriculum-sidebar.mobile-sheet .curriculum-scroll {
    padding-bottom: 3.5rem !important;
  }

  .curriculum-sidebar.mobile-sheet.open,
  .curriculum-sidebar.mobile-sheet.sheet-open {
    transform: translateY(0) !important;
  }

  .sheet-grab-bar {
    display: flex !important;
    justify-content: center;
    padding: 0.75rem 0 0.25rem;
    cursor: grab;
  }

  .sheet-grab-handle {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: var(--border);
  }

  .sidebar-header-top {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 0.5rem;
  }

  .btn-close-sheet {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
  }

  .btn-close-sheet:hover {
    color: var(--danger);
    border-color: var(--danger);
  }

  /* Ultra-slim lesson banner on mobile (clean 1-line overview) */
  .lesson-banner {
    padding: 0.75rem 1rem !important;
    border-radius: 16px !important;
    gap: 0.25rem !important;
    margin: 0 !important;
  }

  .lesson-banner-text h2 {
    font-size: 1.05rem !important;
    gap: 0.4rem !important;
  }

  .lesson-banner-text p {
    font-size: 0.78rem !important;
    margin-top: 0.1rem !important;
  }

  /* Hide huge inline token badge on mobile - accessible via header and bottom dock */
  .lesson-controls {
    display: none !important;
  }

  .course-stage {
    width: 100%;
    gap: 0.85rem !important;
  }

  .sentences-container {
    gap: 0.85rem !important;
  }

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

  /* Lesson Footer Navigation */
  .lesson-footer {
    padding: 0.75rem 1rem !important;
    border-radius: 16px !important;
    margin: 0 !important;
  }

  .footer-nav-btns {
    width: 100%;
    display: flex;
    gap: 0.65rem;
  }

  .btn-nav {
    flex: 1;
    min-height: 46px;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
  }

  #next-day-btn:not(:disabled) {
    background: linear-gradient(135deg, #4f46e5, #4338ca) !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 12px rgba(79, 70, 229, 0.3) !important;
  }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  /* Sentence Card & Focus Mode */
  .sentence-card {
    padding: 1.1rem 1rem !important;
    border-radius: 16px !important;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
  }

  .sentence-card.is-locked {
    padding: 0.9rem 1rem !important;
    border-radius: 16px !important;
    margin: 0 !important;
  }

  .sentence-card.is-mastered.is-collapsed {
    padding: 0.75rem 1rem !important;
    border-radius: 16px !important;
    margin: 0 !important;
  }

  .korean-headline {
    font-size: clamp(1.3rem, 5.5vw, 1.65rem);
    line-height: 1.45;
    word-break: keep-all;
    overflow-wrap: break-word;
    margin: 0.6rem 0 0.4rem;
  }

  .input-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  .step-input {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 16px !important;
    min-height: 48px !important;
    padding: 0.85rem 1rem !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-md) !important;
  }

  .btn-ai-verify {
    width: 100% !important;
    min-height: 52px !important;
    justify-content: center !important;
    font-size: 1.02rem !important;
    font-weight: 700 !important;
    border-radius: 16px !important;
    background: linear-gradient(180deg, #5b51f5 0%, #4338ca 100%) !important;
    box-shadow: 0 4px 0 #312e81, 0 8px 18px rgba(79, 70, 229, 0.3) !important;
    letter-spacing: 0.2px;
  }

  .btn-ai-verify:active:not(:disabled) {
    transform: translateY(3px) !important;
    box-shadow: 0 1px 0 #312e81, 0 3px 8px rgba(79, 70, 229, 0.2) !important;
  }

  .card-footer-actions {
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .card-footer-actions .btn-secondary,
  .card-footer-actions .btn-action {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Modals on Mobile */
  .modal-box {
    width: 95%;
    max-height: 90vh;
    padding: 1.25rem 1rem;
    margin: 0.75rem;
  }

  .token-logs-modal-box {
    width: 96%;
    max-height: 92vh;
  }

  .token-logs-body {
    padding: 0.85rem;
  }

  .token-summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .token-summary-card {
    padding: 0.65rem 0.75rem;
  }

  .token-summary-val {
    font-size: 1.15rem;
  }

  .token-table th,
  .token-table td {
    padding: 0.5rem 0.55rem;
    font-size: 0.72rem;
  }
}

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
  .app-body {
    padding: 0.6rem;
    padding-bottom: 84px !important;
  }

  .mab-day-text {
    max-width: 65px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mab-seg {
    width: 10px;
    height: 5px;
  }

  .mab-token-pill strong {
    font-size: 0.7rem;
  }

  .korean-headline {
    font-size: 1.25rem;
  }
}

/* ==========================================================================
   Admin Navigation & Link Styles
   ========================================================================== */
.btn-admin-header {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
}

.btn-admin-header:hover {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-admin-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
}

.btn-admin-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.auth-admin-helper {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.auth-admin-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.auth-admin-link:hover {
  text-decoration: underline;
}
