/* Accordeur · Platypus Coaching
   Charte : crème / beige / brun, Cormorant Garamond + DM Sans, accents terracotta et sauge. */
:root {
  --cream: #F7F2EA; --beige: #EDE4D4; --sand: #D9CCBA; --white: #FEFCF8;
  --terracotta: #C4714A; --terracotta-dark: #a35a38;
  --sage: #7A9B7F; --sage-dark: #4F6E54; --sage-light: #A8C4AC;
  --brown: #4A3728; --brown-mid: #6B4F3A; --text: #2E2318; --muted: #6F604F;
  --wood-1: #5b3a25; --wood-2: #3a2316; --ivory: #F3E9D6; --brass: #D9B26F;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow-sm: 0 2px 8px rgba(44, 31, 20, .08);
  --shadow-md: 0 4px 18px rgba(44, 31, 20, .10);
  --shadow-lg: 0 8px 32px rgba(44, 31, 20, .16);
  --r: 18px;
  --state: var(--muted);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: hidden; min-height: 100dvh; color: var(--text); font-family: var(--font-body); font-size: 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #fffaf2 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(74,55,40,.035) 38px 39px),
    var(--cream);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── En-tête ───────────────────────────────────────────── */
.top {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  max-width: 1040px; margin: 0 auto; padding: 12px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 6px; color: var(--brown); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.brand h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; margin: 0; letter-spacing: .01em; }
.seg {
  display: inline-flex; background: var(--beige); border-radius: 999px; padding: 4px; gap: 2px;
  box-shadow: inset 0 1px 2px rgba(44,31,20,.08);
}
.seg button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 500;
  color: var(--brown-mid); min-height: 40px; transition: background .2s, color .2s;
}
.seg button[aria-checked="true"] { background: var(--brown); color: var(--cream); box-shadow: var(--shadow-sm); }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--sand); background: var(--white); color: var(--brown);
}
.icon-btn svg { width: 22px; height: 22px; }

/* ── Mise en page ──────────────────────────────────────── */
.layout {
  max-width: 1040px; margin: 0 auto; padding: 8px 16px 20px;
  display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: stretch; padding-top: 20px; gap: 24px; }
  .top { padding-top: 24px; }
  .meter { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px; }
  .gauge { width: 100%; }
}

/* ── Indicateur ────────────────────────────────────────── */
.card {
  position: relative; background: var(--white); border-radius: var(--r); box-shadow: var(--shadow-md);
  border: 1px solid rgba(74,55,40,.08); padding: 14px 16px 16px; text-align: center; overflow: hidden;
  transition: box-shadow .3s, border-color .3s;
}
.meter[data-state="up"]   { --state: var(--terracotta-dark); }
.meter[data-state="down"] { --state: var(--terracotta-dark); }
.meter[data-state="ok"]   { --state: var(--sage-dark); border-color: var(--sage); box-shadow: 0 0 0 3px rgba(122,155,127,.35), var(--shadow-md); }
.meter[data-state="hold"] .note-wrap, .meter[data-state="hold"] .gauge { opacity: .45; }
.target { margin: 0; min-height: 1.4em; font-weight: 500; color: var(--brown-mid); letter-spacing: .02em; }
.note-wrap { display: flex; justify-content: center; align-items: baseline; gap: 6px; line-height: 1; margin-top: 2px; transition: opacity .3s; }
.note {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(4.2rem, 19vw, 6.4rem);
  color: var(--brown); transition: color .25s;
}
.meter[data-state="ok"] .note { color: var(--sage-dark); }
.sci { font-weight: 500; color: var(--muted); font-size: 1rem; min-width: 1ch; }

.gauge { display: block; width: 100%; max-width: 420px; margin: 0 auto; transition: opacity .3s; }
.gauge .tick { stroke: var(--sand); stroke-width: 2; stroke-linecap: round; }
.gauge .tick.major { stroke: var(--brown-mid); stroke-width: 2.6; }
.gauge .tick-label { fill: var(--muted); font: 500 11px var(--font-body); }
.gauge .ok-zone { fill: none; stroke: var(--sage-light); stroke-width: 14; stroke-linecap: butt; transition: stroke .3s; }
.meter[data-state="ok"] .ok-zone { stroke: var(--sage); }
.gauge .flat-sym, .gauge .sharp-sym { fill: var(--brown-mid); font: 600 26px var(--font-display); }
.gauge .hub { fill: var(--brown); stroke: var(--white); stroke-width: 3; }
.needle { transform-origin: 160px 166px; transform-box: view-box; will-change: transform; }

