/* ==========================================================================
   R&T Lab — feuille de style
   Thème clair par défaut, thème sombre automatique (système) ou forcé.
   ========================================================================== */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --surface-3: #e7ecf2;
  --border: #e0e5ec;
  --border-strong: #c9d1dc;
  --text: #111823;
  --text-2: #4a5566;
  --text-3: #7b8696;
  --accent: #0e7c86;
  --accent-2: #0a636b;
  --accent-soft: #dff1f2;
  --on-accent: #ffffff;
  --ok: #157a3c;
  --ok-soft: #e3f4e8;
  --warn: #a8560a;
  --warn-soft: #fcf0de;
  --err: #c0262d;
  --err-soft: #fbe8e8;
  --info: #2f62c9;
  --info-soft: #e5edfb;
  --canvas: #fafbfc;
  --grid: #e4e8ee;
  --lk-eth: #5b6a7e;
  --code-bg: #0f141b;
  --code-text: #d5dde8;
  --code-comment: #7d8a9c;
  --code-kw: #6ccad2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .22);
  --radius: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1016;
    --surface: #141a22;
    --surface-2: #1a212b;
    --surface-3: #222b37;
    --border: #252e3a;
    --border-strong: #34404f;
    --text: #e6ecf2;
    --text-2: #a5afbc;
    --text-3: #77828f;
    --accent: #35b9c4;
    --accent-2: #5ccbd4;
    --accent-soft: #11313a;
    --on-accent: #03181b;
    --ok: #46c06a;
    --ok-soft: #12291a;
    --warn: #e0a43a;
    --warn-soft: #2e2312;
    --err: #f2665f;
    --err-soft: #3a1719;
    --info: #78a6f5;
    --info-soft: #172338;
    --canvas: #0f141b;
    --grid: #1b232e;
    --lk-eth: #8794a6;
    --code-bg: #0a0e13;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c1016;
  --surface: #141a22;
  --surface-2: #1a212b;
  --surface-3: #222b37;
  --border: #252e3a;
  --border-strong: #34404f;
  --text: #e6ecf2;
  --text-2: #a5afbc;
  --text-3: #77828f;
  --accent: #35b9c4;
  --accent-2: #5ccbd4;
  --accent-soft: #11313a;
  --on-accent: #03181b;
  --ok: #46c06a;
  --ok-soft: #12291a;
  --warn: #e0a43a;
  --warn-soft: #2e2312;
  --err: #f2665f;
  --err-soft: #3a1719;
  --info: #78a6f5;
  --info-soft: #172338;
  --canvas: #0f141b;
  --grid: #1b232e;
  --lk-eth: #8794a6;
  --code-bg: #0a0e13;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -.015em; }
