/* ToneSolver · tools (tuner, metronome, capo, pedal order). Tool-specific styles only: tokens, buttons, cards, chips and
   form controls come from site.css. Every class here is prefixed (tool-, tn-, mt-, cp-, po-) so nothing collides. */

/* ---------------------------------------------------------------- shared */
.tool { display: grid; gap: 20px; min-width: 0; padding-bottom: clamp(48px, 7vw, 88px); }
.tool > * { min-width: 0; }
.tool [hidden] { display: none !important; }
.tool .card { display: grid; gap: 24px; }
.tool .card > * { min-width: 0; }
.tool .card h2, .tool .card h3 { margin-bottom: 0; }
.tool .card p + p { margin-top: 0; }
.tool button { font-family: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.tool-block { display: grid; gap: 10px; min-width: 0; }

.tool-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-opt { min-height: 40px; min-width: 44px; padding: 0 15px; border-radius: 980px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 15px; line-height: 1.2; cursor: pointer; transition: border-color 0.2s, background 0.2s, color 0.2s; }
.tool-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.tool-stepper { display: flex; align-items: center; gap: 8px; }
.tool-step { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0 0 2px; border: 0; border-radius: 50%; background: var(--bg-alt); color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer; transition: background 0.2s, transform 0.2s; }
.tool-step:active { transform: scale(0.94); }

.tool-opt:focus-visible, .tool-step:focus-visible, .tn-string:focus-visible, .cp-opt:focus-visible, .cp-x:focus-visible, .po-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tool-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 32px; margin: 0; padding: 0; background: transparent; cursor: pointer; }
.tool-range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--line) var(--fill, 0%)); }
.tool-range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
.tool-range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
.tool-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.28); }
.tool-range::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.28); }
.tool-range:focus-visible { outline: 0; box-shadow: none; }
.tool-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 1.5px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.28); }
.tool-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 1.5px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.28); }

