:root {
    color-scheme: light;
}

body {
    font-family: system-ui, sans-serif;
    margin: 0 auto;
    max-width: 1100px;
    padding: 24px;
    color: #1a1a1a;
    background: #fafafa;
}

h1 {
    margin-bottom: 4px;
}

a {
    color: #1a1a1a;
}

.subtitle {
    color: #666;
    margin-top: 0;
}

h2 {
    border-bottom: 2px solid #ddd;
    padding-bottom: 4px;
    margin-top: 32px;
}

.category-desc {
    color: #666;
    max-width: 720px;
    margin: 8px 0 16px;
}

.chord-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 16px;
}

.chord-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.chord-card h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.chord-diagram {
    width: 100%;
    height: auto;
}

.loop-section {
    margin-top: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #ddd;
}

.loop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.loop-header h2 {
    border-bottom: none;
    margin: 0;
    padding-bottom: 0;
}

.shuffle-btn {
    display: inline-block;
    padding: 6px 14px;
    background: #222;
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
}

.shuffle-btn:hover {
    background: #444;
}

.loop-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.loop-row .chord-card {
    width: 110px;
}

.loop-arrow {
    font-size: 20px;
    color: #999;
}

/* ---------- Site navigation ---------- */

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: -8px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.site-nav a {
    color: #444;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 15px;
}

.site-nav a:hover {
    background: #eee;
}

.site-nav a.active {
    background: #222;
    color: #fff;
}

