/* ============================================================
   Historical Tunings
   Mobile first. Palette taken from nova-akademija.si so the app
   reads as part of the association's site. Accidentals are drawn
   as SVG, never as font glyphs, so ♯/♭ render identically on
   every device.
   ============================================================ */

:root {
    --ground:      #0f131a;   /* page, behind the plate */
    --panel:       #141b29;
    --well:        #0b0f16;   /* recessed surfaces: gauge, keybed */

    --gold:        #f2cc5a;
    --gold-deep:   #d4a93a;

    --text:        #eeece8;
    --text-soft:   #9aa3b5;
    --text-faint:  #8b95a8;   /* 5.7:1 on the panel; the 9px labels need the full 4.5:1 */

    --green:       #68c79b;   /* verdigris; sits between the navy and the gold rather than beside them */
    --green-deep:  #3f8f6c;

    --edge:        rgba(242, 204, 90, 0.16);
    --edge-soft:   rgba(255, 255, 255, 0.07);

    --sans:  ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono:  ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

    --gap: 12px;
    --stage-pad: 20px;   /* the keyboard cancels this to sit flush with the plate edges */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    background: var(--ground);
    color: var(--text);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    padding: 0;
}

/* Baroque manuscript behind everything, held still while the page scrolls */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url('ozadje.jpg') center / cover no-repeat;
    z-index: -2;
}

/* Warm black rather than the navy ground, so the paper keeps its sepia and the
   cool plate reads against it */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: #0b0906;
    opacity: 0.90;
    z-index: -1;
}

/* Adds tooth to the flat navy so the large gradients don't band */
.grain::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.30;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.32'/%3E%3C/svg%3E");
}

/* ---------- the plate ---------- */

/* Left translucent so the manuscript ghosts through the panel rather than
   stopping at its edge */
.stage {
    position: relative;
    width: 100%;
    max-width: 460px;
    min-width: 0;        /* without this the wide keyboard drags the plate past the viewport */
    min-height: 100vh;
    min-height: 100dvh;
    background: rgba(20, 27, 41, 0.82);
    background-image:
        radial-gradient(120% 70% at 50% -10%, rgba(46, 58, 84, 0.55) 0%, transparent 60%),
        radial-gradient(100% 60% at 50% 110%, rgba(5, 8, 13, 0.5) 0%, transparent 55%);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.75);
    padding: 26px var(--stage-pad) calc(20px + env(safe-area-inset-bottom));
    padding-top: calc(26px + env(safe-area-inset-top));
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

/* ---------- header ---------- */

/* Symmetric inset centres the title and leaves room for the back link, so long
   names like "Werckmeister III" can't run underneath it */
.stage-head {
    text-align: center;
    position: relative;
    padding: 0 46px;
    --title-size: clamp(14px, 4.4vw, 19px);
}

/* Centred on the title's line box, so it tracks the title as that scales with
   the viewport. min-height carries the tap target without shifting the centre. */
.back {
    position: absolute;
    left: 0;
    top: calc(2px + var(--title-size) * 0.6);
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-right: 12px;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    text-decoration: none;
}
.back:active { color: var(--gold); }

.tuning-name {
    font-size: var(--title-size);
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin: 2px 0 0;
    color: var(--gold);
    line-height: 1.2;
}

.tuning-note {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-soft);
    margin: 8px auto 0;
    max-width: 34ch;
}

/* Mirrors .back so the title stays centred between the two */
.info-btn {
    position: absolute;
    right: 0;
    top: calc(2px + var(--title-size) * 0.6);
    transform: translateY(-50%);
    width: 26px; height: 26px;
    margin-right: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--edge);
    border-radius: 50%;
    background: transparent;
    color: var(--text-faint);
    font-family: var(--sans);
    font-size: 13px;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}
.info-btn:active { color: var(--gold); border-color: var(--gold); }
.info-btn[hidden] { display: none; }

/* The 26px circle is the mark; this carries the tap target around it */
.info-btn::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 44px; height: 44px;
    transform: translate(-50%, -50%);
}

.rule {
    height: 1px;
    background: var(--edge-soft);
    position: relative;
}
.rule::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -3px;
    width: 7px; height: 7px;
    transform: translateX(-50%) rotate(45deg);
    background: var(--panel);
    border: 1px solid var(--edge);
}

