* { box-sizing: border-box; }
:root {
    color-scheme: dark;
    --navy: #071b34;
    --surface: #0a2844;
    --line: #27607a;
    --ink: #effaff;
    --muted: #a9c9db;
    --aqua: #32d8df;
    --green: #70edae;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body { margin: 0; min-height: 100vh; padding: 22px 12px; background: radial-gradient(ellipse at top, #133953, var(--navy) 68%); color: var(--ink); }
main { max-width: 440px; margin: 0 auto; }
h1 { font-size: clamp(1.4rem, 5vw, 1.85rem); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.04em; }
.dial-panel, .controls { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.dial-panel { padding: 10px 14px 12px; text-align: center; }
.reading { min-height: 96px; }
#note { color: var(--aqua); font-size: 3.65rem; font-weight: 780; line-height: 1.12; letter-spacing: -.06em; }
.values { display: flex; justify-content: center; gap: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
#dial { display: block; width: min(100%, 360px); height: auto; margin: 0 auto; }
#tuning { min-height: 1.35em; margin: 2px 0 0; color: var(--muted); font-weight: 700; }
.dial-panel.in-tune :is(#note, #tuning) { color: var(--green); }
#strings { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 10px 0; padding: 0; list-style: none; }
#strings[hidden] { display: none; }
#strings.bass { grid-template-columns: repeat(5, 1fr); }
#strings li { min-width: 0; text-align: center; padding: 5px 1px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
#strings li.active { border-color: var(--aqua); color: var(--aqua); }
#strings strong, #strings span { display: block; }
#strings span { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { padding: 12px; }
label { display: block; font-size: .875rem; font-weight: 720; margin-bottom: 4px; }
select, input, button { font: inherit; }
select, input { width: 100%; min-width: 0; min-height: 39px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--navy); color: var(--ink); }
.settings { display: grid; grid-template-columns: 1.4fr 1fr; gap: 9px; margin-top: 9px; }
.settings > div { min-width: 0; }
.reference, .level-label { display: flex; align-items: center; gap: 7px; }
.reference span, #decibels, .details { color: var(--muted); font-size: .8125rem; }
.details { margin: 8px 0; line-height: 1.4; overflow-wrap: anywhere; }
.details:empty, #error:empty { display: none; }
.level-label { justify-content: space-between; margin-top: 8px; }
.level-label label { margin: 0; }
meter { display: block; width: 100%; height: 13px; margin: 4px 0 12px; accent-color: var(--aqua); }
meter::-webkit-meter-bar { background: var(--navy); border: 1px solid var(--line); }
meter::-webkit-meter-optimum-value { background: var(--aqua); }
button { width: 100%; min-height: 42px; border: 1px solid var(--aqua); border-radius: 9px; background: #0a6074; color: var(--ink); font-weight: 760; cursor: pointer; }
button:hover { background: #14768c; }
:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }
#error { color: #ffd4ad; margin: 8px 0 0; font-size: .875rem; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.modes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 0 0 10px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--navy);
    min-width: 0;
}
.modes label { position: relative; margin: 0; cursor: pointer; }
.modes input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.modes span { display: block; padding: 6px 3px; border: 1px solid transparent; border-radius: 8px; text-align: center; color: var(--muted); }
.modes input:checked + span { border-color: var(--line); background: var(--surface); color: var(--aqua); }
.modes input:focus-visible + span { outline: 2px solid var(--aqua); outline-offset: 1px; }

body.embedded { padding: 12px; background: var(--navy); }
.embedded h1 { padding-inline-end: 28px; font-size: clamp(1.25rem, 5vw, 1.75rem); }
#toggle[hidden] { display: none; }

/* The parent sets this factor only when the standard spacing would overflow a desktop. */
body.embedded { padding-block: calc(12px - var(--tuner-squeeze, 0) * 6px); }
.embedded h1 { margin-bottom: calc(14px - var(--tuner-squeeze, 0) * 7px); }
.embedded .modes {
    margin-bottom: calc(10px - var(--tuner-squeeze, 0) * 5px);
    padding-block: calc(4px - var(--tuner-squeeze, 0) * 2px);
}
.embedded .dial-panel {
    padding-top: calc(10px - var(--tuner-squeeze, 0) * 6px);
    padding-bottom: calc(12px - var(--tuner-squeeze, 0) * 7px);
}
.embedded #strings { margin-block: calc(10px - var(--tuner-squeeze, 0) * 5px); }
.embedded .controls { padding-block: calc(12px - var(--tuner-squeeze, 0) * 5px); }
.embedded .settings { margin-top: calc(9px - var(--tuner-squeeze, 0) * 3px); }
.embedded .details { margin-block: calc(8px - var(--tuner-squeeze, 0) * 3px); }
.embedded meter { margin-bottom: calc(12px - var(--tuner-squeeze, 0) * 5px); }
