/* CutLink — interface façon macOS (clair / sombre selon le système) */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #f5f5f7;
  --canvas: #e5e5ea;
  --surface: #ffffff;
  --sidebar: rgba(236, 236, 240, .82);
  --toolbar: rgba(250, 250, 252, .8);
  --line: rgba(0, 0, 0, .1);
  --line-strong: rgba(0, 0, 0, .18);
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .2);
  --txt: #1d1d1f;
  --txt-2: #6e6e73;
  --txt-3: #aeaeb2;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, .12);
  --on-accent: #fff;
  --green: #28cd41; --orange: #ff9500; --red: #ff3b30; --pink: #ff2d92;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.08);
  --r: 8px;
  --sel: rgba(0, 122, 255, .16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1e1e1e; --canvas: #141414; --surface: #2a2a2c;
    --sidebar: rgba(40, 40, 42, .82); --toolbar: rgba(38, 38, 40, .82);
    --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .16);
    --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
    --txt: #f5f5f7; --txt-2: #98989d; --txt-3: #636366;
    --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .2);
    --green: #32d74b; --orange: #ff9f0a; --red: #ff453a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    --shadow-lg: 0 24px 64px rgba(0,0,0,.6);
    --sel: rgba(10, 132, 255, .28);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1e1e1e; --canvas: #141414; --surface: #2a2a2c;
  --sidebar: rgba(40, 40, 42, .82); --toolbar: rgba(38, 38, 40, .82);
  --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .16);
  --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
  --txt: #f5f5f7; --txt-2: #98989d; --txt-3: #636366;
  --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, .2);
  --green: #32d74b; --orange: #ff9f0a; --red: #ff453a;
  --sel: rgba(10, 132, 255, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--txt); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
[hidden], .hidden { display: none !important; }
code { font: 11.5px var(--mono); background: var(--fill); padding: 1px 5px; border-radius: 4px; }
kbd { font: 11px var(--font); min-width: 20px; display: inline-block; text-align: center; padding: 1px 5px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line-strong); border-bottom-width: 2px; margin-right: 2px; }
.muted { color: var(--txt-2); }
button, input, select { font: inherit; color: inherit; }
button { cursor: default; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 1px; border-radius: 6px; }

