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

:root {
  --bg: #0d0e10;
  --bg2: #15171b;
  --bg3: #1c1f25;
  --bg4: #22262e;
  --accent: #c8a96e;
  --accent2: #e8c98e;
  --green: #5ec48a;
  --red: #e05c6e;
  --text: #f0ead8;
  --muted: #6a6050;
  --muted2: #8a7a60;
  --border: rgba(200,169,110,0.14);
  --border2: rgba(200,169,110,0.28);
  --sidebar-w: 260px;
  --radius: 10px;
}

body.white-theme {
  --bg: #f8f7f4;
  --bg2: #ffffff;
  --bg3: #efede8;
  --bg4: #e1ddd5;
  --accent: #5d5d5d;
  --accent2: #2e2e2e;
  --green: #2f7f53;
  --red: #9f2c3f;
  --text: #121314;
  --muted: #646464;
  --muted2: #8c8c8c;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.16);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  z-index: 90;
}
.sidebar-overlay.open { opacity: 1; pointer-events: all; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 0.5px solid var(--border);
  transform: translateX(calc(-1 * var(--sidebar-w)));
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  z-index: 100;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 0.5px solid var(--border);
}
.sidebar-head h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem; color: var(--accent2); font-weight: 700;
}
.sidebar-head p {
  font-size: 0.62rem; color: var(--muted2);
  letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px;
}

.nav-section { padding: 1rem 0.75rem 0.5rem; }
.nav-section-label {
  font-size: 0.58rem; color: var(--muted);
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0 0.5rem; margin-bottom: 0.4rem;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 0.58rem 0.75rem; border-radius: 8px;
  cursor: pointer; transition: all 0.15s;
  font-size: 0.78rem; color: var(--muted2);
  border: none; background: none; width: 100%; text-align: left;
  font-family: 'DM Mono', monospace;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: rgba(200,169,110,0.09);
  color: var(--accent2);
  border: 0.5px solid var(--border);
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-settings { padding: 0.75rem 1.25rem; border-top: 0.5px solid var(--border); }
.sb-label { font-size: 0.62rem; color: var(--muted2); letter-spacing: 0.08em; margin-bottom: 6px; }
.sb-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 1rem; }

.pill-btn {
  padding: 0.26rem 0.58rem;
  font-family: 'DM Mono', monospace; font-size: 0.65rem;
  border-radius: 99px; border: 0.5px solid var(--border);
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.pill-btn.active { background: rgba(200,169,110,0.14); border-color: var(--accent); color: var(--accent2); }

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem;
  border-top: 0.5px solid var(--border);
  font-size: 0.63rem; color: var(--muted);
  letter-spacing: 0.05em; line-height: 1.7;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
}
.hamburger {
  background: none; border: 0.5px solid var(--border);
  border-radius: 8px; padding: 0.42rem 0.52rem;
  cursor: pointer; color: var(--muted2);
  display: flex; flex-direction: column; gap: 4px;
  transition: all 0.15s;
}
.hamburger:hover { border-color: var(--accent); color: var(--accent); }
.hamburger span { display: block; width: 18px; height: 1.5px; background: currentColor; border-radius: 1px; }
.topbar-title { font-family: 'Playfair Display', serif; font-size: 1.05rem; color: var(--accent2); font-weight: 700; }
.topbar-mode { font-size: 0.63rem; color: var(--muted2); letter-spacing: 0.1em; text-transform: uppercase; margin-left: auto; }

/* Main */
.main { max-width: 700px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 1.1rem; }
.stat-card {
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 0.65rem 0.75rem; text-align: center;
}
.stat-label { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.stat-value { font-size: 1.5rem; font-weight: 500; color: var(--accent2); line-height: 1.2; margin-top: 2px; }

.streak-bar { display: flex; gap: 4px; margin-bottom: 1.1rem; justify-content: center; min-height: 8px; }
.streak-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg3); border: 0.5px solid var(--border); transition: all 0.3s;
}
.streak-dot.hit { background: var(--green); border-color: var(--green); }
.streak-dot.miss { background: var(--red); border-color: var(--red); }

/* Main panel */
.main-panel {
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: 16px; padding: 1.6rem; margin-bottom: 1rem;
}

.mode-tabs {
  display: flex; gap: 4px; background: var(--bg3);
  border-radius: 8px; padding: 4px; margin-bottom: 1.4rem;
}
.mode-tab {
  flex: 1; padding: 0.4rem;
  font-family: 'DM Mono', monospace; font-size: 0.67rem;
  letter-spacing: 0.07em; text-transform: uppercase;
  background: transparent; border: none; border-radius: 6px;
  color: var(--muted); cursor: pointer; transition: all 0.18s;
}
.mode-tab.active { background: var(--bg2); color: var(--accent2); border: 0.5px solid var(--border); }

.play-area { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 0.25rem 0; }

.answer-display {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem; color: var(--accent);
  min-height: 2.8rem; letter-spacing: 0.03em;
  text-align: center; transition: color 0.3s; line-height: 1.2;
}
.answer-display.revealed { color: var(--accent2); }

