@font-face { font-family: 'VisionDesign'; src: url('./fonts/vision-design-variable.ttf') format('truetype'); font-style: normal; font-weight: 100 900; }
@font-face { font-family: 'VisionDesign'; src: url('./fonts/vision-design-italic-variable.ttf') format('truetype'); font-style: italic; font-weight: 100 900; }
@font-face { font-family: 'Dorienne'; src: url('./fonts/dorienne-variable.ttf') format('truetype'); font-style: normal; font-weight: 300 700; }

:root {
  --paper: #f1f0eb;
  --ink: #101010;
  --bench: #cfcec9;
  --rule: #a3a29d;
  --muted: #5b5b57;
  --hover: #e2e1db;
  --panel-w: 272px;
  --gutter: 20px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bench); color: var(--ink); font-family: 'VisionDesign', Arial, sans-serif; font-synthesis: none; -webkit-font-smoothing: antialiased; }
button, input, output { font: inherit; color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr); }

/* Panneau --------------------------------------------------------- */
.control-panel { position: sticky; top: 0; z-index: 5; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: var(--gutter); background: var(--paper); border-right: 1px solid var(--ink); }


.control-group { border-bottom: 1px solid var(--ink); }
.control-group:first-child { border-top: 1px solid var(--ink); }
.group-title { display: flex; gap: 10px; align-items: baseline; margin: 0; padding: 16px 0 6px; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.group-title span { font-family: 'Dorienne', Georgia, serif; font-size: 11px; font-weight: 550; letter-spacing: 0; color: var(--muted); }

.control-block { padding: 8px 0 10px; }
.control-block + .control-block { border-top: 1px solid var(--rule); }
.control-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.control-label label, .control-label .static-label, .switch-row b { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.control-label output { font-family: 'Dorienne', Georgia, serif; font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }

input[type='range'] { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 1px; background: var(--ink); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 9px; height: 18px; margin-top: -9px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); }
input[type='range']:active::-webkit-slider-thumb { background: var(--ink); }
input[type='range']::-moz-range-track { height: 1px; background: var(--ink); }
input[type='range']::-moz-range-thumb { width: 9px; height: 18px; border: 1px solid var(--ink); border-radius: 0; background: var(--paper); }

.switch-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; padding: 10px 0; border-top: 1px solid var(--rule); cursor: pointer; }
.group-title + .switch-row { border-top: 0; }
.switch-row b { display: block; }
.switch-row input { appearance: none; -webkit-appearance: none; flex: none; width: 30px; height: 16px; margin: 0; border: 1px solid var(--ink); background: var(--paper); cursor: pointer; }
.switch-row input::after { content: ''; display: block; width: 10px; height: 10px; margin: 2px; background: var(--ink); transition: transform .15s ease; }
.switch-row input:checked { background: var(--ink); }
.switch-row input:checked::after { background: var(--paper); transform: translateX(14px); }



.actions { display: grid; gap: 6px; margin-top: auto; padding-top: 16px; }
.actions button { display: flex; justify-content: space-between; align-items: center; height: 34px; padding: 0 12px; border: 1px solid var(--ink); border-radius: 0; background: transparent; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.actions button:hover { background: var(--hover); }
.actions .action-primary { background: var(--ink); color: var(--paper); }
.actions .action-primary:hover { background: #2a2a2a; }

.find-input { width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--ink); border-radius: 0; background: #fff; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.find-input::placeholder { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.find-result { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; min-height: 0; padding-top: 8px; }
.find-result:empty { padding-top: 0; }
.find-result b, .tip b { font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.find-result span, .tip span { font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.find-result small, .tip small { grid-column: 1 / -1; font-family: 'Dorienne', Georgia, serif; font-size: 12px; font-weight: 550; line-height: 1.25; color: var(--ink); }
.tip { position: fixed; z-index: 20; max-width: 280px; padding: 7px 9px; background: var(--paper); border: 1px solid var(--ink); pointer-events: none; }
.poster-sheet .frame { cursor: pointer; }
.poster-sheet .frame:hover polygon { stroke-width: 1.6; }

.seg { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 10px; border: 1px solid var(--ink); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 8px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.seg label + label span { border-left: 1px solid var(--ink); }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -4px; }

.mini-actions { display: flex; gap: 6px; padding: 4px 0 6px; }
.mini-actions button { flex: 1; height: 28px; padding: 0 8px; border: 1px solid var(--ink); border-radius: 0; background: transparent; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.mini-actions button:hover { background: var(--hover); }
.hint { margin: 0 0 12px; color: var(--muted); font-family: 'Dorienne', Georgia, serif; font-size: 11px; font-weight: 550; line-height: 1.25; }
.select { width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--ink); border-radius: 0; background: #fff; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.dims-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.dims-row label { display: flex; align-items: center; gap: 5px; flex: 1; }
.dims-row span { font-size: 10px; font-weight: 700; }
.dims-row input { width: 100%; height: 28px; padding: 0 6px; border: 1px solid var(--ink); border-radius: 0; background: #fff; font-size: 12px; font-variant-numeric: tabular-nums; }
.dims-row .unit { font-family: 'Dorienne', Georgia, serif; font-weight: 550; font-size: 12px; }
.variants { margin: 4px 0 0; padding: 0; list-style: none; }
.variants:empty::after { content: 'Aucune variante enregistrée.'; display: block; color: var(--muted); font-family: 'Dorienne', Georgia, serif; font-size: 11px; font-weight: 550; padding: 2px 0 6px; }
.variants li { display: grid; grid-template-columns: 1fr auto; border-top: 1px solid var(--rule); }
.variants li button { border: 0; background: transparent; padding: 7px 0; text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .04em; cursor: pointer; }
.variants li button:hover { text-decoration: underline; }
.variants li .del { padding: 7px 4px; color: var(--muted); }
.poster-sheet.dragging { cursor: grabbing; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Plan de travail ------------------------------------------------- */
.stage { min-width: 0; height: 100vh; display: grid; place-items: center; padding: 28px clamp(20px, 3vw, 56px); }
.stage-inner { width: min(100%, calc((100vh - 96px) * var(--ratio, 1.4286))); }
.stage-toolbar { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 9px; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.poster-sheet { width: 100%; aspect-ratio: var(--ratio, 1.4286); overflow: hidden; background: #fff; outline: 1px solid var(--ink); box-shadow: 10px 12px 0 rgba(16, 16, 16, .12); }
.poster-sheet svg { display: block; width: 100%; height: 100%; }

@media (max-width: 640px) { .stage-toolbar span:nth-child(2) { display: none; } }
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .control-panel { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--ink); }
    .stage { height: auto; padding: 22px 16px 36px; }
  .stage-inner { width: 100%; }
}
@media print {
  html, body { overflow: hidden; background: #fff; }
  .app-shell { display: block; min-height: 0; }
  .control-panel, .stage-toolbar, .tip, .screen-only { display: none !important; }
  .stage, .stage-inner { display: block; padding: 0; }
  .poster-sheet { outline: 0; box-shadow: none; }
}
