/* Mixnetic Tools – Studio Teal. Scoped to .mx-tool. */
.mx-tool {
  --mx-bg: #101719; --mx-section: #172124; --mx-card: #202D30; --mx-border: #526568;
  --mx-text: #F1F7F6; --mx-text2: #BDCECF; --mx-accent: #7DE0CF; --mx-accent2: #A7C8FF;
  --mx-ok: #9BE7A6; --mx-stripe: #263639; --mx-input: #111C1E; --mx-hover: #2C4143;
  --mx-active: #345554; --mx-tab-off: #263638; --mx-white: #F1F3EF; --mx-black: #202628;
  --mx-hl: #63CBB7; --mx-komal: #F5A7A7; --mx-tivra: #91C8FF; --mx-error: #FFB4A8;
  --mx-wk: 40px; --mx-bk: 26px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--mx-text2); font-size: 16px; line-height: 1.6;
  min-height: 420px; /* reserve space before JS paints, reduces layout shift */
}
.mx-tool[data-mx-ready] { min-height: 0; }
.mx-tool *, .mx-tool *::before, .mx-tool *::after { box-sizing: border-box; }
.mx-tool button, .mx-tool input, .mx-tool select { font: inherit; }
.mx-tool :focus-visible { outline: 2px solid var(--mx-accent2); outline-offset: 2px; }
.mx-tool [hidden] { display: none !important; }
.mx-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mx-noscript { padding: 16px; background: #202D30; color: #F1F7F6; border-radius: 12px; }

.mx-stack { display: flex; flex-direction: column; gap: 24px; }
.mx-card { background: var(--mx-card); border: 1px solid var(--mx-border); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.mx-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mx-grid2--top { gap: 24px; align-items: stretch; }
.mx-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.mx-h { margin: 0; color: var(--mx-text); font-size: 24px; line-height: 1.25; font-weight: 700; }
.mx-h3 { margin: 8px 0 0; color: var(--mx-text); font-size: 17px; line-height: 1.3; font-weight: 600; }
.mx-help { margin: 0; font-size: 14px; color: var(--mx-text2); }
.mx-hint, .mx-note { margin: 0; font-size: 14px; }
.mx-note { border-left: 3px solid var(--mx-accent2); padding-left: 12px; }

/* Fields */
.mx-field { display: flex; flex-direction: column; gap: 6px; }
.mx-label { color: var(--mx-text); font-weight: 600; font-size: 15px; }
.mx-input, .mx-select {
  min-height: 48px; padding: 10px 14px; background: var(--mx-input); color: var(--mx-text);
  border: 1px solid var(--mx-border); border-radius: 8px; width: 100%;
}
.mx-tool .mx-input--bpm { max-width: 220px; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mx-input[aria-invalid="true"] { border-color: var(--mx-error); }
.mx-error { margin: 0; min-height: 1.2em; font-size: 14px; color: var(--mx-error); }
.mx-error:not(:empty)::before { content: "⚠ "; }
.mx-select { appearance: auto; }

/* Buttons */
.mx-btn { min-height: 48px; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; border: 1px solid transparent; }
.mx-btn--tap { width: 100%; min-height: 120px; font-size: 28px; letter-spacing: 2px; text-transform: uppercase; background: var(--mx-accent); color: #101719; }
.mx-btn--tap:hover { background: #9BE7D9; }
.mx-btn--tap.is-pulse { animation: mx-pulse .12s ease-out; }
@keyframes mx-pulse { from { transform: scale(.98); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .mx-btn--tap.is-pulse { animation: none; } }
.mx-btn--outline { background: transparent; color: var(--mx-accent); border-color: var(--mx-accent); }
.mx-btn--outline:hover { background: var(--mx-hover); }
.mx-btn--quiet { background: transparent; color: var(--mx-text2); border-color: var(--mx-border); }
.mx-btn--quiet:hover { background: var(--mx-hover); color: var(--mx-text); }
.mx-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Tabs */
.mx-tabs { display: flex; gap: 4px; background: var(--mx-input); padding: 4px; border-radius: 10px; width: fit-content; max-width: 100%; }
.mx-tab { min-height: 44px; padding: 8px 22px; border: 0; border-radius: 8px; background: var(--mx-tab-off); color: var(--mx-text2); cursor: pointer; font-weight: 600; }
.mx-tab[aria-selected="true"] { background: var(--mx-accent); color: #101719; }
.mx-tab[aria-selected="false"]:hover { background: var(--mx-hover); color: var(--mx-text); }
.mx-tabs-wrap { display: flex; flex-direction: column; gap: 16px; }

/* Segmented control */
.mx-seg { display: inline-flex; gap: 4px; background: var(--mx-input); padding: 4px; border-radius: 10px; width: fit-content; max-width: 100%; flex-wrap: wrap; }
.mx-seg-btn { min-height: 44px; padding: 8px 18px; border: 0; border-radius: 8px; background: transparent; color: var(--mx-text2); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.mx-seg-tick { display: none; }
.mx-seg-btn[aria-checked="true"] { background: var(--mx-accent); color: #101719; }
.mx-seg-btn[aria-checked="true"] .mx-seg-tick { display: inline; }

/* Tables */
.mx-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 0; }
.mx-table th, .mx-table td { padding: 10px 12px; text-align: left; border: 0; border-bottom: 1px solid var(--mx-stripe); vertical-align: middle; }
.mx-table thead th { color: var(--mx-text); font-size: 14px; font-weight: 600; background: var(--mx-section); }
.mx-table tbody tr:nth-child(even) { background: var(--mx-stripe); }
.mx-rowhead { color: var(--mx-text); font-weight: 600; }
.mx-sub { display: block; font-size: 13px; font-weight: 400; color: var(--mx-text2); }
.mx-tool.is-stale .mx-val, .mx-card.is-stale .mx-val { opacity: .4; }

/* Copy value buttons */
.mx-val {
  position: relative; display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; min-height: 44px;
  padding: 6px 10px; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--mx-text);
  cursor: pointer; text-align: left; font-variant-numeric: tabular-nums;
}
.mx-val:hover { background: var(--mx-hover); border-color: var(--mx-border); }
.mx-num { font-size: 22px; font-weight: 600; }
.mx-unit { font-size: 14px; color: var(--mx-text2); }
.mx-hz { flex-basis: 100%; font-size: 12px; color: var(--mx-text2); }
.mx-hz:empty { display: none; }
.mx-copied { position: absolute; top: -10px; right: -4px; padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 999px; background: var(--mx-ok); color: #101719; opacity: 0; transition: opacity .15s; pointer-events: none; }
.mx-val.is-copied .mx-copied { opacity: 1; }
.mx-val.is-copied { border-color: var(--mx-ok); }
.mx-val--big .mx-num { font-size: 28px; }

.mx-details summary { cursor: pointer; color: var(--mx-accent2); font-size: 14px; font-weight: 600; }
.mx-details ul { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.mx-details li { margin: 4px 0; }

/* BPM tool */
.mx-tap { display: flex; flex-direction: column; gap: 14px; }
.mx-readout { display: flex; align-items: baseline; gap: 8px; }
.mx-big { font-size: 56px; line-height: 1; font-weight: 700; color: var(--mx-ok); font-variant-numeric: tabular-nums; }
.mx-unit-big { font-size: 18px; color: var(--mx-text2); font-weight: 600; }
.mx-results { display: flex; flex-direction: column; gap: 12px; }
.mx-result { display: flex; flex-direction: column; gap: 2px; padding: 12px; background: var(--mx-input); border-radius: 10px; }
.mx-result-label { font-size: 14px; }

/* Scale finder */
.mx-mode { display: flex; flex-direction: column; gap: 14px; }
.mx-scale-title { margin: 4px 0 0; font-size: 22px; font-weight: 700; color: var(--mx-text); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.mx-tag { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--mx-active); color: var(--mx-text); }
.mx-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mx-table--notes th[scope="row"] { color: var(--mx-text2); font-size: 14px; font-weight: 600; white-space: nowrap; }
.mx-table--notes td { color: var(--mx-text); font-weight: 600; text-align: center; min-width: 52px; }
.mx-chords { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.mx-chord { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; background: var(--mx-input); border: 1px solid var(--mx-stripe); border-radius: 10px; }
.mx-chord-num { font-size: 13px; color: var(--mx-accent); font-weight: 600; }
.mx-chord-name { font-size: 18px; color: var(--mx-text); font-weight: 700; }
.mx-picked { margin: 0; color: var(--mx-text); font-weight: 600; flex: 1 1 200px; }
.mx-count { margin: 0; font-size: 14px; }
.mx-match-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.mx-match { width: 100%; min-height: 48px; text-align: left; padding: 10px 12px; background: var(--mx-input); border: 1px solid var(--mx-stripe); border-radius: 10px; color: var(--mx-text); cursor: pointer; display: flex; flex-direction: column; }
.mx-match:hover { border-color: var(--mx-accent); }
.mx-match-name { font-weight: 700; }
.mx-match-sub { font-size: 13px; color: var(--mx-text2); }

/* Piano */
.mx-piano { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 0 8px; }
.mx-keys { position: relative; display: flex; height: 170px; }
.mx-key { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; border: 0; padding: 0 0 8px; margin: 0; font-size: 11px; font-weight: 700; }
.mx-key--white { width: var(--mx-wk); flex: 0 0 var(--mx-wk); height: 100%; background: var(--mx-white); border: 1px solid #9AA7A8; border-radius: 0 0 6px 6px; color: #101719; }
.mx-key--black { position: absolute; top: 0; z-index: 2; width: var(--mx-bk); height: 62%; background: var(--mx-black); border: 1px solid #000; border-radius: 0 0 5px 5px; color: var(--mx-text); padding-bottom: 6px; }
button.mx-key { cursor: pointer; }
.mx-key-dot { display: none; width: 10px; height: 10px; border-radius: 50%; background: #101719; border: 2px solid #fff; margin-bottom: 4px; }
.mx-key-label { line-height: 1.1; text-align: center; }
.mx-key-name { position: absolute; bottom: 2px; font-size: 9px; font-weight: 600; color: #5B6668; }
.mx-key.is-on .mx-key-name { display: none; }
.mx-key--white.is-on { background: var(--mx-hl); }
.mx-key--black.is-on { background: #2E8E7E; }
.mx-key.is-on .mx-key-dot { display: block; }
.mx-key.is-root .mx-key-dot { border-radius: 2px; background: #FFD08A; }
.mx-key--black .mx-key-label { font-size: 9px; }

/* Raga notation */
.mx-chip-group { display: flex; flex-direction: column; gap: 8px; }
.mx-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mx-chip { min-height: 48px; padding: 6px 12px; background: var(--mx-input); border: 1px solid var(--mx-stripe); border-radius: 10px; color: var(--mx-text); cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.25; }
.mx-chip:hover { border-color: var(--mx-accent); }
.mx-chip[aria-pressed="true"] { background: var(--mx-active); border-color: var(--mx-accent); box-shadow: inset 3px 0 0 var(--mx-accent); }
.mx-chip-a { font-weight: 700; font-size: 15px; }
.mx-chip-b { font-size: 12px; color: var(--mx-text2); }
.mx-raga-out { display: flex; flex-direction: column; gap: 12px; }
.mx-raga-head { display: flex; flex-direction: column; gap: 4px; }
.mx-equiv { margin: 0; font-size: 18px; color: var(--mx-text); }
.mx-equiv strong { color: var(--mx-accent); }
.mx-equiv-label { color: var(--mx-text2); font-size: 15px; }
.mx-swaras { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.mx-swara { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; background: var(--mx-input); border: 1px solid var(--mx-stripe); border-radius: 10px; }
.mx-swara .mx-sw { font-size: 26px; }
.mx-swara-name { color: var(--mx-text); font-weight: 600; }
.mx-west-big { font-size: 18px; color: var(--mx-text); font-weight: 700; }
.mx-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--mx-stripe); color: var(--mx-text2); }
.mx-badge--komal { background: var(--mx-komal); color: #101719; }
.mx-badge--tivra { background: var(--mx-tivra); color: #101719; }
.mx-line { display: flex; flex-wrap: wrap; gap: 6px; }
.mx-cell { display: flex; flex-direction: column; align-items: center; min-width: 46px; padding: 8px 6px 6px; background: var(--mx-input); border-radius: 8px; }
.mx-cell .mx-sw { font-size: 20px; }
.mx-west { font-size: 13px; color: var(--mx-text2); font-weight: 600; }
.mx-sw { position: relative; display: inline-block; color: var(--mx-text); font-weight: 700; line-height: 1.2; padding: 4px 2px; }
.mx-sw--komal > span:first-child { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; color: var(--mx-komal); }
.mx-sw--tivra > span:first-child { color: var(--mx-tivra); }
.mx-sw--tivra::before { content: ""; position: absolute; top: -2px; left: 50%; width: 2px; height: .4em; background: var(--mx-tivra); transform: translateX(-50%); }
.mx-sw--taar::after, .mx-sw--mandra::after { content: ""; position: absolute; left: 50%; width: 5px; height: 5px; border-radius: 50%; background: currentColor; transform: translateX(-50%); }
.mx-sw--taar::after { top: -1px; }
.mx-sw--tivra.mx-sw--taar::after { top: -8px; }
.mx-sw--mandra::after { bottom: -3px; }
.mx-details li .mx-sw { font-size: 18px; margin-right: 6px; }

/* Mobile */
@media (max-width: 767px) {
  .mx-card { padding: 16px; }
  .mx-grid2 { grid-template-columns: 1fr; }
  .mx-big { font-size: 48px; }
  .mx-num { font-size: 20px; }
  .mx-tool { --mx-wk: 36px; --mx-bk: 22px; }
  /* Wide tables become labelled cards */
  .mx-table--cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .mx-table--cards, .mx-table--cards tbody, .mx-table--cards tr, .mx-table--cards th, .mx-table--cards td { display: block; width: 100%; }
  .mx-table--cards tr { background: var(--mx-input) !important; border: 1px solid var(--mx-stripe); border-radius: 10px; margin-bottom: 10px; padding: 6px 4px; }
  .mx-table--cards th[scope="row"] { border: 0; padding: 8px 10px 4px; }
  .mx-table--cards td { display: flex; justify-content: space-between; align-items: center; border: 0; padding: 2px 10px; }
  .mx-table--cards td::before { content: attr(data-label); font-size: 14px; color: var(--mx-text2); font-weight: 600; }
}

/* ---- Reverb & Delay: single-view layout ---- */
.mx-rd { display: flex; flex-direction: column; gap: 32px; }
.mx-bpm-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 28px 20px; background: var(--mx-card); border: 1px solid var(--mx-border); border-radius: 14px; }
.mx-label--hero { font-size: 18px; }
.mx-bpm-row { display: flex; align-items: stretch; gap: 10px; width: 100%; max-width: 520px; }
.mx-tool .mx-input--hero { max-width: none; flex: 1; text-align: center; font-size: 30px; font-weight: 700; min-height: 60px; border: 2px solid var(--mx-accent); color: var(--mx-text); }
.mx-tool .mx-step { min-width: 60px; border-radius: 8px; border: 1px solid var(--mx-border); background: var(--mx-input); color: var(--mx-accent); font-size: 26px; font-weight: 700; cursor: pointer; }
.mx-step:hover { background: var(--mx-hover); color: var(--mx-text); }
.mx-block { display: flex; flex-direction: column; gap: 14px; }
.mx-block .mx-h { font-size: 26px; }
.mx-table--striped { border-radius: 12px; overflow: hidden; border: 1px solid var(--mx-stripe); }
.mx-table--striped thead th { background: transparent; color: var(--mx-text2); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; padding: 14px 12px; border-bottom: 1px solid var(--mx-border); }
.mx-table--striped tbody tr { background: var(--mx-card); }
.mx-table--striped tbody tr:nth-child(odd) { background: rgba(125, 224, 207, .15); }
.mx-table--striped tbody tr:hover { background: rgba(125, 224, 207, .2); }
.mx-table--striped td, .mx-table--striped th { border-bottom: 0; }
.mx-table--striped .mx-num { font-size: 17px; }
.mx-table--striped .mx-hz { flex-basis: auto; font-size: 14px; color: var(--mx-text2); }
.mx-sub-inline { font-weight: 400; color: var(--mx-text2); font-size: 14px; }
@media (max-width: 767px) {
  .mx-bpm-hero { padding: 20px 14px; }
  .mx-tool .mx-input--hero { font-size: 26px; }
  .mx-step { min-width: 52px; }
  .mx-block .mx-h { font-size: 22px; }
  .mx-table--striped { border: 0; }
  .mx-table--striped tbody tr:nth-child(odd) { background: rgba(125, 224, 207, .15) !important; }
  .mx-table--striped .mx-hz { font-size: 12px; }
}
.mx-bpm-hero .mx-error:empty { display: none; }
