:root {
  --bg: #f6eee4;
  --surface: #fffaf3;
  --ink: #2b1d14;
  --muted: #7a6656;
  --line: #e4d6c5;
  --accent: #c8682c;
  --accent-ink: #fff;
  --ok: #2f7d4f;
  --ok-bg: #e3f2e8;
  --ko: #b23a2f;
  --ko-bg: #f8e2df;
  --new: #2f6db3;
  --learn: #b23a2f;
  --review: #2f7d4f;
  --wood: #6b4429;
  --fret: #cfc6b8;
  --string: #e9dfcf;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1410;
    --surface: #261c16;
    --ink: #f3e8da;
    --muted: #b3a08e;
    --line: #3d2f25;
    --ok: #6fcf97;
    --ok-bg: #1f3a2a;
    --ko: #ff8a7a;
    --ko-bg: #46241f;
    --new: #7fb2f0;
    --learn: #ff8a7a;
    --review: #6fcf97;
    --wood: #4a2f1d;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); }
h2 { margin: 0.2em 0 0.3em; font-size: 1.35rem; }
h3 { margin: 1.4em 0 0.5em; font-size: 1.05rem; }
.sub { color: var(--muted); margin: 0 0 0.8em; }

header {
  position: sticky; top: 0; z-index: 2;
  background: var(--ink); color: var(--bg);
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
  padding: 0.6rem max(1rem, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 0.5rem; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
nav { display: flex; gap: 0.25rem; overflow-x: auto; }
nav a { color: inherit; text-decoration: none; padding: 0.4rem 0.7rem; border-radius: 999px; white-space: nowrap; opacity: 0.8; }
nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); opacity: 1; }
.badge { background: var(--bg); color: var(--ink); border-radius: 999px; padding: 0 0.45em; font-size: 0.8em; font-weight: 700; margin-left: 0.2em; }

main { max-width: 760px; margin: 0 auto; padding: 1rem; }
main:focus, main:focus-visible { outline: none; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.3rem; box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}
.card.is-ok { border-color: var(--ok); }
.card.is-ko { border-color: var(--ko); }
.deck-name { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.done { text-align: center; }

.counts { display: flex; justify-content: center; gap: 1rem; margin-bottom: 0.7rem; font-weight: 600; font-size: 0.95rem; }
.c-new { color: var(--new); }
.c-learn { color: var(--learn); }
.c-review { color: var(--review); }

/* boutons */
button { font: inherit; color: inherit; cursor: pointer; }
.btn, .btn-ghost, .btn-danger {
  border-radius: 10px; padding: 0.6rem 1rem; border: 1px solid var(--line); background: var(--surface);
}
.btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--ko); border-color: var(--ko); background: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-top: 0.8rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.pad { display: grid; gap: 0.5rem; margin-top: 1rem; grid-template-columns: repeat(4, 1fr); }
.pad-7 { grid-template-columns: repeat(7, 1fr); }
.pad-12 { grid-template-columns: repeat(6, 1fr); }
.pad-4 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 560px) {
  .pad-7 { grid-template-columns: repeat(4, 1fr); }
  .pad-12 { grid-template-columns: repeat(4, 1fr); }
}
.note {
  min-height: 3.2rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  font-weight: 600; font-size: 1rem;
}
.note:hover { border-color: var(--accent); }

.shapes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-top: 1rem; }
@media (min-width: 640px) { .shapes { grid-template-columns: repeat(4, 1fr); } }
.shape { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 0.5rem; }
.shape:hover { border-color: var(--accent); }

.feedback { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; margin-top: 1rem; padding: 0.8rem 1rem; border-radius: 12px; }
.is-ok .feedback { background: var(--ok-bg); }
.is-ko .feedback { background: var(--ko-bg); }
.verdict { margin: 0; font-size: 1.1rem; }

