/* ZPL Studio — feuille de style (sans framework). */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --sunken: #eef0f3;
  --border: #dfe3e8;
  --border-strong: #c9cfd6;
  --text: #1b2230;
  --muted: #5d6877;
  --faint: #8a94a3;
  --accent: #0f766e;
  --accent-hover: #0c5f58;
  --accent-soft: #e2f3f1;
  --on-accent: #ffffff;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --info: #2458b3;
  --info-soft: #e8effb;
  --warn: #9a5b00;
  --warn-soft: #fdf2dc;
  --error: #b42318;
  --error-soft: #fdeceb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
  --sheet: #ffffff;
  --sheet-shadow: 0 1px 4px rgba(0, 0, 0, .18);

  --t-cmd: #6d28d9;
  --t-fmt: #0f766e;
  --t-str: #a14a00;
  --t-prm: #1b2230;
  --t-sep: #98a2b3;
  --t-cm: #7a8494;
  --t-qry: #c0262d;
  --t-sgd: #2458b3;
  --t-var-bg: #dbe8ff;
  --t-var: #1d4ed8;

  --radius: 8px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --topbar: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1b2029;
    --sunken: #11151b;
    --border: #2a303b;
    --border-strong: #394150;
    --text: #e4e8ee;
    --muted: #a0aab8;
    --faint: #6f7a89;
    --accent: #2cc5b0;
    --accent-hover: #4fd6c3;
    --accent-soft: #123a36;
    --on-accent: #06221f;
    --ok: #4ccf8e;
    --ok-soft: #12301f;
    --info: #7aa7ff;
    --info-soft: #172743;
    --warn: #f0b44c;
    --warn-soft: #33260c;
    --error: #ff7b72;
    --error-soft: #3a1614;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    --sheet: #f4f4f0;
    --sheet-shadow: 0 1px 6px rgba(0, 0, 0, .6);
    --t-cmd: #c4a7ff;
    --t-fmt: #4fd6c3;
    --t-str: #f2b366;
    --t-prm: #e4e8ee;
    --t-sep: #6f7a89;
    --t-cm: #7f8a99;
    --t-qry: #ff8a80;
    --t-sgd: #7aa7ff;
    --t-var-bg: #1f3561;
    --t-var: #a9c6ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1b2029;
  --sunken: #11151b;
  --border: #2a303b;
  --border-strong: #394150;
  --text: #e4e8ee;
  --muted: #a0aab8;
  --faint: #6f7a89;
  --accent: #2cc5b0;
  --accent-hover: #4fd6c3;
  --accent-soft: #123a36;
  --on-accent: #06221f;
  --ok: #4ccf8e;
  --ok-soft: #12301f;
  --info: #7aa7ff;
  --info-soft: #172743;
  --warn: #f0b44c;
  --warn-soft: #33260c;
  --error: #ff7b72;
  --error-soft: #3a1614;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  --sheet: #f4f4f0;
  --sheet-shadow: 0 1px 6px rgba(0, 0, 0, .6);
  --t-cmd: #c4a7ff;
  --t-fmt: #4fd6c3;
  --t-str: #f2b366;
  --t-prm: #e4e8ee;
  --t-sep: #6f7a89;
  --t-cm: #7f8a99;
  --t-qry: #ff8a80;
  --t-sgd: #7aa7ff;
  --t-var-bg: #1f3561;
  --t-var: #a9c6ff;
  color-scheme: dark;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--sunken); border-radius: 4px; padding: .05em .35em; }
