:root {
  /* charte Mow-Logo : encre, papier, pierre, orange */
  --bg: #0E0E10;
  --panel: #1C1C1F;
  --line: rgba(247, 244, 237, 0.12);
  --line-strong: rgba(247, 244, 237, 0.24);
  --text: #F7F4ED;
  --muted: #B7AFA1;
  --stone: #8B8378;
  --accent: #FF5A1F;
  --accent-soft: #FFB088;
  --accent-ink: #0E0E10;
  --raised: #26262A;
  --danger: #FF7A6B;
  --radius: 4px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font-body); display: flex; flex-direction: column; }
button { font: inherit; color: inherit; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--line-strong); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 600; padding: 11px 14px; width: 100%; }
button.primary:hover:not(:disabled) { background: #ff7240; }
button.on { background: rgba(255, 90, 31, 0.14); border-color: var(--accent); color: var(--text); }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand small { font-family: var(--font-body); color: var(--muted); font-weight: 400; font-size: 12px; }
.brand a { color: inherit; text-decoration: none; }
.badge { font-family: var(--font-body); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); border: 1px solid rgba(255, 90, 31, 0.45); border-radius: 999px; padding: 2px 8px; }
.manual { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.manual a, .beta a, .export-note a { color: var(--accent); text-decoration: none; font-weight: 600; }
.manual a:hover, .beta a:hover, .export-note a:hover { text-decoration: underline; }
.mark { width: 18px; height: 18px; border-radius: 50% 50% 50% 4px; border: 2.5px solid var(--accent); }
.stats { flex: 1; color: var(--muted); font-size: 12.5px; text-align: right; }

.home { position: relative; overflow: hidden; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px 16px; text-align: center; }
.bg-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.home > :not(.bg-art) { position: relative; z-index: 1; }
.home h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 5vw, 52px); line-height: 1.1; margin: 0; letter-spacing: -.01em; }
.home h1 em { font-style: italic; color: var(--accent); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0; }
.eyebrow i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.beta { max-width: 560px; margin: 4px 0 0; padding: 14px 18px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); background: var(--panel); color: var(--muted); font-size: 13.5px; text-align: left; }
.beta strong { color: var(--text); }
.lead { color: var(--muted); max-width: 560px; margin: 0; }
.drop { width: min(560px, 100%); border: 1.5px dashed var(--accent-soft); border-radius: var(--radius); padding: 44px 20px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; background: var(--panel); transition: border-color .15s, background .15s; }
.drop strong { font-size: 18px; }
.drop span { color: var(--muted); }
.drop.over { border-color: var(--accent); background: rgba(255, 90, 31, 0.08); }
.err { color: var(--danger); margin: 0; }

.editor { flex: 1; display: grid; grid-template-columns: 290px 1fr 270px; min-height: 0; }
.panel { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 8px 14px 16px; }
.panel.export { border-right: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; padding-top: 14px; }
.panel h2 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 17px; }
details { border-bottom: 1px solid var(--line); padding: 4px 0; }
details[open] { padding-bottom: 14px; }
summary { cursor: pointer; font-weight: 600; padding: 10px 0; list-style: none; display: flex; align-items: center; gap: 12px; border-radius: var(--radius); }
summary:hover .st { color: var(--accent); }
.sic { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: rgba(255, 90, 31, 0.1); color: var(--accent); }
.sic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.stx { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.st { font-size: 15px; transition: color .15s; }
.sd { font-weight: 400; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.chev { flex: 0 0 8px; width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; margin-right: 4px; }
details[open] .chev { transform: rotate(45deg); }
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 24px; line-height: 1.15; margin: 10px 0 6px; }
summary::-webkit-details-marker { display: none; }
summary b { font-weight: 500; color: var(--accent); margin-left: 6px; font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row.undo { margin-top: 12px; }
.row.undo button { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.presets button { padding: 3px 0; width: 30px; font-size: 12px; }
.presets button:first-child { width: auto; padding: 3px 8px; }
.swatches { display: flex; flex-direction: column; gap: 4px; }
.sw { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; }
.sw.sel { border-color: var(--accent); background: rgba(255, 90, 31, 0.10); }
.sw.hidden .chip { opacity: .25; }
.sw input[type=color] { width: 26px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }
.sw .chip { width: 26px; height: 26px; border-radius: var(--radius); border: 1px solid #0006; }
.sw .bar { flex: 1; height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.sw .bar i { display: block; height: 100%; background: var(--stone); }
.sw .pct { font-size: 11.5px; color: var(--muted); width: 40px; text-align: right; }
.sw .eye { padding: 2px 6px; font-size: 12px; background: transparent; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { font-size: 12.5px; padding: 6px 9px; }
.sl { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin: 10px 0; font-size: 13px; }
.sl input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.sl output { color: var(--muted); font-size: 12px; }

.viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.zoom { display: flex; gap: 4px; }
.stage-wrap { position: relative; flex: 1; overflow: hidden; cursor: grab; background-color: #F7F4ED; background-image: linear-gradient(45deg, #ECE7DA 25%, transparent 25%), linear-gradient(-45deg, #ECE7DA 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ECE7DA 75%), linear-gradient(-45deg, transparent 75%, #ECE7DA 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.stage-wrap.dragging { cursor: grabbing; }
.stage-wrap.erase { cursor: crosshair; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage img, .stage .vec { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage img { image-rendering: pixelated; user-select: none; }
.stage .vec svg { width: 100%; height: 100%; display: block; }
.split { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid var(--accent); pointer-events: none; }
.split-range { margin: 6px 12px; accent-color: var(--accent); }
.busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(14, 14, 16, 0.7); color: var(--text); font-weight: 600; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff3; border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.cards { display: flex; flex-direction: column; gap: 6px; }
.cards button { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; }
.cards span { color: var(--muted); font-size: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.check input { accent-color: var(--accent); }
.out { color: var(--muted); font-size: 12px; margin: 0; word-break: break-all; }
.export-note { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

.diag-box { position: absolute; top: 10px; left: 10px; z-index: 5; max-width: 330px; padding: 10px 12px; background: rgba(14, 14, 16, 0.9); border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.diag-box details { border: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.diag-box summary { padding: 0 0 4px; }
.diag-box label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.diag-box i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

@media (max-width: 900px) {
  .manual { display: none; }
  .editor { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .viewer { order: -1; }
}