.site-nav .brand {
    font-weight: 700;
    color: #1a1a1a;
    margin-right: auto;
    padding-left: 0;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.site-nav .brand:hover {
    background: none;
}

.subtitle a {
    color: inherit;
}

/* ---------- Tuner ---------- */

.tuner {
    max-width: 640px;
}

.tuner-display {
    --accent: #222;
    --zone: rgba(46, 140, 72, 0.14);
    --muted: #bbb;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 24px 24px 16px;
    text-align: center;
    transition: border-color 0.15s;
}

.tuner-display[data-state="idle"],
.tuner-display[data-state="listening"] {
    --accent: #999;
}

.tuner-display[data-state="off"] {
    --accent: #c0392b;
}

.tuner-display[data-state="in-tune"] {
    --accent: #2e8c48;
    border-color: #2e8c48;
}

.tuner-note {
    font-size: 88px;
    line-height: 1;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    transition: color 0.15s;
}

.tuner-note sup {
    font-size: 28px;
    font-weight: 400;
    color: #999;
    margin-left: 2px;
}

.tuner-freq {
    color: #666;
    font-size: 14px;
    margin-top: 6px;
    min-height: 18px;
    font-variant-numeric: tabular-nums;
}

.cents-meter {
    position: relative;
    height: 44px;
    margin: 20px 0 4px;
    border-bottom: 2px solid #ddd;
}

.cents-zone {
    position: absolute;
    left: 45%;
    width: 10%;
    top: 0;
    bottom: 0;
    background: var(--zone);
    border-radius: 4px 4px 0 0;
}

.cents-ticks {
    position: absolute;
    inset: auto 0 4px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
}

.cents-needle {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: -2px;
    width: 4px;
    margin-left: -2px;
    border-radius: 2px;
    background: var(--accent);
    transition: left 0.08s ease-out, background 0.15s;
}

.tuner-status {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    margin: 8px 0 12px;
    min-height: 20px;
}

.tuner-graph {
    display: block;
    width: 100%;
    height: 60px;
}

.level {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 260px;
    margin: 12px auto 0;
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.level-track {
    flex: 1;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.level-bar {
    width: 0;
    height: 100%;
    background: #222;
    transition: width 0.05s;
}

.tuner-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin: 20px 0 16px;
}

.tuner-start {
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    padding: 9px 20px;
}

.tuner-start.listening {
    background: #2e8c48;
}

.tuner-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #444;
}

.tuner-field span {
    color: #666;
}

.tuner-field select,
.tuner-field input {
    font: inherit;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
}

.tuner-field input {
    width: 64px;
}

.tuner-strings {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.string-chip {
    flex: 1 1 84px;
    display: flex;
    align-items: stretch;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.string-chip button {
    font: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}

.string-chip button:hover {
    background: #f2f2f2;
}

.string-chip.auto {
    flex: 0 0 auto;
    align-items: center;
    padding: 0 14px;
    font-size: 14px;
    color: #444;
}

.string-pick {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
}

.string-name {
    font-size: 20px;
    font-weight: 700;
}

.string-name sub {
    font-size: 11px;
    font-weight: 400;
    color: #999;
}

.string-hz {
    font-size: 11px;
    color: #999;
    font-variant-numeric: tabular-nums;
}

.string-play {
    padding: 0 8px;
    border-left: 1px solid #eee !important;
    font-size: 12px;
    color: #666 !important;
}

.string-chip.selected {
    border-color: #222;
    box-shadow: inset 0 0 0 1px #222;
}

.string-chip.target {
    border-color: #c0392b;
}

.string-chip.in-tune {
    border-color: #2e8c48;
    box-shadow: inset 0 0 0 1px #2e8c48;
}

.tuner-hint,
.tuner-privacy {
    color: #888;
    font-size: 13px;
}

.tuner-privacy {
    margin-top: 32px;
}

@media (max-width: 480px) {
    body {
        padding: 16px;
    }

    .tuner-note {
        font-size: 68px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cents-needle,
    .tuner-note,
    .level-bar {
        transition: none;
    }
}

/* ---------- Playable chord cards ---------- */

.chord-card[data-frets] {
    position: relative;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.chord-card[data-frets]:hover {
    border-color: #bbb;
}

.chord-card[data-frets]:focus-visible {
    outline: 2px solid #222;
    outline-offset: 2px;
}

.chord-play {
    position: absolute;
    top: 8px;
    right: 9px;
    font-size: 10px;
    color: #bbb;
    transition: color 0.15s;
}

.chord-card:hover .chord-play {
    color: #222;
}

.chord-label {
    position: absolute;
    top: 8px;
    left: 9px;
    font-size: 12px;
    color: #888;
    font-family: Georgia, serif;
}

.chord-card.strummed {
    animation: strum-flash 0.35s ease-out;
}

@keyframes strum-flash {
    from { box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.25); transform: scale(1.03); }
    to { box-shadow: 0 0 0 0 rgba(34, 34, 34, 0); transform: none; }
}

/* ---------- Practice player ---------- */

.loop-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

button.shuffle-btn {
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
}

button.shuffle-btn:disabled {
    background: #bbb;
    cursor: default;
}

.shuffle-btn.secondary {
    background: #fff;
    color: #222;
    box-shadow: inset 0 0 0 1px #ccc;
}

.shuffle-btn.secondary:hover {
    background: #f0f0f0;
}

.shuffle-btn.playing {
    background: #2e8c48;
}

.practice-controls,
.pair-form,
.trainer-buttons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-top: 14px;
}

.control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #444;
}

.control > span {
    color: #666;
}

.control select,
.control input[type="number"] {
    font: inherit;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
}

.control input[type="number"] {
    width: 84px;
}

.control input[type="range"] {
    width: 140px;
    accent-color: #222;
}

.control output {
    min-width: 2.2em;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.beat-dots {
    display: flex;
    gap: 6px;
}

.beat-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
}

.beat-dots span:first-child {
    width: 12px;
    height: 12px;
}

.beat-dots span.on {
    background: #222;
}

.practice-hint {
    color: #888;
    font-size: 13px;
    margin: 8px 0 0;
}

kbd {
    font-family: inherit;
    font-size: 12px;
    padding: 1px 6px;
    border: 1px solid #ccc;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #fff;
}

.loop-key {
    margin: 16px 0 0;
    color: #555;
    font-size: 14px;
}

.loop-key a {
    color: inherit;
}

.loop-row .chord-card.current {
    border-color: #222;
    box-shadow: 0 0 0 2px #222;
}

.loop-row .chord-card.next {
    border-style: dashed;
    border-color: #222;
}

/* ---------- Chord-change trainer ---------- */

.pair-swap {
    color: #999;
    font-size: 18px;
}

.pair-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: 13px;
    color: #666;
}

.chip {
    padding: 3px 10px;
    border: 1px solid #ddd;
    border-radius: 999px;
    color: #333;
    text-decoration: none;
    background: #fff;
}

.chip:hover {
    border-color: #999;
}

.chip.active {
    background: #222;
    border-color: #222;
    color: #fff;
}

.trainer {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 24px;
}

.trainer-pair {
    display: flex;
    align-items: center;
    gap: 12px;
}

.trainer-pair .chord-card {
    width: 150px;
}

.trainer-panel {
    flex: 1 1 320px;
}

.trainer-clock {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px 20px;
    text-align: center;
    user-select: none;
    touch-action: manipulation;
}

.trainer-clock[data-state="running"] {
    cursor: pointer;
    border-color: #222;
}

.trainer-clock.tapped {
    animation: strum-flash 0.25s ease-out;
}

.trainer-time {
    font-size: 64px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.trainer-clock[data-state="count-in"] .trainer-time {
    color: #c0392b;
}

.trainer-progress {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0;
}

.trainer-progress div {
    height: 100%;
    width: 0;
    background: #222;
}

.trainer-count {
    color: #666;
    font-size: 14px;
}

.trainer-count span {
    font-weight: 700;
    color: #222;
    font-variant-numeric: tabular-nums;
}

.trainer-result {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #222;
    border-radius: 8px;
}

.trainer-result[hidden],
.trainer-history[hidden],
.trainer-pairs[hidden] {
    display: none;
}

.chart {
    position: relative;
    max-width: 720px;
}

.chart svg {
    display: block;
    width: 100%;
    height: auto;
}

.chart .grid,
.chart .axis {
    stroke: #e6e6e6;
    stroke-width: 1;
}

.chart .axis {
    stroke: #ccc;
}

.chart .tick {
    font-size: 11px;
    fill: #888;
}

.chart .value {
    font-size: 12px;
    font-weight: 600;
    fill: #222;
}

.chart .bar {
    fill: #3a3a3a;
}

.chart .hit {
    fill: transparent;
    cursor: default;
    outline: none;
}

.chart .hit:hover,
.chart .hit:focus {
    fill: rgba(0, 0, 0, 0.04);
}

.chart-tooltip {
    position: absolute;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
}

.chart-tooltip strong {
    font-size: 14px;
}

.chart-tooltip[hidden] {
    display: none;
}

.trainer-history table,
.trainer-pairs table {
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

.trainer-history th,
.trainer-history td,
.trainer-pairs th,
.trainer-pairs td {
    text-align: left;
    padding: 6px 16px 6px 0;
    border-bottom: 1px solid #eee;
}

.trainer-history th,
.trainer-pairs th {
    color: #666;
    font-weight: 600;
}

.trainer-pairs tr.current td {
    font-weight: 700;
}

.history-table {
    margin-top: 12px;
}

.history-table summary {
    cursor: pointer;
    color: #555;
    font-size: 14px;
}

/* ---------- Scales ---------- */

.scale-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 2px solid #ddd;
    margin-top: 28px;
}

.scale-head h2 {
    border: none;
    margin: 0;
    padding-bottom: 4px;
}

.segmented {
    display: inline-flex;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
}

.segmented button {
    font: inherit;
    font-size: 13px;
    border: none;
    background: #fff;
    padding: 6px 12px;
    cursor: pointer;
    color: #444;
}

.segmented button.active {
    background: #222;
    color: #fff;
}

.scale-notes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.scale-notes span {
    padding: 3px 10px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #ddd;
    font-weight: 600;
}

.scale-notes span.root {
    background: #c0392b;
    border-color: #c0392b;
    color: #fff;
}

.fretboard-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 8px 4px;
}

.fretboard {
    display: block;
    min-width: 860px;
    width: 100%;
    height: auto;
}

.fb-inlay {
    fill: #eee;
}

.fb-nut {
    fill: #222;
}

.fb-fret {
    stroke: #bbb;
    stroke-width: 2;
}

.fb-string {
    stroke: #999;
}

.fb-fretnum {
    font-size: 11px;
    fill: #999;
    text-anchor: middle;
}

.fb-note {
    cursor: pointer;
}

.fb-note circle {
    fill: #222;
    stroke: #fff;
    stroke-width: 2;
    transition: transform 0.1s;
}

.fb-note.root circle {
    fill: #c0392b;
}

.fb-note text {
    font-size: 10px;
    font-weight: 700;
    fill: #fff;
    text-anchor: middle;
    pointer-events: none;
}

.fb-note .fb-degree,
.show-degrees .fb-note .fb-name {
    display: none;
}

.show-degrees .fb-note .fb-degree {
    display: inline;
}

.fb-note:hover circle {
    transform: scale(1.2);
}

.fb-note.played circle {
    animation: note-flash 0.5s ease-out;
}

@keyframes note-flash {
    from { fill: #2e8c48; transform: scale(1.35); }
}

@media (max-width: 560px) {
    .site-nav {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .site-nav .brand {
        flex-basis: 100%;
    }

    .site-nav a {
        padding: 6px 10px;
    }

    .loop-row {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .loop-row .chord-card {
        width: auto;
    }

    .loop-row .loop-arrow {
        display: none;
    }
}

@media (max-width: 480px) {
    .trainer-pair .chord-card {
        width: 120px;
    }

    .trainer-time {
        font-size: 52px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chord-card.strummed,
    .trainer-clock.tapped,
    .fb-note.played circle {
        animation: none;
    }
}

/* ---------- Tuning / loop style switches ---------- */

.switch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 28px;
    margin: 16px 0 6px;
}

.switch-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch-label {
    font-size: 14px;
    color: #666;
    min-width: 3.4em;
}

.segmented a {
    font-size: 14px;
    background: #fff;
    padding: 8px 14px;
    color: #444;
    text-decoration: none;
    white-space: nowrap;
}

.segmented a + a {
    border-left: 1px solid #ccc;
}

.segmented a:hover {
    background: #f0f0f0;
}

.segmented a.active {
    background: #222;
    color: #fff;
}

.loop-key {
    line-height: 1.5;
}

.loop-tip {
    color: #777;
    font-size: 13px;
    line-height: 1.5;
    margin: 6px 0 0;
}
