:root {
  --bg: #14110e;
  --bg-2: #1c1814;
  --surface: #221d18;
  --surface-2: #2b251f;
  --line: #3a322a;
  --text: #f4ede4;
  --muted: #a89c8e;
  --accent: #ffb347;
  --accent-ink: #2a1a05;
  --ok: #3ee39a;
  --flat: #6cb8ff;
  --sharp: #ff7a6b;
  --wood: #8a4b2a;
  --wood-dark: #5a2d17;
  --string: #d9cbb8;
  --radius: 22px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(255, 179, 71, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* ---------- Cabecera ---------- */
.site-header { border-bottom: 1px solid var(--line); background: rgba(20, 17, 14, .8); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font: 600 20px var(--display); letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 800; }
.brand-mark { width: 28px; height: 28px; }
.nav { display: flex; gap: 22px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; }
.nav a:hover { color: var(--text); }
@media (max-width: 640px) { .nav { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: 36px 0 24px; }
.hero-copy { max-width: 720px; margin-bottom: 22px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; line-height: 1.1; }
h1 { font-size: clamp(32px, 5vw, 52px); margin: 0 0 10px; font-weight: 800; }
.lede { color: var(--muted); font-size: clamp(16px, 2vw, 19px); margin: 0; }
.lede strong { color: var(--text); }

/* ---------- Afinador ---------- */
.tuner {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7);
  overflow: hidden;
  --state: var(--muted);
}
.tuner[data-status="ok"] { --state: var(--ok); }
.tuner[data-status="flat"] { --state: var(--flat); }
.tuner[data-status="sharp"] { --state: var(--sharp); }

.tuner-bar { display: flex; gap: 12px; align-items: flex-end; padding: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-grow { flex: 1 1 260px; }
.field-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
select {
  appearance: none;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a89c8e' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 38px 10px 14px;
  width: 100%;
  font-weight: 600;
  text-overflow: ellipsis;
}
select:hover { border-color: #57493b; }
.icon-btn { width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; margin-left: auto; }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; }

.tuner-body {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "readout neck";
  gap: 12px 40px;
  padding: 28px 40px 16px;
  align-items: center;
}
.readout { grid-area: readout; text-align: center; transition: opacity .3s; }
.neck-area { grid-area: neck; display: flex; flex-direction: column; align-items: center; gap: 6px; }

.gauge { width: min(100%, 420px); display: block; margin: 0 auto -6px; overflow: visible; }
.gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 18; stroke-linecap: round; }
.gauge-zone { fill: none; stroke: var(--ok); stroke-width: 18; opacity: .35; transition: opacity .2s; }
.tuner[data-status="ok"] .gauge-zone { opacity: 1; filter: drop-shadow(0 0 8px var(--ok)); }
.tick { stroke: #5a4e42; stroke-width: 1.5; }
.tick-major { stroke: #8a7b6a; stroke-width: 2.2; }
.tick-label { fill: var(--muted); font: 600 11px var(--body); }
.gauge-side { fill: var(--muted); font: 600 12px var(--body); text-transform: uppercase; letter-spacing: .08em; }
.needle { transform-box: view-box; transform-origin: 150px 160px; transition: transform .12s ease-out; }
.needle line { stroke: var(--state); stroke-width: 4; stroke-linecap: round; transition: stroke .2s; }
.needle circle { fill: var(--state); transition: fill .2s; }

.note { display: flex; justify-content: center; align-items: baseline; gap: 8px; min-height: 1em; font-family: var(--display); line-height: 1; }
.note-main { font-size: clamp(64px, 11vw, 104px); font-weight: 800; color: var(--state); transition: color .2s; letter-spacing: -.03em; }
.note-alt { font-size: clamp(22px, 3vw, 30px); font-weight: 600; color: var(--muted); }
.note-detail { margin: 8px 0 0; color: var(--muted); font-size: 14px; min-height: 1.5em; font-variant-numeric: tabular-nums; }
.hint { margin: 10px auto 0; font-size: 18px; min-height: 1.6em; max-width: 30ch; }
.hint strong { color: var(--state); }
.hint span { color: var(--text); font-weight: 600; white-space: nowrap; }

/* Clavijero */
.headstock { position: relative; flex: none; }
.headstock svg { position: absolute; inset: 0; overflow: visible; }
.string-shadow { fill: none; stroke: rgba(0, 0, 0, .45); }
.string { fill: none; transition: stroke .2s, filter .2s; }
.string.wound { stroke: #cfa96f; }
.string.plain { stroke: #e8e8e6; }
.string.is-tuned { stroke: #9af0c8; }
.string.is-active { stroke: var(--accent); filter: drop-shadow(0 0 3px var(--accent)); }

.peg {
  position: absolute;
  width: 48px; height: 48px;
  translate: -50% -50%;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
  transition: background .15s, border-color .15s, transform .15s;
}
.peg:hover { border-color: var(--accent); }
.peg:active { transform: scale(.94); }
.peg-main { font-weight: 700; font-size: 15px; }
.peg-alt { font-size: 10px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.peg-alt:empty { display: none; }
.peg.is-active { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 6px rgba(255, 179, 71, .18); }
.peg.is-active .peg-alt { color: var(--accent-ink); opacity: .7; }
.peg.is-tuned { border-color: var(--ok); }
.peg.is-tuned::after {
  content: '✓';
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ok); color: #05301c;
  font-size: 12px; font-weight: 800;
  display: grid; place-items: center;
}
.peg.is-ringing { animation: ring .9s ease-out; }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 rgba(255, 179, 71, .55); }
  100% { box-shadow: 0 0 0 18px rgba(255, 179, 71, 0); }
}
.progress { margin: 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.progress.is-done { color: var(--ok); }

/* Pantalla de inicio (sobre el medidor) */
.start-overlay {
  grid-area: readout;
  z-index: 2;
  align-self: stretch;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  text-align: center;
  padding: 16px;
  background: radial-gradient(closest-side, rgba(28, 24, 20, .96), rgba(28, 24, 20, .75));
  border-radius: 18px;
}
.start-overlay[hidden] { display: none; }
.tuner:not(.is-listening) .readout { opacity: .35; }
.start-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 18px 30px;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 19px;
  box-shadow: 0 10px 30px -8px rgba(255, 179, 71, .6);
  transition: transform .15s, box-shadow .15s;
}
.start-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 36px -8px rgba(255, 179, 71, .7); }
.start-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.start-note { margin: 0; color: var(--muted); font-size: 14px; max-width: 34ch; }
.mic-error { margin: 0; color: var(--sharp); background: rgba(255, 122, 107, .1); border: 1px solid rgba(255, 122, 107, .35); border-radius: 12px; padding: 10px 14px; font-size: 14px; max-width: 42ch; }

.tuner-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.foot-actions { display: flex; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 6px 0; font-weight: 600; font-size: 15px; text-align: left; }
.switch-track { width: 44px; height: 26px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); position: relative; flex: none; transition: background .2s; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(18px); background: var(--accent-ink); }
.ghost-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; font-size: 15px; }
.ghost-btn:hover { border-color: #57493b; }
.ghost-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.ghost-btn[hidden] { display: none; }

@media (max-width: 820px) {
  .tuner-body { grid-template-columns: 1fr; grid-template-areas: "readout" "neck"; padding: 20px 16px 12px; gap: 18px; }
  .start-overlay { background: rgba(28, 24, 20, .92); }
  .hint { font-size: 17px; }
}
@media (max-width: 480px) {
  .tuner-foot { flex-direction: column; align-items: stretch; }
  .foot-actions { justify-content: stretch; }
  .foot-actions .ghost-btn { flex: 1; justify-content: center; }
  .tuner-bar .field:first-child { flex: 1 1 100%; }
  .field-grow { flex-basis: 0; }
}

/* ---------- Ventajas ---------- */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; padding: 24px 0 8px; }
.feature { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.feature h3 { margin: 0 0 6px; font-size: 19px; }
.feature p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- Contenido ---------- */
.content { padding: 40px 0 8px; max-width: 820px; }
.content h2 { font-size: clamp(26px, 3.4vw, 34px); margin: 32px 0 14px; }
.content h2:first-child { margin-top: 0; }
.content p, .content li { color: #d9cfc3; }
.steps { padding-left: 1.3em; display: grid; gap: 10px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.tips { padding-left: 1.2em; display: grid; gap: 8px; }
.tips li::marker { color: var(--accent); }
strong { color: var(--text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--bg-2); }
tbody tr:last-child td { border-bottom: 0; }

.tuning-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tuning-grid article { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.tuning-grid h3 { margin: 0 0 4px; font-size: 20px; }
.tuning-grid .notes { color: var(--accent); font-weight: 600; margin: 0 0 8px; font-size: 14px; }
.tuning-grid p { margin: 0; font-size: 15px; }

.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 17px; padding: 12px 0; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--accent); font-size: 22px; line-height: 1; }
.faq details[open] summary::after { content: '−'; }
.faq details p { margin: 0 0 14px; }

.site-footer { margin-top: 56px; border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 14px; }

/* ---------- Ajustes ---------- */
.settings { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 24px; width: min(420px, 100% - 32px); }
.settings::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.settings h2 { margin: 0 0 16px; font-size: 24px; }
.settings fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.settings legend { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.radio { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.radio input { accent-color: var(--accent); width: 18px; height: 18px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button:not(.link-btn) { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 20px; }
.stepper output { font-weight: 700; font-size: 18px; min-width: 80px; text-align: center; font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 600; margin-left: auto; }
.help { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.primary-btn { width: 100%; padding: 12px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
