:root {
  --bg: #fff; --surface: #f4f4f2; --line: #d9d9d4; --text: #1c1c1a; --muted: #6a6a64;
  --accent: #0b57d0; --accent-ink: #fff; --good: #1a7f37; --warn: #9a5b00; --bad: #b3261e;
  --mark: rgba(11, 87, 208, .16);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151614; --surface: #1d1f1c; --line: #34372f; --text: #e8e8e3; --muted: #9a9b93;
    --accent: #8ab4f8; --accent-ink: #0d1b33; --good: #5fd07a; --warn: #e3a14a; --bad: #ff8a80; --mark: rgba(138, 180, 248, .22); }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--bg); color: var(--text); }
.muted { color: var(--muted); font-size: 12px; }
.grow { flex: 1; }

header { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
header strong { margin-right: 8px; }
button, .btn { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
button:hover, .btn:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd { font: 11px ui-monospace, monospace; padding: 0 4px; border: 1px solid currentColor; border-radius: 3px; opacity: .7; }

main { display: grid; grid-template-columns: 260px minmax(0, 1fr) 380px; grid-template-rows: minmax(0, 1fr); min-height: 0; }
body { overflow: hidden; }
@media (max-width: 1000px) {
  main { grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 45%); }
  #panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}
#queue, #panel { overflow: auto; min-height: 0; }
#queue { border-right: 1px solid var(--line); }
#panel { border-left: 1px solid var(--line); padding: 12px; }

.doc { display: grid; grid-template-columns: 10px 1fr; gap: 0 8px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 8px 12px; }
.doc[aria-current="true"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.doc .dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; border: 2px solid var(--muted); }
.doc .dot.high { border-color: var(--good); } .doc .dot.mid { border-color: var(--warn); } .doc .dot.low { border-color: var(--bad); }
.doc .dot.accepted { background: var(--accent); border-color: var(--accent); }
.doc .dot.skipped { border-style: dashed; }
.doc .dot.busy { border-style: dotted; }
.doc .title { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.doc.skipped .title { text-decoration: line-through; color: var(--muted); }
.doc .sub { grid-column: 2; }

#viewer { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; background: var(--surface); }
.toolbar { display: flex; gap: 6px; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.toolbar .sep { width: 12px; }
#stage { overflow: auto; padding: 16px; }
#empty { max-width: 44ch; margin: 12vh auto; }
#sheet { position: relative; width: max-content; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); background: #fff; }
#canvas { display: block; }
#marks { position: absolute; inset: 0; }
.mark { position: absolute; border: 1px solid var(--accent); background: var(--mark); padding: 0; border-radius: 2px; opacity: .55; cursor: pointer; }
.mark.sel { opacity: 1; border-width: 2px; }
#stage.drag { outline: 2px dashed var(--accent); outline-offset: -8px; }

.field { margin-bottom: 12px; }
label { display: block; font-weight: 600; margin-bottom: 2px; }
input { font: inherit; width: 100%; padding: 4px 6px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
input[aria-invalid="true"] { border-color: var(--bad); }
#name { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
#visible b { color: var(--text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { padding: 1px 7px; font-size: 12px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip small { opacity: .75; }
#flags { margin: 4px 0 12px; font-size: 12px; }
#flags .f { display: inline-block; margin: 0 6px 4px 0; color: var(--warn); }
.actions { display: flex; gap: 6px; margin-bottom: 6px; }
#message { min-height: 1.4em; font-size: 12px; color: var(--bad); }
details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; }
pre { white-space: pre-wrap; font: 12px/1.4 ui-monospace, monospace; background: var(--surface); padding: 8px; border-radius: 4px; max-height: 40vh; overflow: auto; }
dialog { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; max-width: min(720px, 94vw); }
dialog td { padding: 2px 16px 2px 0; }
dialog h2 { font-size: 16px; margin: 0 0 8px; }
dialog h3 { font-size: 14px; margin: 16px 0 4px; }
dialog section + section { border-top: 1px solid var(--line); margin-top: 12px; }
label.inline { display: block; font-weight: 400; margin: 6px 0; }
label.inline input[type="checkbox"] { width: auto; margin-right: 4px; }
label.inline input[size] { width: auto; }
textarea { width: 100%; font: 12px/1.4 ui-monospace, monospace; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 6px; margin-bottom: 6px; }
#applyLog { padding-left: 18px; font-size: 12px; max-height: 30vh; overflow: auto; }
#applyLog .bad { color: var(--bad); } #applyLog .warn { color: var(--warn); }
#toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: 80vw; padding: 8px 14px; background: var(--text); color: var(--bg); border-radius: 4px; z-index: 10; }
#toast.bad { background: var(--bad); color: #fff; }
.doc .dot.applied { background: var(--good); border-color: var(--good); }

/* Dialog "Renommer": Drive first, the terminal commands are a discreet debugging aid at the bottom. */
fieldset.place { border: 1px solid var(--line); border-radius: 4px; margin: 8px 0; padding: 4px 10px 8px; }
fieldset.place legend { font-size: 13px; padding: 0 4px; }
fieldset.place label.inline input[type="radio"] { width: auto; margin-right: 6px; }
.dest { font-weight: 600; }
fieldset.place:has(#placeStay:checked) #driveDest { display: none; }
fieldset.place:has(#placeStay:checked) .dest { display: none; }
details.debug { margin-top: 16px; font-size: 12px; color: var(--muted); }
details.debug summary { font-size: 12px; }