.mono, code, kbd { font-family: var(--mono); }
code { font-size: .92em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
kbd { font-size: 12px; background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.ico { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 12px;
  text-decoration: none; color: var(--text);
  font-weight: 750; font-size: 17px; letter-spacing: -.02em;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
}
.brand-mark svg { width: 20px; height: 20px; }
.nav-group { padding: 2px 10px 6px; }
.nav-label {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); padding: 12px 10px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none;
  font-size: 14px; font-weight: 550;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot {
  margin-top: auto; padding: 12px 14px 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--text-3);
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.scrim { display: none; }

.view { padding: 34px 44px 72px; width: 100%; max-width: 1260px; margin: 0 auto; outline: none; }
.view.wide { padding: 0; max-width: none; margin: 0; }

.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 27px; line-height: 1.2; margin: 0 0 6px; }
.page-head p { margin: 0; color: var(--text-2); max-width: 75ch; }

.stack > * + * { margin-top: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row.center { align-items: center; }
.spacer { flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card h2 { font-size: 16.5px; margin: 0; }
.card h3 { font-size: 14px; margin: 18px 0 8px; }
.card .sub { color: var(--text-2); font-size: 13.5px; margin: 3px 0 0; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
input, select, textarea {
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%; min-width: 0;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid, textarea.invalid { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
input.mono, textarea.mono { font-family: var(--mono); font-size: 13.5px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.input-unit { display: flex; }
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit select, .input-unit .unit {
  width: auto; flex: none; border-left: 0;
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  background: var(--surface-2); font-size: 13px;
}
.input-unit .unit { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 8px 8px 0; color: var(--text-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.sm .ico { width: 15px; height: 15px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); }
.icon-btn .ico { width: 17px; height: 17px; }

/* ---------- Data display ---------- */
.kv {
  display: grid; grid-template-columns: minmax(130px, max-content) minmax(0, 1fr);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.kv > div { padding: 8px 12px; border-bottom: 1px solid var(--border); min-width: 0; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.kv .k { color: var(--text-2); font-size: 13px; background: var(--surface-2); }
.kv .v { font-family: var(--mono); font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
.kv .v.sans { font-family: var(--sans); font-size: 14px; }
.kv .v strong { font-weight: 700; }
.copy-mini {
  border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 5px;
  display: inline-grid; place-items: center; opacity: 0; transition: opacity .12s;
}
.kv .v:hover .copy-mini, .copy-mini:focus-visible { opacity: 1; }
.copy-mini:hover { color: var(--accent); background: var(--surface-2); }
.copy-mini .ico { width: 14px; height: 14px; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap.tall { max-height: 520px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 650; color: var(--text-2);
  padding: 9px 12px; border-bottom: 1px solid var(--border-strong);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.mono, .tbl .mono { font-size: 13px; white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.group td { background: var(--surface-3); font-weight: 650; font-size: 12.5px; color: var(--text-2); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 650; line-height: 1.6;
  padding: 1px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; border-radius: 10px; font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.callout .ico { margin-top: 1px; }
.callout.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.err { background: var(--err-soft); border-color: transparent; color: var(--err); }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--info); }

.code {
  background: var(--code-bg); color: var(--code-text);
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  padding: 16px 18px; border-radius: 10px; margin: 0;
  overflow: auto; white-space: pre; tab-size: 2;
  border: 1px solid var(--border);
}
.code .c { color: var(--code-comment); }
.code .k { color: var(--code-kw); }

.bin { font-family: var(--mono); font-size: 13px; letter-spacing: .02em; line-height: 1.9; overflow-x: auto; }
.bin .n { color: var(--accent); font-weight: 650; }
.bin .h { color: var(--warn); }
.bin-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; white-space: nowrap; }
.bin-row > span:first-child { color: var(--text-2); font-family: var(--sans); font-size: 12.5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.result-big { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.result-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.stat .v { font-family: var(--mono); font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.stat .l { font-size: 12px; color: var(--text-2); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab {
  padding: 9px 13px; border: 0; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 5px 11px; border-radius: 6px; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Toast & modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 550;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 300;
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); color: #fff; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 12, 18, .5);
  display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
}
.modal.wide { width: min(1040px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 14px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* Dropdown menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: none; color: var(--text);
  font: inherit; font-size: 13.5px; text-align: left;
  padding: 7px 10px; border-radius: 7px; cursor: pointer;
}
.menu button:hover { background: var(--surface-2); }
.menu button .ico { width: 16px; height: 16px; color: var(--text-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 4px; }
.menu .menu-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 6px 10px 2px; }

/* ---------- Home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: center;
  padding: 30px 32px; border-radius: 18px; margin-bottom: 30px;
  background:
    radial-gradient(1200px 300px at 0% 0%, var(--accent-soft), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
}
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin: 0 0 8px; }
.hero h1 { font-size: 34px; line-height: 1.12; margin: 0 0 12px; letter-spacing: -.03em; }
.hero .lead { color: var(--text-2); font-size: 16px; margin: 0; max-width: 56ch; }
.quick { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.quick label { font-size: 12.5px; font-weight: 650; color: var(--text-2); display: block; margin-bottom: 6px; }
.input-row { display: flex; gap: 8px; }
.quick-res { margin-top: 12px; }
.quick .kv { grid-template-columns: max-content minmax(0, 1fr); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 700; margin: 0 0 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 30px; }
.tool-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px; border-radius: 14px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool-card .ti { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tool-card .ti .ico { width: 20px; height: 20px; }
.tool-card h3 { margin: 4px 0 0; font-size: 15.5px; }
.tool-card p { margin: 0; font-size: 13.5px; color: var(--text-2); }
.tool-card.feature { grid-column: span 2; background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }

/* ---------- Topology editor ---------- */
.topo {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}
.topo-toolbar {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topo-title { display: block !important; font-weight: 700; font-size: 14px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.tb-text { margin-left: 2px; }
@media (max-width: 1360px) { .topo-toolbar .tb-text { display: none; } }
.tb-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.topo-toolbar select { width: auto; padding: 5px 26px 5px 9px; font-size: 13px; }
.topo-palette { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 10px 8px; }
.pal-title { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 4px 8px 6px; }
.pal-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 5px 8px; margin-bottom: 2px; border-radius: 9px; border: 1px solid transparent;
  background: none; color: var(--text); font: inherit; font-size: 13px; font-weight: 550;
  cursor: grab; text-align: left;
}
.pal-item:hover { background: var(--surface-2); border-color: var(--border); }
.pal-item svg { width: 34px; height: 34px; flex: none; }
.topo-canvas { position: relative; overflow: hidden; background: var(--canvas); min-height: 0; }
.topo-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.topo-svg.panning { cursor: grabbing; }
.topo-svg.mode-link, .topo-svg.mode-link .node { cursor: crosshair; }
.topo-panel { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; padding: 16px 16px 40px; }
.topo-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin: 18px 0 8px; }
.topo-panel h3:first-child { margin-top: 0; }
.topo-panel .field { margin-bottom: 10px; }
.topo-panel input, .topo-panel select, .topo-panel textarea { font-size: 13.5px; padding: 6px 9px; }
.iface {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 8px; background: var(--surface-2);
}
.iface-top { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.iface-top input { font-family: var(--mono); font-weight: 650; }
.iface-grid { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 6px; }
.iface-grid.three { grid-template-columns: minmax(0, 1fr) 58px 78px; }
.iface-peer { font-size: 12px; color: var(--text-2); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.iface-peer .ico { width: 13px; height: 13px; }
.panel-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--text); }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 12.5px; color: var(--text-2); align-items: center; }
.shortcuts kbd { justify-self: start; }
.link-legend { display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.link-legend span { display: flex; align-items: center; gap: 8px; }
.link-legend svg { width: 34px; height: 8px; }

.zoom-ctl {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; box-shadow: var(--shadow);
}
.zoom-ctl span { font-size: 12px; font-family: var(--mono); color: var(--text-2); min-width: 46px; text-align: center; }
.canvas-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 550;
  padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow-lg); pointer-events: none; white-space: nowrap;
}
.empty-hint {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.empty-hint > div {
  text-align: center; color: var(--text-2); max-width: 360px; padding: 20px;
  pointer-events: auto;
}
.empty-hint h2 { color: var(--text); font-size: 18px; margin: 0 0 6px; }
.empty-hint p { margin: 0 0 14px; font-size: 14px; }

/* SVG canvas content */
.grid-line { stroke: var(--grid); stroke-width: 1; }
.t-label { fill: var(--text); font: 650 12.5px var(--sans); text-anchor: middle; paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; stroke-linejoin: round; }
.t-sub { fill: var(--text-2); font: 11px var(--mono); text-anchor: middle; paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; stroke-linejoin: round; }
.t-if { fill: var(--text-2); font: 10.5px var(--mono); text-anchor: middle; paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; stroke-linejoin: round; }
.t-if.ip { fill: var(--accent); }
.t-link { fill: var(--text-2); font: italic 11px var(--sans); text-anchor: middle; paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; }
.t-if, .t-link, .t-sub, .zone-label { pointer-events: none; }
.lk { fill: none; stroke-linecap: round; }
.lk-gap { stroke: var(--canvas); stroke-width: 7; }
.lk-eth { stroke: var(--lk-eth); }
.lk-fiber { stroke: #e8920c; }
.lk-serial { stroke: #d6453d; }
.lk-wifi { stroke: #8b5cf6; }
.lk-vpn { stroke: #16a34a; }
.lk-hit { stroke: transparent; stroke-width: 16; fill: none; cursor: pointer; }
.lk-sel { stroke: var(--accent); stroke-opacity: .28; stroke-width: 10; fill: none; stroke-linecap: round; }
.node { cursor: move; }
.node .hit { fill: transparent; }
.selbox { fill: none; stroke: none; }
.node.sel .selbox { stroke: var(--accent); stroke-width: 2; fill: var(--accent-soft); fill-opacity: .55; stroke-dasharray: 5 3; }
.node.from .selbox { stroke: var(--warn); stroke-width: 2.5; fill: var(--warn-soft); fill-opacity: .6; }
.zone-rect { cursor: move; }
.zone.sel .zone-rect { stroke-width: 2.5; stroke-dasharray: none; }
.zone-label { font: 700 13px var(--sans); paint-order: stroke; stroke: var(--canvas); stroke-width: 5px; stroke-linejoin: round; }
.zone-handle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; cursor: nwse-resize; }
.rubber { stroke: var(--warn); stroke-width: 2; stroke-dasharray: 6 4; fill: none; pointer-events: none; }

/* Issues list */
.issues { display: grid; gap: 8px; }
.issue { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; border: 1px solid var(--border); }
.issue .ico { margin-top: 1px; }
.issue.err { background: var(--err-soft); border-color: transparent; }
.issue.err .ico { color: var(--err); }
.issue.warn { background: var(--warn-soft); border-color: transparent; }
.issue.warn .ico { color: var(--warn); }
.issue.info { background: var(--info-soft); border-color: transparent; }
.issue.info .ico { color: var(--info); }

/* Project list */
.proj-list { display: grid; gap: 8px; }
.proj { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.proj.current { border-color: var(--accent); background: var(--accent-soft); }
.proj .meta { flex: 1; min-width: 0; }
.proj .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj .meta span { font-size: 12.5px; color: var(--text-2); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tpl { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 14px; cursor: pointer; font: inherit; color: var(--text); }
.tpl:hover { border-color: var(--accent); background: var(--accent-soft); }
.tpl b { display: block; font-size: 14.5px; margin-bottom: 4px; }
.tpl span { font-size: 13px; color: var(--text-2); }

/* ---------- Cisco generator ---------- */
.gen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.gen-out { position: sticky; top: 18px; }
.gen-out .code { max-height: calc(100vh - 170px); min-height: 300px; }
.sec { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 12px; }
.sec-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; user-select: none; }
.sec-head h2 { font-size: 15px; margin: 0; flex: 1; }
.sec-head .sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.sec-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.sec.off .sec-body { display: none; }
.sec.off .sec-head h2 { color: var(--text-2); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.rep { display: grid; gap: 8px; margin-top: 12px; }
.rep-row { display: grid; gap: 8px; align-items: end; }
.rep-row .icon-btn { margin-bottom: 1px; }
.rep-head { display: grid; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; margin-top: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; }

/* ---------- Memo ---------- */
.memo-search { position: relative; max-width: 460px; margin-bottom: 16px; }
.memo-search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.memo-search input { padding-left: 36px; }
.cmd { font-family: var(--mono); font-size: 13px; cursor: pointer; color: var(--text); }
.cmd:hover { color: var(--accent); }
.memo-section + .memo-section { margin-top: 26px; }
.memo-section h2 { font-size: 16px; margin: 0 0 10px; }
.wire { display: inline-block; width: 26px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; border: 1px solid rgba(0,0,0,.15); }

/* ---------- Notes ---------- */
.notes { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.note-list { display: grid; gap: 6px; max-height: calc(100vh - 290px); overflow-y: auto; }
.note-item { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--text); }
.note-item:hover { border-color: var(--border-strong); }
.note-item.active { border-color: var(--accent); background: var(--accent-soft); }
.note-item b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item span { font-size: 12px; color: var(--text-2); }
.note-editor textarea { min-height: 420px; font-family: var(--mono); font-size: 13.5px; }
.note-title { font-size: 20px !important; font-weight: 700; border: 0 !important; padding: 4px 0 !important; box-shadow: none !important; background: transparent !important; }

/* VLSM */
.vlsm-grid { grid-template-columns: 340px minmax(0, 1fr); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.alloc-bar { position: relative; height: 30px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface-3) 6px, var(--surface-3) 12px); }
.alloc-bar > div { position: absolute; top: 0; height: 100%; border-right: 1px solid var(--surface); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; overflow: hidden; white-space: nowrap; min-width: 2px; }

/* Barre latérale réduite (pages pleine largeur comme l'éditeur) */
@media (min-width: 901px) {
  .app.compact .sidebar { width: 62px; }
  .app.compact .brand { padding: 15px; justify-content: center; }
  .app.compact .brand > span:last-child,
  .app.compact .nav-link span,
  .app.compact .sidebar-foot span { display: none; }
  .app.compact .nav-group { padding: 0 8px; }
  .app.compact .nav-label { font-size: 0; padding: 0; height: 1px; margin: 8px 6px; background: var(--border); }
  .app.compact .nav-link { justify-content: center; padding: 9px; }
  .app.compact .sidebar-foot { justify-content: center; padding: 12px 8px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .topo { grid-template-columns: 160px minmax(0, 1fr) 290px; }
  .gen { grid-template-columns: 1fr; }
  .gen-out { position: static; }
}
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; padding: 24px; }
}
@media (max-width: 980px) {
  .tool-card.feature { grid-column: auto; }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notes { grid-template-columns: 1fr; }
  .note-list { max-height: 260px; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
    z-index: 90;
  }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(8, 12, 18, .45); z-index: 80; }
  .topbar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar-title { font-weight: 700; font-size: 15px; }
  .view { padding: 20px 16px 56px; }
  .page-head h1 { font-size: 23px; }
  .hero h1 { font-size: 27px; }
  .grid2, .vlsm-grid { grid-template-columns: 1fr; }
  .auto-grid { grid-template-columns: 1fr; }
  .topo { grid-template-columns: 1fr; grid-template-rows: auto auto 62vh auto; height: auto; }
  .topo-palette { border-right: 0; border-bottom: 1px solid var(--border); display: flex; overflow-x: auto; gap: 4px; padding: 6px 8px; }
  .pal-title { display: none; }
  .pal-item { flex-direction: column; gap: 2px; width: auto; min-width: 74px; font-size: 11.5px; padding: 4px 6px; }
  .topo-panel { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 560px) {
  .grid3, .grid4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv .k { border-bottom: 0 !important; padding-bottom: 2px; }
  .card { padding: 16px; }
  .input-row { flex-direction: column; }
}

@media print {
  .sidebar, .topbar, .btn, .icon-btn { display: none !important; }
  .view { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