.grades { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.grades button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  padding: 0.7rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.grades small { font-weight: 400; color: var(--muted); }
.g-again { border-color: var(--ko) !important; }
.g-good { border-color: var(--ok) !important; background: var(--ok-bg) !important; }

/* manche */
.fretboard { width: 100%; height: auto; display: block; margin: 0.6rem 0; user-select: none; }
.scroll-x { overflow-x: auto; }
.scroll-x .fretboard { min-width: 680px; }
.fb-wood { fill: var(--wood); }
.fb-fret { stroke: var(--fret); stroke-width: 2.5; }
.fb-nut { stroke: #efe6d6; stroke-width: 7; }
.fb-string { stroke: var(--string); }
.fb-inlay { fill: #e9dcc6; opacity: 0.55; }
.fb-num, .fb-label { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.fb-label { font-weight: 700; font-family: ui-monospace, monospace; font-size: 14px; }
.fb-mark circle { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.fb-mark.mark-q circle { fill: var(--accent); }
.fb-mark.mark-ok circle { fill: var(--ok); }
.fb-mark.mark-ko circle { fill: var(--ko); }
.fb-mark.mark-label circle { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.fb-mark.mark-label .fb-mark-text { fill: var(--ink); }
.fb-mark-text { fill: #fff; font-size: 10px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.fb-hit { fill: transparent; cursor: pointer; }
.fb-hit:hover, .fb-hit:focus-visible { fill: rgb(232 176 75 / 0.35); outline: none; }
.mark-q circle { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .mark-q circle { animation: none; } }
/* corde ciblée dans « trouver la note » */
.focus-string-1 .s-1, .focus-string-2 .s-2, .focus-string-3 .s-3, .focus-string-4 .s-4, .focus-string-5 .s-5, .focus-string-6 .s-6 { stroke: var(--accent); stroke-width: 3.5; }

/* tab et accords */
.tab {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; line-height: 1.35;
  background: var(--bg); border-radius: 10px; padding: 0.7rem 1rem; margin: 0.6rem auto; width: fit-content;
}
.chord-pair { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1.5rem; }
.chord { width: 150px; height: auto; }
.chord-small { width: 100%; max-width: 120px; }
.ch-nut { stroke: var(--ink); stroke-width: 5; }
.ch-fret, .ch-string { stroke: var(--muted); stroke-width: 1.5; }
.ch-dot { fill: var(--ink); }
.ch-finger { fill: var(--surface); font-size: 12px; font-weight: 700; text-anchor: middle; }
.ch-open { fill: var(--muted); font-size: 15px; text-anchor: middle; }
.ch-open-dot { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.chord-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.7rem; }
.chord-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 0.7rem 0.4rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.chord-card:hover { border-color: var(--accent); }
.chord-card code { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0.5rem 0; }
details { margin-top: 1rem; }
summary { cursor: pointer; font-weight: 600; }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.tile { background: var(--bg); border-radius: 12px; padding: 0.8rem; display: flex; flex-direction: column; }
.tile-l { font-size: 0.8rem; color: var(--muted); }
.tile-v { font-size: 1.8rem; font-weight: 700; }
.tile-u { font-size: 0.8rem; color: var(--muted); }
.deck-row { margin: 0.7rem 0; }
.deck-row.off { opacity: 0.5; }
.deck-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.95rem; margin-bottom: 0.25rem; }
.deck-head .sub { margin: 0; }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.bar span { display: block; height: 100%; }
.b-mature { background: var(--ok); }
.b-young { background: #8cc7a2; }
.b-learn { background: #e8b04b; }
.legend { font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.legend .k { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.forecast { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; height: 150px; align-items: end; }
.fc { display: flex; flex-direction: column; align-items: center; justify-content: end; height: 100%; gap: 0.2rem; }
.fc-bar { width: 70%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; }
.fc-n { font-size: 0.8rem; font-weight: 600; }
.fc-l { font-size: 0.8rem; color: var(--muted); }
.hardest { padding-left: 1.2rem; }

/* réglages */
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 1rem; padding: 0.6rem 1rem 0.9rem; }
legend { font-weight: 700; padding: 0 0.3rem; }
.opt { display: flex; align-items: center; gap: 0.4rem; margin: 0.45rem 0; }
.deck-opt { align-items: flex-start; }
.deck-opt input { margin-top: 0.3rem; }
.deck-opt small { color: var(--muted); }
input[type="number"] { width: 5rem; font: inherit; padding: 0.3rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
