:root {
  --bg: #11110f;
  --panel: #181713;
  --panel-2: #141410;
  --line: rgba(230, 216, 191, .15);
  --line-strong: rgba(230, 216, 191, .28);
  --text: #f1eadf;
  --muted: #9d968a;
  --accent: #d9b978;
  --accent-soft: rgba(217, 185, 120, .09);
  --accent-2: #a9b5a8;
  --radius: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: block;
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  background: var(--bg);
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 100% 0, rgba(217, 185, 120, .08), transparent 34rem),
    radial-gradient(circle at 0 38%, rgba(169, 181, 168, .045), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

html.fits-screen,
html.fits-screen body { overflow-y: hidden; }

button, select, input { font: inherit; }
button { cursor: pointer; }

button,
.player-menu-button {
  transition: transform .16s ease, border-color .16s ease, background .16s ease,
    color .16s ease, box-shadow .16s ease;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

button:active { transform: translateY(1px); }

.app {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 12px 0 100px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 23, 19, .88);
  box-shadow: 0 22px 64px rgba(0, 0, 0, .16), inset 0 1px rgba(255, 255, 255, .018);
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
}

.control {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 10, 8, .16);
  transition: border-color .16s ease, background .16s ease;
}

.control:focus-within {
  border-color: rgba(217, 185, 120, .42);
  background: rgba(217, 185, 120, .045);
}

.control.full { min-width: 0; }

.practice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
}

.control-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
}

.control select {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-weight: 650;
}

.bpm-control,
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bpm-control button,
.stepper button {
  display: inline-grid;
  flex: 0 0 38px;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  line-height: 1;
}

.bpm-control button:hover,
.stepper button:hover,
.ghost:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .16);
}

.bpm-control button:active,
.stepper button:active,
.settings-reset:active,
.player-menu-button:active {
  transform: translateY(1px) scale(.96);
}

.bpm-value {
  font-size: 24px;
  font-weight: 750;
  white-space: nowrap;
}

.bpm-value small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stepper-value {
  font-size: 20px;
  font-weight: 750;
  white-space: nowrap;
}

.stepper-value strong { color: var(--accent); }

.settings-reset {
  display: inline-grid;
  place-items: center;
  align-self: stretch;
  width: 50px;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  line-height: 1;
}

.settings-reset:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .16);
}

.stepper-value small,
.timer-value small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stage {
  margin-top: 12px;
  padding: 18px;
}

.stage-top {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 14px;
}

.box {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(12, 12, 10, .18);
}

.kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .11em;
}

.current-bar strong { color: var(--text); }

.current-bar {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .04em;
}

.chord-focus {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.chord-guide {
  min-width: 0;
  text-align: center;
}

.chord-diagram-card {
  width: 100%;
  max-width: 154px;
  min-width: 0;
  margin: 0 auto;
  padding: 9px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(8, 8, 7, .2);
  text-align: center;
}

.chord-diagram-card.current {
  border-color: rgba(217, 185, 120, .34);
  background: var(--accent-soft);
}

.chord-diagram-card.upcoming {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, .012);
}

.diagram-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.diagram-label strong {
  display: block;
  margin-top: 1px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
}

.chord-diagram-card.upcoming .diagram-label strong,
.chord-diagram-card.upcoming .chord-fingering { color: var(--accent); }

.chord-diagram {
  display: block;
  width: 100%;
  height: 106px;
  margin: 3px auto 0;
}