/* ---------- gauge ---------- */

.gauge {
    position: relative;
    background: var(--well);
    border: 1px solid var(--edge);
    border-radius: 16px;
    padding: 12px 10px 6px;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}
.gauge svg { display: block; width: 100%; height: auto; }

.tick        { stroke: var(--text-faint); stroke-width: 1; }
.tick.major  { stroke: var(--text-soft); stroke-width: 1.4; }
.tick.zero   { stroke: var(--green); stroke-width: 2.2; }
.tick-label  { fill: var(--text-faint); font-family: var(--mono); font-size: 9px; text-anchor: middle; }
.arc         { fill: none; stroke: rgba(255, 255, 255, 0.10); stroke-width: 1; }
.arc-centre  { fill: none; stroke: var(--green); stroke-width: 2.5; opacity: 0.35; }

#needle {
    fill: var(--gold);
    transition: fill 180ms ease;
}
#needle.in-tune { fill: var(--green); }
.pivot      { fill: var(--text-soft); }
.pivot-ring { fill: none; stroke: var(--text-soft); stroke-width: 1; opacity: 0.4; }

/* ---------- readout ---------- */

/* The side columns are equal by definition, so the note stays dead centre
   however wide the accidental or the cents figure gets */
.readout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: baseline;
}

.note {
    --note-size: 92px;
    grid-column: 2;
    height: 92px;                /* fixed: keeps layout still across ♯/♭/idle */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
}

/* Clipped to nothing, but it holds the row's baseline, so the cents figure
   stays put when the note goes idle and has no text of its own */
.note::before {
    content: "\200B";
    font-size: var(--note-size);
    line-height: 1;
}

.note-letter {
    font-size: var(--note-size);
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.04em;
}
.accidental { height: 54px; width: auto; margin-bottom: 9px; margin-left: 2px; }

/* Idle state: a dim bar holding the note's place */
.note-idle {
    width: 78px;
    height: 3px;
    border-radius: 2px;
    background: var(--text-faint);
    opacity: 0.5;
}

.cents {
    grid-column: 3;
    justify-self: start;
    padding-left: 14px;
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--gold);
    text-align: left;
}
.cents.in-tune { color: var(--green); }

/* ---------- mic ---------- */

/* The column's only auto margin: everything below is anchored to the bottom,
   so spare height collects here as one gap instead of scattering */
