:root {
  color-scheme: dark;
  --bg: #160d12;
  --panel: #21151b;
  --line: #483037;
  --ink: #f8eee6;
  --muted: #c2aaa8;
  --brass: #edbd8b;
  --subtle: #a68c8c;
  --ink-dark: #361d22;
  font-family: "HB Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}
@font-face { font-family: "HB Montserrat"; src: url("/assets/Montserrat.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(ellipse 90% 630px at 67% 6%, #25141b, transparent 77%), var(--bg); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #f8ce9e; outline-offset: 4px; }
[hidden] { display: none !important; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.wrap { width: min(100% - 80px, 1260px); margin-inline: auto; }

.main { padding: clamp(12px, 2vh, 20px) 0; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; column-gap: 10px; row-gap: 4px; font-size: .78rem; color: var(--muted); }
.breadcrumbs a:hover { color: var(--brass); }
.breadcrumbs span[aria-hidden] { color: #927277; }
.breadcrumbs [aria-current] { color: var(--ink); }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 14px; }
.intro h1 { margin: 0; font-size: clamp(1.55rem, 2.65vw, 2.75rem); font-weight: 550; line-height: 1.12; letter-spacing: -.055em; }

.button { border: 1px solid var(--line); min-height: 38px; border-radius: 8px; background: #29191f; color: var(--ink); display: inline-flex; justify-content: center; align-items: center; gap: 9px; padding: 0 14px; font-size: .86rem; font-weight: 590; transition: background .18s, border .18s, color .18s, filter .18s; }
.button:not(:disabled):hover { border-color: #9e6761; background: #38222a; }
.button:disabled { color: #ae9494; opacity: .68; }
.a4 { flex: none; padding-inline: 12px; gap: 9px; white-space: nowrap; background: #28191f; }
.a4-mark { color: var(--brass); font-size: .75rem; line-height: 23px; padding: 0 6px; border: 1px solid #674540; border-radius: 5px; }
.a4 strong { font-weight: 650; }
.a4 .icon { margin-inline-start: 5px; color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(0, 2.08fr) minmax(260px, 1fr); grid-template-areas: "instrument source" "instrument peaks" "spectrum spectrum"; grid-template-rows: auto 1fr auto; gap: 10px 14px; }
.instrument { grid-area: instrument; }
.input-panel { grid-area: source; }
.modes-panel { grid-area: peaks; }
.spectrum-panel { grid-area: spectrum; }
.card { border: 1px solid var(--line); border-radius: 17px; background: var(--panel); min-width: 0; }
.instrument { display: flex; flex-direction: column; overflow: hidden; position: relative; background: #201219; border-color: #61403e; }
.instrument-core {
  min-height: clamp(178px, 24vh, 275px);
  flex: 1;
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 68% 83%, #59241f 0, #3d171d 26%, transparent 58%),
    radial-gradient(ellipse at 75% 31%, #381720, transparent 64%),
    linear-gradient(124deg, #211116 18%, #26131a 100%);
  overflow: hidden;
}
.instrument-core::after { content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none; background: linear-gradient(90deg, #231218 1%, #231218c9 23%, transparent 57%), linear-gradient(0deg, #241419a8 0, transparent 23%); }
#resonance-art { display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.instrument-top { position: absolute; top: 13px; left: 19px; right: 17px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.status { display: inline-flex; width: 18em; min-width: 0; gap: 9px; align-items: center; color: #f0c498; background: #26181ed9; border: 1px solid #644641; padding: 8px 11px; font-size: .78rem; line-height: 1.1; border-radius: 30px; }
.status span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status i { width: 6px; height: 6px; border-radius: 50%; flex: none; background: #ce9a80; box-shadow: 0 0 8px #d89061a0; }
.status[data-kind="stable"] i { background: #ffe0a5; box-shadow: 0 0 10px 2px #f7a6637d; }
.status[data-kind="error"] { color: #ffbdab; }
.status[data-kind="error"] i { background: #ffab9b; }
.mode-control { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #664440; border-radius: 30px; padding: 0 11px; min-height: 31px; font-size: .76rem; color: var(--ink); background: #28171cbd; white-space: nowrap; }
.mode-control .icon { color: var(--brass); width: 14px; height: 14px; }
.mode-control:disabled { color: #d9bfba; }
.mode-control:disabled .icon { display: none; }
.mode-control:not(:disabled):hover { background: #4b2830; }

.readout { position: relative; width: max-content; max-width: calc(100% - 48px); margin: 54px 0 16px 22px; pointer-events: none; }
.readout-note { height: 1em; color: #eec092; font-weight: 520; font-size: clamp(1.55rem, 3.7vh, 2.1rem); line-height: 1; letter-spacing: -.04em; white-space: nowrap; }
.readout-note sub { font-size: .58em; line-height: 0; vertical-align: -.12em; margin-left: .1em; }
.readout-frequency { display: flex; flex-wrap: nowrap; gap: 13px; align-items: baseline; margin: 2px 0; line-height: 1; }
#frequency { flex: none; width: 2.9em; text-align: right; white-space: nowrap; font-size: clamp(3.3rem, min(6.5vw, 9vh), 5.9rem); font-weight: 300; letter-spacing: -.092em; font-variant-numeric: tabular-nums; }
.readout-frequency .unit { font-size: 1.14rem; color: var(--brass); font-weight: 550; }
.readout p { font-size: .85rem; color: #e0b9b4; margin: 5px 0 0; line-height: 1.35; max-width: 250px; }
.sun-trigger { position: absolute; z-index: 1; left: var(--sun-x, 70%); top: var(--sun-y, 62%); transform: translate(-50%, -50%); width: var(--sun-size, 94px); height: var(--sun-size, 94px); border: 0; background: transparent; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.sun-trigger span { display: block; width: 100%; height: 100%; transform: scale(var(--sun-audio-scale, 1)) rotate(var(--sun-audio-tilt, 0deg)); filter: brightness(var(--sun-audio-brightness, 1)); background: linear-gradient(145deg, #ffe2a2 13%, #edaa69 46%, #be614d 95%); mask: url("./brand-sun.svg") center / contain no-repeat; }
.sun-wordmark {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: calc(100% + 62px);
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.sun-trigger:hover span { filter: brightness(calc(var(--sun-audio-brightness, 1) + .15)); }
.sun-trigger::after { content: ""; position: absolute; inset: 28%; border-radius: 50%; box-shadow: 0 0 calc(28px + var(--sun-audio-glow, 0px)) 10px #fc925778; pointer-events: none; }

.tuning-scale { padding: 8px 18px 9px; background: linear-gradient(90deg, #281820, #24161c); border-block: 1px solid #53353a; }
.scale-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; color: var(--muted); font-size: .81rem; }
.scale-head strong { min-width: 12ch; text-align: right; color: var(--brass); font-size: 1rem; font-variant-numeric: tabular-nums; }
.scale-track { height: 20px; margin-top: 2px; position: relative; display: flex; align-items: center; }
.scale-ticks { width: 100%; height: 15px; opacity: .69; background-image: linear-gradient(90deg, #9d7376 1px, transparent 1px), linear-gradient(90deg, #9d7376 1px, transparent 1px); background-repeat: repeat-x; background-size: 5% 8px, 25% 100%; background-position: left center; border-right: 1px solid #9d7376; }
.scale-center, .scale-marker { position: absolute; width: 3px; height: 22px; left: 50%; transform: translateX(-50%); border-radius: 3px; background: #c79680; }
.scale-center { background: #a7766e; box-shadow: 0 0 0 5px #bc7c6420; }
.scale-marker { width: 4px; height: 24px; background: #ffe7ad; box-shadow: 0 0 12px #ffb26d; left: var(--position, 50%); transition: left .13s linear; }
.scale-labels, .spectrum-labels { display: flex; justify-content: space-between; font-size: .69rem; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.instrument-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 10px; }
.history-button { margin-inline-start: auto; background: transparent; }
.instrument-actions .icon { width: 1rem; height: 1rem; }
#hold-button span { display: inline-grid; }
#hold-button span::after { content: "Снять фиксацию"; visibility: hidden; grid-area: 1 / 1; height: 0; }

.input-panel, .modes-panel { padding: 12px 15px; }
h2 { font-size: 1rem; font-weight: 650; margin: 0; letter-spacing: -.025em; line-height: 1.3; }
.source-guidance { block-size: 2.8em; overflow-y: auto; overflow-wrap: anywhere; scrollbar-width: thin; color: var(--muted); margin: 4px 0 9px; font-size: .78rem; font-weight: 500; line-height: 1.4; }
.browser-link { display: inline; padding: 0; border: 0; background: transparent; color: var(--brass); font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.browser-link:focus-visible { outline-offset: -1px; }
.input-panel > .button { width: 100%; }
.button.gold { border-color: #ddad82; background: linear-gradient(110deg, #edc393, #d6a074); color: #2b1719; font-weight: 700; }
.button.gold:not(:disabled):hover { background: linear-gradient(110deg, #f6d2aa, #e6b48c); border-color: #f8d4ac; }
.button.outline { background: #281920; border-color: #684247; }
.input-panel .outline { margin-top: 6px; }
.input-panel .outline .icon { color: var(--brass); }
.input-meter { margin-top: 8px; }
.meter-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: .73rem; }
#input-level { min-width: 10ch; text-align: right; color: #e9baa4; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-track { background: #3b282e; border-radius: 4px; height: 4px; overflow: hidden; margin-top: 4px; }
#input-meter-fill { height: 100%; width: 100%; transform: scaleX(var(--level, 0)); transform-origin: left center; background: linear-gradient(90deg, #8d514c 0, #deb184 70%, #f5c591 100%); transition: transform .13s ease-out; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.peak-count { font-size: .73rem; color: var(--brass); }
.peaks-body { height: 109px; margin-top: 7px; }
.empty-peaks { color: var(--muted); font-size: .79rem; line-height: 1.45; margin: 0; }
.peak-list { display: grid; align-content: start; gap: 3px; height: 100%; overflow-y: auto; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #815c55 transparent; }
.peak-list:empty { display: none; }
.peak { width: 100%; display: grid; grid-template-columns: minmax(88px, auto) 1fr auto; gap: 9px; background: #281920; border: 1px solid #4b3339; border-radius: 7px; align-items: center; text-align: left; padding: 2px 8px; min-height: 25px; color: var(--muted); font-size: .73rem; }
.peak:hover, .peak[aria-pressed="true"] { background: #3a242a; border-color: #9b6d5c; }
.peak[aria-pressed="true"] strong { color: var(--brass); }
.peak strong { color: #f3ded4; font-size: .8rem; font-weight: 630; font-variant-numeric: tabular-nums; white-space: nowrap; }
.peak span:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.spectrum-panel { padding: 10px 16px; }
.spectrum-heading { cursor: pointer; list-style: none; min-height: 26px; }
.spectrum-heading::-webkit-details-marker { display: none; }
.spectrum-meta { display: inline-flex; align-items: center; gap: 10px; }
.spectrum-meta .icon { width: 14px; height: 14px; }
.spectrum-panel details[open] .spectrum-meta .icon { transform: rotate(180deg); }
.spectrum-panel h2 { display: inline-flex; gap: 9px; align-items: center; }
.spectrum-panel .icon { color: var(--brass); }
.spectrum-kind { font-size: .73rem; color: var(--muted); text-align: right; }
.spectrum-frame { height: clamp(76px, 12vh, 136px); margin-top: 5px; border: 1px solid #493137; position: relative; border-radius: 6px; overflow: hidden; background: #1a1016; }
.spectrum-frame:focus-visible { outline-offset: 2px; }
#spectrum { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.spectrum-labels { margin: 4px 0 0; }
.spectrum-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: .76rem; color: #bda1a2; pointer-events: none; }
#spectrum-cursor { position: absolute; width: 11px; height: 11px; transform: translate(-50%, -50%); border: 1px solid #ffd99e; border-radius: 50%; pointer-events: none; }
#spectrum-tooltip {
  position: absolute; z-index: 1; max-width: calc(100% - 12px); padding: 4px 8px; border: 1px solid #a9795b; border-radius: 5px;
  background: #2d1c22; color: #ffdfb0; box-shadow: 0 2px 6px #10090c88; pointer-events: none;
  font-size: .72rem; font-variant-numeric: tabular-nums; line-height: 1.25; white-space: nowrap;
}
#spectrum-tooltip[data-kind="estimated"] { border-style: dashed; }
#spectrum-announcement { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.privacy-note { display: flex; align-items: center; gap: 7px; color: var(--subtle); font-size: .74rem; margin: 9px 0 0; }
.privacy-note .icon { width: 15px; height: 15px; }

.dialog { width: min(440px, calc(100% - 36px)); max-height: min(82vh, 620px); overflow: auto; padding: 22px; border: 1px solid #6d4848; border-radius: 16px; background: #291a21; color: var(--ink); }
.dialog::backdrop { background: #10090cbb; backdrop-filter: blur(4px); }
.dialog-title { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.dialog-title h2 { font-size: 1.22rem; }
.icon-button { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 8px; padding: 0; border: 1px solid var(--line); color: var(--ink); background: #321f27; }
.dialog p { color: var(--muted); font-size: .86rem; line-height: 1.5; margin: 7px 0 18px; }
.input-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .8rem; }
#reference { display: block; width: 100%; min-height: 45px; border: 1px solid #775156; border-radius: 7px; background: #201218; color: var(--ink); padding: 8px 11px; }
.reference-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 11px 0 14px; }
.reference-presets .button { padding-inline: 5px; }
.dialog-action { width: 100%; }
.history-list { display: grid; gap: 7px; margin-top: 13px; }
.history-row { display: grid; gap: 6px; border: 1px solid #573840; border-radius: 9px; padding: 9px 12px; }
.history-row strong { color: var(--brass); font-size: .9rem; }
.history-row time { color: var(--muted); font-size: .74rem; }
.toast { position: fixed; bottom: 20px; right: 20px; max-width: calc(100% - 40px); z-index: 10; background: #4c2d35; border: 1px solid #885f58; border-radius: 9px; padding: 12px 16px; color: #f7e6da; font-size: .84rem; box-shadow: 0 5px 25px #10080ca0; }

@media (max-width: 1100px) {
  .wrap { width: calc(100% - 38px); }
  .workspace { grid-template-columns: minmax(0, 1.7fr) minmax(245px, 1fr); gap: 9px 11px; }
  .source-guidance { block-size: 4.2em; }
  .instrument-actions .button { padding-inline: 9px; }
}
@media (max-width: 850px) {
  .wrap { width: calc(100% - 24px); }
  .workspace { grid-template-columns: minmax(0, 1.55fr) minmax(224px, 1fr); gap: 8px; }
  .instrument-top { top: 11px; left: 12px; right: 12px; gap: 5px; }
  .readout { margin-left: 15px; }
  .status { font-size: .71rem; gap: 6px; padding: 7px 9px; }
  .mode-control { min-height: 29px; font-size: .7rem; padding-inline: 8px; }
  .sun-trigger { --sun-size: 77px; --sun-x: 74%; }
  .instrument-actions { padding: 7px; }
  .instrument-actions .button { min-height: 34px; gap: 5px; padding-inline: 7px; font-size: .73rem; }
  .instrument-actions .icon { width: 14px; height: 14px; }
  .input-panel, .modes-panel { padding: 10px 11px; }
  .peak { grid-template-columns: auto 1fr auto; gap: 5px; }
}
@media (max-width: 700px) and (min-width: 601px) {
  .history-button { position: relative; }
  .history-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .history-button { min-width: 33px; }
}
@media (max-width: 600px) {
  .wrap { width: calc(100% - 18px); }
  .main { padding-top: 10px; }
  .intro { margin: 5px 0 9px; gap: 6px; }
  .intro h1 { font-size: clamp(1.2rem, 5vw, 1.68rem); }
  .breadcrumbs { font-size: .68rem; gap: 7px; }
  .a4 { min-height: 30px; padding-inline: 6px; font-size: .73rem; gap: 4px; }
  .a4-mark { line-height: 17px; font-size: .63rem; padding-inline: 3px; }
  .a4 .icon { width: 12px; height: 12px; margin: 0; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "instrument" "source" "spectrum" "peaks"; gap: 7px; }
  .card { border-radius: 12px; }
  .instrument-core { min-height: 130px; }
  .instrument-top { top: 8px; }
  .readout { display: grid; grid-template-columns: 2.7rem max-content; align-items: baseline; width: max-content; max-width: 69%; column-gap: 8px; margin: 49px 0 12px 13px; }
  .readout-note { font-size: 1.3rem; }
  .readout-frequency { gap: 4px; }
  #frequency { font-size: clamp(2.1rem, 8.9vw, 3rem); }
  .readout-frequency .unit { font-size: .82rem; }
  .readout p { grid-column: 1 / -1; font-size: .7rem; margin-top: 2px; }
  .sun-wordmark { width: calc(100% + 43px); }
  .sun-trigger { --sun-size: 60px; --sun-x: 79%; --sun-y: 65%; }
  .tuning-scale { padding: 5px 13px 6px; }
  .scale-head { font-size: .72rem; }
  .scale-head strong { font-size: .82rem; }
  .scale-track { height: 15px; margin: 1px 0; }
  .scale-ticks { height: 9px; }
  .scale-center, .scale-marker { height: 14px; }
  .scale-labels, .spectrum-labels { font-size: .62rem; }
  .instrument-actions { gap: 4px; padding: 5px 7px; }
  .instrument-actions .button { font-size: .69rem; padding-inline: 5px; min-height: 30px; }
  .input-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 6px; }
  .input-panel h2 { grid-column: 1; }
  .source-guidance { grid-column: 1 / -1; margin: 0; font-size: .73rem; }
  .input-panel .button { min-height: 34px; margin: 0; padding-inline: 4px; gap: 4px; font-size: .72rem; }
  .input-panel .button .icon { width: 15px; height: 15px; }
  .input-meter { grid-row: 1; grid-column: 2; align-self: center; margin: 0; }
  .meter-head { font-size: .63rem; }
  .meter-track { height: 3px; margin-top: 2px; }
  .spectrum-panel { padding: 7px 11px; }
  .spectrum-kind { font-size: .61rem; }
  .spectrum-meta { gap: 4px; }
  .spectrum-frame { height: clamp(64px, 10vh, 94px); }
  .peaks-body { height: 129px; }
  .peak { min-height: 30px; }
  .privacy-note { align-items: start; font-size: .65rem; }
}
@media (max-width: 360px) {
  .instrument-actions .icon { display: none; }
  .spectrum-kind { display: none; }
  .sun-trigger { --sun-size: 51px; }
}
@media (min-width: 601px) and (max-height: 800px) {
  .main { padding-top: 8px; }
  .intro { margin: 4px 0 8px; }
  .workspace { row-gap: 7px; }
  .input-panel, .modes-panel { padding-block: 8px; }
  .source-guidance { margin-block: 2px 5px; }
  .input-panel > .button { min-height: 34px; }
  .input-meter { margin-top: 5px; }
  .spectrum-panel { padding-block: 7px; }
  .spectrum-frame { height: clamp(64px, 10vh, 80px); }
}
@media (min-width: 1200px) and (max-height: 780px) {
  .intro { margin-bottom: 6px; }
  .workspace { row-gap: 6px; }
  .readout { margin-block: 51px 11px; }
  .tuning-scale { padding-block: 7px 8px; }
  .instrument-actions { padding-block: 6px; }
  .input-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 6px; }
  .input-panel > :not(.button) { grid-column: 1 / -1; }
  .input-panel > .button { margin: 0; padding-inline: 5px; gap: 5px; font-size: .8rem; }
  .input-panel > .button .icon { width: 16px; height: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
