/* ============================================================
   PRANA — Main Stylesheet
   Dark theme, mobile-first, minimal UI
   ============================================================ */

:root {
  --bg: #050510;
  --text: #e2e0ea;
  --text-dim: rgba(226, 224, 234, 0.45);
  --accent: #a855f7;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --font: -apple-system, "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

/* ── Screens ── */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* ── Home Screen ── */

#home {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom) 20px;
}

.home-header {
  text-align: center;
  padding: 14px 0 20px;
  position: relative;
}

.title-mandala {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  opacity: 0.5;
  position: absolute;
  top: 22px;
}

.title-mandala-left {
  left: calc(18% - 27px);
}

.title-mandala-right {
  right: calc(18% - 27px);
}

.home-header h1 {
  font-size: 2.2rem;
  font-weight: 200;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-header p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.title-deco {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0;
  opacity: 0.45;
}

.deco-line {
  display: inline-block;
  width: 44px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent));
}

.title-deco:first-child .deco-line:last-child,
.title-deco:last-child .deco-line:last-child {
  background: linear-gradient(90deg, var(--accent), transparent);
}

.deco-dot {
  display: inline-block;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
}

.deco-diamond {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 0 6px var(--accent);
}

/* ── Top bar (home) ── */

.home-toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 20px;
  flex-wrap: wrap;
}

.toolbar-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: var(--font);
  font-weight: 300;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.toolbar-btn:hover,
.toolbar-btn:active {
  background: var(--surface-hover);
  border-color: var(--accent);
}

/* ── Category ── */

.category {
  margin-bottom: 24px;
}

.category-title {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 0 4px 8px;
}

/* ── Mode cards ── */

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 40px 14px 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.25s, transform 0.15s;
}

.mode-card:hover,
.mode-card:active {
  background: var(--surface-hover);
  border-color: var(--accent);
  transform: scale(1.01);
}

.mode-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.mode-card-name {
  font-size: 1rem;
  font-weight: 400;
}

.breath-curve {
  flex-shrink: 0;
  opacity: 0.9;
}

.mode-card-timing {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

.nostril-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.65rem;
  color: rgba(255, 150, 50, 0.6);
  letter-spacing: 0.02em;
}

.mode-card-info {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 150, 50, 0.08);
  border: 1px solid rgba(255, 150, 50, 0.25);
  color: rgba(255, 150, 50, 0.7);
  font-size: 0.7rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
}

.mode-card-info:hover {
  background: rgba(255, 150, 50, 0.15);
  color: rgba(255, 150, 50, 0.9);
}

/* ── Session config (bottom of mode card on select) ── */

.session-config {
  display: none;
  padding: 16px 0 0;
}