.mic {
    margin-top: auto;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-height: 54px;
    border: 2px solid var(--gold);
    border-radius: 14px;
    background: transparent;
    color: var(--gold);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 160ms ease, color 160ms ease;
}
.mic:active { background: rgba(242, 204, 90, 0.12); }
.mic .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
    flex: none;
}
.mic.live { background: var(--gold); color: #141b29; }
.mic.live .dot { background: #141b29; opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- controls ---------- */

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.field input, .field select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-height: 44px;
    background: var(--well);
    border: 1px solid var(--edge-soft);
    border-radius: 10px;
    color: var(--gold);
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    padding: 0 8px;
    outline: none;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
.field select {
    font-family: var(--sans);
    background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%),
                      linear-gradient(135deg, var(--gold) 50%, transparent 50%);
    background-position: calc(100% - 16px) 20px, calc(100% - 11px) 20px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.field select option { background: var(--panel); color: var(--text); }
/* A long temperament name needs the whole row; the short controls pair off above it */
.field-wide { grid-column: 1 / -1; }

/* ---------- enharmonics ---------- */

.enharmonics { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.enh-pair {
    display: inline-flex;
    border: 1px solid var(--edge-soft);
    border-radius: 10px;
    overflow: hidden;
    background: var(--well);
}
.enh-btn {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    min-height: 34px;
    min-width: 36px;
    padding: 0 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 600;
}
.enh-btn .accidental { height: 15px; margin-bottom: 3px; }
.enh-btn.active { background: var(--gold); color: #141b29; }

/* ---------- keyboard ---------- */

/* Full-bleed: the negative side margins cancel the plate's padding, and the
   negative bottom margin lets the keybed run into the safe-area strip below */
/* Takes the column's leftover height up to the cap; whatever is left over past
   that still collects at the mic's auto margin */
.keyboard-wrap {
    flex: 1 0 auto;
    max-height: 250px;
    display: flex;
    flex-direction: column;
    margin-left: calc(-1 * var(--stage-pad));
    margin-right: calc(-1 * var(--stage-pad));
    margin-bottom: calc(-20px - env(safe-area-inset-bottom));
    padding-top: 4px;
    min-width: 0;
}

.kb-head {
    margin-bottom: 7px;
    padding: 0 var(--stage-pad);
}
.kb-head span {
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.kb-scroll {
    flex: 1;
    min-height: 121px;   /* border box: the 1px top border is inside it */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border: 0;
    border-top: 1px solid var(--edge-soft);
    border-radius: 0;
    background: var(--well);
    /* keys stop above the home indicator; the dark keybed continues under it */
    padding-bottom: env(safe-area-inset-bottom);
    /* fade the edges so it reads as continuing past the frame */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.kb-scroll::-webkit-scrollbar { display: none; }

.keyboard {
    position: relative;
    height: 100%;
    display: block;
}

.wkey, .bkey {
    position: absolute;
    top: 0;
    border: 0;
    padding: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-family: var(--sans);
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

/* Held below white so a full octave of them doesn't glare against the dark app */
.wkey {
    height: 100%;
    background: linear-gradient(180deg, #e7e3da 0%, #d5cfc2 88%, #b9b2a2 100%);
    border-right: 1px solid rgba(11, 15, 22, 0.55);
    color: #4a4437;
    font-size: 11px;
    padding-bottom: 9px;
}
.wkey.playing {
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 100%);
    color: #241d05;
}

.bkey {
    height: 62.5%;
    background: linear-gradient(180deg, #1a2132 0%, #05070b 100%);
    border-radius: 0 0 3px 3px;
    color: rgba(238, 236, 232, 0.55);
    font-size: 10px;
    padding-bottom: 7px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}
.bkey.playing {
    background: linear-gradient(180deg, var(--gold-deep) 0%, #8a6c1e 100%);
    color: #241d05;
}

.wkey .kb-acc, .bkey .kb-acc { height: 10px; margin-bottom: 1px; }
.key-label { display: inline-flex; align-items: flex-end; gap: 0.5px; }
/* Size alone separates the octave digit from the note letter; dimming it far
   enough to read as secondary would drop it under 4.5:1 */
.key-oct { font-family: var(--mono); font-size: 8px; opacity: 0.85; margin-left: 1px; }

/* ---------- index / picker ---------- */

body.home .stage { justify-content: flex-start; }

.masthead { text-align: center; padding: 18px 0 6px; }
.masthead h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    margin: 0;
    line-height: 1.25;
    color: var(--gold);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
}
.masthead p {
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--text-soft);
    margin: 12px 0 0;
}

/* Negative margins cancel the plate's padding so rows and rules reach both
   edges; each child pads its own text back to the text column */
#list, .extras {
    margin-left: calc(-1 * var(--stage-pad));
    margin-right: calc(-1 * var(--stage-pad));
}

.group-label {
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 16px 0 8px;
    padding-left: var(--stage-pad);
    display: flex;
    align-items: center;
    gap: 10px;
}
.group-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--edge);
}

.tuning-list { display: flex; flex-direction: column; gap: 1px; }
.tuning-link {
    display: block;
    padding: 14px var(--stage-pad);
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--edge-soft);
    min-height: 44px;
}
/* Whatever follows a list — the next group label, or the footer — brings its own edge */
.tuning-link:last-child { border-bottom: none; }
.tuning-link:active { background: rgba(242, 204, 90, 0.13); }
.tuning-link .t-name {
    font-size: 17px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.tuning-link .t-name::after {
    content: "→";
    color: var(--text-faint);
    font-size: 13px;
}
.tuning-link .t-note {
    font-size: 11.5px;
    color: var(--text-soft);
    margin-top: 3px;
    line-height: 1.45;
}

/* ---------- info sheet ---------- */

/* Fixed rather than absolute: the tall-window rule clips .stage */
.sheet {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(6, 9, 14, 0.72);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 24px 0 0;
}
.sheet[hidden] { display: none; }
/* On html, not body: body already carries overflow-x, which stops its own
   overflow propagating to the viewport, so a lock set there does nothing */
html.sheet-open { overflow: hidden; }

.sheet-plate {
    width: 100%;
    max-width: 460px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--edge);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.6);
}

/* Outside .sheet-body, the only scroller, so it holds the title and the close
   button still while the panel scrolls under them */
.sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px var(--stage-pad) 12px;
    border-bottom: 1px solid var(--edge-soft);
    background: var(--panel);
    border-radius: 16px 16px 0 0;
}

.sheet-title {
    flex: 1;
    margin: 0;
    min-width: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
}

.sheet-close {
    flex: none;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--edge);
    border-radius: 50%;
    background: transparent;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}
