:root {
    --bg: #000000;
    --surface: #0f0f0f;
    --border: #2a241c;
    --border-strong: #3a3228;
    --text: #f0e4c8;
    --text-muted: #8a7e66;
    --accent: #d63a2a;
    --stripe-cyan: #5fd0d0;
    --stripe-green: #6ec744;
    --stripe-yellow: #edc12a;
    --stripe-orange: #e8772a;
    --stripe-red: #d63a2a;
    --beat-size: 3rem;
}

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

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    min-height: 100dvh;
}

/* Home page */
.home {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
    text-align: center;
}

.home h1 {
    font-size: 3rem;
    margin-bottom: 0.25rem;
}

.home p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.home h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.join-btn {
    margin-top: 1.5rem;
    margin-bottom: 2rem;
    font-size: 1.3rem;
    padding: 1rem 3rem;
}

.song-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.song-card-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.song-card-row .song-card {
    flex: 1;
}

.song-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s;
}

.song-card:hover, .song-card:focus {
    border-color: var(--accent);
}

.song-card.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.song-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.song-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.mode-picker {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--text);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
    transition: border-color 0.15s;
}

.mode-btn:hover, .mode-btn:focus {
    border-color: var(--accent);
}

.mode-btn.selected {
    border-color: var(--accent);
    background: rgba(214, 58, 42, 0.15);
}

/* Session page */
.session {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 1rem;
    gap: 2rem;
}

/* Metronome */
.metronome {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.session-bar {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.config-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.config-panel {
    background: var(--surface);
    border-top: 2px solid var(--border-strong);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80dvh;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.config-header h2 {
    font-size: 1.3rem;
}

.config-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.config-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.config-section a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.config-section a:hover {
    color: var(--text);
}

.config-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    cursor: pointer;
}

.config-toggle input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--accent);
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1rem;
}

.config-stepper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.beats {
    display: flex;
    gap: 1rem;
}

.beat {
    width: var(--beat-size);
    height: var(--beat-size);
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.beat.active {
    background: var(--stripe-green);
    transform: scale(1.2);
    box-shadow: 0 0 20px rgba(110, 199, 68, 0.6);
    border-color: var(--stripe-green);
}

.beat.downbeat {
    border-color: var(--border-strong);
}

.beat.downbeat.active {
    background: var(--stripe-orange);
    box-shadow: 0 0 30px rgba(232, 119, 42, 0.7);
    border-color: var(--stripe-orange);
}

.beat.active.count-in,
.beat.downbeat.active.count-in {
    background: var(--stripe-cyan);
    box-shadow: 0 0 30px rgba(95, 208, 208, 0.7);
    border-color: var(--stripe-cyan);
}

/* Chord display */
.chord-display {
    width: 100%;
    max-width: 600px;
    overflow: hidden;
    flex-shrink: 0;
    --line-height: 4.5rem;
    height: calc(var(--visible-lines, 3) * var(--line-height));
}

.chord-display.with-lyrics {
    --line-height: 8rem;
}

.chord-scroll {
    display: flex;
    flex-direction: column;
    transition: transform 1s ease;
}

.chord-group {
    border-radius: 8px;
    transition: background 0.15s;
    height: var(--line-height);
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}

.placeholder-chord {
    opacity: 0.15;
}

.chord-group.active-line {
    background: rgba(255, 255, 255, 0.05);
}

.chord-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    position: relative;
}

.chord-line::before {
    content: attr(data-measure);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.08;
    pointer-events: none;
}

.lyrics-line {
    display: flex;
    gap: 0.5rem;
    padding: 0 0.6rem 0.4rem;
    align-items: baseline;
}

.lyrics-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

.lyric-segment {
    color: var(--text-muted);
    opacity: 0.4;
    transition: opacity 0.4s ease, color 0.4s ease;
}

.lyric-segment::after {
    content: "\00a0";
}

.lyric-segment.active {
    opacity: 1;
    color: var(--text);
}

.chord-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    transition: background 0.4s ease;
}

.chord-cell.active {
    background: rgba(255, 255, 255, 0.08);
}

.chord-name {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.4s ease;
}

.chord-cell.active .chord-name {
    color: var(--text);
}

.chord-beats {
    display: flex;
    gap: 0.3rem;
}

.chord-beat-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.chord-beat-dot.lit {
    background: var(--stripe-green);
    box-shadow: 0 0 6px rgba(110, 199, 68, 0.5);
    transform: scale(1.3);
}

.chord-beat-dot.downbeat.lit {
    background: var(--stripe-orange);
    box-shadow: 0 0 6px rgba(232, 119, 42, 0.5);
    transform: scale(1.3);
}

.lines-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 1.5rem;
    text-align: center;
}

/* TV mode chord overrides */
.session.mode-tv .chord-display {
    max-width: none;
    --line-height: 9rem;
}

.session.mode-tv .chord-display.with-lyrics {
    --line-height: 13rem;
}

.session.mode-tv .chord-name {
    font-size: 5vw;
}

.session.mode-tv .chord-beat-dot {
    width: 1.2rem;
    height: 1.2rem;
}

.session.mode-tv .lyrics-text {
    font-size: 2.5vw;
}

/* Song controls */
.song-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 400px;
}

.song-selector select {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    min-width: 250px;
    min-height: 48px;
}

.song-info {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.transport {
    display: flex;
    gap: 0.75rem;
}

.btn {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover, .btn:focus {
    border-color: var(--accent);
}

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

.btn.play {
    background: rgba(214, 58, 42, 0.2);
    border-color: var(--accent);
}


/* Button icons */
.btn-icon {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 48px;
    height: 48px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: border-color 0.15s;
    flex-shrink: 0;
}

.btn-icon:hover, .btn-icon:focus {
    border-color: var(--accent);
}

.btn-icon.danger:hover, .btn-icon.danger:focus {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Song editor */
.editor {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.editor-header h1 {
    font-size: 1.8rem;
}

.editor-header a {
    color: var(--text-muted);
    text-decoration: none;
}

.editor-header a:hover {
    color: var(--text);
}

.editor-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.editor-form h2 {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.field-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.field-row .field {
    flex: 1;
    min-width: 80px;
}

.editor input[type="text"],
.editor input[type="number"] {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    min-height: 44px;
}

.editor input:focus {
    outline: none;
    border-color: var(--accent);
}

.editor input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--accent);
    vertical-align: middle;
    margin-right: 0.4rem;
}

.chord-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chord-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chord-name-input {
    flex: 1;
    min-width: 60px;
}

.chord-dur-input {
    width: 70px;
}

.chord-dur-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.chord-entry {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.lyrics-input {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-style: italic;
}

.lyrics-input:focus {
    outline: none;
    border-color: var(--accent);
}

.extend-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.editor-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn.danger {
    border-color: var(--accent);
    color: var(--accent);
}

.btn.danger:hover {
    background: rgba(214, 58, 42, 0.2);
}

.song-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.song-actions .btn,
.home .btn {
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

/* TV mode overrides */
.session.mode-tv .beat {
    width: 6rem;
    height: 6rem;
}

.session.mode-tv .beats {
    gap: 2rem;
}
