@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ─── Design Tokens ─── */
:root {
  --bg: #0a0b0f;
  --surface: #12141a;
  --surface-2: #1a1d26;
  --surface-3: #22263a;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);

  --accent: #6c63ff;
  --accent-glow: rgba(108, 99, 255, 0.3);
  --accent-2: #ff6b6b;
  --accent-3: #43e97b;
  --accent-warm: #f093fb;

  --text: #f0f0f5;
  --text-2: rgba(240,240,245,0.80);
  --text-3: rgba(240,240,245,0.62);

  --score-low: #ff6b6b;
  --score-mid: #ffd93d;
  --score-high: #43e97b;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Typography ─── */
h1, h2, h3, h4 { font-family: var(--font-body); font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(1.9rem, 8vw, 3.2rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.4rem, 5vw, 2.2rem); letter-spacing: -0.02em; }
h3 { font-size: clamp(1.05rem, 3vw, 1.3rem); letter-spacing: -0.01em; }

/* ─── Links ─── */
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-warm); }

/* ─── Layout Utilities ─── */
.container { max-width: 480px; margin: 0 auto; padding: 0 20px; }
.container-lg { max-width: 800px; margin: 0 auto; padding: 0 20px; }
.center { text-align: center; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.w-full { width: 100%; }

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-sm { padding: 14px 16px; }
.card-lg { padding: 28px; border-radius: var(--radius-lg); }
.card-glow {
  box-shadow: 0 0 40px var(--accent-glow);
  border-color: rgba(108,99,255,0.3);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.btn-primary:hover {
  background: #7b73ff;
  box-shadow: 0 8px 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-outline:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

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

.btn-danger {
  background: var(--accent-2);
  color: white;
}
.btn-success {
  background: var(--accent-3);
  color: #0a0f0a;
}

.btn-lg { padding: 18px 32px; font-size: 1.1rem; border-radius: var(--radius-lg); font-weight: 700; }
.btn-sm { padding: 8px 16px; font-size: 0.875rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* Shimmer effect on primary btn */
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}
.btn-primary:hover::after { transform: translateX(100%); }

/* ─── Form Elements ─── */
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color var(--transition);
  outline: none;
  appearance: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input::placeholder { color: var(--text-3); }
.input-label { font-size: 0.875rem; color: var(--text-2); margin-bottom: 6px; display: block; font-weight: 500; }

/* ─── Score Circle ─── */
.score-circle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.score-circle svg { transform: rotate(-90deg); }
.score-circle .score-value {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}
.score-circle .score-label {
  position: absolute;
  bottom: -4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* ─── Progress Bar ─── */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Badge / Pill ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.badge-accent { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(108,99,255,0.3); }
.badge-success { background: rgba(67,233,123,0.15); color: var(--accent-3); }
.badge-warning { background: rgba(255,217,61,0.15); color: #ffd93d; }
.badge-danger { background: rgba(255,107,107,0.15); color: var(--accent-2); }
.badge-free { background: var(--surface-3); color: var(--text-3); }

/* ─── Tag ─── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
}

/* ─── Bottom Nav ─── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10,11,15,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text-3);
  border: none;
  background: none;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 0.72rem; font-weight: 600; }
.nav-item.active { color: var(--accent); }
.nav-item:hover { color: var(--text-2); }

/* ─── App Shell ─── */
.app-shell {
  min-height: 100dvh;
  padding-bottom: 80px; /* bottom nav space */
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(10,11,15,0.95);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; }
.logo-img { display: block; width: auto; height: auto; max-height: 52px; max-width: 140px; }
@media (min-width: 640px)  { .logo-img { max-height: 60px; max-width: 160px; } }
@media (min-width: 1024px) { .logo-img { max-height: 70px; max-width: 190px; } }

/* ─── Toast ─── */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.9rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: toast-in 0.3s var(--transition-spring);
}
.toast.error { border-color: var(--accent-2); color: var(--accent-2); }
.toast.success { border-color: var(--accent-3); color: var(--accent-3); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Loading States ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Divider ─── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ─── Page Transitions ─── */
.page { animation: page-in 0.3s ease; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Recording Button ─── */
.record-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all var(--transition-spring);
}
.record-btn-idle {
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.record-btn-idle:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 12px rgba(108,99,255,0.2);
}
.record-btn-recording {
  background: var(--accent-2);
  animation: pulse-record 1.5s ease-in-out infinite;
}
@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.5); }
  50% { box-shadow: 0 0 0 20px rgba(255,107,107,0); }
}

/* ─── Waveform ─── */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}
.wave-bar {
  width: 3px;
  border-radius: 99px;
  background: var(--accent);
  min-height: 4px;
  transition: height 0.1s ease;
}
.wave-bar.idle { background: var(--surface-3); height: 4px; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) var(--radius) var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  animation: modal-in 0.35s var(--transition-spring);
}
@keyframes modal-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ─── Score Color Helpers ─── */
.score-low { color: var(--score-low); }
.score-mid { color: var(--score-mid); }
.score-high { color: var(--score-high); }

