:root {
  --bg-deep: #120c0a;
  --bg: #1a1210;
  --surface: #251c18;
  --surface-2: #2f2420;
  --text: #f4ebe4;
  --muted: #a89488;
  --gold: #d4a574;
  --gold-bright: #e8c49a;
  --burgundy: #6b2d3c;
  --wood: #5c3d2e;
  --wood-light: #8b6a52;
  --sharp: #e8a598;
  --flat: #9fd4c1;
  --center: #f0d78c;
  --glow: rgba(212, 165, 116, 0.35);
  font-family: "DM Sans", system-ui, sans-serif;
  font-optical-sizing: auto;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  line-height: 1.55;
  background: var(--bg-deep);
  position: relative;
  overflow-x: hidden;
}

.bg-noise {
  position: fixed;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.bg-fhole {
  position: fixed;
  width: min(42vw, 220px);
  height: min(70vh, 520px);
  border-radius: 50% 50% 48% 52% / 42% 44% 56% 58%;
  border: 2px solid rgba(212, 165, 116, 0.12);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 0;
}

.bg-fhole::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: inherit;
  border: 1px solid rgba(212, 165, 116, 0.08);
}

.bg-fhole--left {
  left: -8%;
  top: 10%;
  transform: rotate(-6deg);
}

.bg-fhole--right {
  right: -10%;
  bottom: 5%;
  transform: rotate(8deg);
  opacity: 0.65;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3.5rem;
}

.header {
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.clef {
  flex-shrink: 0;
  color: var(--gold);
  opacity: 0.9;
  filter: drop-shadow(0 4px 12px var(--glow));
}

.clef--hero {
  width: 36px;
  height: 90px;
}

.clef--inline {
  width: 28px;
  height: 72px;
  float: left;
  margin: 0 0.75rem 0.25rem 0;
  shape-outside: margin-box;
}

.kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--gold);
  margin: 0 0 0.15rem;
  font-weight: 500;
}

.header h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text) 0%, var(--gold-bright) 55%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 1.75rem 0 1.25rem;
  padding: 0.35rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 0.75rem;
  border: 1px solid rgba(212, 165, 116, 0.12);
}

.mode-tab {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 0.5rem;
  padding: 0.65rem 0.5rem;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab[aria-selected="true"] {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 165, 116, 0.2);
}

.mode-tab__icon {
  font-size: 1rem;
  opacity: 0.85;
}

.panel.hidden {
  display: none !important;
}