.advice {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px;
  min-height: 52px; padding: 8px 20px; border-radius: 999px; font-weight: 700; font-size: 1.35rem;
  color: var(--state); background: color-mix(in srgb, var(--state) 10%, transparent);
  transition: color .2s, background .2s;
}
.meter[data-state="idle"] .advice, .meter[data-state="hold"] .advice { font-weight: 500; font-size: 1.05rem; }
.advice-icon { display: inline-flex; gap: 1px; }
.advice-icon svg { width: 22px; height: 22px; }
.detail { margin: 8px 0 0; color: var(--muted); font-size: .95rem; min-height: 1.3em; font-variant-numeric: tabular-nums; }

/* Écran d'activation du micro, posé sur l'indicateur */
.start {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px; background: rgba(254,252,248,.86); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.start[hidden] { display: none; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px; border: 0; border-radius: 999px;
  background: var(--brown); color: var(--cream); padding: 16px 28px; font-size: 1.1rem; font-weight: 700;
  box-shadow: var(--shadow-lg); min-height: 56px; transition: transform .15s, background .2s;
}
.btn-primary:hover { background: var(--brown-mid); }
.btn-primary:active { transform: scale(.97); }
.btn-primary svg { width: 22px; height: 22px; }
.start-note { margin: 0; color: var(--brown-mid); font-size: .92rem; line-height: 1.45; max-width: 32ch; }
.start-note.error { color: var(--terracotta-dark); font-weight: 500; }

/* ── Instrument ────────────────────────────────────────── */
.card-wood {
  border-radius: var(--r); padding: 10px 12px 14px; color: var(--ivory); box-shadow: var(--shadow-lg);
  background:
    repeating-linear-gradient(92deg, rgba(255,255,255,.025) 0 3px, transparent 3px 9px),
    linear-gradient(160deg, #6a452d, #2f1c11);
  display: flex; flex-direction: column;
}
.headstock { display: block; width: 100%; max-height: 46vh; margin: 0 auto; flex: 1; touch-action: manipulation; }
@media (min-width: 820px) { .headstock { max-height: 470px; } }
.headstock .hs-body { fill: url(#woodGrad); stroke: rgba(0,0,0,.35); stroke-width: 1.5; }
.headstock .hs-neck { fill: #2a170c; }
.headstock .fret { stroke: #b9b2a5; stroke-width: 3; }
.headstock .nut { fill: var(--ivory); }
.headstock .post { fill: #cfcac0; stroke: #8c857a; stroke-width: 1.5; }
.headstock .shaft { stroke: #b8b1a4; stroke-width: 5; stroke-linecap: round; }
.headstock .string { stroke: #d8d2c6; fill: none; stroke-linecap: round; transition: stroke .2s; }
.headstock .string.wound { stroke: #c9a46a; }
.headstock .string.active { stroke: #f2c879; filter: drop-shadow(0 0 3px rgba(242,200,121,.9)); }
.headstock .string.active.buzz { animation: buzz .07s linear infinite alternate; }
.headstock .string.done { stroke: #bcd7c0; }
@keyframes buzz { from { transform: translateX(-.7px); } to { transform: translateX(.7px); } }

.peg { cursor: pointer; outline: none; }
.peg .peg-head { fill: var(--ivory); stroke: rgba(0,0,0,.35); stroke-width: 1.5; transition: fill .2s, transform .15s; transform-box: fill-box; transform-origin: center; }
.peg .peg-hit { fill: transparent; }
.peg .peg-label { fill: var(--brown); font: 700 17px var(--font-body); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.peg .peg-num { fill: rgba(243,233,214,.75); font: 600 12px var(--font-body); text-anchor: middle; pointer-events: none; }
.peg .peg-check { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; pointer-events: none; }
.peg:hover .peg-head { fill: #fff8ea; }
.peg:active .peg-head { transform: scale(.94); }
.peg:focus-visible .peg-head { stroke: var(--brass); stroke-width: 4; }
.peg.active .peg-head { fill: var(--terracotta); }
.peg.active .peg-label { fill: #fff; }
.peg.locked .peg-head { stroke: var(--brass); stroke-width: 4; }
.peg.done .peg-head { fill: var(--sage); }
.peg.done .peg-label { opacity: 0; }
.peg.done .peg-check { opacity: 1; }

.bar { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 6px; }
.chip { flex: none; }
.select { flex: 0 1 auto; }
.select select { width: 100%; overflow: hidden; white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid rgba(243,233,214,.35); background: rgba(0,0,0,.22); color: var(--ivory); font-weight: 500;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(243,233,214,.35); }
.chip[aria-pressed="true"] { background: var(--ivory); color: var(--brown); border-color: var(--ivory); }
.chip[aria-pressed="true"] .dot { background: var(--sage); }
.select { position: relative; min-width: 0; max-width: 100%; }
.select select {
  appearance: none; -webkit-appearance: none; max-width: 100%; text-overflow: ellipsis; min-height: 44px; padding: 8px 38px 8px 16px; border-radius: 999px;
  border: 1px solid rgba(243,233,214,.35); background: rgba(0,0,0,.22); color: var(--ivory); font-weight: 500;
}
.select::after { content: ''; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; border: solid var(--ivory); border-width: 0 2px 2px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select option { color: var(--text); background: var(--white); }
.hint { margin: 10px 0 0; text-align: center; font-size: .9rem; color: rgba(243,233,214,.82); min-height: 1.3em; }

/* ── Réglages ──────────────────────────────────────────── */
dialog {
  border: 0; padding: 0; border-radius: 22px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--cream); color: var(--text); box-shadow: 0 16px 56px rgba(44,31,20,.3);
}
dialog::backdrop { background: rgba(26,18,10,.45); }
.sheet { padding: 18px 20px 22px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { font-family: var(--font-display); font-size: 1.7rem; margin: 0; color: var(--brown); }
.help-title { margin-top: 22px !important; }
.field { margin-top: 16px; }
.field-label { display: block; font-weight: 700; margin-bottom: 8px; color: var(--brown); }
.field-help { color: var(--muted); font-size: .92rem; line-height: 1.45; margin: 8px 0 0; }
.stepper { display: inline-flex; align-items: center; background: var(--white); border: 1px solid var(--sand); border-radius: 999px; }
.stepper button { width: 48px; height: 44px; border: 0; background: none; font-size: 1.4rem; color: var(--brown); border-radius: 999px; }
.stepper output { min-width: 84px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.seg-small button { padding: 6px 14px; min-height: 38px; }
.help { padding-left: 1.3em; line-height: 1.5; margin: 10px 0 0; }
.help li { margin-bottom: 6px; }
.credits { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: .9rem; color: var(--muted); }
.credits a { color: var(--terracotta-dark); }
.noscript { text-align: center; padding: 20px; }

@media (max-width: 430px) {
  .top { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .brand h1 { font-size: 1.3rem; }
  .brand-mark { width: 30px; height: 30px; }
  .seg button { padding: 8px 11px; font-size: .95rem; }
}
@media (max-width: 360px) {
  .brand h1 { display: none; }
}
/* Téléphone : tout doit tenir sur un écran, cordes comprises */
@media (max-width: 819px) {
  .layout { gap: 10px; padding-top: 4px; }
  .card { padding: 10px 14px 12px; }
  .note { font-size: clamp(3.2rem, 14vw, 4.2rem); }
  .gauge { max-width: 270px; margin-top: -6px; }
  .advice { min-height: 46px; font-size: 1.25rem; margin-top: 0; }
  .detail { margin-top: 6px; }
  .headstock { max-height: 36vh; }
  .hint { margin-top: 6px; font-size: .85rem; }
  .card-wood { padding: 8px 10px 10px; }
}
@media (max-width: 819px) and (max-height: 700px) {
  .note { font-size: 3rem; }
  .gauge { max-width: 220px; }
  .headstock { max-height: 33vh; }
  .hint { display: none; }
  .advice { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