.sheet-close:active { color: var(--gold); border-color: var(--gold); }

.sheet-body {
    outline-offset: -2px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 4px var(--stage-pad) calc(20px + env(safe-area-inset-bottom));
}

.sheet-p {
    font-size: 13px;
    line-height: 1.62;
    color: var(--text-soft);
    margin: 14px 0 0;
}

.sheet-h {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin: 26px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--edge-soft);
}

.sheet-note {
    font-size: 11px;
    line-height: 1.55;
    color: var(--text-faint);
    margin: 10px 0 0;
}

.sheet-src {
    font-size: 11px;
    line-height: 1.55;
    color: var(--text-faint);
    margin: 26px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--edge-soft);
}

.sheet-table { font-family: var(--mono); font-size: 11.5px; }

/* Tracks in rem, not em: the header row is set smaller than the body rows, and
   em would resolve against each row's own size and misalign the two */
.sheet-row {
    display: grid;
    grid-template-columns: 3.3rem 3rem 1fr 3.2rem;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text);
}
.sheet-row:last-child { border-bottom: none; }

.sheet-row.head {
    font-family: var(--sans);
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
    border-bottom-color: var(--edge-soft);
}

.sheet-row .num { text-align: right; color: var(--text-soft); }
.sheet-row.head span:nth-child(2), .sheet-row.head span:nth-child(4) { text-align: right; }
.sheet-row .tag { font-family: var(--sans); font-size: 10.5px; color: var(--text-faint); }
.sheet-row.closing { color: var(--gold); }
.sheet-row.closing .num, .sheet-row.closing .tag { color: var(--gold-deep); }

.sheet-acc { height: 0.82em; width: auto; vertical-align: -0.02em; margin-left: 1px; }

/* ---------- about ---------- */

/* Borrows the sheet's prose classes, so the page reads as the same kind of
   document as a temperament's information panel */
.about { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.about p a { color: var(--text-soft); text-decoration: none; border-bottom: 1px solid var(--edge); }
.about em { color: var(--text); font-style: italic; }

.credits {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}
/* Quieter than a link in prose, so the one name that carries one doesn't
   outweigh the other three */
.credits a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--edge-soft); }

/* Carries the picker's arrow, so a row that opens another page reads the same
   here as it does on the list of temperaments */
.doc-link {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    min-height: 44px;
    padding: 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.doc-link::after { content: "→"; color: var(--text-faint); font-size: 13px; }
.doc-link:active { color: var(--gold); }

.lib-name { font-size: 15px; font-weight: 600; margin: 22px 0 0; }
.lib-meta {
    font-size: 11px;
    color: var(--text-faint);
    margin: 3px 0 0;
}

/* Recessed like the gauge and the keybed, so verbatim legal text reads as
   quoted rather than as more of the prose above it */
.licence {
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.65;
    color: var(--text-faint);
    background: var(--well);
    border: 1px solid var(--edge-soft);
    border-radius: 8px;
    margin: 12px 0 0;
    padding: 14px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* ---------- picker footer ---------- */

.foot {
    margin-top: 18px;
    padding-top: 10px;
    border-top: 1px solid var(--edge-soft);
    text-align: center;
}
.foot a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-faint);
    text-decoration: none;
}
.foot a:active { color: var(--gold); }

/* ---------- pure ratios ---------- */

/* Long enough to need the scroll, so the plate is not pinned to the viewport */
body.ratios .stage { justify-content: flex-start; }

.ratio-readout { text-align: center; }

.ratio-figure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: var(--mono);
    font-size: 46px;
    font-weight: 700;
    line-height: 1;
    color: var(--gold);
}
.ratio-figure .r-bar { color: var(--text-faint); font-weight: 400; }