.tool-switch { position: relative; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; line-height: 1.3; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tool-switch input { position: absolute; left: 0; top: 50%; width: 1px; height: 1px; margin: 0; opacity: 0; }
.tool-switch-ui { flex: none; position: relative; width: 46px; height: 28px; border-radius: 980px; background: var(--line); transition: background 0.25s; }
.tool-switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tool-switch input:checked + .tool-switch-ui { background: var(--green); }
.tool-switch input:checked + .tool-switch-ui::after { transform: translateX(18px); }
.tool-switch input:focus-visible + .tool-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- tuner */
.tn-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.tn-a4-box { position: relative; display: inline-flex; align-items: center; }
.tn-a4-box .input { width: 108px; padding: 0 42px 0 12px; text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.tn-a4-box .input::-webkit-outer-spin-button, .tn-a4-box .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tn-a4-box span { position: absolute; right: 14px; color: var(--ink-3); font-size: 15px; pointer-events: none; }

.tn-display { display: grid; justify-items: center; gap: 6px; padding-top: 4px; text-align: center; }
.tn-note { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); width: 100%; font-size: clamp(96px, 26vw, 136px); line-height: 1; font-weight: 600; letter-spacing: -0.03em; color: var(--ink); transition: color 0.2s; }
.tn-letter { grid-column: 2; min-width: 0.62em; text-align: center; }
.tn-side { grid-column: 3; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; padding: 0.3em 0 0.42em 0.12em; font-size: 0.28em; letter-spacing: 0; }
.tn-acc { min-height: 1em; font-size: 1.3em; line-height: 1; }
.tn-oct { min-height: 1em; line-height: 1; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tn-display[data-signal="0"] .tn-note { color: var(--ink-3); }
.tn-display[data-tune="ok"] .tn-note { color: var(--green); }
.tn-readout { display: flex; justify-content: center; align-items: baseline; gap: 14px; min-height: 1.5em; font-variant-numeric: tabular-nums; }
.tn-cents { font-weight: 600; }
.tn-freq { color: var(--ink-2); }

.tn-meter { position: relative; width: 100%; max-width: 520px; height: 48px; margin-top: 14px; }
.tn-ticks { position: absolute; left: 0; bottom: 9px; width: 100%; height: 30px; max-width: none; overflow: visible; }
.tn-ticks line { stroke: var(--line); stroke-width: 1.5; stroke-linecap: round; }
.tn-zone { position: absolute; top: 0; bottom: 0; left: 45%; width: 10%; border-radius: 8px; background: color-mix(in srgb, var(--green) 16%, transparent); }
.tn-needle { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
.tn-needle i { position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; border-radius: 4px; background: var(--ink); transition: background 0.2s, opacity 0.3s; }
.tn-display[data-signal="0"] .tn-needle i { opacity: 0.22; }
.tn-display[data-tune="ok"] .tn-needle i { background: var(--green); }
.tn-scale { display: flex; justify-content: space-between; width: 100%; max-width: 520px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tn-scale span { min-width: 3ch; }
.tn-scale span:first-child { text-align: left; }
.tn-scale span:last-child { text-align: right; }
.tn-hint { min-height: 1.5em; margin-top: 6px; font-size: 17px; font-weight: 500; color: var(--ink-2); }
.tn-display[data-tune="ok"] .tn-hint { color: var(--green); }

.tn-strings { display: flex; gap: 6px; width: 100%; }
.tn-strings.is-chromatic { justify-content: center; }
.tn-string { flex: 1 1 0; min-width: 0; height: 56px; padding: 0; border-radius: 14px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 19px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: border-color 0.2s, background 0.2s, color 0.2s; }
.tn-string small { margin-left: 1px; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.tn-string.is-playing { background: var(--accent-soft); }
.tn-string.is-near { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tn-string.is-ok { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); color: var(--green); }
.tn-strings-hint { margin-top: -14px; text-align: center; }
.tn-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.tn-start { min-width: 148px; }
.tn-state { flex: 1 1 200px; min-width: 0; display: grid; gap: 8px; }
.tn-level { display: block; height: 3px; border-radius: 3px; background: var(--line-soft); overflow: hidden; opacity: 0; transition: opacity 0.3s; }
.tn-level i { display: block; height: 100%; background: var(--ink-3); transform: scaleX(0); transform-origin: left center; }
.tool[data-state="listening"] .tn-level { opacity: 1; }

/* ---------------------------------------------------------------- metronome */
.mt-card { justify-items: center; text-align: center; }
.mt-beats { display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%; min-height: 30px; }
.mt-beats[data-count="12"] { gap: 6px; }
.mt-dot { flex: 0 1 18px; max-width: 18px; aspect-ratio: 1; border-radius: 50%; background: var(--line); transition: background 0.3s; }
.mt-dot.is-weak { flex-basis: 12px; max-width: 12px; }
.mt-dot.is-group { margin-left: 8px; }
.mt-dot.is-accent { box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 3.5px var(--line); }
.mt-dot.on { background: var(--accent); transition: none; }
.mt-dot.is-accent.on { box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 3.5px var(--accent); }
.mt-tempo { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 28px); width: 100%; }
.mt-bpm { display: grid; justify-items: center; cursor: text; }
.mt-bpm input { width: 2.2em; padding: 0; border: 0; border-radius: 16px; background: transparent; color: var(--ink); font-size: clamp(64px, 18vw, 96px); line-height: 1.05; font-weight: 600; letter-spacing: -0.03em; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; transition: background 0.2s, box-shadow 0.2s; }
.mt-bpm input::-webkit-outer-spin-button, .mt-bpm input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mt-bpm input:focus { outline: 0; background: var(--bg-alt); box-shadow: 0 0 0 4px var(--accent-soft); }
.mt-unit { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-3); }
.mt-name { display: grid; gap: 2px; margin-top: -10px; }
.mt-italian { font-size: 19px; font-style: italic; color: var(--ink-2); }
.mt-pulse { font-size: 13px; color: var(--ink-3); }
.mt-card .tool-range { max-width: 480px; }
.mt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 480px; }
.mt-actions .btn { min-width: 0; padding: 0 12px; }
.mt-keys { margin-top: -12px; }
.mt-notice { width: 100%; text-align: left; }
.mt-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 32px; align-items: center; }
.mt-sigs .tool-opt { min-width: 56px; font-variant-numeric: tabular-nums; }
@media (hover: none) { .mt-keys { display: none; } }

/* ---------------------------------------------------------------- capo */
.cp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.cp-tabs { display: flex; max-width: 100%; border-radius: 22px; }
.cp-tabs button { flex: 1 1 auto; min-height: 38px; border-radius: 19px; line-height: 1.25; }
.cp-spell .tool-opt { min-height: 36px; font-size: 14px; }
.cp-frets { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 6px; }
.cp-frets .tool-opt { min-width: 0; padding: 0; font-variant-numeric: tabular-nums; }
.cp-shapes .tool-opt { min-width: 54px; }
.cp-add { display: flex; gap: 8px; margin-top: 4px; }
.cp-add .input { flex: 1 1 auto; min-width: 0; }
.cp-add .btn { flex: none; min-height: 48px; }
.cp-error { color: var(--red); }
.cp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.cp-results { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.cp-pair { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; min-width: 0; padding: 14px 8px 14px 16px; border-radius: 14px; background: var(--bg-alt); }
.cp-pair-main { display: grid; gap: 2px; min-width: 0; }
.cp-pair-shape { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.cp-pair b { font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.cp-x { flex: none; width: 32px; height: 32px; margin-top: -6px; padding: 0 0 2px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); font-size: 19px; line-height: 1; cursor: pointer; transition: background 0.2s, color 0.2s; }
.cp-empty { grid-column: 1 / -1; }
.cp-where { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.cp-ranked { display: grid; gap: 14px; min-width: 0; }
.cp-best { display: grid; gap: 6px; }
.cp-best-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 19px; line-height: 1.25; }
.cp-best-title b { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.cp-options-title { margin-top: 10px; }
.cp-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cp-opt { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; width: 100%; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line-soft); background: var(--bg-raised); color: var(--ink); font-size: 15px; text-align: left; cursor: pointer; transition: border-color 0.2s; }
.cp-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cp-opt-fret { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; }
.cp-opt-shapes { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.cp-shape { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 980px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.cp-shape.e2 { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.cp-shape.e1 { background: var(--bg-alt); color: var(--ink-2); }
.cp-shape.e0 { box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-3); }
.cp-opt-score { font-size: 13px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tool .cp-table { gap: 12px; }
.cp-keys { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.cp-keys li { display: flex; justify-content: center; padding: 11px 4px; border-radius: 12px; background: var(--bg-alt); font-size: 15px; white-space: nowrap; }
.cp-keys li > span[aria-hidden] { display: inline-flex; align-items: baseline; gap: 6px; }
.cp-keys b { font-weight: 600; }
.cp-key-from { color: var(--ink-2); }
.cp-arrow { color: var(--ink-3); }

/* ---------------------------------------------------------------- pedal order */
.po-groups { display: grid; gap: 16px; }
.po-group { display: grid; gap: 8px; }
.po-board-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 32px; }
.po-board-actions { display: inline-flex; gap: 8px; }
.po-chips { align-items: center; min-height: 32px; }
.po-chip { height: 32px; padding: 0 10px 0 13px; border: 0; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; cursor: pointer; transition: background 0.2s; }
.po-chip span { font-size: 16px; line-height: 1; opacity: 0.7; }
.po-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 4px 24px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.po-out-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.po-result { display: grid; gap: 14px; min-width: 0; }
.po-chain { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.po-card { position: relative; display: grid; align-content: start; gap: 4px; min-width: 0; padding: 14px 14px 16px; border-radius: 14px; border: 1px solid var(--line-soft); background: var(--bg-raised); }
.po-card b { padding-right: 30px; font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.po-n { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 980px; background: var(--bg-alt); color: var(--ink-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.po-why { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.po-end { display: grid; place-items: center; min-height: 52px; padding: 12px; border-radius: 14px; background: var(--bg-alt); color: var(--ink-2); font-size: 14px; font-weight: 600; text-align: center; }
.po-section { margin-top: 6px; }
.po-sub { margin-top: 14px; }
.po-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.po-notes li { display: grid; gap: 3px; }
.po-notes b { font-weight: 600; }
.po-notes span { font-size: 15px; line-height: 1.45; }
.po-footer { margin-top: 6px; }

/* ---------------------------------------------------------------- hover (pointer devices only), small screens, motion */
@media (hover: hover) {
  .tool-opt:not([aria-pressed="true"]):hover, .tn-string:not(.is-near):not(.is-ok):hover, .cp-opt:not([aria-pressed="true"]):hover { border-color: var(--ink-3); }
  .tool-step:hover { background: var(--line-soft); }
  .mt-bpm input:hover { background: var(--bg-alt); }
  .cp-x:hover { background: var(--line-soft); color: var(--ink); }
  .po-chip:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
}
@media (max-width: 640px) {
  .tn-top { grid-template-columns: minmax(0, 1fr); }
  .mt-row { grid-template-columns: minmax(0, 1fr); }
  .cp-tabs { width: 100%; }
  .cp-tabs button { flex: 1 1 0; padding: 8px 10px; }
  .cp-frets { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cp-where { grid-template-columns: minmax(0, 1fr); }
  .cp-opt { grid-template-columns: minmax(0, 1fr) auto; }
  .cp-opt-shapes { grid-column: 1 / -1; grid-row: 2; }
  .cp-keys { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .tool .card { padding: 20px 16px; }
  .tn-string { height: 52px; font-size: 17px; }
  .cp-keys { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .po-chain { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .tool *, .tool *::before, .tool *::after { transition: none !important; animation: none !important; }
}