.controls {
  margin: 1rem 0 1.25rem;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 0.55rem;
  padding: 0.7rem 1.35rem;
  transition: transform 0.12s ease, box-shadow 0.2s, filter 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(165deg, #8b5a4a, #5c3528);
  color: #fdf6f0;
  box-shadow: 0 6px 24px rgba(92, 53, 40, 0.45);
  border: 1px solid rgba(212, 165, 116, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary[aria-pressed="true"] {
  background: linear-gradient(165deg, #6b3d4d, #4a2630);
  box-shadow: 0 6px 24px rgba(80, 40, 50, 0.5);
}

.btn-gold {
  background: linear-gradient(165deg, #c99862, #9a6b3d);
  color: #1a100c;
  font-weight: 600;
  box-shadow: 0 6px 28px var(--glow);
  border: 1px solid rgba(255, 230, 200, 0.35);
}

.btn-gold:hover {
  filter: brightness(1.06);
}

.btn-gold:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn-ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(212, 165, 116, 0.35);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(212, 165, 116, 0.08);
}

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

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.display {
  background: linear-gradient(165deg, var(--surface), var(--bg));
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid rgba(212, 165, 116, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.readout-muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.note-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.note-name {
  font-family: "Cormorant Garamond", serif;
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--gold-bright);
}

.freq {
  font-size: 0.88rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meter-wrap {
  margin-bottom: 1rem;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  padding: 0 0.25rem;
}

.meter {
  position: relative;
  height: 1.35rem;
  border-radius: 0.4rem;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0%;
  background: linear-gradient(90deg, var(--flat), var(--center), var(--sharp));
  opacity: 0.88;
  transition: left 0.06s linear, width 0.06s linear;
}

.meter-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.cents-line {
  text-align: center;
}

#cents-text {
  font-size: 1.28rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.cents-detail {
  display: block;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.session-intro {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  overflow: auto;
}

.session-intro strong {
  color: var(--gold-bright);
  font-weight: 600;
}

.duration-row {
  margin-bottom: 1rem;
}

.duration-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.duration-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  font: inherit;
  cursor: pointer;
  border-radius: 2rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border: 1px solid rgba(212, 165, 116, 0.22);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(212, 165, 116, 0.4);
}

.chip--active {
  background: rgba(212, 165, 116, 0.15);
  color: var(--gold-bright);
  border-color: rgba(212, 165, 116, 0.45);
}

.session-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.session-hint {
  min-height: 2.75rem;
}

.session-live {
  margin-top: 1.25rem;
  padding: 1.1rem;
  border-radius: 0.85rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(212, 165, 116, 0.1);
}

.session-timer {
  font-family: "Cormorant Garamond", serif;
  font-size: 2.5rem;
  font-weight: 600;
  text-align: center;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
}

.session-detect {
  margin: 1rem 0 0.75rem;
  padding: 1rem 0.85rem;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(212, 165, 116, 0.12);
}

.session-detect__label {
  margin: 0 0 0.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.session-detect__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.session-note-name {
  font-family: "Cormorant Garamond", serif;
  font-size: 2.35rem;
  font-weight: 600;
  line-height: 1;
  color: var(--gold-bright);
}

.session-freq {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.session-meter-wrap {
  margin-bottom: 0.5rem;
}

.session-meter .meter-fill {
  transition: left 0.05s linear, width 0.05s linear;
}

.session-cents-line {
  margin-top: 0.35rem;
}

#session-cents-text {
  font-size: 1.1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.note-strip-wrap {
  margin: 0.75rem 0 0.5rem;
}

.note-strip-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.note-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-height: 1.75rem;
}

.note-strip__empty {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.note-chip {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  padding: 0.3rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(212, 165, 116, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.note-chip--good {
  border-color: rgba(159, 212, 193, 0.45);
  background: rgba(90, 140, 120, 0.2);
}

.note-chip--ok {
  border-color: rgba(240, 215, 140, 0.4);
  background: rgba(140, 120, 70, 0.2);
}

.note-chip--wide {
  border-color: rgba(232, 165, 152, 0.45);
  background: rgba(120, 70, 70, 0.22);
}

.session-stats-row {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  margin: 0.75rem 0;
  text-align: center;
}

.session-stat-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.session-stat-value {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.mini-meter {
  height: 6px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.mini-meter__fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--flat), var(--gold));
  transition: width 0.12s linear;
}

.results {
  position: relative;
  margin-top: 1.5rem;
  padding: 1.5rem 1.25rem;
  border-radius: 1rem;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid rgba(212, 165, 116, 0.18);
  overflow: hidden;
}

.results__glow {
  position: absolute;
  top: -40%;
  left: 50%;
  width: 120%;
  height: 80%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, var(--glow), transparent 65%);
  pointer-events: none;
  opacity: 0.7;
}

.score-block,
.rank-card,
.encouragement,
.personal-best {
  position: relative;
  z-index: 1;
}

.score-label {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.score-value {
  font-family: "Cormorant Garamond", serif;
  font-size: 3.75rem;
  font-weight: 700;
  margin: 0.15rem 0;
  line-height: 1;
  background: linear-gradient(180deg, #fff 20%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.score-sub {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.rank-card {
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(212, 165, 116, 0.12);
  margin-bottom: 0.85rem;
}

.rank-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0;
  color: var(--gold-bright);
}

.rank-tagline {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  font-style: italic;
}

.encouragement {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}

.personal-best {
  margin-top: 1rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  background: rgba(107, 45, 60, 0.35);
  border: 1px solid rgba(232, 165, 152, 0.25);
  color: var(--sharp);
  font-weight: 600;
  font-size: 0.88rem;
  text-align: center;
}

.pb-icon {
  margin-right: 0.35rem;
}

.progress-card {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: 0.85rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(212, 165, 116, 0.2);
}

.progress-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-card__title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.progress-card__badge {
  font-family: "Cormorant Garamond", serif;
  font-size: 1rem;
  color: var(--gold);
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
}

.progress-stats dt {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.progress-stats dd {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.footer {
  margin-top: 2.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

@media (min-width: 480px) {
  .app {
    max-width: 32rem;
  }
}
