:root {
  color-scheme: light;
  --page: #ffffff; --surface: #f5f6f7; --subtle: #f9fafb; --ink: #242629;
  --muted: #62676b; --faint: #666e73; --line: #dfe2e4; --grid: #eceff0;
  --accent: #087e7e; --accent-ink: #076a6a; --accent-wash: #e8f3f2;
  --copper: #a46042; --focus: #176a91; --danger: #a83737; --danger-wash: #fbeded;
  --disabled: #8a9094; --inactive: #c3c9cc; --on-accent: #ffffff;
  --control: 44px; --duration: 150ms; --switch-duration: 200ms; --selection-duration: 250ms;
  font-synthesis: none;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #171819; --surface: #1e2022; --subtle: #1a1c1e; --ink: #eceeef;
  --muted: #abb0b3; --faint: #a0a6aa; --line: #383b3e; --grid: #2b2e31;
  --accent: #6bc5bf; --accent-ink: #82d6cf; --accent-wash: #243c3b;
  --copper: #d4a28c; --focus: #8bcbdc; --danger: #ed9a9a; --danger-wash: #3b2527;
  --disabled: #80888c; --inactive: #555e62; --on-accent: #152725;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, select, input { font: inherit; color: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, select { min-height: var(--control); border: 1px solid var(--line); border-radius: 6px; background: var(--page); }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; cursor: pointer; white-space: nowrap; transition: background-color var(--duration), border-color var(--duration), color var(--duration), transform var(--duration); }
button:hover:not(:disabled) { background: var(--surface); border-color: var(--faint); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { color: var(--disabled); cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }
button.primary:disabled { opacity: .5; }
button[data-playing="true"] { border-color: var(--accent); }
.icon-button { width: var(--control); padding: 0; flex: 0 0 var(--control); }
select { padding: 0 28px 0 11px; max-width: 100%; font-variant-numeric: tabular-nums; }
a { color: var(--muted); text-decoration: none; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.lucide { width: 17px; height: 17px; stroke-width: 1.6; flex: 0 0 auto; }
.app-header, main { max-width: 1560px; margin-inline: auto; padding-inline: 32px; }
.app-header { height: 84px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: .5px solid var(--line); }
.brand, .header-actions, .quiet-link, .theme-picker { display: flex; align-items: center; }
.brand { gap: 14px; min-width: 0; }
h1 { margin: 0; font-size: 22px; font-weight: 500; white-space: nowrap; }
.brand > span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.brand .bank-meta { font-size: 12px; padding-left: 16px; border-left: .5px solid var(--line); }
.header-actions { gap: 22px; }
.quiet-link { gap: 8px; min-height: 44px; font-size: 13px; }
.theme-picker { gap: 6px; color: var(--muted); }
.theme-picker select { font-size: 12px; min-height: 36px; border-color: transparent; background: transparent; padding-left: 2px; }
.theme-picker select:hover { background: var(--surface); }
.transport { padding: 24px 0; display: flex; align-items: end; gap: 24px; border-bottom: .5px solid var(--line); }
.instrument-section { padding: 24px 0; border-bottom: .5px solid var(--line); }
.instrument-heading, .catalog-heading, .pitch-identity { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.instrument-heading > div { display: flex; align-items: baseline; gap: 15px; }
.instrument-heading span, .catalog-heading, .pitch-identity { color: var(--muted); font-size: 11px; }
#bellModel { position: relative; height: 360px; width: 100%; overflow: hidden; }
#bellModel canvas { width: 100%; height: 100%; }
#modelLabels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
#modelLabels > * { position: absolute; font-size: 11px; line-height: 1.2; color: var(--ink); background: var(--page); padding: 3px 4px; border: .5px solid var(--line); border-radius: 3px; transform: translate(-50%,-50%); }
#modelLabels > .selected, #modelLabels > [data-selected="true"] { color: var(--accent-ink); border-color: var(--accent); }
.model-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.catalog-heading { padding: 10px 0; }
.bell-catalog { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 6px; }
.bell-key { min-width: 0; min-height: 65px; padding: 8px 10px; display: flex; flex-direction: column; align-items: start; gap: 3px; border-radius: 4px; }
.bell-key[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.bell-name { display: flex; gap: 7px; align-items: baseline; font-size: 13px; }
.bell-name small, .bell-tone { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bell-tone { white-space: normal; text-align: left; }
.pitch-identity { padding-top: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; gap: 4px 16px; }
.sound-selectors { display: flex; gap: 10px; }
.sound-selectors label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
#bell { width: 177px; color: var(--ink); font-size: 14px; }
#layer { width: 73px; color: var(--ink); font-size: 14px; }
.commands { display: flex; gap: 8px; align-items: center; }
.commands .primary { min-width: 94px; }
#reference { min-width: 120px; }
.playback-readout { align-self: end; display: grid; grid-template-columns: 6px 1fr; align-items: center; gap: 2px 7px; min-width: 126px; padding-block: 1px; }
.status-dot { width: 5px; height: 5px; background: var(--muted); border-radius: 50%; }
body[data-playing="synth"] .status-dot, body[data-playing="reference"] .status-dot { background: var(--accent); }
#status { font-size: 12px; color: var(--muted); white-space: nowrap; }
#time { grid-column: 2; font-size: 14px; font-variant-numeric: tabular-nums; }
#time span { color: var(--muted); font-size: 11px; }
.monitor { margin-left: auto; min-width: 170px; width: 190px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 12px; }
.monitor > span { display: inline-flex; align-items: center; gap: 6px; }
.monitor output { color: var(--ink); font-variant-numeric: tabular-nums; }
input[type="range"] { margin: 0; grid-column: 1 / -1; width: 100%; min-height: 26px; accent-color: var(--accent); cursor: pointer; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; padding: 28px 0 22px; }
.visuals, .component-panel { min-width: 0; }
.component-panel { padding-left: 24px; border-left: .5px solid var(--line); position: sticky; top: 18px; align-self: start; }
h2 { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.5; }
.plot-heading { min-height: 36px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plot-heading > span { font-size: 11px; color: var(--muted); }
.plot-title, .channel-legend { display: flex; align-items: center; }
.plot-title { gap: 15px; }
.channel-legend { gap: 5px; font-size: 11px; color: var(--muted); }
.channel-legend i { width: 10px; height: 2px; margin-left: 5px; }
.left { background: var(--accent); } .right { background: var(--copper); }
.view-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; padding: 2px; background: var(--surface); border-radius: 5px; position: relative; isolation: isolate; }
.view-switch::before { content: ""; position: absolute; left: 2px; top: 2px; bottom: 2px; width: calc((100% - 6px) / 2); background: var(--page); border-radius: 3px; transform: translateX(calc(var(--selection, 0) * (100% + 2px))); transition: transform var(--selection-duration) cubic-bezier(.645,.045,.355,1); pointer-events: none; }
.view-switch button { min-height: 30px; padding: 0 10px; border: 0; font-size: 11px; border-radius: 3px; background: transparent; color: var(--muted); }
.view-switch button[aria-pressed="true"] { color: var(--ink); }
.view-switch button { position: relative; z-index: 1; }
.plot-surface { position: relative; min-width: 0; background: var(--subtle); border-top: .5px solid var(--line); border-bottom: .5px solid var(--line); transition: opacity var(--duration); }
canvas { display: block; width: 100%; height: 228px; }
#wave { height: 256px; }
#spectrum { cursor: crosshair; }
#waveCursor { display: none; position: absolute; top: 16px; bottom: 31px; left: 0; width: 1px; background: var(--ink); pointer-events: none; opacity: .5; }
#progress { display: block; width: 100%; height: 2px; border: 0; appearance: none; background: var(--line); margin-top: -1px; position: relative; }
#progress::-webkit-progress-bar { background: var(--line); }
#progress::-webkit-progress-value { background: var(--accent); }
.measurements { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 12px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; min-height: 32px; }
.sample-rate { margin-left: auto; }
.lower-plots { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.research-section { margin-top: 28px; }
#spectrogram { height: 260px; }
.spectral-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 14px; color: var(--muted); font-size: 11px; padding-top: 9px; }
.color-key { display: inline-flex; gap: 8px; align-items: center; }
.color-key > span { display: inline-flex; gap: 4px; align-items: center; }
.color-key i { width: 8px; height: 8px; background: color-mix(in srgb,var(--accent) var(--shade),var(--subtle)); border: .5px solid var(--line); }
.signal-metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; padding: 17px 0 0; }
.signal-metrics > div { display: flex; flex-direction: column; gap: 4px; }
.signal-metrics span { color: var(--muted); font-size: 11px; }
.signal-metrics output { font-size: 18px; font-variant-numeric: tabular-nums; }
.theory-strip { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; border-top: .5px solid var(--line); margin-top: 24px; padding-top: 18px; }
.theory-strip span { font-size: 11px; color: var(--muted); }
math { font-size: 16px; margin-block: 8px; max-width: 100%; }
math * { font-size: inherit; math-depth: 0; }
math msub > :nth-child(2), math msup > :nth-child(2) { font-size: 11px; }
.tau-readout { display: flex; flex-direction: column; gap: 7px; }
.tau-readout output { font-size: 18px; font-variant-numeric: tabular-nums; }
.method-notes { border-top: .5px solid var(--line); padding: 20px 0; }
.method-notes summary { font-size: 13px; cursor: pointer; color: var(--muted); min-height: 24px; }
.method-copy { max-width: 880px; padding-top: 12px; font-size: 14px; line-height: 1.85; color: var(--muted); }
.method-copy p { margin: 0 0 12px; }
.method-references { font-size: 12px; padding-left: 22px; }
.plot-readout { position: absolute; right: 12px; top: 8px; color: var(--accent-ink); font-size: 11px; font-variant-numeric: tabular-nums; pointer-events: none; background: var(--subtle); padding-left: 4px; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; min-height: 36px; }
.panel-heading > span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.segments { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; border: 0; border-radius: 5px; background: var(--surface); padding: 3px; margin: 10px 0 16px; position: relative; isolation: isolate; }
.segments::before { content: ""; position: absolute; left: 3px; top: 3px; bottom: 3px; width: calc((100% - 18px) / 5); background: var(--page); border-radius: 3px; transform: translateX(calc(var(--selection, 4) * (100% + 3px))); transition: transform var(--selection-duration) cubic-bezier(.645,.045,.355,1), opacity var(--duration); pointer-events: none; }
.segments[data-custom="true"]::before { opacity: 0; }
.segments button { min-height: 34px; padding: 0; border: 0; background: transparent; border-radius: 3px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.segments button[aria-pressed="true"] { color: var(--accent-ink); }
.partial-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.partial { position: relative; display: flex; min-width: 0; min-height: 50px; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: .5px solid var(--line); border-radius: 4px; color: var(--muted); cursor: pointer; background: var(--page); transition: background-color var(--duration), border-color var(--duration), color var(--duration), transform var(--duration); font-variant-numeric: tabular-nums; }
.partial input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.partial span { font-size: 12px; line-height: 1.3; }
.partial small { font-size: 11px; line-height: 1.3; color: var(--faint); }
.partial:has(input:checked) { color: var(--ink); border-color: var(--inactive); }
.partial:has(input:not(:checked)) { background: var(--surface); }
.partial:has(input:not(:checked)) span { text-decoration: line-through; }
.partial:hover { border-color: var(--accent); }
.partial:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.partial:active { transform: translateY(1px); }
.partial.selected { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-ink); }
.inspector { margin-top: 20px; padding-top: 15px; border-top: .5px solid var(--line); }
.component-select { display: flex; align-items: center; gap: 8px; justify-content: space-between; color: var(--muted); font-size: 12px; }
.component-select select { width: 164px; min-height: 34px; font-size: 12px; }
#parameters { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 12px; margin: 15px 0 20px; font-variant-numeric: tabular-nums; }
#parameters div { min-width: 0; }
dt { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
dd { margin: 0; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
#parameters div:first-child dd, #parameters div:nth-child(2) dd { font-size: 18px; }
.corrections { padding-top: 10px; border-top: .5px solid var(--line); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; position: relative; cursor: pointer; font-size: 12px; }
.switch-row input { position: absolute; right: 0; width: 40px; height: 30px; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { display: block; width: 29px; height: 17px; border-radius: 9px; background: var(--inactive); flex: 0 0 auto; pointer-events: none; transition: background-color var(--switch-duration) cubic-bezier(.215,.61,.355,1); }
.switch-track::after { content: ""; display: block; width: 11px; height: 11px; border-radius: 50%; background: var(--page); margin: 3px; transition: transform var(--switch-duration) cubic-bezier(.215,.61,.355,1); }
.switch-row input:checked + .switch-track { background: var(--accent); }
.switch-row input:checked + .switch-track::after { transform: translateX(12px); }
.switch-row input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 3px; }
.switch-row:has(input:disabled) { opacity: .45; cursor: default; }
.source-line { display: flex; gap: 14px; margin-top: 19px; padding-top: 14px; border-top: .5px solid var(--line); color: var(--muted); font-size: 11px; min-width: 0; }
#origin { white-space: nowrap; color: var(--accent-ink); }
#identity { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
footer { display: flex; align-items: center; gap: 22px; padding: 18px 0 26px; border-top: .5px solid var(--line); color: var(--muted); font-size: 11px; }
footer > span { margin-right: auto; }
footer a { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; }
footer .lucide { width: 14px; height: 14px; }
#error { margin-top: 16px; padding: 12px 16px; color: var(--danger); background: var(--danger-wash); border-left: 2px solid var(--danger); overflow-wrap: anywhere; }
body[data-busy="true"] .measurements, body[data-busy="true"] .plot-surface { opacity: .65; }
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px); padding: 6px 9px; border-radius: 4px; background: var(--ink); color: var(--page); font-size: 11px; font-weight: 400; line-height: 1.5; white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; z-index: 5; transition: opacity var(--duration) ease-out, transform var(--duration) ease-out, visibility var(--duration); }
.header-actions [data-tip]::after { bottom: auto; top: calc(100% + 8px); }
#resetModel[data-tip]::after { left: auto; right: 0; transform: translateY(4px); }
#resetModel[data-tip]:hover::after, #resetModel[data-tip]:focus-visible::after { transform: translateY(0); }
[data-tip]:focus-visible::after, .partial:has(input:focus-visible)::after { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.partial[data-tip]::after { width: max-content; max-width: 205px; white-space: normal; left: 0; transform: translate(0, 4px); }
.partial:nth-child(6n+4)::after, .partial:nth-child(6n+5)::after, .partial:nth-child(6n+6)::after { left: auto; right: 0; }
.partial:has(input:focus-visible)::after { transform: translateY(0); }
.partial:has(input:focus-visible) { z-index: 3; }
@media (hover: hover) {
  [data-tip]:hover::after { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
  .partial[data-tip]:hover::after { transform: translateY(0); }
  .partial:hover { z-index: 3; }
}
.skip-link { position: absolute; left: 16px; top: -100px; padding: 10px; background: var(--page); z-index: 2; }
.skip-link:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 1250px) {
  .transport { gap: 16px; flex-wrap: wrap; }
  .monitor { width: 170px; }
  .playback-readout { margin-right: auto; }
  .workspace { grid-template-columns: minmax(0,1fr) 295px; gap: 24px; }
  .component-panel { padding-left: 20px; }
}
@media (max-width: 1050px) {
  .app-header, main { padding-inline: 24px; }
  .workspace { grid-template-columns: minmax(0,1fr); gap: 28px; }
  .component-panel { padding: 24px 0 0; border-left: 0; border-top: .5px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 28px; }
  .component-panel { position: static; }
  .bell-catalog { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .panel-heading, .segments, .partial-grid { grid-column: 1; }
  .parameter-column { grid-column: 2; grid-row: 1 / span 3; min-width: 0; }
  .inspector { margin-top: 0; padding-top: 0; border: 0; }
  .partial { min-height: 46px; }
}
@media (max-width: 620px) {
  .app-header, main { padding-inline: 18px; }
  .app-header { height: 72px; gap: 12px; }
  .brand { gap: 10px; }
  .brand > span { font-size: 12px; }
  .brand .bank-meta { display: none; }
  .header-actions { gap: 10px; }
  .quiet-link span { display: none; }
  .quiet-link { width: 44px; justify-content: center; }
  .theme-picker { gap: 1px; }
  .theme-picker select { width: 82px; min-height: 44px; padding-right: 18px; }
  .transport { padding: 18px 0; gap: 16px 12px; }
  .instrument-heading > div { display: block; }
  .instrument-heading span { display: block; margin-top: 4px; }
  #bellModel { height: 300px; }
  .bell-catalog { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .catalog-heading { align-items: baseline; }
  .catalog-heading > span:last-child { text-align: right; }
  .bell-key { min-height: 64px; }
  .pitch-identity { align-items: start; flex-direction: column; }
  .signal-metrics { gap: 8px; }
  .signal-metrics output { font-size: 16px; }
  .signal-metrics span { min-height: 32px; }
  .sound-selectors { flex: 1; }
  #bell { width: 170px; }
  #layer { width: 72px; }
  .commands { order: 3; flex: 1; gap: 6px; }
  .commands .primary { min-width: 82px; padding-inline: 12px; }
  #reference { min-width: 108px; padding-inline: 10px; }
  .playback-readout { order: 4; min-width: 0; width: 100%; display: flex; margin: 0; gap: 8px; }
  #time { margin-left: auto; }
  .monitor { width: 100%; min-width: 0; order: 5; grid-template-columns: auto 1fr auto; gap: 12px; margin: 0; }
  .monitor input { grid-column: 2; grid-row: 1; min-width: 0; }
  .monitor output { grid-column: 3; grid-row: 1; min-width: 39px; text-align: right; }
  .workspace { padding-top: 20px; }
  .plot-title { gap: 8px; }
  h2 { font-size: 16px; }
  .view-switch button { min-height: 44px; padding-inline: 7px; }
  .channel-legend { gap: 3px; }
  .channel-legend i { width: 7px; margin-left: 2px; }
  #wave { height: 220px; }
  .measurements { gap: 6px 10px; }
  .sample-rate { margin-left: 0; }
  .lower-plots { grid-template-columns: minmax(0,1fr); gap: 24px; margin-top: 24px; }
  .component-panel { display: block; }
  .segments { margin-top: 10px; }
  .segments button { min-height: 44px; }
  .partial { min-height: 53px; }
  .inspector { margin-top: 20px; padding-top: 15px; border-top: .5px solid var(--line); }
  .corrections { margin: 0; }
  .switch-row { min-height: 44px; }
  .component-select select { min-height: 40px; width: 180px; }
  .source-line { flex-direction: column; gap: 5px; }
  #identity { font-size: 11px; }
  footer { gap: 14px; flex-wrap: wrap; }
  footer > span { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --duration: 0ms; --switch-duration: 0ms; --selection-duration: 0ms; }
  button:active:not(:disabled), .partial:active { transform: none; }
}
@media (max-width: 360px) {
  .commands .primary, #reference { min-width: 0; padding-inline: 8px; font-size: 12px; }
  .plot-heading { flex-wrap: wrap; }
}
