.tuner-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* Controls bar: presets + tone selector side by side */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 20px;
    flex-wrap: wrap;
}

/* Preset bar */
.preset-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-label {
    font-size: 9pt;
    color: #aaaaaa;
    margin-right: 2px;
}

.preset-btn {
    font: inherit;
    font-size: 9.5pt;
    padding: 5px 14px;
    border: 1px solid #dddddd;
    background: #ffffff;
    color: #555555;
    border-radius: 20px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.preset-btn:hover  { border-color: #999999; color: #000000; }
.preset-btn:active { background: #f5f5f5; }

/* Tone selector */
.tone-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.tone-label {
    font-size: 9pt;
    color: #aaaaaa;
}

.tone-select {
    font: inherit;
    font-size: 9.5pt;
    padding: 4px 8px;
    border: 1px solid #dddddd;
    border-radius: 6px;
    background: #ffffff;
    color: #555555;
    cursor: pointer;
}

.tone-select:focus { outline: none; border-color: #aaaaaa; }

/* Main tuner display */
.tuner-display {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 28px 28px 24px;
    margin: 0 0 20px;
    text-align: center;
}

.display-note {
    font-size: 56pt;
    font-weight: bold;
    line-height: 1;
    letter-spacing: -2px;
    margin: 0 0 6px;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    transition: color 0.2s;
}

.display-note.in-tune { color: #2a9940; }

.display-cents {
    font-size: 9.5pt;
    color: #888888;
    margin: 0 0 22px;
    min-height: 18px;
}

/* Meter */
.meter-wrap { margin: 0 0 18px; }

.meter-bar {
    position: relative;
    height: 18px;
    background: linear-gradient(
        to right,
        #cc3333 0%,
        #dd8833 25%,
        #44aa44 44%,
        #44aa44 56%,
        #dd8833 75%,
        #cc3333 100%
    );
    border-radius: 9px;
}

.meter-needle {
    position: absolute;
    top: -7px;
    width: 3px;
    height: 32px;
    background: #000000;
    border-radius: 2px;
    transform: translateX(-50%);
    transition: left 0.06s linear;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.meter-scale {
    display: flex;
    justify-content: space-between;
    font-size: 8pt;
    color: #bbbbbb;
    margin-top: 8px;
    padding: 0 2px;
}

.display-status {
    font-size: 10pt;
    color: #888888;
    min-height: 22px;
}

.display-status.in-tune { color: #2a9940; font-weight: 600; }

/* Listen button */
.listen-btn {
    display: block;
    width: 100%;
    font: inherit;
    font-size: 10.5pt;
    padding: 12px;
    border: 1px solid #000000;
    background: #000000;
    color: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin: 0 0 36px;
}

.listen-btn:hover { background: #333333; border-color: #333333; }
.listen-btn.active { background: #ffffff; color: #000000; border-color: #cccccc; }
.listen-btn.active:hover { background: #f5f5f5; }

/* Strings section */
.strings-section h3 {
    font-size: 11pt;
    font-weight: 600;
    margin: 0 0 10px;
    color: #000000;
}

.strings-hint {
    font-size: 8.5pt;
    color: #cccccc;
    font-weight: 400;
}

.strings-list {
    border-top: 1px solid #eeeeee;
}

.string-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px;
    border-bottom: 1px solid #eeeeee;
    border-radius: 4px;
    transition: background 0.1s;
}

.string-row.highlighted { background: #f5f5f5; }

.string-num {
    width: 18px;
    text-align: right;
    color: #cccccc;
    font-size: 9pt;
    flex-shrink: 0;
}

/* Editable area */
.string-edit {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.string-input {
    font: inherit;
    font-size: 11pt;
    font-weight: 600;
    color: #000000;
    width: 54px;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    transition: border-color 0.12s, background 0.12s;
    flex-shrink: 0;
}

.string-input:hover  { border-color: #dddddd; background: #fafafa; }
.string-input:focus  { outline: none; border-color: #aaaaaa; background: #ffffff; }
.string-input.invalid { border-color: #cc4444; background: #fff5f5; color: #cc4444; }

/* Mobile select — hidden on desktop */
.string-select {
    display: none;
    font: inherit;
    font-size: 11pt;
    font-weight: 600;
    color: #000000;
    padding: 2px 4px;
    border: 1px solid #dddddd;
    border-radius: 4px;
    background: #ffffff;
    flex-shrink: 0;
}

.string-hz {
    font-size: 9pt;
    color: #bbbbbb;
    white-space: nowrap;
}

/* Play button */
.string-play {
    font: inherit;
    font-size: 9pt;
    padding: 4px 12px;
    border: 1px solid #dddddd;
    background: #ffffff;
    color: #444444;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
    flex-shrink: 0;
}

.string-play:hover  { border-color: #999999; color: #000000; }
.string-play:active { background: #f0f0f0; }

.tuner-note {
    font-size: 9pt;
    color: #bbbbbb;
    margin-top: 32px;
    line-height: 1.6;
}

/* ===== MOBILE =====
   Lock the page to the viewport height and let the strings list absorb
   whatever space is left. Nothing can overflow, so the page never scrolls. */
@media (max-width: 600px) {
    html, body {
        height: 100%;
        margin: 0;
        overflow: hidden;
    }

    body {
        height: 100vh;        /* fallback */
        height: 100dvh;       /* tracks the dynamic toolbar on mobile */
        display: flex;
        flex-direction: column;
    }

    header {
        flex: none;
        margin: 6px auto 4px;
        padding: 0 12px;
    }
    header h1 { font-size: 10.5pt; margin-bottom: 0; }
    header p  { display: none; }

    .tuner-main {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 0 12px 8px;
    }

    /* Controls */
    .controls-bar {
        flex: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        margin: 0;
    }

    .preset-label { display: none; }

    .preset-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .preset-btn {
        border-radius: 6px;
        padding: 7px 4px;
        text-align: center;
        font-size: 9pt;
    }

    .tone-bar { justify-content: center; gap: 8px; }
    .tone-select { flex: 1; }

    /* Display */
    .tuner-display {
        flex: none;
        padding: 10px 14px 8px;
        margin: 0;
    }
    .display-note  { font-size: clamp(28pt, 9vh, 40pt); min-height: 0; margin-bottom: 2px; }
    .display-cents { font-size: 9pt; margin-bottom: 8px; min-height: 14px; }
    .meter-wrap    { margin-bottom: 8px; }
    .meter-scale   { display: none; }
    .display-status { min-height: 16px; }

    .listen-btn {
        flex: none;
        padding: 8px;
        font-size: 9.5pt;
        margin: 0;
    }

    /* Strings — fill remaining height, rows share it evenly */
    .strings-section {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .strings-section h3 { display: none; }

    .strings-list {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .string-row {
        flex: 1;
        min-height: 0;
        padding: 0 4px;
        gap: 10px;
    }

    .string-edit { align-items: center; }

    .string-num { font-size: 8.5pt; }

    .string-input  { display: none; }
    .string-hz     { display: none; }

    .string-select {
        display: block;
        width: 100%;
        max-width: 110px;
        padding: 5px 6px;
    }

    .string-play { padding: 6px 14px; }

    footer, .tuner-note { display: none; }
}
