/* Kagu — le noir, c'est le vide.
   Une seule idée graphique : l'emplacement est une fenêtre noire, le meuble y entre en couleur de matière,
   et ce qui reste de noir autour de lui est le vide restant. La barre de navigation applique la même règle :
   l'onglet actif est un bloc posé dans une niche noire. */

@font-face {
  font-family: 'Anybody';
  src: url('../assets/fonts/anybody.woff2') format('woff2-variations'), url('../assets/fonts/anybody.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 50% 150%;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../assets/fonts/atkinson.woff2') format('woff2-variations'), url('../assets/fonts/atkinson.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: oklch(0.955 0.006 110);
  --paper: oklch(0.985 0.004 110);
  --fg: oklch(0.16 0.01 270);
  --muted: oklch(0.43 0.012 270);
  --line: oklch(0.8 0.008 110);
  --void: oklch(0.13 0.008 270);
  --on-void: oklch(0.97 0.004 110);
  --lime: oklch(0.9 0.19 122);
  --lime-hover: oklch(0.81 0.19 122);
  --oak: oklch(0.78 0.09 75);
  --press: oklch(0.9 0.008 110);

  --display: 'Anybody', 'Arial Narrow', sans-serif;
  --body: 'Atkinson Hyperlegible Next', system-ui, sans-serif;

  --pad: 16px;
  --dock-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
.dock :focus-visible, .sheet :focus-visible.on-void { outline-color: var(--on-void); }

.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 12px 16px; background: var(--fg); color: var(--bg); }

/* ───────── Coque ───────── */
.app { max-width: 430px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 var(--pad);
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; min-height: 44px; }
.brand span { font: 900 24px/1 var(--display); font-stretch: 150%; letter-spacing: -0.01em; }
.top .tag { margin: 0; font-size: 13px; color: var(--muted); }

main { padding: 4px var(--pad) calc(var(--dock-h) + 40px + env(safe-area-inset-bottom)); outline: none; }
main:has(.cmpbar:not([hidden])) { padding-bottom: calc(var(--dock-h) + 110px); }

h1 {
  margin: 8px 0 6px;
  font: 800 30px/1.02 var(--display); font-stretch: 125%; letter-spacing: -0.015em;
  outline: none; text-wrap: balance;
}
.lede { margin: 0 0 16px; color: var(--muted); max-width: 34ch; text-wrap: pretty; }

/* ───────── Barre de navigation : une niche noire, l'onglet actif est le bloc posé dedans ───────── */
.dock {
  position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  display: grid; grid-template-columns: 1.15fr 1fr 0.8fr; gap: 6px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--void);
}
.dock a {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 8px;
  color: var(--on-void); text-decoration: none; font-weight: 700; font-size: 15px;
}
.dock a b { font: 800 15px/1 var(--display); font-stretch: 125%; min-width: 26px; padding: 5px 6px; text-align: center; background: oklch(0.3 0.01 270); color: var(--on-void); }
.dock a[aria-current="page"] { background: var(--lime); color: var(--void); }
.dock a[aria-current="page"] b { background: var(--void); color: var(--lime); }
@media (hover: hover) {
  .dock a:not([aria-current="page"]):hover { background: oklch(0.28 0.01 270); }
  .dock a[aria-current="page"]:hover { background: var(--lime-hover); }
}