/* Held at one line's height so a ratio with no name doesn't collapse the row */
.ratio-name {
    margin-top: 10px;
    min-height: 17px;
    font-size: 13px;
    color: var(--text);
}
.ratio-limit { color: var(--text-faint); }

.ratio-facts {
    margin-top: 4px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text-soft);
}

.harm-picker { display: flex; flex-direction: column; gap: 10px; }
.harm-row { display: flex; flex-direction: column; gap: 5px; }
.harm-label {
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.harm-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.harm-btn {
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
    padding: 0;
    background: var(--well);
    border: 1px solid var(--edge-soft);
    border-radius: 8px;
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.harm-btn.active { background: var(--gold); border-color: var(--gold); color: #141b29; }

/* Each voice carries the system it comes from over the note that system gives, so
   the pair reads as a comparison rather than as two unexplained words */
.voice-row { display: flex; flex-direction: column; gap: 5px; }
.voice-row .enh-pair { display: flex; border-radius: 12px; }
.voice-row .enh-btn {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-height: 70px;
    padding: 8px;
}
/* Size alone separates the two lines: dimming the 9px one would drop it under 4.5:1 */
.voice-sys {
    font-size: 9px;
    line-height: 1.25;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
}
.voice-val {
    display: inline-flex;
    align-items: flex-end;
    gap: 1px;
    font-size: 15px;
    font-weight: 700;
}
.voice-row .enh-btn .accidental { height: 13px; margin-bottom: 1px; }
/* How far this voice sits from the ratio: the deviation, then the beat rate it makes */
.voice-off {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 400;
    line-height: 1.2;
}
/* Green only while the button is dark: on the lit one it would fight the gold */
.enh-btn:not(.active) .voice-off.exact { color: var(--green); }

.sound-btn {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-height: 48px;
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 12px;
    color: var(--gold);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    cursor: pointer;
}
.sound-btn:active { background: rgba(242, 204, 90, 0.12); }
.sound-btn.live { background: var(--gold); color: #141b29; }

/* The ratio drawn where it actually falls, which is usually between two keys */
.kb-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: var(--gold);
    box-shadow: 0 0 6px rgba(242, 204, 90, 0.75);
    z-index: 3;
    pointer-events: none;
}
.kb-marker::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 9px solid var(--gold);
}
.kb-marker[hidden] { display: none; }
/* Pinned to the edge because the ratio lands past it, so it is drawn as an estimate */
.kb-marker.off { opacity: 0.45; }

.wkey.root {
    background: linear-gradient(180deg, var(--green) 0%, var(--green-deep) 100%);
    color: #0c2019;
}
.bkey.root {
    background: linear-gradient(180deg, var(--green-deep) 0%, #265944 100%);
    color: #0c2019;
}
/* Marks the key the ratio is measured against without competing with the marker */
.wkey.near { box-shadow: inset 0 -4px 0 var(--gold-deep); }
.bkey.near { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7), inset 0 -4px 0 var(--gold-deep); }

/* ---------- laptops and up ---------- */

/* The plate widens and the display type grows with it, so the extra room reads
   as a larger instrument rather than the phone layout stretched */
@media (min-width: 700px) {
    :root { --stage-pad: 30px; --gap: 16px; }
    .stage { max-width: 690px; }

    .masthead { padding: 26px 0 10px; }
    .masthead h1 { font-size: 36px; }
    .masthead p { font-size: 12px; }

    .stage-head { padding: 0 64px; --title-size: 23px; }
    .tuning-note { font-size: 13.5px; max-width: 56ch; }

    /* The dial is 2:1, so left to fill it would be half the plate tall */
    .gauge { padding: 16px 14px 8px; }
    .gauge svg { max-width: 440px; margin: 0 auto; }

    .note { height: 128px; --note-size: 124px; }
    .accidental { height: 72px; margin-bottom: 12px; }
    .note-idle { width: 104px; height: 4px; }
    .cents { font-size: 32px; }

    .mic { min-height: 60px; font-size: 13px; }
    .controls { gap: 18px; }

    .ratio-figure { font-size: 58px; }
    .ratio-name { font-size: 14px; }
    .harm-grid { grid-template-columns: repeat(16, 1fr); }
    .sound-btn { min-height: 56px; font-size: 13px; }

    .group-label { font-size: 10px; margin: 22px 0 10px; }
    .tuning-link { padding: 17px var(--stage-pad); }
    .tuning-link .t-name { font-size: 19px; }
    .tuning-link .t-note { font-size: 12.5px; }

    .credits { font-size: 17px; }
    .licence { font-size: 10.5px; padding: 18px; }
}

/* ---------- pointer devices ---------- */

/* Gated on a real pointer: on a touchscreen :hover latches after a tap and
   leaves the control lit until you touch something else. */
@media (hover: hover) and (pointer: fine) {

    .tuning-link, .tuning-link .t-name::after,
    .back, .foot a, .about p a, .credits a, .doc-link, .field input, .field select,
    .enh-btn, .wkey, .bkey, .harm-btn, .sound-btn {
        transition: background-color 140ms ease, border-color 140ms ease,
                    color 140ms ease, transform 140ms ease, filter 140ms ease;
    }

    .tuning-link:hover { background: rgba(242, 204, 90, 0.08); }
    .tuning-link:hover .t-name::after {
        color: var(--gold);
        transform: translateX(3px);
    }

    .back:hover, .foot a:hover { color: var(--gold); }
    .about p a:hover, .credits a:hover { color: var(--gold); border-color: var(--gold); }
    .doc-link:hover, .doc-link:hover::after { color: var(--gold); }
    .info-btn:hover, .sheet-close:hover { color: var(--gold); border-color: var(--gold); }

    .mic:not(.live):hover { background: rgba(242, 204, 90, 0.12); }
    .mic.live:hover { background: var(--gold-deep); }

    .field input:hover, .field select:hover { border-color: var(--text-faint); }

    .enh-btn:not(.active):hover { background: rgba(242, 204, 90, 0.10); color: var(--text); }
    .enh-btn.active:hover { background: var(--gold-deep); }

    .harm-btn:not(.active):hover { background: rgba(242, 204, 90, 0.10); color: var(--text); }
    .harm-btn.active:hover { background: var(--gold-deep); border-color: var(--gold-deep); }
    .sound-btn:not(.live):hover { background: rgba(242, 204, 90, 0.12); }
    .sound-btn.live:hover { background: var(--gold-deep); }

    /* filter rather than a second gradient, so the change animates */
    .wkey:not(.playing):hover { filter: brightness(1.06); }
    .bkey:not(.playing):hover { filter: brightness(1.5); }
    .wkey.playing:hover, .bkey.playing:hover { filter: brightness(1.07); }
}

/* ---------- narrow phones ---------- */

@media (max-width: 360px) {
    :root { --stage-pad: 14px; }
    /* bottom stays 20px so the keyboard's negative margin still cancels exactly */
    .stage { padding: 20px var(--stage-pad) calc(20px + env(safe-area-inset-bottom)); }
    .accidental { height: 52px; }
    .note { height: 88px; --note-size: 76px; }
    .stage-head { --title-size: 16px; }
    .tuning-name { letter-spacing: 0.22em; }
}

/* Wide but short, which most laptops are: the desktop scale-up above doesn't
   fit in the height, so pull the dial and the note back toward phone size */
@media (min-width: 700px) and (max-height: 860px) {
    .note { height: 96px; --note-size: 92px; }
    .accidental { height: 54px; margin-bottom: 9px; }
    .cents { font-size: 26px; }
    .gauge svg { max-width: 380px; }
}

/* Narrow windows far taller than any phone: centre the plate rather than letting
   the extra height open up as dead space. Width-gated, because the desktop layout
   fills its height on its own, and page-gated, because a fixed height would cut
   off the picker and the about page, which run as long as their content. */
@media (max-width: 699px) and (min-height: 880px) {
    body:not(.home):not(.doc):not(.ratios) { align-items: center; }
    body:not(.home):not(.doc):not(.ratios) .stage {
        min-height: 0;
        height: 860px;
        border-radius: 20px;
        overflow: hidden;
    }
}

/* Short screens: give the keyboard room by trimming the prose */
@media (max-height: 700px) {
    .tuning-note { display: none; }
    .note { height: 88px; --note-size: 76px; }
    .accidental { height: 52px; }
}