/* ─── Miscellaneous ─── */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.font-display { font-family: var(--font-display); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.hidden { display: none !important; }
.opacity-0 { opacity: 0; }

/* ─── Landing Page specific ─── */
.landing-hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 24px 100px;
  position: relative;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(108,99,255,0.2) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}
.hero-glow-2 {
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(240,147,251,0.1) 0%, transparent 70%);
  bottom: 100px;
  left: -80px;
  pointer-events: none;
}

/* Selection card */
.select-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 14px;
}
.select-card:hover { border-color: var(--accent); background: var(--surface-2); }
.select-card.selected { border-color: var(--accent); background: rgba(108,99,255,0.1); }
.select-card .icon { width: 36px; height: 36px; font-size: 1.3rem; display: flex; align-items: center; justify-content: center; }

/* Exercise card */
.exercise-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.exercise-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.exercise-card.locked { opacity: 0.6; cursor: not-allowed; }
.exercise-card.locked:hover { transform: none; }
.exercise-card .level-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* ─── XP Progress Card (shared: dashboard + feedback) ─── */
.xp-progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.xpc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.xpc-left { display: flex; flex-direction: column; gap: 3px; }
.xpc-level-badge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-warm) 100%);
  color: white;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.8rem;
  padding: 3px 11px;
  border-radius: 99px;
  letter-spacing: 0.02em;
  width: fit-content;
}
.xpc-title {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.xpc-right { text-align: right; flex-shrink: 0; }
.xpc-earned {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.xpc-total {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 2px;
}
.xpc-bar-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.xpc-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  border-radius: 99px;
  transition: width 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}
.xpc-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ─── Sentence Complete ─── */
.sentence-starter-card {
  background: linear-gradient(135deg, rgba(108,99,255,0.15) 0%, rgba(108,99,255,0.05) 100%);
  border: 2px solid rgba(108,99,255,0.4);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  margin-bottom: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sentence-pressure-card {
  border-color: rgba(255,107,107,0.45);
  background: linear-gradient(135deg, rgba(255,107,107,0.12) 0%, rgba(255,107,107,0.04) 100%);
}
.sentence-starter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 14px;
}
.sentence-pressure-card .sentence-starter-label { color: var(--accent-2); }
.sentence-starter-text {
  font-family: var(--font-body);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 10px;
  color: var(--text);
}
.sentence-starter-hint {
  font-size: 0.8rem;
  color: var(--text-3);
}

/* Speed mode: slide transition when starter changes */
.sentence-speed-card {
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.sentence-change {
  opacity: 0;
  transform: translateY(-6px);
}

/* Speed progress dots */
.speed-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.speed-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-3);
  transition: all 0.3s var(--transition-spring);
}
.speed-dot.active {
  background: var(--accent-2);
  transform: scale(1.3);
  box-shadow: 0 0 8px rgba(255,107,107,0.5);
}
.speed-dot.done {
  background: var(--score-high);
}

/* Pressure mode: floating interruption messages */
.pressure-messages-area {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.pressure-msg {
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.4);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-2);
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  letter-spacing: 0.01em;
}
.pressure-msg.pressure-msg-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ─── Journey Dashboard Widget ─── */

/* The journey card color variable propagates via --jc-color set inline */
.journey-card { transition: none; }

/* Journey step dots on dashboard */
.jpd { transition: background 0.5s ease; }

/* ─── Training Areas ─── */

/* Dashboard compact row */
.dash-area-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  border-left: 3px solid var(--area-color);
}
.dash-area-row:hover { border-color: var(--area-color); transform: translateX(3px); }
.dar-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--area-color) 15%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.dar-body { flex: 1; min-width: 0; }
.dar-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.dar-title { font-weight: 700; font-size: 0.88rem; }
.dar-milestone { font-size: 0.72rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dar-bar-track {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.dar-bar-fill {
  height: 100%;
  background: var(--area-color);
  border-radius: 99px;
  transition: width 0.8s ease;
}
.dar-pct {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--area-color);
  flex-shrink: 0;
  min-width: 32px;
  text-align: right;
}

/* ─── Responsive tweaks ─── */
@media (min-width: 640px) {
  .container, .container-lg { padding: 0 32px; }
}