/* Icônes (SVG injectés) */
i[data-i] { display: inline-flex; width: 16px; height: 16px; flex: none; }
i[data-i] svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ───── Barre d'outils unifiée ───── */
#toolbar { height: 52px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 12px 0 14px;
  background: var(--toolbar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.tb-left, .tb-right, .tb-center { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.app-icon { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(160deg, #ff5fae, #ff2d92 55%, #d6006f); display: grid; place-items: center; box-shadow: 0 1px 3px rgba(214,0,111,.35); flex: none; }
.app-icon svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.title b { font-size: 13px; font-weight: 600; }
.title span { font-size: 11px; color: var(--txt-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-btn { height: 28px; min-width: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 6px; background: transparent; color: var(--txt-2); }
.tb-btn:hover:not(:disabled) { background: var(--fill); color: var(--txt); }
.tb-btn:active:not(:disabled) { background: var(--fill-2); }
.tb-btn:disabled { opacity: .35; }
.tb-group { display: flex; gap: 2px; padding-left: 8px; border-left: 1px solid var(--line); }
.zoom { display: flex; align-items: center; }
.zval { min-width: 58px; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--txt); }

/* Contrôle segmenté */
.seg { display: inline-flex; background: var(--fill); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 24px; padding: 0 10px; border-radius: 5px; color: var(--txt); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.seg button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.06); font-weight: 500; }
.seg.wide { display: flex; } .seg.wide button { flex: 1; }
.seg.small button { padding: 0 8px; font-size: 11.5px; height: 22px; }
.seg.icons button { padding: 0; width: 100%; height: 30px; }
.seg.icons { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; }
.seg.icons button i { width: 18px; height: 18px; }

/* Boutons */
.btn, .btn-primary { height: 28px; padding: 0 12px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.btn { background: var(--surface); border: .5px solid var(--line-strong); box-shadow: 0 .5px 1px rgba(0,0,0,.08); }
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--surface) 92%, var(--txt)); }
.btn:active:not(:disabled) { background: color-mix(in srgb, var(--surface) 85%, var(--txt)); }
.btn-primary { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 500; box-shadow: 0 1px 2px rgba(0,122,255,.3); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-primary:active:not(:disabled) { filter: brightness(.94); }
.btn:disabled, .btn-primary:disabled { opacity: .4; }
.btn.danger { color: var(--red); }
.btn.wide, .btn-primary.wide { width: 100%; height: 32px; margin-bottom: 8px; }
.big { height: 38px; padding: 0 18px; font-size: 14px; border-radius: 9px; }
.link { border: 0; background: none; color: var(--accent); font-size: 11.5px; padding: 0 3px; }
.link:hover { text-decoration: underline; }
.icon-btn { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; border: 0; background: none; color: var(--txt-2); }
.icon-btn:hover { background: var(--fill); color: var(--txt); }
.btn-row { display: flex; gap: 6px; } .btn-row .btn { flex: 1; padding: 0 6px; }

.pill { height: 24px; border-radius: 12px; border: 0; padding: 0 10px 0 8px; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: color-mix(in srgb, var(--green) 75%, var(--txt)); }
.pill.warn { background: color-mix(in srgb, var(--orange) 18%, transparent); color: color-mix(in srgb, var(--orange) 80%, var(--txt)); }
.pill.err { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--fill-2); border-top-color: var(--txt-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── Structure ───── */
#shell { display: grid; grid-template-columns: 264px 1fr 300px; height: calc(100% - 52px); }
#sidebar { background: var(--sidebar); backdrop-filter: blur(30px) saturate(160%); -webkit-backdrop-filter: blur(30px) saturate(160%); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#inspector { background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 14px 24px; min-height: 0; }
#center { position: relative; min-width: 0; min-height: 0; }
#stage { position: absolute; inset: 0; background: var(--canvas); overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#stage.tool-hand #view, #stage.space #view { cursor: grab; }
#stage.panning #view { cursor: grabbing !important; }
#stage.over-item #view { cursor: move; }

/* Barre latérale */
.sb-section { padding: 10px 8px 6px; display: flex; flex-direction: column; min-height: 0; }
.sb-section.grow { flex: 1; border-top: 1px solid var(--line); }
.sb-section:first-child { max-height: 46%; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 6px; font-size: 11px; font-weight: 600; color: var(--txt-2); letter-spacing: .02em; }
.sb-head > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-actions { display: flex; gap: 2px; flex: none; }
.sb-empty { color: var(--txt-3); font-size: 12px; padding: 6px 10px 10px; }
.sb-empty span { font-size: 11px; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.row { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 7px; margin-bottom: 1px; position: relative; }
.row:hover { background: var(--fill); }
.row.sel { background: var(--sel); }
.row.off .meta, .row.off .th { opacity: .45; }
.th { width: 34px; height: 34px; border-radius: 5px; flex: none; background: repeating-conic-gradient(#d8d8dc 0 25%, #fff 0 50%) 0 0/8px 8px; box-shadow: inset 0 0 0 .5px var(--line); object-fit: contain; }
.art .th { width: 40px; height: 40px; }
.meta { flex: 1; min-width: 0; }
.meta b { display: block; font-weight: 500; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta small { display: block; color: var(--txt-2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tag { font-size: 10px; font-weight: 500; padding: 0 5px; border-radius: 4px; background: var(--fill); color: var(--txt-2); margin-left: 4px; vertical-align: 1px; }
.count { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--txt-2); background: var(--fill); border-radius: 9px; padding: 1px 7px; flex: none; }

/* Interrupteur macOS */
.switch { position: relative; width: 32px; height: 19px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 10px; background: var(--fill-2); transition: background .18s; }
.switch i::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 0 0 .5px rgba(0,0,0,.05); transition: transform .18s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(13px); }
.switch input:disabled + i { opacity: .4; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }

/* Inspecteur */
#tabSeg { margin-bottom: 14px; }
.group { background: var(--surface); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; box-shadow: 0 0 0 .5px var(--line), 0 1px 2px rgba(0,0,0,.03); }
.group h4 { margin: 0 0 8px; font-size: 11px; font-weight: 600; color: var(--txt-2); letter-spacing: .02em; }
.insp-head { display: flex; gap: 10px; align-items: center; margin: 0 2px 12px; }
.insp-head .th { width: 44px; height: 44px; }
.insp-head b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insp-head small { color: var(--txt-2); font-size: 11.5px; }
.insp-empty { color: var(--txt-2); text-align: center; padding: 40px 16px; font-size: 12.5px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.field > label { color: var(--txt); flex: 1; min-width: 0; }
.scrub { cursor: ew-resize; }
.scrub:hover { color: var(--accent); }
.inp { display: flex; align-items: center; background: var(--bg); border-radius: 6px; box-shadow: inset 0 0 0 .5px var(--line-strong); height: 24px; padding-right: 7px; width: 104px; }
.inp:focus-within { box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.inp input { width: 100%; min-width: 0; border: 0; background: transparent; padding: 0 4px 0 8px; height: 100%; text-align: right; font-variant-numeric: tabular-nums; outline: none; -moz-appearance: textfield; }
.inp input::-webkit-inner-spin-button { -webkit-appearance: none; }
.inp em { font-style: normal; color: var(--txt-2); font-size: 11.5px; }
select { height: 24px; border-radius: 6px; border: 0; box-shadow: inset 0 0 0 .5px var(--line-strong); background: var(--bg); padding: 0 6px; max-width: 150px; }
input[type=text] { width: 100%; height: 30px; border-radius: 7px; border: 0; box-shadow: inset 0 0 0 .5px var(--line-strong); background: var(--bg); padding: 0 10px; font: 13px var(--mono); user-select: text; }
input[type=text]:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 2px 0 6px; }
.note { color: var(--txt-2); font-size: 11.5px; margin: 0 0 6px; }
.presets { display: flex; gap: 4px; margin: 2px 0 6px; }
.presets button { flex: 1; height: 20px; border-radius: 5px; border: 0; background: var(--fill); font-size: 11px; font-variant-numeric: tabular-nums; }
.presets button.on { background: var(--accent); color: #fff; }
.stepper { display: inline-flex; align-items: center; background: var(--bg); border-radius: 6px; box-shadow: inset 0 0 0 .5px var(--line-strong); height: 24px; }
.stepper button { width: 26px; height: 24px; border: 0; background: none; display: grid; place-items: center; color: var(--txt-2); }
.stepper button:hover { color: var(--txt); }
.stepper span { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
details.adv > summary, details.rl > summary { list-style: none; cursor: default; font-size: 11px; font-weight: 600; color: var(--txt-2); display: flex; align-items: center; gap: 6px; }
details.adv > summary::-webkit-details-marker, details.rl > summary::-webkit-details-marker { display: none; }
details.adv > summary::before, details.rl > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 2px; }
details[open].adv > summary::before, details[open].rl > summary::before { transform: rotate(45deg); }
details.adv[open] > summary { margin-bottom: 6px; }
details.rl ol { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--txt-2); }
details.rl li { margin-bottom: 5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.kv span { color: var(--txt-2); }
.kv b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.kv .names { text-align: right; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.sel-actions { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.vec-info { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 12px; margin-bottom: 8px; }
.vec-info i { color: var(--accent); margin-top: 1px; }

#warnings { list-style: none; padding: 0; margin: 0; }
#warnings li { display: flex; gap: 8px; padding: 6px 0; font-size: 12px; border-bottom: .5px solid var(--line); }
#warnings li:last-child { border-bottom: 0; }
#warnings li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; }
#warnings .err::before { background: var(--red); }
#warnings .warn::before { background: var(--orange); }
#warnings .ok::before { background: var(--green); }
#warnings .info::before { background: var(--accent); }

/* Vide / dépôt */
#empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; }
.empty-card { max-width: 460px; text-align: center; }
.empty-icon { width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; }
.empty-icon svg { width: 42px; height: 42px; fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.empty-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; }
.empty-card p { color: var(--txt-2); margin: 0 0 14px; font-size: 13.5px; }
.empty-card .fine { font-size: 11.5px; color: var(--txt-3); margin-top: 16px; }
.chips { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; flex-wrap: wrap; }
.chips span { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--surface); box-shadow: 0 0 0 .5px var(--line); color: var(--txt-2); }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#dropOverlay { position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 14px; background: var(--accent-soft); display: none; place-items: center; font-size: 16px; font-weight: 600; color: var(--accent); pointer-events: none; z-index: 3; }
body.dragging #dropOverlay { display: grid; }

/* HUD flottant */
#hud { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 14px; border-radius: 11px;
  background: var(--toolbar); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); box-shadow: var(--shadow), 0 0 0 .5px var(--line); font-size: 12px; white-space: nowrap; z-index: 2; }
#hud label { display: flex; align-items: center; gap: 5px; }
#hud input { accent-color: var(--accent); margin: 0; }
.hud-sep { width: 1px; height: 14px; background: var(--line-strong); }
#cursorPos { font-variant-numeric: tabular-nums; color: var(--txt-2); min-width: 130px; }

/* Toast */
.toast { position: fixed; left: 50%; top: 64px; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; padding: 9px 16px; border-radius: 10px; background: var(--toolbar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--shadow-lg), 0 0 0 .5px var(--line); font-size: 13px; z-index: 20; max-width: min(560px, 90vw); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { color: var(--red); }

/* Fenêtres modales (sheets) */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.28); display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; z-index: 30; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-box { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg), 0 0 0 .5px var(--line); max-width: 820px; width: calc(100% - 32px); max-height: 84vh; overflow: auto; padding: 22px 26px; position: relative; user-select: text; animation: pop .18s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-box.small { max-width: 400px; }
.modal-box h2 { margin: 0 0 2px; font-size: 20px; }
.modal-box h3 { font-size: 13px; margin: 18px 0 6px; }
.modal-box.small h3 { margin-top: 0; }
.modal-box ol, .modal-box ul { padding-left: 18px; margin: 0; } .modal-box li { margin-bottom: 5px; }
.modal-box .close { position: absolute; right: 12px; top: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.err-line { color: var(--red); font-size: 12px; min-height: 16px; margin-top: 4px; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.keys { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.keys td { padding: 3px 0; } .keys td:first-child { white-space: nowrap; padding-right: 10px; width: 1%; }

@media (max-width: 1180px) { #shell { grid-template-columns: 230px 1fr 280px; } .tb-group { display: none; } }
@media (max-width: 900px) {
  html, body { overflow: auto; }
  #toolbar { grid-template-columns: 1fr auto; } .tb-center { display: none; } .title span { display: none; }
  #shell { display: flex; flex-direction: column; height: auto; }
  #sidebar { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  #center { height: 60vh; } #inspector { border-left: 0; }
  .help-grid { grid-template-columns: 1fr; }
  #hud { gap: 8px; padding: 6px 10px; } #cursorPos { display: none; }
}