.session-config.visible {
  display: block;
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.config-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.config-options {
  display: flex;
  gap: 6px;
}

.config-option {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.config-option.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-start {
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 1rem;
  font-weight: 400;
  font-family: var(--font);
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-start:hover { opacity: 0.9; }
.btn-start:active { transform: scale(0.98); }

/* ── Palette selector ── */

.palette-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0 8px;
}

.palette-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.palette-dot-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.palette-dot:hover .palette-dot-label {
  opacity: 1;
}

.palette-dot canvas {
  border-radius: 50%;
  display: block;
}

.palette-dot.selected {
  border-color: rgba(255, 255, 255, 0.95);
  transform: scale(1.18);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35), 0 0 4px rgba(255, 255, 255, 0.5);
}

.palette-dot-noborder.selected {
  border-color: transparent;
}

.palette-dot-random {
  background: conic-gradient(
    hsl(270,100%,62%), hsl(160,100%,50%), hsl(10,100%,55%),
    hsl(220,90%,45%), hsl(300,100%,50%), hsl(0,0%,80%), hsl(270,100%,62%)
  );
  font-size: 14px;
  line-height: 36px;
  text-align: center;
  color: #fff;
  font-weight: bold;
}

.palette-dot-mixed {
  background: conic-gradient(
    hsl(270,80%,50%) 0deg, hsl(10,90%,50%) 60deg, hsl(160,80%,45%) 120deg,
    hsl(220,80%,50%) 180deg, hsl(45,90%,50%) 240deg, hsl(300,80%,50%) 300deg,
    hsl(270,80%,50%) 360deg
  );
  font-size: 14px;
  line-height: 36px;
  text-align: center;
  color: rgba(255,255,255,0.85);
}

/* ── Floating palette picker (exercise screen) ── */

.palette-picker {
  position: absolute;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  display: flex;
  gap: 14px;
  padding: 14px 20px;
  background: radial-gradient(ellipse at center, rgba(20, 18, 35, 0.85), rgba(8, 6, 18, 0.9));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-picker.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.palette-picker .pdot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  overflow: visible;
  position: relative;
}

.palette-picker .pdot:hover {
  transform: scale(1.15);
}

.palette-picker .pdot.active {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  outline: 1.5px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.pdot-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.palette-picker .pdot:hover .pdot-label {
  opacity: 1;
}

/* ── Speed gauge (edge swipe) ── */

.speed-gauge {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.speed-gauge.visible {
  opacity: 1;
}

.speed-gauge.left {
  left: 16px;
}

.speed-gauge.right {
  right: 16px;
}

.speed-gauge-track {
  width: 3px;
  height: 120px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.speed-gauge-fill-up {
  position: absolute;
  bottom: 50%;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, rgba(100, 200, 140, 0.3), rgba(100, 200, 140, 0.7));
  border-radius: 2px;
  transition: height 0.15s ease-out;
}

.speed-gauge-center {
  position: absolute;
  top: 50%;
  left: -1px;
  width: calc(100% + 2px);
  height: 2px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.4);
  border-radius: 1px;
}

.speed-gauge-fill-down {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to bottom, rgba(168, 130, 255, 0.3), rgba(168, 130, 255, 0.7));
  border-radius: 2px;
  transition: height 0.15s ease-out;
}

.speed-gauge-label {
  font-size: 11px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.5);
  font-family: -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Exercise Screen ── */

#exercise.active {
  display: block;
}

#exercise > canvas {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none; /* prevent browser gesture interference on iOS */
}

#mandala-canvas { z-index: 1; }


.exercise-ui {
  position: relative;
  z-index: 3;
  pointer-events: none;
}

.exercise-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 12px) + 12px) 16px 0;
  pointer-events: auto;
}

.exercise-bottom {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 12px) + 18px);
  right: 18px;
  z-index: 10;
  pointer-events: auto;
}

.ex-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.5);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.ex-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
}

/* Pause button: discreet, bottom-right */
#ex-pause {
  width: 34px;
  height: 34px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: opacity 0.3s, background 0.2s;
}
#ex-pause:hover,
#ex-pause:active {
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.8);
}

/* Hide info button in freq mode */
#exercise.freq-active #ex-info {
  display: none;
}

.ex-timer {
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
}

/* ── Info Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #0d0d18;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}

.modal h2 {
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 4px;
}

.info-names {
  font-size: 0.75rem;
  font-style: italic;
  color: rgba(226, 224, 234, 0.45);
  margin-bottom: 14px;
  line-height: 1.4;
}

.modal h3 {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 14px 0 4px;
}

.modal h3:first-of-type {
  margin-top: 8px;
}

.modal p {
  font-size: 0.8rem;
  line-height: 1.5;
  color: rgba(226, 224, 234, 0.75);
}

.settings-calibrate-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s;
}
.settings-calibrate-btn:hover {
  background: rgba(168, 85, 247, 0.2);
}

.install-guide {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.5;
}

.install-guide p {
  margin: 8px 0 4px;
}

.install-guide ol {
  margin: 4px 0 8px 20px;
  padding: 0;
}

.install-guide li {
  margin-bottom: 2px;
}

.install-guide em {
  color: rgba(168, 130, 255, 0.8);
  font-style: normal;
}

.settings-update-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.settings-update-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.modal-close {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
}

.settings-footer {
  margin-top: 20px;
  text-align: center;
}

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

.settings-donate span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

.donate-btn {
  display: inline-block;
  padding: 8px 20px;
  background: rgba(220, 50, 80, 0.15);
  border: 1px solid rgba(220, 50, 80, 0.3);
  border-radius: 20px;
  color: #e8607a;
  font-size: 0.85rem;
  text-decoration: none;
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.donate-btn:hover {
  transform: scale(1.08);
  background: rgba(220, 50, 80, 0.25);
  box-shadow: 0 0 12px rgba(220, 50, 80, 0.3);
}

.settings-credits {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

/* ── Calibration Screen ── */