/* ───────── Boutons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 20px;
  border: 2px solid var(--fg); border-radius: 0; background: transparent; color: var(--fg);
  font: 700 16px/1.1 var(--body); text-decoration: none; text-align: center;
}
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--lime); border-color: var(--void); color: var(--void); font-size: 17px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
@media (hover: hover) {
  .btn:not([disabled]):hover { background: var(--press); }
  .btn.primary:not([disabled]):hover { background: var(--lime-hover); }
}
.btn:active { transform: translateY(1px); }
.link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px;
  background: none; border: 0; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px;
}

/* ───────── 1 · Scène : la fenêtre noire ───────── */
.stage { background: var(--paper); padding: 10px 18px 16px; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.cap { margin: 0 0 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.front { position: relative; height: 196px; margin-bottom: 8px; }
.win, .bar { position: absolute; left: 0; bottom: 0; background: var(--void); }
.win { transition: width 0.22s cubic-bezier(.2,.8,.2,1), height 0.22s cubic-bezier(.2,.8,.2,1); }
.core { position: absolute; bottom: 0; left: 50%; background: var(--oak); transform: translateX(-50%);
        transition: width 0.22s cubic-bezier(.2,.8,.2,1), height 0.22s cubic-bezier(.2,.8,.2,1); }
.stage.dragging .win, .stage.dragging .core, .stage.dragging .bar { transition: none; }

.deep { position: relative; height: 40px; margin-top: 4px; }
.bar { height: 40px; transition: width 0.22s cubic-bezier(.2,.8,.2,1); }
.bar .core { left: 0; transform: none; top: 0; bottom: auto; height: 100%; transition: width 0.22s cubic-bezier(.2,.8,.2,1); }

/* Poignées : zone de 44 px, repère visuel de 16 px */
.grip {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0;
  background: transparent; border: 0; border-radius: 0; touch-action: none; cursor: grab; z-index: 3;
}
.grip::after { content: ''; position: absolute; inset: 14px; }
.grip.sq::after { background: var(--on-void); border: 2px solid var(--void); }
.grip.ring::after { border-radius: 50%; background: var(--oak); border: 2px solid var(--void); }
.grip:active { cursor: grabbing; }
.grip:focus-visible { outline: none; }
.grip:focus-visible::after { outline: 3px solid var(--fg); outline-offset: 3px; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 18px; padding: 0; font-size: 13px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; }
.k-void { background: var(--void); }
.k-core { background: var(--oak); }
.k-sq { background: var(--on-void); border: 2px solid var(--void); width: 14px; height: 14px; }
.k-ring { border-radius: 50%; background: var(--oak); border: 2px solid var(--void); }

/* Lignes de cotes : Largeur / Profondeur / Hauteur */
.rows { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1.32fr 1fr; gap: 12px; }
.row label, .row .lab { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.row label em, .row .lab em { font-style: normal; font-weight: 400; color: var(--muted); }
.row label .ia { font-weight: 400; color: var(--muted); white-space: nowrap; }
.row label .ia.edited { color: var(--fg); font-weight: 700; }
.step { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: stretch; height: 54px; border: 2px solid var(--fg); background: var(--paper); }
.row .vide .step { grid-template-columns: 44px minmax(0, 1fr) 44px; }
.step button { position: relative; border: 0; background: transparent; border-radius: 0; touch-action: manipulation; }
.step button::before, .step button.p::after { content: ''; position: absolute; left: 50%; top: 50%; background: currentColor; transform: translate(-50%, -50%); }
.step button::before { width: 16px; height: 3px; }
.step button.p::after { width: 3px; height: 16px; }
.step button:first-child { border-right: 2px solid var(--fg); }
.step button:last-child { border-left: 2px solid var(--fg); }
@media (hover: hover) { .step button:hover { background: var(--fg); color: var(--bg); } }
.step button:active { background: var(--fg); color: var(--bg); }
.step button:focus-visible { outline-offset: -5px; }
.step .val { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; }
.step input {
  width: 100%; height: 100%; padding: 0 0 0 0; border: 0; background: transparent; text-align: center; border-radius: 0;
  font: 800 30px/1 var(--display); font-stretch: 115%; font-variant-numeric: tabular-nums;
}
.row .cote .val::after { content: 'cm'; position: absolute; right: 4px; bottom: 6px; font: 600 12px/1 var(--body); color: var(--muted); pointer-events: none; }
.row .cote input { padding-right: 14px; }
.row .vide input { font-size: 24px; }
.step input:focus-visible { outline: 3px solid var(--fg); outline-offset: -7px; }

.go { margin-top: 22px; }
.go .alt { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 15px; }
.go .alt a { font-weight: 700; color: var(--fg); text-underline-offset: 3px; text-decoration-thickness: 2px; padding: 12px 2px; }

/* ───────── 2 · Résultats ───────── */
.slotbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  margin: 0 calc(var(--pad) * -1); padding: 8px var(--pad); background: var(--bg); border-bottom: 2px solid var(--fg);
}
.slotbar .mini { flex: none; display: flex; align-items: flex-end; width: 44px; height: 44px; }
.slotbar .sum { flex: 1; min-width: 0; line-height: 1.2; }
.slotbar .sum b { display: block; font: 800 18px/1.1 var(--display); font-stretch: 120%; white-space: nowrap; }
.slotbar .sum small { display: block; font-size: 13px; color: var(--muted); }

.hero { display: flex; align-items: flex-end; gap: 14px; margin: 18px 0 16px; }
.hero .big { margin: 0; font: 900 104px/0.8 var(--display); font-stretch: 150%; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.hero .txt { padding-bottom: 2px; line-height: 1.15; }
.hero .txt b { display: block; font: 800 22px/1.05 var(--display); font-stretch: 120%; }
.hero .txt span { font-size: 14px; color: var(--muted); }

.sortbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; border: 2px solid var(--fg); background: var(--fg); }
.sortbar button { min-height: 48px; padding: 4px 6px; border: 0; background: var(--paper); font-weight: 700; font-size: 14px; line-height: 1.1; border-radius: 0; }
.sortbar button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
@media (hover: hover) { .sortbar button[aria-pressed="false"]:hover { background: var(--press); } }
.sortbar button:focus-visible { outline-offset: -6px; }
.sortbar button[aria-pressed="true"]:focus-visible { outline-color: var(--bg); }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.item { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 14px; padding: 16px 0 14px; border-bottom: 1px solid var(--line); }
.item .vis { display: flex; flex-direction: column; justify-content: flex-start; gap: 5px; }
.item .wbox { display: flex; align-items: flex-end; justify-content: center; width: 128px; height: 128px; }
.item .strip { width: 128px; }
.item h2 { margin: 0; font: 800 17px/1.15 var(--body); text-wrap: balance; }
.item .meta { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.item .fill { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 3px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.voids { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; gap: 4px; }
.voids div { padding: 3px 0 4px; border-top: 3px solid var(--void); }
.voids dt { font-size: 12px; font-weight: 700; color: var(--muted); }
.voids dd { margin: 0; font: 800 22px/1.05 var(--display); font-stretch: 115%; font-variant-numeric: tabular-nums; }
.voids div.zero dd { color: var(--muted); }
.item .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.price { font: 800 20px/1 var(--display); font-stretch: 115%; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmp { min-height: 44px; padding: 0 12px; border: 2px solid var(--fg); background: transparent; font-weight: 700; font-size: 14px; border-radius: 0; }
.cmp[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.cmp[disabled] { opacity: 0.4; cursor: not-allowed; }
@media (hover: hover) { .cmp[aria-pressed="false"]:not([disabled]):hover { background: var(--press); } }

/* Fenêtre et bande de profondeur */
svg.win { display: block; position: static; background: none; transition: none; max-width: 100%; height: auto; }
svg .void { fill: var(--void); }
svg .pc rect, svg .pc circle { fill: var(--c); }
svg .pc .hd { fill: oklch(0.12 0.01 270 / 0.55); }
svg .pc .hole { fill: var(--void); }
svg .pc .glass { fill: var(--c); fill-opacity: 0.35; }
svg .pc .wheel { fill: var(--void); }
svg .pc .seam { stroke: oklch(0.12 0.01 270 / 0.45); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.strip { position: relative; height: 10px; background: var(--void); }
.strip i { position: absolute; inset: 0 auto 0 0; width: calc(var(--fill) * 100%); background: var(--c); }

/* Rien n'entre */
.nothing { margin: 8px 0 0; padding: 18px 0 8px; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: end; }
.nothing p { margin: 0; }
.nothing b { display: block; font: 800 22px/1.1 var(--display); font-stretch: 120%; margin-bottom: 6px; text-wrap: balance; }
.nothing span { color: var(--muted); }

.relax { margin-top: 20px; }
.relax h2 { margin: 0 0 8px; font: 800 18px/1.1 var(--display); font-stretch: 120%; }
.relax ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.relax li button {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 14px;
  text-align: left; background: var(--paper); border: 2px solid var(--fg); border-radius: 0; font-weight: 700; line-height: 1.2;
}
.relax li button small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.relax li button .gain { font: 800 22px/1 var(--display); font-stretch: 120%; white-space: nowrap; }
@media (hover: hover) { .relax li button:hover { background: var(--press); } }
.relax .sorry { margin: 0; padding: 14px; border: 2px solid var(--fg); background: var(--paper); }

/* Barre de comparaison */
.cmpbar {
  position: fixed; z-index: 19; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 8px);
  width: calc(100% - 16px); max-width: 414px; display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 14px; background: var(--paper); border: 2px solid var(--fg);
}
.cmpbar p { flex: 1; margin: 0; font-weight: 700; line-height: 1.15; font-size: 15px; }
.cmpbar p small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.cmpbar .btn { min-height: 48px; padding: 0 16px; }

/* Fiche de comparaison */
.sheet {
  width: 100%; max-width: 430px; max-height: 92dvh; margin: auto auto 0; padding: 0; border: 0; border-top: 3px solid var(--void);
  background: var(--bg); color: var(--fg); overflow: auto;
}
.sheet::backdrop { background: oklch(0.13 0.008 270 / 0.6); }
.sheet .sh-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px var(--pad); background: var(--bg); border-bottom: 2px solid var(--fg); }
.sheet h2 { margin: 0; font: 800 20px/1.1 var(--display); font-stretch: 120%; }
.sheet .sh-body { padding: 14px var(--pad) 24px; }
.cols { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 10px; }
.cols .c-vis { display: flex; flex-direction: column; gap: 4px; }
.cols .c-win { display: flex; align-items: flex-end; justify-content: center; height: calc((100vw - 32px - 10px * (var(--n) - 1)) / var(--n)); max-height: 168px; }
.cols .c-name { margin: 6px 0 0; font: 800 15px/1.15 var(--body); text-wrap: balance; }
.cols .c-brand { margin: 0; font-size: 13px; color: var(--muted); }
.cmp-row { margin-top: 14px; }
.cmp-row h3 { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cmp-row .cols > div { padding-top: 4px; border-top: 3px solid var(--void); font: 800 22px/1.1 var(--display); font-stretch: 115%; font-variant-numeric: tabular-nums; }
.cmp-row .cols > div small { font: 400 13px var(--body); color: var(--muted); }
.cmp-row .cols > div.best { border-top-color: transparent; box-shadow: inset 0 3px 0 var(--lime); background: oklch(0.96 0.06 122); }
.cmp-row .cols > div.txt { font: 700 15px/1.2 var(--body); }

/* ───────── 3 · Photo ───────── */
.steps { margin: 4px 0 0; font-size: 13px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.viewfinder { position: relative; margin-top: 14px; padding: 22px 20px; background: var(--void); color: var(--on-void); aspect-ratio: 4 / 3.3; display: flex; flex-direction: column; justify-content: flex-end; }
.viewfinder ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; counter-reset: t; }
.viewfinder li { counter-increment: t; display: grid; grid-template-columns: 28px 1fr; gap: 10px; font-size: 16px; line-height: 1.3; }
.viewfinder li::before { content: counter(t); font: 800 22px/1 var(--display); font-stretch: 125%; color: var(--oak); }
.viewfinder .win-mark { position: absolute; top: 22px; right: 20px; width: 56px; height: 72px; border: 3px solid var(--oak); }
.viewfinder .win-mark::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 0; top: 18px; background: oklch(0.3 0.01 270); }
.actions { display: grid; gap: 8px; margin-top: 14px; }
.actions .alt { margin: 4px 0 0; text-align: center; }
.note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }

.shot { position: relative; display: block; margin-top: 12px; background: var(--void); line-height: 0; }
.shot { text-align: center; }
.shot img { display: block; width: auto; max-width: 100%; max-height: 300px; height: auto; }
.shot .wrap { position: relative; display: inline-block; }
.shot .detect { position: absolute; background: oklch(0.13 0.008 270 / 0.78); outline: 3px solid var(--on-void); outline-offset: 0; }
.shot .detect.scan { animation: grow 1.3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
.shot .stamp { position: absolute; left: 8px; top: 8px; padding: 4px 8px; background: var(--void); color: var(--on-void); font: 700 12px/1.2 var(--body); letter-spacing: 0.06em; text-transform: uppercase; }
.working { margin: 18px 0 0; font: 800 22px/1.1 var(--display); font-stretch: 120%; }
.working span { display: block; margin-top: 6px; font: 400 15px var(--body); color: var(--muted); }

.est { display: grid; gap: 14px; margin-top: 16px; }
.conf { margin: 0; font-size: 14px; color: var(--muted); }
.conf b { color: var(--fg); }
.palette { display: flex; gap: 10px; margin: 12px 0 0; flex-wrap: wrap; }
.palette span { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.palette i { width: 22px; height: 22px; border: 2px solid var(--fg); background: var(--sw); }
.why { margin: 8px 0 0; font-size: 14px; line-height: 1.3; }
.why b { font-weight: 800; }
.adv-list { margin-top: 10px; }

@media (max-width: 380px) {
  .row .cote input { font-size: 24px; padding-right: 18px; letter-spacing: -0.02em; }
}
@media (max-width: 359px) {
  :root { --pad: 12px; }
  h1 { font-size: 26px; }
  .item { grid-template-columns: 104px minmax(0, 1fr); gap: 10px; }
  .item .wbox, .item .strip { width: 104px; }
  .item .wbox { height: 104px; }
  .hero .big { font-size: 88px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
