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

:root {
  --bg: #0e1b3e;
  --surface: #152045;
  --surface-2: #1c2d5e;
  --green: #22c55e;
  --green-light: #4ade80;
  --green-glow: rgba(34, 197, 94, 0.15);
  --orange: #f59e0b;
  --blue: #3b82f6;
  --text: #ffffff;
  --text-muted: #7a9ad4;
  --border: #2a3d6a;
  --radius: 14px;
  --radius-lg: 20px;
}

html, body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ---- Nav ---- */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}

.site-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.site-logo .accent { color: var(--green); }

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}
.nav-links a {
  color: var(--text-muted);
  font-size: 15px;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--text); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  letter-spacing: 0.2px;
}
.btn-green {
  background: var(--green);
  color: #000;
}
.btn-green:hover {
  background: var(--green-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(34, 197, 94, 0.35);
}
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ---- Hero ---- */
.hero {
  text-align: center;
  padding: 80px 24px 64px;
  max-width: 720px;
  margin: 0 auto;
}
.hero-tag {
  display: inline-block;
  background: var(--green-glow);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 24px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.hero h1 {
  font-size: clamp(38px, 8vw, 66px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -2px;
  margin-bottom: 22px;
}
.hero h1 .highlight { color: var(--green); }
.hero p {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 36px;
  line-height: 1.7;
}
.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Features ---- */
.features {
  max-width: 920px;
  margin: 0 auto 80px;
  padding: 0 24px;
}
.section-label {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: border-color 0.2s, transform 0.2s;
}
.feature-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
}
.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.feature-icon.green { background: var(--green-glow); }
.feature-icon.orange { background: rgba(245, 158, 11, 0.15); }
.feature-icon.blue { background: rgba(59, 130, 246, 0.15); }
.feature-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.feature-card p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.65;
}

/* ---- Try Section ---- */
.try-section {
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 64px;
}
.try-section h2 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 12px;
}
.try-section p {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 28px;
}

/* ---- Download ---- */
.download-section {
  text-align: center;
  padding: 0 24px 80px;
  max-width: 600px;
  margin: 0 auto;
}
.download-section h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 12px;
}
.download-section p {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 28px;
}
.app-badges {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.app-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  transition: border-color 0.15s;
  cursor: pointer;
}
.app-badge:hover { border-color: var(--green); }
.app-badge-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ---- Footer ---- */
footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===========================================
   PRACTICE PAGE
   =========================================== */

.practice-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* Header */
.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.score-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 18px;
  font-size: 17px;
  font-weight: 700;
}
.score-correct { color: var(--green); }
.score-sep { color: var(--text-muted); font-weight: 400; margin: 0 1px; }
.score-total { color: var(--text-muted); }

.streak-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--orange);
  min-width: 48px;
  justify-content: flex-end;
}

/* Staff area */
.staff-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 12px;
  gap: 16px;
  min-height: 0;
}

.staff-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 12px 16px 8px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

#staff-render {
  width: 100%;
  min-height: 210px;
  display: flex;
  align-items: center;
}
#staff-render svg {
  display: block;
  width: 100% !important;
  height: auto;
}