#calibration {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.cal-step {
  max-width: 400px;
}

.cal-step h2 {
  font-size: 1.3rem;
  font-weight: 300;
  margin-bottom: 16px;
}

.cal-instruction {
  font-size: 0.9rem;
  color: rgba(226, 224, 234, 0.7);
  line-height: 1.5;
  margin-bottom: 24px;
}

.cal-timer-display {
  font-size: 3rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin-bottom: 24px;
}

.cal-btn {
  padding: 16px 48px;
  border: 2px solid var(--accent);
  border-radius: 50px;
  background: transparent;
  color: var(--accent);
  font-size: 1rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.cal-btn:active,
.cal-btn.active {
  background: var(--accent);
  color: #fff;
}

.cal-results {
  margin-top: 32px;
}

.cal-result-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.cal-result-value {
  color: var(--accent);
  font-weight: 400;
}

/* ── Summary Screen ── */

#summary {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.summary-card {
  max-width: 360px;
}

.summary-card h2 {
  font-size: 1.5rem;
  font-weight: 200;
  margin-bottom: 24px;
}

.summary-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.summary-stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.summary-stat-value {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--accent);
}

.summary-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* ── History Screen ── */

#history {
  overflow-y: auto;
  padding: env(safe-area-inset-top, 12px) 20px env(safe-area-inset-bottom, 12px);
}

.screen-header {
  display: flex;
  align-items: center;
  padding: 24px 0 16px;
  gap: 12px;
}

.screen-header h2 {
  font-size: 1.3rem;
  font-weight: 300;
  flex: 1;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

.history-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 0;
  font-size: 0.9rem;
}

.history-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item-mode {
  font-size: 0.95rem;
  font-weight: 400;
}

.history-item-date {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.history-item-bottom {
  display: flex;
  gap: 16px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ── Stats Screen ── */

#stats {
  overflow-y: auto;
  padding: env(safe-area-inset-top, 12px) 20px env(safe-area-inset-bottom, 12px);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 200;
  color: var(--accent);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Period tabs */
.stats-period-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: 20px;
  padding: 4px;
}

.stats-tab {
  flex: 1;
  padding: 6px 0;
  border-radius: 16px;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.stats-tab.active {
  background: var(--accent);
  color: #fff;
}

/* Motivation */
.stats-motivation {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 200, 100, 0.8);
  font-style: italic;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* Level card */
.stats-level-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.level-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.level-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}

.level-name {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 300;
}

.xp-bar-wrap {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.xp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #c084fc);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.xp-text {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: right;
}

/* Chart card */
.stats-chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.stats-chart-card h3 {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

#stats-curve {
  width: 100%;
  height: 140px;
  display: block;
}

/* Badges */
.stats-badges-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.stats-badges-card h3 {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 16px;
  padding: 4px 10px;
}

.badge-icon {
  font-size: 1rem;
}

.badge-name {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
}

.mode-dist {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

.mode-dist h3 {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.8rem;
}

.dist-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.dist-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

.dist-count {
  font-size: 0.7rem;
  color: var(--text-dim);
  min-width: 24px;
  text-align: right;
}

.btn-reset-stats {
  display: block;
  margin: 24px auto 0;
  padding: 8px 20px;
  background: rgba(255, 60, 60, 0.08);
  border: 1px solid rgba(255, 60, 60, 0.25);
  border-radius: 20px;
  color: rgba(255, 100, 100, 0.7);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset-stats:hover {
  background: rgba(255, 60, 60, 0.15);
  color: rgba(255, 100, 100, 0.9);
}

.btn-reset-stats.btn-reset-confirm {
  background: rgba(255, 40, 40, 0.25);
  border-color: rgba(255, 40, 40, 0.5);
  color: rgba(255, 80, 80, 1);
}

/* ── Guide Screen ── */

#guide {
  overflow-y: auto;
  padding: env(safe-area-inset-top, 12px) 20px env(safe-area-inset-bottom, 12px);
}

.guide-section {
  margin-bottom: 24px;
}

.guide-section h3 {
  font-size: 0.85rem;
  font-weight: 400;
  margin-bottom: 10px;
  color: var(--accent);
}

.guide-section p,
.guide-section li {
  font-size: 0.83rem;
  line-height: 1.6;
  color: rgba(226, 224, 234, 0.7);
}

.guide-section ul {
  padding-left: 20px;
}

.guide-section li {
  margin-bottom: 6px;
}

/* ── Settings row in options ── */

.settings-section {
  padding: 12px 0;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.setting-label {
  font-size: 0.85rem;
}

.setting-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  padding: 0;
}

.toggle.on {
  background: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle.on::after {
  transform: translateX(20px);
}

.lang-toggle {
  display: flex;
  gap: 4px;
}
.lang-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ── Transitions ── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.screen.active {
  animation: fadeIn 0.3s ease;
}

/* ══════════════════════════════════════
   FREQUENCY MODE
   ══════════════════════════════════════ */

/* Home card */
.freq-home-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 16px 8px;
  padding: 16px 18px;
  position: relative;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08), rgba(236, 72, 153, 0.06));
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, border-color 0.25s, transform 0.15s;
}
.freq-home-card:hover,
.freq-home-card:active {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.14), rgba(236, 72, 153, 0.10));
  border-color: rgba(168, 85, 247, 0.4);
  transform: scale(1.01);
}
.freq-home-icon {
  font-size: 1.6rem;
  line-height: 1;
}
.freq-home-text {
  flex: 1;
}
.freq-home-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.freq-home-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}
#freq-home-info {
  position: static;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 150, 50, 0.08);
  border: 1px solid rgba(255, 150, 50, 0.25);
  color: rgba(255, 150, 50, 0.7);
  font-size: 0.7rem;
  font-style: italic;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#freq-home-info:hover {
  background: rgba(255, 150, 50, 0.15);
}
.freq-home-arrow {
  font-size: 1.4rem;
  color: var(--text-dim);
  font-weight: 300;
}