.chord-fingering {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.diagram-legend {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
}

.chord-meta {
  display: grid;
  gap: 6px;
  justify-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.chord-diagram .fret-line,
.chord-diagram .string-line {
  stroke: #77756d;
  stroke-linecap: round;
}

.chord-diagram .fret-line { stroke-width: 1; }
.chord-diagram .string-line { stroke-width: .85; }
.chord-diagram .nut-line { stroke: var(--text); stroke-width: 2.4; }
.chord-diagram .finger-dot { fill: var(--accent); }
.chord-diagram .barre { fill: var(--accent); }
.chord-diagram .finger-number {
  fill: #19150d;
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
}

.chord-diagram .open-mark,
.chord-diagram .mute-mark,
.chord-diagram .position-mark {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
}

.chord-diagram .position-mark {
  text-anchor: start;
  font-size: 10px;
}

.beat-panel { display: grid; align-content: center; }

.beat-grid,
.beatline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.beat-cell {
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  text-align: center;
  transition: transform .08s, background .08s, border-color .08s;
}

.beat-cell .beat-num {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.beat-cell .beat-val {
  min-height: 1.2em;
  font-size: 22px;
  font-weight: 720;
  line-height: 1.15;
}

.beat-cell.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(217, 185, 120, .06);
}

.beat-cell.active .beat-val { color: var(--accent); }

.beatline { margin-top: 10px; }

.beat {
  height: 3px;
  border-radius: 999px;
  background: rgba(230, 216, 191, .12);
  transition: background .08s, box-shadow .08s;
}

.beat.on {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(217, 185, 120, .22);
}

.player {
  position: relative;
  display: grid;
  grid-template-columns: fit-content(360px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 10, 8, .22);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .1);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.player.is-running {
  border-color: rgba(217, 185, 120, .42);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .16), 0 0 0 1px rgba(217, 185, 120, .04);
}

.player.is-done { border-color: rgba(169, 181, 168, .45); }

.player-song {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: fit-content;
  max-width: min(44vw, 360px);
}

.player-song strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-mark {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: var(--accent);
  opacity: .9;
}

.player-menu {
  position: relative;
  flex: 0 0 52px;
  width: 52px;
  height: 48px;
}

.player-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: transparent;
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  pointer-events: none;
}

.player-menu-select {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.player-menu:hover .player-menu-button,
.player-menu:focus-within .player-menu-button {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .16);
}

.player-time {
  display: grid;
  gap: 6px;
  align-content: center;
  min-width: 0;
  width: 100%;
  justify-items: center;
}

.player-time strong {
  color: var(--accent);
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  line-height: 1;
}

.player-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(230, 216, 191, .13);
}

.player-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b99150, var(--accent));
  box-shadow: 0 0 10px rgba(217, 185, 120, .25);
  transition: width .2s linear;
}

.player-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.player button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-height: 48px;
  padding: 0;
}

.player-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.player-reset:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.player-reset:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.primary,
.ghost {
  padding: 13px 16px;
  border-radius: 13px;
  font-weight: 700;
}

.primary {
  border: 1px solid rgba(217, 185, 120, .58);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 7px 18px rgba(217, 185, 120, .08);
}

.primary:hover {
  background: rgba(217, 185, 120, .16);
  box-shadow: 0 8px 22px rgba(217, 185, 120, .14);
  transform: translateY(-1px);
}

.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 24px, 920px);
    padding: 16px 0 calc(112px + env(safe-area-inset-bottom));
  }
  .player {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
    z-index: 20;
    grid-template-columns: fit-content(55%) minmax(0, 1fr);
    grid-template-areas:
      "song time"
      "actions actions";
    row-gap: 8px;
    margin-top: 0;
    border-color: rgba(217, 185, 120, .35);
    background: rgba(31, 28, 21, .94);
    box-shadow: 0 12px 34px rgba(0, 0, 0, .3);
    backdrop-filter: blur(16px);
  }
  .player-song {
    grid-area: song;
    width: fit-content;
    max-width: 100%;
  }
  .player-time { grid-area: time; }
  .player-actions { grid-area: actions; }
  .player-time { gap: 5px; }
  .player-time strong { font-size: 22px; }
  .practice-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-reset {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 42px;
  }
  .controls .full { grid-column: auto; }
  .stage-top { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .stage { padding: 12px; }
  .box { padding: 14px; }
  .chord-focus { gap: 10px; }
  .chord-diagram-card { max-width: 132px; padding-inline: 6px; }
  .chord-diagram { height: 98px; }
  .diagram-legend { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}
