:root {
  --bg: #17130f;
  --surface: #221c16;
  --surface-2: #2d251d;
  --border: #3d3228;
  --text: #f3ece3;
  --muted: #a8998a;
  --accent: #e8a33d;
  --accent-strong: #f5b955;
  --accent-ink: #1d1408;
  --danger: #e2604f;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  max-width: 760px;
  margin: 0 auto;
}
.logo {
  margin-right: auto;
  min-width: 0;
  font-weight: 700;
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang {
  display: flex;
  flex-shrink: 0;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.lang button {
  border: 0;
  border-radius: 999px;
  padding: 4px 9px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.lang button:hover { color: var(--text); }
.lang button.on { background: var(--accent); color: var(--accent-ink); }
.support-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.support-link:hover { color: var(--accent-strong); }

/* Футер */
.footer { display: grid; gap: 14px; margin-top: 8px; }
.donate {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.donate:hover { background: var(--surface); }
.donate b { display: block; }
.donate small { color: var(--muted); }
.heart { font-size: 28px; color: var(--accent); animation: beat 1.4s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .heart { animation: none; } }
.credits { text-align: center; color: var(--muted); font-size: 14px; }
.credits a { color: var(--text); }

.setup {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

/* Темп */
.tempo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.tempo-value { text-align: center; min-width: 110px; }
.tempo-value span { font-size: 56px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.tempo-value small { display: block; color: var(--muted); font-size: 13px; }

.round {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 26px;
  line-height: 1;
}
.round:active { background: var(--border); }
.round.small { width: 36px; height: 36px; font-size: 20px; }

input[type=range] {
  width: 100%;
  margin: 18px 0 12px;
  accent-color: var(--accent);
}

.ghost {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
.ghost.flash { border-color: var(--accent); color: var(--accent); }

/* Режим */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 16px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  color: var(--muted);
}
.segmented button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.hint { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.presets, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.presets { margin-bottom: 12px; }
.presets button {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}
.presets button:hover { color: var(--text); }

.groups { display: grid; gap: 14px; }
.group-title {
  border: 0;
  background: none;
  padding: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.group-title::before { content: '○ '; }
.group-title.on { color: var(--accent); }
.group-title.on::before { content: '● '; }
.group-title:hover { color: var(--text); }

.chip {
  min-width: 52px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
  color: var(--muted);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}
select, input[type=number], input:not([type]), textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
input[type=number] { width: 80px; }

.song-list { display: grid; gap: 8px; }
.song {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  width: 100%;
}
.song.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.song-body { flex: 1; min-width: 0; }
.song-title { font-weight: 600; }
.song-meta { color: var(--muted); font-size: 13px; }
.song-chords { color: var(--accent); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-del {
  border: 0; background: transparent; color: var(--muted);
  font-size: 20px; padding: 4px 8px;
}
.song-del:hover { color: var(--danger); }

.custom { margin-top: 14px; }
.custom summary { cursor: pointer; color: var(--accent); padding: 6px 0; }
.custom input:not([type]), .custom textarea { width: 100%; margin-top: 10px; display: block; }
.custom .ghost { margin-top: 12px; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; min-height: 0; }

.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.voice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin: -4px 0 4px 30px;
  color: var(--muted);
  font-size: 13px;
}
.link-btn {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.link-btn:disabled { color: var(--muted); opacity: .5; cursor: default; }

.start {
  position: sticky;
  bottom: 16px;
  padding: 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.start:hover { background: var(--accent-strong); }

/* Сцена */
.stage {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 12px 16px 20px;
  overflow: auto;
}
.stage[hidden] { display: none; }

.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}
.stage-title { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-tempo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-tempo span { min-width: 36px; text-align: center; }
.stop {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
}

.stage-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 24px;
  align-items: center;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
}

.current { text-align: center; }
.current-name {
  font-size: clamp(64px, 14vw, 140px);
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
}
.current-name.counting { color: var(--text); }
.current-visual { height: min(46vh, 420px); margin: 12px auto 8px; }
.current-visual .chord-svg, .current-visual .chord-photo { height: 100%; max-width: 100%; }
.chord-photo { object-fit: contain; border-radius: 12px; }

.change { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.92); opacity: .4; } to { transform: scale(1); opacity: 1; } }

.beats { display: flex; justify-content: center; gap: 12px; margin: 10px 0 14px; }
.beat {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background .08s, transform .08s;
}
.beat.on { background: var(--accent); border-color: var(--accent); transform: scale(1.25); }
.beat.done { background: var(--border); }

.progress {
  height: 6px;
  max-width: 420px;
  margin: 0 auto;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill { height: 100%; width: 0; background: var(--accent); }

.next {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  opacity: .85;
}
.next-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.next-name { font-size: 40px; font-weight: 800; margin: 4px 0; }
.next-visual { height: 180px; }
.next-visual .chord-svg, .next-visual .chord-photo { height: 100%; max-width: 100%; }

.stage-info { text-align: center; color: var(--muted); font-size: 14px; margin-top: 8px; }

/* Схема аккорда */
.chord-svg .nut { fill: var(--text); }
.chord-svg .fret { stroke: var(--muted); stroke-width: 1.5; }
.chord-svg .string { stroke: var(--text); opacity: .85; }
.chord-svg .dot { fill: var(--accent); }
.chord-svg .finger { fill: var(--accent-ink); font-size: 14px; font-weight: 700; }
.chord-svg .open { fill: none; stroke: var(--text); stroke-width: 2; }
.chord-svg .muted { stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.chord-svg .base-fret { fill: var(--muted); font-size: 16px; font-weight: 700; }
.chord-missing { color: var(--muted); padding: 40px 0; }

@media (max-width: 560px) {
  .logo { font-size: 17px; }
  .support-link span { display: none; }
  .support-link { font-size: 20px; }
}

@media (max-width: 700px) {
  .stage-main { grid-template-columns: 1fr; gap: 12px; align-content: start; }
  .current-visual { height: 38vh; }
  .next { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 14px; }
  .next-name { font-size: 28px; margin: 0; }
  .next-visual { height: 80px; margin-left: auto; }
  .stage-title { display: none; }
  .stage-bar { justify-content: space-between; }
}