/* Frequency screen */
#frequencies {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top, 12px) 20px env(safe-area-inset-bottom, 12px);
}

#freq-content {
  padding: 0 0 100px;
}

.freq-palette-section {
  margin-bottom: 16px;
}

.freq-selection-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

/* Band */
.freq-band {
  margin-bottom: 16px;
}
.freq-band-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 6px;
}
.freq-band-icon {
  font-size: 1rem;
}
.freq-band-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--band-color);
}
.freq-band-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.freq-band-range {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.7;
}

/* Frequency items */
.freq-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.freq-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  position: relative;
}
.freq-item:hover {
  background: var(--surface-hover);
}
.freq-item.selected {
  border-color: var(--band-color);
  background: rgba(255, 255, 255, 0.06);
}
.freq-item-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--band-color);
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}
.freq-item.selected .freq-item-check {
  border-color: var(--band-color);
  background: rgba(255, 255, 255, 0.05);
}
.freq-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.freq-item-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.freq-item-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}
.freq-item-sweep {
  border-style: dashed;
}
.freq-item-info {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 150, 50, 0.08);
  border: 1px solid rgba(255, 150, 50, 0.25);
  color: rgba(255, 150, 50, 0.7);
  font-size: 0.7rem;
  font-style: italic;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.freq-item-info:hover {
  background: rgba(255, 150, 50, 0.15);
}

/* Config */
.freq-config {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.freq-start-btn {
  margin-top: 16px;
}
.freq-start-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Epilepsy modal */
.epilepsy-modal-content {
  text-align: center;
}
.epilepsy-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}
.epilepsy-modal-content p {
  text-align: left;
  line-height: 1.6;
}

/* Epilepsy banner on freq screen */
.freq-epilepsy-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: rgba(231, 76, 60, 0.08);
  border: 1px solid rgba(231, 76, 60, 0.25);
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}
.freq-epilepsy-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Refresh rate warning */
.freq-refresh-warning {
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(241, 196, 15, 0.08);
  border: 1px solid rgba(241, 196, 15, 0.25);
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.7);
}