/* Feedback */
.feedback-area {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feedback {
  font-size: 15px;
  font-weight: 600;
  padding: 7px 20px;
  border-radius: 100px;
  transition: all 0.2s ease;
}
.feedback-correct {
  color: var(--green);
  background: var(--green-glow);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.feedback-wrong {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.feedback-hint {
  color: var(--orange);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Controls */
.practice-controls {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  max-width: 552px;
}
.hint-btn {
  background: var(--green);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 10px 26px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.hint-btn:hover { background: var(--green-light); }
.hint-btn:active { transform: scale(0.96); }

/* Piano section */
.piano-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 0 24px;
  flex-shrink: 0;
}

.piano-wrapper {
  overflow-x: auto;
  padding: 0 20px;
  scrollbar-width: none;
}
.piano-wrapper::-webkit-scrollbar { display: none; }

.piano-keys {
  position: relative;
  height: 158px;
  width: 100%;
  max-width: 640px;
  min-width: 560px;
  margin: 0 auto;
}

/* Keys */
.key {
  position: absolute;
  border: none;
  cursor: pointer;
  border-radius: 0 0 6px 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  transition: background 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.white-key {
  background: #f6f6f6;
  border: 1px solid #c0c0c0;
  border-top: none;
  z-index: 1;
}
.white-key:hover { background: #e6f7ec; }
.white-key:active { background: #c6ecd6; }
.white-key.correct { background: #a7f3d0 !important; border-color: #22c55e !important; }
.white-key.wrong   { background: #fecaca !important; border-color: #ef4444 !important; }
.white-key.reveal  { background: #fef08a !important; border-color: #f59e0b !important; }

.black-key {
  background: #1e1e2e;
  z-index: 2;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.black-key:hover { background: #2d2d42; }
.black-key:active { background: #111118; }
.black-key.correct { background: #059669 !important; }
.black-key.wrong   { background: #dc2626 !important; }
.black-key.reveal  { background: #d97706 !important; }

.key-label {
  font-size: 11px;
  font-weight: 700;
  color: #666;
  pointer-events: none;
  user-select: none;
}

/* Responsive */
@media (max-width: 540px) {
  .hero h1 { font-size: 38px; }
  .hero p { font-size: 16px; }
  .site-nav { padding: 14px 16px; }
  .nav-links { gap: 16px; }
}

@media (max-width: 380px) {
  .practice-header { padding: 10px 14px; }
  .score-pill { padding: 5px 12px; font-size: 15px; }
}

/* ===========================================
   SHARED: content pages (lessons, chart)
   =========================================== */

.back-link-nav {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  min-width: 80px;
  transition: color 0.15s;
}
.back-link-nav:hover { color: var(--text); }

.content-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.page-header {
  text-align: center;
  padding: 48px 0 36px;
}
.page-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 16px;
}

/* ===========================================
   LESSONS — list
   =========================================== */

.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
.lesson-card:hover { transform: translateX(4px); }
.lesson-card-green  { border-left: 3px solid var(--green);  }
.lesson-card-green:hover  { border-color: var(--green); }
.lesson-card-orange { border-left: 3px solid var(--orange); }
.lesson-card-orange:hover { border-color: var(--orange); }
.lesson-card-blue   { border-left: 3px solid var(--blue);   }
.lesson-card-blue:hover   { border-color: var(--blue); }
.lesson-card-disabled {
  opacity: 0.45;
  cursor: default;
}
.lesson-card-disabled:hover { transform: none; }

.lesson-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.lesson-icon-green  { background: var(--green-glow); }
.lesson-icon-orange { background: rgba(245,158,11,0.15); }
.lesson-icon-blue   { background: rgba(59,130,246,0.15); }
.lesson-icon-muted  { background: rgba(255,255,255,0.06); }

.lesson-card-body   { flex: 1; min-width: 0; }
.lesson-card-subtitle {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.lesson-card-title { font-size: 17px; font-weight: 700; }
.lesson-card-meta  { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.lesson-card-chevron { font-size: 24px; color: var(--text-muted); flex-shrink: 0; }

/* ===========================================
   LESSONS — viewer
   =========================================== */

.lesson-viewer {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

.lesson-viewer-title {
  font-size: 16px;
  font-weight: 700;
}
.step-indicator {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

.lesson-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.lesson-diagram-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 12px 16px 8px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.28);
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#lesson-diagram-render { width: 100%; }
#lesson-diagram-render svg { display: block; width: 100% !important; height: auto; }

.lesson-text {
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-muted);
}

.lesson-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lesson-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.lesson-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.lesson-dot.active {
  width: 22px;
  border-radius: 4px;
  background: var(--green);
}

.lesson-nav {
  display: flex;
  gap: 10px;
  width: 100%;
}
.lesson-nav-btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: all 0.15s;
}
.lesson-nav-btn:disabled { opacity: 0.3; cursor: default; }
.lesson-nav-btn:not(:disabled):hover { border-color: var(--green); color: var(--green); }
.lesson-nav-btn-primary {
  background: var(--green);
  color: #000;
  border-color: var(--green);
}
.lesson-nav-btn-primary:not(:disabled):hover {
  background: var(--green-light);
  color: #000;
  border-color: var(--green-light);
}

/* ===========================================
   NOTE CHART
   =========================================== */

.chart-section { margin-bottom: 48px; }

.chart-section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 12px;
}

.chart-card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 8px 12px 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}
.chart-card svg { display: block; width: 100% !important; height: auto; }

/* ---- Web tools grid (home page try section) ---- */
.web-tools-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 540px;
  margin: 0 auto;
  width: 100%;
}

.web-tool-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
.web-tool-card:hover { transform: translateX(4px); }
.web-tool-green:hover  { border-color: var(--green); }
.web-tool-orange:hover { border-color: var(--orange); }
.web-tool-blue:hover   { border-color: var(--blue); }
.web-tool-green  { border-left: 3px solid var(--green); }
.web-tool-orange { border-left: 3px solid var(--orange); }
.web-tool-blue   { border-left: 3px solid var(--blue); }

.web-tool-icon {
  font-size: 26px;
  flex-shrink: 0;
}
.web-tool-body  { flex: 1; min-width: 0; }
.web-tool-title { font-size: 17px; font-weight: 700; }
.web-tool-desc  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.web-tool-arrow { font-size: 22px; color: var(--text-muted); }

/* ---- Chart main card ---- */
.chart-card-main {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 20px 20px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.32);
  overflow-x: auto;
}
.chart-card-main svg { display: block; width: 100% !important; height: auto; min-width: 360px; }

/* ---- Mnemonic grid ---- */
.mnemonic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.mnemonic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mnemonic-treble { border-top: 3px solid var(--green); }
.mnemonic-bass   { border-top: 3px solid var(--orange); }

.mnemonic-clef-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.mnemonic-clef-label-treble { color: var(--green); }
.mnemonic-clef-label-bass   { color: var(--orange); }

.mnemonic-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mnemonic-type-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.mnemonic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mnemonic-chips span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 800;
}
.mnemonic-chips-treble span {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(34,197,94,0.25);
}
.mnemonic-chips-bass span {
  background: rgba(245,158,11,0.12);
  color: var(--orange);
  border: 1px solid rgba(245,158,11,0.25);
}

.mnemonic-hint {
  font-size: 12px;
  font-style: italic;
  color: rgba(255,255,255,0.4);
  line-height: 1.4;
}

@media (max-width: 560px) {
  .mnemonic-grid { grid-template-columns: 1fr; }
}