kbd {
  display: inline-block;
  padding: 0 .4em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: .78em;
  line-height: 1.5;
  background: var(--surface);
  color: var(--muted);
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.3rem; font-weight: 650; }
h2 { font-size: 1.02rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
svg { width: 1em; height: 1em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.grow { flex: 1 1 auto; }
.hint { margin: .35rem 0 0; color: var(--muted); font-size: .82rem; }

/* ---------- barre du haut ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--topbar);
  padding: 0 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.brand svg rect { fill: var(--accent); }
.brand svg path { fill: none; stroke: var(--on-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.nav a {
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
}
.nav a:hover { background: var(--sunken); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- boutons et champs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 34px;
  padding: .35rem .85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--sunken); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary kbd { background: transparent; color: inherit; border-color: currentColor; opacity: .75; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-small { min-height: 28px; padding: .2rem .6rem; font-size: .82rem; }
.btn-lg { min-height: 42px; padding: .5rem 1.1rem; font-size: .98rem; }
.danger { color: var(--error) !important; }
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 28px; height: 28px; font-size: .9rem; border-color: var(--border); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
input, select { min-height: 34px; padding: .3rem .55rem; font-size: .9rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.field > span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.field.narrow { width: 7.5rem; }
.field.grow { flex: 1 1 12rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; }
textarea.mono {
  width: 100%;
  padding: .6rem .7rem;
  font-family: var(--mono);
  font-size: .85rem;
  line-height: 1.5;
  resize: vertical;
  background: var(--surface-2);
}

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip code { background: none; padding: 0; color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block;
  padding: .05rem .45rem;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .72rem;
  font-weight: 600;
}
.count {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 .4em;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--muted);
  font-size: .75rem;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- notes, alertes ---------- */

.note, .alert {
  margin: 0 0 .5rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .86rem;
}
.note ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.note-info { background: var(--info-soft); color: var(--info); }
.note-warn { background: var(--warn-soft); color: var(--warn); }
.note-error, .alert-error { background: var(--error-soft); color: var(--error); }
.note-ok { background: var(--ok-soft); color: var(--ok); }
.note-muted { background: var(--sunken); color: var(--muted); }
.note code, .alert code { background: rgba(127, 127, 127, .15); color: inherit; }
.alert p { margin: .25rem 0 0; font-family: var(--mono); font-size: .82rem; white-space: pre-wrap; word-break: break-word; }
.queries { list-style: none; padding: 0 !important; }
.queries li { margin: .15rem 0; }
.error-text { margin: .4rem 0 0; color: var(--error); }
.warn-text { margin: .4rem 0 0; color: var(--warn); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 160px;
  padding: 1.5rem;
  color: var(--muted);
  text-align: center;
}
.empty p { margin: 0; }
.empty svg { width: 40px; height: 40px; fill: none; stroke: var(--faint); stroke-width: 1.4; }

/* ---------- mise en page ---------- */

.main { max-width: 1680px; margin: 0 auto; padding: 1.25rem; }
.workspace { display: grid; gap: 1.25rem; align-items: start; }
.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pane {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  min-width: 0;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.pane-foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.settings { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: flex-end; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.field-head label { font-weight: 600; font-size: .88rem; }
.field-tools { display: flex; gap: .75rem; }

.card { padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card h3 { margin-bottom: .6rem; }

/* menu déroulant */
.menu { position: relative; }
.menu-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 240px;
  padding: .3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.menu-list button {
  padding: .45rem .6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  text-align: left;
  cursor: pointer;
}
.menu-list button:hover { background: var(--sunken); }

/* ---------- accueil ---------- */

.hero { max-width: 760px; margin: 1.5rem auto 2rem; text-align: center; }
.eyebrow { margin: 0 0 .5rem; color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hero h1 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); font-weight: 750; letter-spacing: -.02em; }
.lead { margin: .9rem auto 0; color: var(--muted); font-size: 1.05rem; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; max-width: 1320px; margin: 0 auto 1.5rem; }
.tile {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.tile h2 { font-size: 1.15rem; }
.tile p { margin: 0; flex: 1; color: var(--muted); font-size: .92rem; }
.tile-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.tile-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-cta { color: var(--accent); font-weight: 600; font-size: .9rem; }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; max-width: 1200px; margin: 0 auto; }
.steps { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; }
.steps li { margin: .35rem 0; }
.memo { width: 100%; border-collapse: collapse; font-size: .86rem; }
.memo td { padding: .3rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.memo td:first-child { padding-right: .75rem; white-space: nowrap; }
.memo td:last-child { color: var(--muted); }
.memo tr:last-child td { border-bottom: 0; }
.facts { margin: 0; display: grid; gap: .6rem; font-size: .88rem; }
.facts dt { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; }

/* ---------- zone de code ---------- */

.code {
  --code-font: 13px;
  --code-line: 20px;
  --code-pad: 10px;
  position: relative;
  display: flex;
  min-height: 200px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}
.code:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-gutter {
  flex: none;
  min-width: 3em;
  padding: var(--code-pad) .55em var(--code-pad) .4em;
  overflow: hidden;
  background: var(--sunken);
  border-right: 1px solid var(--border);
  color: var(--faint);
  font: var(--code-font)/var(--code-line) var(--mono);
  text-align: right;
  white-space: pre;
  user-select: none;
}
.code-body { position: relative; flex: 1; min-width: 0; }
.code-hl, .code textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: var(--code-pad);
  border: 0;
  border-radius: 0;
  font: var(--code-font)/var(--code-line) var(--mono);
  letter-spacing: 0;
  tab-size: 4;
  white-space: pre;
  word-wrap: normal;
  overflow: auto;
}
.code-hl { overflow: hidden; pointer-events: none; color: var(--text); }
.code textarea {
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  box-shadow: none !important;
}
.code textarea::placeholder { color: var(--faint); }
.code textarea::selection { background: rgba(44, 140, 200, .3); color: transparent; }
.code-medium { height: 240px; resize: vertical; }
.code-fill { flex: 1 1 auto; height: 55vh; min-height: 260px; }
.t-cmd { color: var(--t-cmd); font-weight: 600; }
.t-fmt { color: var(--t-fmt); font-weight: 700; }
.t-str { color: var(--t-str); }
.t-prm { color: var(--t-prm); }
.t-sep { color: var(--t-sep); }
.t-cm { color: var(--t-cm); font-style: italic; }
.t-qry { color: var(--t-qry); font-weight: 700; }
.t-sgd { color: var(--t-sgd); }
.t-var { color: var(--t-var); background: var(--t-var-bg); border-radius: 3px; }
.code-block {
  margin: 0;
  padding: .6rem .75rem;
  max-height: 320px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  white-space: pre;
}

/* ---------- aperçu ---------- */

.preview-frame { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.preview-bar { display: flex; align-items: center; gap: .6rem; min-height: 32px; }
.coords { flex: 1; font-family: var(--mono); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coords.muted { font-family: var(--font); }
.zoom { display: flex; align-items: center; gap: .25rem; }
.zoom select { min-height: 28px; padding: .1rem .3rem; font-size: .82rem; }
.preview {
  min-height: 220px;
  max-height: calc(100vh - 230px);
  padding: 1rem;
  overflow: auto;
  border-radius: var(--radius-sm);
  background:
    repeating-conic-gradient(var(--sunken) 0 25%, transparent 0 50%) 0 0 / 18px 18px,
    var(--surface-2);
  border: 1px solid var(--border);
}
.labels { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.label-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; max-width: 100%; }
.zoom-fixed .label-fig { max-width: none; }
.label-sheet { background: var(--sheet); box-shadow: var(--sheet-shadow); line-height: 0; }
.label-sheet img { display: block; cursor: crosshair; }
.zoom-fit .label-sheet img { max-width: 100%; height: auto; }
.zoom-fixed .label-sheet img { width: calc(var(--w) * var(--zoom)); max-width: none; height: auto; }
.zoom-fixed .labels { align-items: flex-start; }
.preview img { image-rendering: auto; }
.zoom-fixed img { image-rendering: pixelated; }
.label-fig figcaption { display: flex; gap: .75rem; align-items: baseline; color: var(--muted); font-size: .8rem; }
.render-meta { margin: .75rem 0 0; color: var(--faint); font-size: .78rem; text-align: center; }
.final-zpl { margin-top: .75rem; }
.final-zpl summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-bottom: .4rem; }

/* ---------- envoi ---------- */

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.mode-switch label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .7rem .85rem .7rem 2.2rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mode-switch label:hover { border-color: var(--accent); }
.mode-switch label.active { border-color: var(--accent); background: var(--accent-soft); }
.mode-switch input { position: absolute; left: .8rem; top: .95rem; }
.mode-title { font-weight: 650; }
.mode-desc { color: var(--muted); font-size: .8rem; }
.conn {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem .75rem;
  margin: 0;
  padding: .75rem .85rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.conn legend { padding: 0 .35rem; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.conn .hint { flex-basis: 100%; }
.transport { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .75rem; flex-basis: 100%; }
#send-form { display: flex; flex-direction: column; gap: .85rem; }
#inspect:empty { display: none; }
#inspect .note:last-child { margin-bottom: 0; }

.response-panel { display: flex; flex-direction: column; gap: .85rem; }
.exchange { padding: .7rem .85rem; border-radius: var(--radius); border: 1px solid var(--border); border-left-width: 4px; }
.exchange-ok { border-left-color: var(--ok); }
.exchange-error { border-left-color: var(--error); background: var(--error-soft); }
.exchange-title { margin: 0; font-weight: 650; }
.stats { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: .5rem 0 0; }
.stats dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stats dd { margin: 0; font-weight: 600; }
.response-form { display: flex; flex-direction: column; gap: .35rem; }

.tabs { display: flex; gap: .25rem; margin-bottom: .75rem; border-bottom: 1px solid var(--border); }
.tabs button {
  margin-bottom: -1px;
  padding: .45rem .8rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.status-banner {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-bottom: .75rem;
  padding: .7rem .9rem;
  border-radius: var(--radius);
  font-size: .92rem;
}
.status-banner ul { margin: 0; padding-left: 1.1rem; }
.status-ok { background: var(--ok-soft); color: var(--ok); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-error { background: var(--error-soft); color: var(--error); }
.an-section { margin-bottom: 1rem; }
.an-section h3 { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; font-size: .9rem; }
.an-section h3 code { font-size: .75rem; color: var(--accent); }
.an-section .code-block { margin-top: .4rem; }
.kv { width: 100%; border-collapse: collapse; font-size: .86rem; }
.kv th, .kv td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.kv th { width: 45%; color: var(--muted); font-weight: 500; }
.kv td small { display: block; color: var(--faint); font-size: .76rem; }
.kv tr.lvl-error td { color: var(--error); font-weight: 650; }
.kv tr.lvl-warn td { color: var(--warn); font-weight: 650; }
.kv tr.lvl-ok td { color: var(--ok); }
.hexdump {
  margin: 0;
  padding: .6rem .75rem;
  max-height: 360px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .78rem;
  line-height: 1.55;
}
.hx-off { color: var(--faint); }
.hx-asc { color: var(--t-str); }

/* ---------- éditeur ---------- */

.main-editor { max-width: none; }
.editor { display: flex; flex-direction: column; gap: 1rem; }
.filebar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.file-title { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.file-name { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-family: var(--mono); font-size: .85rem; }
.file-name svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.dirty { color: var(--warn); font-family: var(--font); font-weight: 600; font-size: .8rem; }
.editor-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.editor-work { display: contents; }
.library { position: sticky; top: calc(var(--topbar) + 1rem); gap: .6rem; }
.search { width: 100%; }
.label-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; max-height: 60vh; overflow: auto; }
.label-list button {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.label-list button:hover { background: var(--sunken); }
.label-list button.active { background: var(--accent-soft); border-color: var(--accent); }
.label-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-meta { color: var(--muted); font-size: .75rem; }
.props { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: flex-end; }
.insert-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.pick { display: inline-flex; align-items: center; gap: .3rem; margin-left: .25rem; color: var(--muted); font-size: .82rem; }
.editor-main .code-fill { height: calc(100vh - 330px); min-height: 320px; }
.side { gap: .75rem; }
.var-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
  padding: .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.var-form .actions, .var-form .error-text { grid-column: 1 / -1; }
.vars { display: flex; flex-direction: column; gap: .4rem; }
.var-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: end;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.var-row.unused { border-style: dashed; }
.var-row .badge { position: absolute; top: -.55rem; right: .5rem; }
.var-id { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.var-id input { min-height: 28px; padding: .15rem .4rem; }
.var-name { font-weight: 650; color: var(--t-var); }
.var-desc { font-size: .8rem !important; color: var(--muted); }
.var-row .field input { width: 100%; }
.var-actions { display: flex; gap: .2rem; }
.side-preview { display: flex; flex-direction: column; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.side-preview .preview { max-height: 60vh; }

/* ---------- assistant SGD ---------- */

.sgd-builder {
  padding: .6rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.sgd-builder[open] { padding-bottom: .85rem; }
.sgd-builder summary { cursor: pointer; font-size: .88rem; font-weight: 600; }
.sgd-builder summary code { font-weight: 600; color: var(--t-sgd); }
.sgd-row { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: flex-end; margin-top: .75rem; }
.sgd-preview { display: flex; flex-wrap: wrap; align-items: baseline; gap: .75rem; margin: .6rem 0 .5rem; }
.sgd-preview code { color: var(--t-sgd); font-size: .85rem; word-break: break-all; }

/* ---------- paramètres de l'imprimante ---------- */

.settings-page { display: flex; flex-direction: column; gap: 1.25rem; }
.settings-form { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: flex-end; }
.settings-form .field.grow { flex-basis: 16rem; }
.identity {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .5rem;
  margin: 0 0 .85rem;
}
.identity div { padding: .5rem .7rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); min-width: 0; }
.identity dt { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.identity dd { margin: .1rem 0 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; margin-bottom: .75rem; }
.settings-toolbar input[type="search"] { flex: 0 1 22rem; min-width: 12rem; }
.menu-right { left: auto; right: 0; min-width: 320px; }
.settings-group { margin-bottom: .75rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.settings-group summary {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .85rem;
  background: var(--surface-2);
  cursor: pointer;
  list-style: none;
}
.settings-group summary::-webkit-details-marker { display: none; }
.settings-group summary::before { content: "▸"; color: var(--faint); transition: transform .15s; }
.settings-group[open] summary::before { transform: rotate(90deg); }
.settings-group summary code { background: none; font-size: .75rem; }
.settings-table { width: 100%; border-collapse: collapse; font-size: .86rem; table-layout: fixed; }
.settings-table th {
  padding: .4rem .85rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.settings-table th:nth-child(1) { width: 34%; }
.settings-table th:nth-child(2) { width: 34%; }
.settings-table th:nth-child(4) { width: 48px; }
.settings-table td { padding: .4rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.settings-table tr:last-child td { border-bottom: 0; }
.settings-table td small { display: block; color: var(--muted); font-size: .76rem; }
.setting-name { background: none; padding: 0; color: var(--t-sgd); font-size: .82rem; }
.setting-value { font-family: var(--mono); font-size: .82rem; }
.setting-range { color: var(--muted); font-size: .78rem; }
.setting-actions { text-align: right; }
.inline-edit { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.inline-edit input, .inline-edit select { flex: 1 1 10rem; min-height: 30px; font-family: var(--mono); font-size: .82rem; }
.row-msg { margin-top: .25rem; }
tr.row-ok td { background: var(--ok-soft); }
tr.row-ok .row-msg { color: var(--ok) !important; }
tr.row-warn td { background: var(--warn-soft); }
tr.row-warn .row-msg { color: var(--warn) !important; }
tr.row-error .row-msg { color: var(--error) !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- notifications ---------- */

.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast {
  padding: .65rem .9rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  box-shadow: var(--shadow-lg);
  font-size: .88rem;
  cursor: pointer;
  animation: toast-in .18s ease-out;
}
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--error); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- écrans étroits ---------- */

@media (max-width: 1280px) {
  .editor-grid { grid-template-columns: 210px minmax(0, 1fr); }
  .side { grid-column: 2; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 900px; }
}
@media (max-width: 1080px) {
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-table th:nth-child(3), .settings-table td:nth-child(3) { display: none; }
  .preview { max-height: none; }
  .code-fill, .editor-main .code-fill { height: 50vh; }
}
@media (max-width: 820px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .side { grid-column: auto; }
  .library { position: static; }
  .var-form { grid-template-columns: 1fr; }
  .var-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .var-id { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .main { padding: 1rem; }
  .topbar { gap: .75rem; padding: 0 1rem; }
  .brand span { display: none; }
  .mode-switch { grid-template-columns: 1fr; }
  .field.narrow { width: 6rem; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .settings-table th:nth-child(1), .settings-table th:nth-child(2) { width: auto; }
}