.notes-display {
  font-size: 0.72rem; color: var(--muted2);
  letter-spacing: 0.08em; min-height: 1rem; text-align: center;
}

.btn-play {
  display: flex; align-items: center; gap: 10px;
  padding: 0.68rem 1.6rem;
  background: var(--accent); color: var(--bg);
  border: none; border-radius: 8px;
  font-family: 'DM Mono', monospace; font-size: 0.77rem;
  font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; transition: all 0.18s;
}
.btn-play:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-play:active { transform: scale(0.98); }
.btn-play svg { width: 16px; height: 16px; }

.divider { width: 40px; height: 1px; background: var(--border); }

.answer-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; width: 100%; }
@media (max-width: 500px) { .answer-grid { grid-template-columns: repeat(3,1fr); } }

.answer-btn {
  padding: 0.52rem 0.2rem;
  background: var(--bg3); border: 0.5px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'DM Mono', monospace; font-size: 0.67rem;
  cursor: pointer; transition: all 0.15s; line-height: 1.3; text-align: center;
}
.answer-btn:hover:not(:disabled) { background: var(--bg4); border-color: var(--border2); color: var(--accent2); }
.answer-btn.correct { background: rgba(94,196,138,0.12); border-color: var(--green); color: var(--green); }
.answer-btn.wrong   { background: rgba(224,92,110,0.12);  border-color: var(--red);   color: var(--red); }
.answer-btn:disabled { cursor: default; }

.feedback-msg { font-size: 0.78rem; min-height: 1rem; text-align: center; letter-spacing: 0.04em; }
.feedback-msg.correct { color: var(--green); }
.feedback-msg.wrong   { color: var(--red); }
.scale-notes-tag {
  display: none;
  font-size: 0.63rem; color: var(--muted2);
  background: var(--bg3); border: 0.5px solid var(--border);
  border-radius: 4px; padding: 3px 8px; letter-spacing: 0.05em;
}

.next-btn {
  padding: 0.48rem 1.35rem;
  background: transparent; border: 0.5px solid var(--border);
  border-radius: 8px; color: var(--muted);
  font-family: 'DM Mono', monospace; font-size: 0.68rem;
  letter-spacing: 0.08em; cursor: pointer; transition: all 0.18s;
  text-transform: uppercase; display: none;
}
.next-btn.visible { display: block; color: var(--accent); border-color: var(--accent); }
.next-btn:hover { background: rgba(200,169,110,0.09); }

/* Settings panel */
.settings-panel {
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: 16px; padding: 1.35rem;
}
.settings-panel h3 {
  font-family: 'Playfair Display', serif;
  font-size: 0.92rem; color: var(--accent); margin-bottom: 0.9rem; font-weight: 400;
}
.toggle-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ivt {
  padding: 0.27rem 0.58rem;
  font-family: 'DM Mono', monospace; font-size: 0.64rem;
  border-radius: 6px; border: 0.5px solid var(--border);
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s;
}
.ivt.active { background: rgba(200,169,110,0.1); border-color: var(--accent); color: var(--accent); }

/* ── Page system ── */
.page { display: none; }
.page.active { display: block; }

/* ── Home page ── */
.home-hero {
  min-height: calc(100vh - 60px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem 1.5rem 4rem;
  text-align: center;
  position: relative;
}
.home-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, rgba(200,169,110,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.hero-eyebrow {
  font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1.2rem;
  border: 0.5px solid var(--border); border-radius: 99px;
  padding: 0.3rem 0.9rem; display: inline-block;
}
.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 700; line-height: 1.1;
  color: var(--text); margin-bottom: 0.4rem;
}
.hero-title em {
  font-style: italic; color: var(--accent);
}
.hero-sub {
  font-size: 0.8rem; color: var(--muted2); line-height: 1.8;
  max-width: 400px; margin: 1.2rem auto 2.4rem;
  letter-spacing: 0.03em;
}
.hero-cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0.78rem 2rem;
  background: var(--accent); color: var(--bg);
  border: none; border-radius: 10px;
  font-family: 'DM Mono', monospace; font-size: 0.8rem;
  font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: all 0.18s;
}
.hero-cta:hover { background: var(--accent2); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(200,169,110,0.2); }

.home-features {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 12px;
  max-width: 700px; margin: 3.5rem auto 0; padding: 0 1.25rem;
}
@media (max-width: 540px) { .home-features { grid-template-columns: 1fr; } }
.feature-card {
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: 14px; padding: 1.3rem 1.1rem;
  transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--border2); }
.feature-icon { font-size: 1.5rem; margin-bottom: 0.65rem; }
.feature-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.92rem; color: var(--accent2);
  margin-bottom: 0.45rem; font-weight: 700;
}
.feature-desc { font-size: 0.67rem; color: var(--muted2); line-height: 1.75; }

