/* Acordează — the microphone guitar tuner (js/acordeaza.js + js/pitch.js). Theme-aware like the other
   tool pages: tokens on :root, redefined under body.dark-theme. Green = in tune, amber = flat/sharp. */
:root {
    --ac-bg: #f2f6f3;
    --ac-surface: #ffffff;
    --ac-surface-2: #f6f9f7;
    --ac-ink: #10231a;
    --ac-muted: #5a6b62;
    --ac-line: #d9e3dd;
    --ac-accent: #15803d;
    --ac-accent-ink: #ffffff;
    --ac-accent-soft: rgba(21, 128, 61, .12);
    --ac-good: #16a34a;
    --ac-good-soft: rgba(22, 163, 74, .16);
    --ac-warn: #d97706;
    --ac-bad: #dc2626;
    --ac-needle: #10231a;
    --ac-tick: #9fb0a7;
    --ac-shadow: 0 10px 30px rgba(16, 35, 26, .10);
    --ac-nav: 72px;
}

body.dark-theme {
    --ac-bg: #0b1410;
    --ac-surface: #121e18;
    --ac-surface-2: #17261f;
    --ac-ink: #e8f2ec;
    --ac-muted: #9db0a5;
    --ac-line: #263a30;
    --ac-accent: #22c55e;
    --ac-accent-ink: #052e16;
    --ac-accent-soft: rgba(34, 197, 94, .16);
    --ac-good: #4ade80;
    --ac-good-soft: rgba(74, 222, 128, .16);
    --ac-warn: #fbbf24;
    --ac-bad: #f87171;
    --ac-needle: #e8f2ec;
    --ac-tick: #4d6157;
    --ac-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` makes <body> a scroll container that
   never scrolls, which silently kills any position: sticky inside. */
.ac-body, body.ac-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--ac-bg);
    color: var(--ac-ink);
    min-height: 100vh;
    overflow-x: clip;
}
/* body already reserves 72px for the fixed #mainNav (styles.css) */
.ac-main { padding-top: 40px; padding-bottom: 40px; }
.ac-main .container { max-width: 1080px; }
.ac-main a { color: var(--ac-accent); }

/* ---- hero ---- */
.ac-hero { text-align: center; padding: 4px 0 12px; }
.ac-hero-icon { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, #22c55e, #15803d 55%, #14532d); box-shadow: var(--ac-shadow); }
.ac-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.4rem); letter-spacing: -.02em; margin: 0 0 8px; }
.ac-lead { max-width: 680px; margin: 0 auto; color: var(--ac-muted); font-size: 1rem; line-height: 1.55; }

/* ---- cards ---- */
.ac-wrap { display: grid; gap: 18px; }
.ac-card { background: var(--ac-surface); border: 1px solid var(--ac-line); border-radius: 20px; box-shadow: var(--ac-shadow); padding: 18px; }

/* ---- controls ---- */
.ac-controls { display: grid; gap: 12px; }
.ac-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--ac-surface-2); border: 1px solid var(--ac-line); }
.ac-seg-btn { border: 0; background: transparent; color: var(--ac-muted); font-weight: 600; font-size: .92rem; padding: 9px 6px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.ac-seg-btn:hover { color: var(--ac-ink); }
.ac-seg-btn[aria-checked="true"] { background: var(--ac-accent); color: var(--ac-accent-ink); box-shadow: 0 2px 8px rgba(21, 128, 61, .25); }
.ac-seg-btn svg { margin-right: 4px; }
.ac-control-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.ac-field { display: grid; gap: 4px; margin: 0; }
.ac-field-tuning { flex: 1 1 260px; min-width: 0; }
.ac-field-label { font-size: .78rem; font-weight: 600; color: var(--ac-muted); text-transform: uppercase; letter-spacing: .04em; }
.ac-select { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--ac-line); background: var(--ac-surface-2); color: var(--ac-ink); font-size: .98rem; }
.ac-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--ac-line); border-radius: 12px; overflow: hidden; background: var(--ac-surface-2); min-height: 42px; }
.ac-step { width: 42px; border: 0; background: transparent; color: var(--ac-ink); font-size: 1.25rem; font-weight: 700; cursor: pointer; }
.ac-step:hover { background: var(--ac-accent-soft); }
.ac-step:disabled { opacity: .35; cursor: default; background: transparent; }
.ac-a4-val { min-width: 88px; border: 0; border-left: 1px solid var(--ac-line); border-right: 1px solid var(--ac-line); background: transparent; color: var(--ac-ink); font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; }
.ac-a4-val.is-custom { color: var(--ac-warn); }

/* ---- stage: gauge + strings ---- */
.ac-stage { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; margin-top: 16px; align-items: start; }
.ac-meter { position: relative; background: var(--ac-surface-2); border: 1px solid var(--ac-line); border-radius: 18px; padding: 10px 12px 14px; text-align: center; transition: background-color .25s, border-color .25s; }
.ac-tuner.is-intune .ac-meter { border-color: var(--ac-good); background: var(--ac-good-soft); }
.ac-gauge { display: block; width: 100%; max-width: 420px; margin: 0 auto; overflow: visible; }
.ac-arc { fill: none; stroke: var(--ac-line); stroke-width: 10; stroke-linecap: round; }
.ac-arc-zone { fill: none; stroke: var(--ac-good); stroke-width: 10; opacity: .55; }
.ac-tick-line { stroke: var(--ac-tick); stroke-width: 2; stroke-linecap: round; }
.ac-tick-line.is-major { stroke-width: 3; stroke: var(--ac-muted); }
.ac-tick-label { fill: var(--ac-muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ac-needle line { stroke: var(--ac-needle); stroke-width: 4; stroke-linecap: round; }
.ac-needle circle { fill: var(--ac-needle); }
.ac-tuner.is-idle .ac-needle { opacity: .25; }
.ac-tuner.is-hold .ac-needle { opacity: .55; }
.ac-tuner.is-flat .ac-needle line, .ac-tuner.is-sharp .ac-needle line { stroke: var(--ac-warn); }
.ac-tuner.is-flat .ac-needle circle, .ac-tuner.is-sharp .ac-needle circle { fill: var(--ac-warn); }
.ac-tuner.is-far .ac-needle line { stroke: var(--ac-bad); }
.ac-tuner.is-far .ac-needle circle { fill: var(--ac-bad); }
.ac-tuner.is-intune .ac-needle line { stroke: var(--ac-good); }
.ac-tuner.is-intune .ac-needle circle { fill: var(--ac-good); }
.ac-hub { fill: var(--ac-surface); stroke: var(--ac-needle); stroke-width: 3; }
.ac-flat-label, .ac-sharp-label { fill: var(--ac-muted); font-size: 12px; font-weight: 700; }

.ac-readout { margin-top: 0; position: relative; }
.ac-note { font-size: clamp(3.4rem, 13vw, 5.2rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ac-note-oct { font-size: .42em; font-weight: 700; color: var(--ac-muted); margin-left: 2px; }
.ac-tuner.is-intune .ac-note { color: var(--ac-good); }
.ac-tuner.is-hold .ac-note { opacity: .6; }
.ac-note-ro { font-size: 1.15rem; font-weight: 700; color: var(--ac-muted); margin-top: 2px; min-height: 1.4em; }
.ac-cents { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; min-height: 1.3em; margin-top: 4px; }
.ac-tuner.is-flat .ac-cents, .ac-tuner.is-sharp .ac-cents { color: var(--ac-warn); }
.ac-tuner.is-far .ac-cents { color: var(--ac-bad); }
.ac-tuner.is-intune .ac-cents { color: var(--ac-good); }
.ac-hint { font-size: .98rem; font-weight: 600; min-height: 1.4em; }
.ac-sub { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; color: var(--ac-muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.ac-level { position: relative; height: 6px; margin: 12px auto 0; max-width: 260px; border-radius: 999px; background: var(--ac-line); overflow: hidden; }
.ac-level span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ac-accent); border-radius: inherit; transition: width .08s linear; }
.ac-level i { position: absolute; top: 0; bottom: 0; width: 2px; left: 0; background: var(--ac-ink); opacity: .45; }

.ac-strings-wrap { display: grid; gap: 10px; }
.ac-strings-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ac-strings-title { font-weight: 700; }
.ac-strings { display: grid; gap: 8px; }
.ac-string { display: grid; grid-template-columns: 1fr auto; align-items: stretch; border: 1px solid var(--ac-line); border-radius: 14px; background: var(--ac-surface-2); overflow: hidden; transition: border-color .2s, background-color .2s, box-shadow .2s; }
.ac-string-main { display: grid; grid-template-columns: 28px 64px 1fr auto; align-items: center; gap: 8px; text-align: left; border: 0; background: transparent; color: var(--ac-ink); padding: 8px 10px; cursor: pointer; min-height: 46px; }
.ac-s-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: var(--ac-line); color: var(--ac-muted); }
.ac-s-en { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ac-s-en sub { font-size: .65em; color: var(--ac-muted); bottom: 0; margin-left: 1px; }
.ac-s-ro { color: var(--ac-muted); font-weight: 600; }
.ac-s-hz { color: var(--ac-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.ac-s-state { display: none; color: var(--ac-good); }
.ac-string-play { width: 48px; border: 0; border-left: 1px solid var(--ac-line); background: transparent; color: var(--ac-accent); cursor: pointer; font-size: 1rem; }
.ac-string-play:hover, .ac-string-main:hover { background: var(--ac-accent-soft); }
.ac-string-play.is-playing { background: var(--ac-accent); color: var(--ac-accent-ink); }
.ac-string.is-target { border-color: var(--ac-accent); box-shadow: 0 0 0 2px var(--ac-accent-soft); }
.ac-string.is-target .ac-s-num { background: var(--ac-accent); color: var(--ac-accent-ink); }
.ac-string.is-locked .ac-s-num { outline: 2px dashed var(--ac-warn); outline-offset: 2px; }
.ac-string.is-tuned { border-color: var(--ac-good); background: var(--ac-good-soft); }
.ac-string.is-tuned .ac-s-hz { display: none; }
.ac-string.is-tuned .ac-s-state { display: inline; }
.ac-strings-note { margin: 0; color: var(--ac-muted); font-size: .85rem; }
.ac-tuner.is-chromatic .ac-strings-wrap { display: none; }
.ac-tuner.is-chromatic .ac-stage { grid-template-columns: minmax(0, 1fr); }
.ac-tuner.is-chromatic .ac-meter { max-width: 560px; width: 100%; margin: 0 auto; }

/* ---- actions ---- */
.ac-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.ac-start { flex: 0 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 12px 26px; border: 0; border-radius: 999px; background: var(--ac-accent); color: var(--ac-accent-ink); font-size: 1.08rem; font-weight: 800; cursor: pointer; box-shadow: 0 6px 18px rgba(21, 128, 61, .3); }
.ac-start:hover { filter: brightness(1.06); }
.ac-start .ac-when-on { display: none; }
.ac-start.is-on { background: var(--ac-surface-2); color: var(--ac-ink); border: 1px solid var(--ac-line); box-shadow: none; }
.ac-start.is-on .ac-when-on { display: inline; }
.ac-start.is-on .ac-when-off { display: none; }
.ac-start:disabled { opacity: .6; cursor: progress; }
.ac-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.ac-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--ac-line); background: var(--ac-surface-2); color: var(--ac-muted); font-size: .88rem; font-weight: 600; cursor: pointer; margin: 0; }
.ac-chip[aria-pressed="true"] { border-color: var(--ac-accent); color: var(--ac-accent); background: var(--ac-accent-soft); }
.ac-chip-select select { border: 0; background: transparent; color: var(--ac-ink); font-weight: 600; font-size: .88rem; padding: 0 2px; cursor: pointer; }
.ac-chip-select select option { color: #10231a; background: #fff; }

.ac-msg { margin-top: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--ac-warn); background: rgba(217, 119, 6, .1); line-height: 1.5; font-size: .95rem; }
.ac-msg.is-info { border-color: var(--ac-line); background: var(--ac-surface-2); }
.ac-msg strong { display: block; margin-bottom: 4px; }
.ac-msg ul { margin: 6px 0 0; padding-left: 20px; }
.ac-resume { margin-top: 12px; width: 100%; min-height: 48px; border: 0; border-radius: 14px; background: var(--ac-warn); color: #1c1203; font-weight: 800; cursor: pointer; }

/* ---- help ---- */
.ac-help h2 { font-size: 1.2rem; font-weight: 800; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.ac-help h2 svg { color: var(--ac-accent); }
.ac-help h3 { font-size: 1rem; font-weight: 700; margin: 0 0 6px; }
.ac-steps { padding-left: 20px; line-height: 1.6; margin-bottom: 14px; }
.ac-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ac-help ul { padding-left: 18px; margin: 0; line-height: 1.55; color: var(--ac-muted); }
.ac-help li strong, .ac-steps strong { color: var(--ac-ink); }

/* ---- responsive ---- */
@media (max-width: 860px) {
    .ac-stage { grid-template-columns: minmax(0, 1fr); }
    .ac-help-grid { grid-template-columns: 1fr; }
}
@media (max-width: 575.98px) {
    .ac-main { padding-top: 28px; }
    .ac-main .container { padding-left: 16px; padding-right: 16px; }
    .ac-card { padding: 14px; border-radius: 16px; }
    .ac-hero { padding-bottom: 8px; }
    .ac-hero-icon { display: none; }
    .ac-lead { font-size: .92rem; }
    .ac-seg-btn { font-size: .82rem; padding: 8px 2px; }
    .ac-seg-btn svg { display: none; }
    .ac-field-a4 { flex: 1 1 100%; }
    .ac-stepper { width: 100%; }
    .ac-a4-val { flex: 1; }
    .ac-actions { flex-direction: column; align-items: stretch; }
    .ac-start { width: 100%; }
    .ac-toggles { justify-content: center; }
    .ac-strings { grid-template-columns: 1fr 1fr; }
    .ac-string-main { grid-template-columns: 24px 1fr; grid-template-rows: auto auto; gap: 0 6px; padding: 6px 8px; }
    .ac-s-num { grid-row: span 2; width: 22px; height: 22px; font-size: .7rem; }
    .ac-s-en { font-size: 1.1rem; }
    .ac-s-ro { font-size: .82rem; }
    .ac-s-hz, .ac-string.is-tuned .ac-s-state { display: none; }
    .ac-string-play { width: 40px; }
}
/* phones in landscape: gauge and strings side by side, compact header area */
@media (orientation: landscape) and (max-height: 520px) {
    .ac-main { padding-top: 14px; }
    .ac-hero { display: none; }
    .ac-card { padding: 10px 12px; }
    .ac-controls { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px; align-items: end; }
    .ac-control-row { flex-wrap: nowrap; gap: 8px; }
    .ac-field-tuning { flex: 1 1 0; }
    .ac-field-a4 { flex: 0 0 auto; }
    .ac-field-label { display: none; }
    .ac-seg-btn { padding: 6px 4px; font-size: .82rem; }
    .ac-seg-btn svg { display: none; }
    .ac-select, .ac-stepper { min-height: 36px; }
    .ac-select { padding: 4px 8px; font-size: .88rem; }
    .ac-step { width: 34px; }
    .ac-a4-val { min-width: 70px; }
    .ac-meter { padding: 6px 8px 8px; }
    .ac-cents { font-size: 1.2rem; }
    .ac-actions { margin-top: 10px; }
    .ac-stage { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; margin-top: 10px; }
    .ac-gauge { max-width: 230px; }
    .ac-note { font-size: 3rem; }
    .ac-strings { grid-template-columns: 1fr 1fr; gap: 6px; }
    .ac-string-main { grid-template-columns: 24px 1fr; min-height: 40px; padding: 4px 8px; gap: 0 6px; }
    .ac-s-ro, .ac-s-hz, .ac-string.is-tuned .ac-s-state { display: none; }
    .ac-strings-note { display: none; }
    .ac-start { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    .ac-meter, .ac-string, .ac-level span { transition: none; }
}