.home-exercises {
  max-width: 700px; margin: 2.5rem auto 0; padding: 0 1.25rem 4rem;
}
.section-label {
  font-size: 0.6rem; color: var(--muted); letter-spacing: 0.16em;
  text-transform: uppercase; margin-bottom: 0.9rem;
  padding-bottom: 0.5rem; border-bottom: 0.5px solid var(--border);
}
.exercise-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
@media (max-width: 500px) { .exercise-cards { grid-template-columns: 1fr; } }
.ex-card {
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: 12px; padding: 1.1rem;
  cursor: pointer; transition: all 0.18s; text-align: left;
  font-family: 'DM Mono', monospace;
}
.ex-card:hover { background: var(--bg3); border-color: var(--accent); transform: translateY(-2px); }
.ex-card-icon { font-size: 1.3rem; margin-bottom: 0.55rem; }
.ex-card-name { font-size: 0.82rem; color: var(--accent2); margin-bottom: 0.3rem; font-weight: 500; }
.ex-card-count { font-size: 0.62rem; color: var(--muted); }

/* ── About page ── */
.about-wrap {
  max-width: 640px; margin: 0 auto; padding: 2.5rem 1.25rem 5rem;
}
.about-hero-text {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  font-weight: 700; line-height: 1.2;
  color: var(--text); margin-bottom: 0.5rem;
}
.about-hero-text em { color: var(--accent); font-style: italic; }
.about-intro {
  font-size: 0.78rem; color: var(--muted2); line-height: 1.85;
  margin-bottom: 2.5rem; max-width: 520px;
}
.about-divider {
  height: 0.5px; background: var(--border); margin: 2rem 0;
}
.about-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem; color: var(--accent); font-weight: 400;
  margin-bottom: 0.9rem;
}
.about-body {
  font-size: 0.74rem; color: var(--muted2); line-height: 1.9;
  margin-bottom: 1.1rem;
}
.about-pillars {
  display: grid; grid-template-columns: repeat(2,1fr); gap: 10px;
  margin: 1.5rem 0;
}
@media (max-width: 480px) { .about-pillars { grid-template-columns: 1fr; } }
.pillar {
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: 12px; padding: 1.1rem;
}
.pillar-num {
  font-size: 0.6rem; color: var(--accent); letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}
.pillar-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.88rem; color: var(--text); margin-bottom: 0.35rem;
}
.pillar-text { font-size: 0.66rem; color: var(--muted2); line-height: 1.7; }

.about-quote {
  background: var(--bg2); border-left: 2px solid var(--accent);
  border-radius: 0 10px 10px 0; padding: 1.1rem 1.3rem;
  margin: 1.8rem 0;
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem; color: var(--text); line-height: 1.6; font-style: italic;
}
.about-quote cite {
  display: block; font-size: 0.6rem; color: var(--muted);
  letter-spacing: 0.1em; text-transform: uppercase; font-style: normal;
  margin-top: 0.6rem;
}

.about-start-btn {
  margin-top: 2rem;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 0.72rem 1.8rem;
  background: transparent; border: 0.5px solid var(--accent);
  border-radius: 10px; color: var(--accent);
  font-family: 'DM Mono', monospace; font-size: 0.75rem;
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; transition: all 0.18s;
}
.about-start-btn:hover { background: rgba(200,169,110,0.09); transform: translateY(-1px); }

/* ── Ad overlay ── */
.ad-container {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: adFadeIn 0.2s ease;
}
@keyframes adFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ad-content {
  position: relative;
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-radius: 18px;
  padding: 2.2rem 2.4rem 2rem;
  max-width: 340px; width: 90%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  animation: adSlideUp 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes adSlideUp {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ad-label {
  font-size: 0.52rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1.2rem;
  border: 0.5px solid var(--border);
  border-radius: 99px; padding: 0.22rem 0.7rem;
  display: inline-block;
}

.ad-icon {
  font-size: 2.2rem; margin-bottom: 0.7rem; line-height: 1;
}

.ad-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem; color: var(--accent2);
  font-weight: 700; margin-bottom: 0.5rem; line-height: 1.25;
}

.ad-body {
  font-size: 0.7rem; color: var(--muted2);
  line-height: 1.75; margin-bottom: 1.5rem;
}

.ad-timer-bar {
  height: 2px; background: var(--border);
  border-radius: 99px; overflow: hidden; margin-bottom: 1.1rem;
}
.ad-timer-fill {
  height: 100%; background: var(--accent);
  border-radius: 99px;
  animation: adTimer 3s linear forwards;
}
@keyframes adTimer {
  from { width: 100%; }
  to   { width: 0%; }
}

.ad-skip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.45rem 1.1rem;
  background: transparent; border: 0.5px solid var(--border);
  border-radius: 8px; color: var(--muted);
  font-family: 'DM Mono', monospace; font-size: 0.65rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; transition: all 0.18s;
}
.ad-skip:hover { border-color: var(--accent); color: var(--accent); }
.ad-skip.ready { border-color: var(--accent); color: var(--accent); background: rgba(200,169,110,0.07); }

.ad-close {
  position: absolute; top: 0.85rem; right: 1rem;
  font-size: 1.1rem; color: var(--muted);
  cursor: pointer; line-height: 1;
  transition: color 0.15s; background: none; border: none;
  font-family: inherit;
}
.ad-close:hover { color: var(--text); }

.ad-slot {
  margin: 0 auto 1rem;
  min-height: 100px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 0.5px solid var(--border);
  border-radius: 8px; overflow: hidden;
}