/* Simulation réseaux — Académie de Bordeaux */

:root {
  --fn-bg: #e8eef4;
  --fn-desk: #f4f7fa;
  --fn-surface: #ffffff;
  --fn-border: #c5d0dc;
  --fn-text: #1e293b;
  --fn-muted: #64748b;
  --fn-accent: #2563eb;
  --fn-accent-soft: #dbeafe;
  --fn-ok: #16a34a;
  --fn-err: #dc2626;
  --fn-warn: #d97706;
  --fn-radius: 10px;
  --fn-font: "Instrument Sans", system-ui, sans-serif;
  --fn-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

[data-theme="dark"] {
  --fn-bg: #0f172a;
  --fn-desk: #1e293b;
  --fn-surface: #334155;
  --fn-border: #475569;
  --fn-text: #f1f5f9;
  --fn-muted: #94a3b8;
  --fn-accent: #60a5fa;
  --fn-accent-soft: #1e3a5f;
}

*, *::before, *::after { box-sizing: border-box; }

body.fn-app {
  margin: 0;
  min-height: 100vh;
  font-family: var(--fn-font);
  font-size: 0.95rem;
  color: var(--fn-text);
  background: var(--fn-bg);
  display: flex;
  flex-direction: column;
}

/* Header */
.fn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  background: var(--fn-surface);
  border-bottom: 1px solid var(--fn-border);
  flex-wrap: wrap;
}

.fn-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--fn-text);
  font-weight: 600;
}

.fn-brand-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fn-accent);
  color: #fff;
  border-radius: 8px;
  font-size: 1.1rem;
}

.fn-brand small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--fn-muted);
}

.fn-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.fn-btn {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--fn-border);
  background: var(--fn-surface);
  color: var(--fn-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fn-btn:hover { border-color: var(--fn-accent); }

.fn-btn--primary {
  background: var(--fn-accent);
  border-color: var(--fn-accent);
  color: #fff;
}

.fn-btn--primary:hover { filter: brightness(1.08); }

.fn-btn--sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.fn-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Main layout */
.fn-main {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  grid-template-rows: 1fr auto;
  gap: 0;
  min-height: 0;
}

.fn-sidebar {
  grid-row: 1 / 3;
  background: var(--fn-surface);
  border-right: 1px solid var(--fn-border);
  padding: 1rem;
  overflow-y: auto;
}

.fn-sidebar h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fn-muted);
}

.fn-level-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.fn-level-tab {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--fn-border);
  border-radius: var(--fn-radius);
  background: var(--fn-desk);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--fn-text);
  transition: border-color 0.15s, background 0.15s;
}

.fn-level-tab strong { display: block; }

.fn-level-tab span {
  font-size: 0.75rem;
  color: var(--fn-muted);
}

.fn-level-tab.is-active {
  border-color: var(--fn-accent);
  background: var(--fn-accent-soft);
}

.fn-objectives {
  margin: 0;
  padding: 0 0 0 1.1rem;
  font-size: 0.82rem;
  color: var(--fn-muted);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.fn-objectives li.is-done { color: var(--fn-ok); }
.fn-objectives li.is-done::marker { content: "✓ "; }

.fn-program-note {
  margin-top: 1.25rem;
  padding: 0.75rem;
  background: var(--fn-desk);
  border-radius: var(--fn-radius);
  font-size: 0.78rem;
  color: var(--fn-muted);
  line-height: 1.45;
}

/* Workspace */
.fn-workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--fn-desk);
  border-bottom: 1px solid var(--fn-border);
}

.fn-workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: color-mix(in srgb, var(--fn-surface) 80%, transparent);
  border-bottom: 1px solid var(--fn-border);
  font-size: 0.82rem;
  color: var(--fn-muted);
}

.fn-canvas {
  flex: 1;
  position: relative;
  min-height: 360px;
  overflow: auto;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--fn-border) 35%, transparent) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(color-mix(in srgb, var(--fn-border) 35%, transparent) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--fn-desk);
}

.fn-canvas-inner {
  position: relative;
  min-width: 100%;
  min-height: 360px;
}

.fn-canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  margin: 0;
  font-size: 0.95rem;
  color: var(--fn-muted);
  pointer-events: none;
}

.fn-links-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

.fn-ping-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.fn-svg-link {
  pointer-events: stroke;
  cursor: pointer;
}

.fn-svg-line {
  stroke: var(--fn-accent);
  stroke-linecap: round;
  pointer-events: stroke;
  opacity: 0.85;
}

.fn-svg-line.is-selected {
  stroke: var(--fn-ok);
  opacity: 1;
}

.fn-svg-line.is-subnet-conflict {
  stroke: var(--fn-err);
  stroke-dasharray: 10 7;
  opacity: 1;
}

.fn-svg-line.is-ping-active {
  stroke: var(--fn-ok);
  stroke-width: 5;
  opacity: 1;
  animation: fn-ping-cable 0.45s ease-in-out infinite alternate;
}

@keyframes fn-ping-cable {
  from { stroke-width: 4; opacity: 0.75; }
  to { stroke-width: 6; opacity: 1; }
}

.fn-ping-dot {
  pointer-events: none;
}

.fn-ping-dot--out {
  fill: var(--fn-ok);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--fn-ok) 70%, transparent));
}

.fn-ping-dot--reply {
  fill: color-mix(in srgb, var(--fn-ok) 55%, #fff);
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--fn-ok) 50%, transparent));
}

.fn-ping-dot--fail {
  fill: var(--fn-err);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--fn-err) 75%, transparent));
}

.fn-svg-bar-bg {
  fill: var(--fn-surface);
  stroke: var(--fn-err);
  stroke-width: 2;
  pointer-events: none;
}

.fn-svg-bar-x {
  stroke: var(--fn-err);
  stroke-width: 2.5;
  stroke-linecap: round;
  pointer-events: none;
}

.fn-props-warn {
  margin: 0.5rem 0 0;
  padding: 0.6rem;
  background: color-mix(in srgb, var(--fn-err) 12%, var(--fn-desk));
  border: 1px solid color-mix(in srgb, var(--fn-err) 40%, transparent);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--fn-err);
  line-height: 1.45;
}

.fn-props-hint {
  margin: -0.15rem 0 0.65rem;
  font-size: 0.72rem;
  color: var(--fn-muted);
  line-height: 1.4;
}

.fn-toolbox {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.fn-tool {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 2px solid var(--fn-border);
  border-radius: var(--fn-radius);
  background: var(--fn-desk);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--fn-text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.fn-tool:hover {
  border-color: var(--fn-accent);
  background: var(--fn-accent-soft);
}

.fn-tool-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.fn-mode-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.fn-mode-btn {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 2px solid var(--fn-border);
  border-radius: 8px;
  background: var(--fn-desk);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  color: var(--fn-text);
}

.fn-mode-btn.is-active {
  border-color: var(--fn-accent);
  background: var(--fn-accent-soft);
  font-weight: 600;
}

.fn-mode-icon--rj45 {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  margin-right: 0.35rem;
  vertical-align: -0.2em;
  object-fit: contain;
  filter: brightness(0);
  opacity: 0.82;
}

[data-theme="dark"] .fn-mode-icon--rj45 {
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.fn-file-bar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.fn-file-hint {
  margin: 0 0 1rem;
  font-size: 0.72rem;
  color: var(--fn-muted);
  line-height: 1.4;
}

.fn-btn--help {
  font-weight: 600;
}

.fn-help-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--fn-text);
}

.fn-help-steps li + li {
  margin-top: 0.65rem;
}

.fn-help-steps code {
  font-family: var(--fn-mono);
  font-size: 0.9em;
  background: var(--fn-desk);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* Scénarios & problèmes */
.fn-btn--scenario {
  background: var(--fn-accent-soft);
  border-color: var(--fn-accent);
  color: var(--fn-accent);
  font-weight: 600;
}

.fn-btn--problem {
  background: color-mix(in srgb, var(--fn-warn) 14%, var(--fn-surface));
  border-color: var(--fn-warn);
  color: var(--fn-warn);
  font-weight: 600;
}

.fn-btn--capture {
  font-weight: 600;
}

.fn-workspace-toolbar {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.fn-scenario-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--fn-accent-soft);
  border: 1px solid color-mix(in srgb, var(--fn-accent) 35%, var(--fn-border));
  border-radius: 8px;
}

.fn-scenario-bar--problem {
  background: color-mix(in srgb, var(--fn-warn) 12%, var(--fn-surface));
  border-color: color-mix(in srgb, var(--fn-warn) 40%, var(--fn-border));
}

.fn-scenario-bar--problem .fn-scenario-bar__level {
  color: var(--fn-warn);
}

.fn-scenario-bar[hidden],
#fn-scenario-verify[hidden] {
  display: none !important;
}

.fn-scenario-bar__level {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fn-accent);
  margin-bottom: 0.15rem;
}

.fn-scenario-bar__info strong {
  display: block;
  font-size: 0.92rem;
}

.fn-scenario-bar__info p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--fn-muted);
  line-height: 1.4;
}

.fn-scenario-bar__actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
}

.fn-scenario-result {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  white-space: pre-line;
  line-height: 1.5;
}

.fn-scenario-result.is-ok {
  background: color-mix(in srgb, var(--fn-ok) 12%, var(--fn-surface));
  border: 1px solid color-mix(in srgb, var(--fn-ok) 40%, transparent);
  color: var(--fn-ok);
}

.fn-scenario-result.is-partial {
  background: color-mix(in srgb, var(--fn-warn) 12%, var(--fn-surface));
  border: 1px solid color-mix(in srgb, var(--fn-warn) 40%, transparent);
  color: var(--fn-warn);
}

.fn-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.fn-modal[hidden] {
  display: none;
}

.fn-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.fn-modal__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--fn-surface);
  border: 1px solid var(--fn-border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.fn-modal__panel--wide {
  max-width: 640px;
}

.fn-modal__panel--capture {
  max-width: 520px;
}

.fn-capture-modal__body {
  padding: 1rem 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fn-capture-preview-wrap {
  position: relative;
  min-height: 160px;
  border: 1px solid var(--fn-border);
  border-radius: 10px;
  background: var(--fn-desk);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fn-capture-preview-wrap--transparent {
  background:
    repeating-conic-gradient(color-mix(in srgb, var(--fn-border) 40%, var(--fn-surface)) 0% 25%, var(--fn-surface) 0% 50%)
    50% / 14px 14px;
}

.fn-capture-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  border: 2px solid var(--fn-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
}

.fn-capture-option input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.fn-capture-option span {
  font-weight: 600;
  display: block;
}

.fn-capture-option small {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--fn-muted);
  font-weight: 400;
}

.fn-capture-preview {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.fn-capture-preview-loading,
.fn-capture-preview-empty {
  margin: 0;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: var(--fn-muted);
  text-align: center;
}

.fn-capture-formats {
  margin: 0;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.fn-capture-formats legend {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fn-muted);
  margin-bottom: 0.35rem;
}

.fn-capture-format {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 2px solid var(--fn-border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.fn-capture-format:has(input:checked) {
  border-color: var(--fn-accent);
  background: var(--fn-accent-soft);
}

.fn-capture-format input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.fn-capture-format span {
  font-weight: 700;
  font-size: 0.9rem;
  display: block;
}

.fn-capture-format small {
  display: block;
  font-size: 0.75rem;
  color: var(--fn-muted);
  margin-top: 0.1rem;
}

.fn-capture-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.fn-capture-actions .fn-btn--primary {
  flex: 1;
  min-width: 140px;
}

.fn-modal__intro {
  margin: 0;
  padding: 0.65rem 1.15rem 0;
  font-size: 0.8rem;
  color: var(--fn-muted);
  line-height: 1.45;
}

.fn-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--fn-border);
}

.fn-modal__head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.fn-modal__close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--fn-desk);
  cursor: pointer;
  font-size: 1rem;
  color: var(--fn-muted);
}

.fn-modal__body {
  overflow-y: auto;
  padding: 1rem 1.15rem 1.25rem;
}

.fn-scenario-group h3 {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fn-muted);
}

.fn-scenario-group + .fn-scenario-group {
  margin-top: 1.25rem;
}

.fn-scenario-cards {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.fn-scenario-card {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border: 2px solid var(--fn-border);
  border-radius: 10px;
  background: var(--fn-desk);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.fn-scenario-card:hover {
  border-color: var(--fn-accent);
  background: var(--fn-accent-soft);
}

.fn-scenario-card--problem {
  border-color: color-mix(in srgb, var(--fn-warn) 35%, var(--fn-border));
}

.fn-scenario-card--problem:hover {
  border-color: var(--fn-warn);
  background: color-mix(in srgb, var(--fn-warn) 10%, var(--fn-surface));
}

.fn-scenario-card__tag {
  display: inline-block;
  margin-bottom: 0.2rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--fn-warn) 18%, var(--fn-surface));
  color: var(--fn-warn);
}

.fn-scenario-card__title {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--fn-text);
}

.fn-scenario-card__brief {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--fn-muted);
  line-height: 1.4;
}

body.fn-modal-open {
  overflow: hidden;
}

.app-version {
  position: fixed;
  left: 0.65rem;
  bottom: 0.45rem;
  z-index: 50;
  font-size: 0.68rem;
  font-family: var(--fn-font);
  color: var(--fn-muted);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 640px) {
  .fn-scenario-bar {
    flex-direction: column;
  }

  .fn-scenario-bar__actions {
    width: 100%;
  }

  .fn-scenario-bar__actions .fn-btn {
    flex: 1;
  }
}

/* Devices */
.fn-device {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 110px;
  padding: 0.85rem 0.5rem 0.65rem;
  background: var(--fn-surface);
  border: 2px solid var(--fn-border);
  border-radius: var(--fn-radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  z-index: 2;
  user-select: none;
}

.fn-device--placed {
  position: absolute;
  cursor: grab;
}

.fn-device--placed:active {
  cursor: grabbing;
}

.fn-device.is-link-pending {
  border-color: var(--fn-warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-warn) 35%, transparent);
}

.fn-device:hover { border-color: var(--fn-accent); }

.fn-device.is-selected {
  border-color: var(--fn-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-accent) 30%, transparent);
}

.fn-device.is-active {
  border-color: var(--fn-ok);
  animation: fn-pulse 0.6s ease;
}

.fn-device.is-ping-src {
  border-color: var(--fn-ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-ok) 35%, transparent);
  animation: fn-ping-device 0.45s ease-in-out infinite alternate;
}

.fn-device.is-ping-dest {
  border-color: var(--fn-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-accent) 35%, transparent);
  animation: fn-ping-device 0.45s ease-in-out infinite alternate;
}

.fn-device.is-ping-fail {
  border-color: var(--fn-err);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-err) 35%, transparent);
  animation: fn-ping-device-fail 0.4s ease-in-out infinite alternate;
}

@keyframes fn-ping-device {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

@keyframes fn-ping-device-fail {
  from { transform: scale(1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-err) 25%, transparent); }
  to { transform: scale(1.02); box-shadow: 0 0 0 5px color-mix(in srgb, var(--fn-err) 45%, transparent); }
}

.fn-device.is-off {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.fn-device.is-hidden { display: none; }

@keyframes fn-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.fn-device-icon {
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
}

.fn-device-icon--img {
  width: 2.35rem;
  height: 2.35rem;
  object-fit: contain;
}

.fn-tool-icon--img {
  width: 1.55rem;
  height: 1.55rem;
  object-fit: contain;
  display: block;
}

.fn-device-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.fn-device-meta {
  font-size: 0.7rem;
  color: var(--fn-muted);
  font-family: var(--fn-mono);
  margin-top: 0.15rem;
  text-align: center;
  word-break: break-all;
}

.fn-device-meta--placeholder {
  color: var(--fn-warn);
  font-style: italic;
  opacity: 0.85;
}

.fn-device-meta--valid {
  color: var(--fn-ok);
  font-weight: 600;
}

.fn-device-meta--error {
  color: var(--fn-err);
  font-weight: 700;
}

.fn-device.is-ip-error {
  border-color: var(--fn-err);
  background: color-mix(in srgb, var(--fn-err) 8%, var(--fn-surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-err) 22%, transparent);
}

.fn-device.is-ip-error.is-selected {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-err) 35%, transparent);
}

.fn-device-error-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fn-err);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--fn-surface);
  line-height: 1;
}

.fn-device-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fn-err);
  border: 2px solid var(--fn-surface);
}

.fn-device-badge.is-ok { background: var(--fn-ok); }

/* Links */
.fn-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 72px;
  min-width: 48px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.fn-link-line {
  width: 100%;
  height: 5px;
  background: var(--fn-border);
  border-radius: 3px;
  position: relative;
  transition: background 0.2s;
}

.fn-link.is-connected .fn-link-line { background: var(--fn-accent); }
.fn-link.is-active .fn-link-line { background: var(--fn-ok); box-shadow: 0 0 6px var(--fn-ok); }

.fn-link-label {
  font-size: 0.65rem;
  color: var(--fn-muted);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.fn-link-btn {
  margin-top: 0.35rem;
  font-size: 0.68rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--fn-border);
  border-radius: 4px;
  background: var(--fn-surface);
  cursor: pointer;
  color: var(--fn-muted);
  font-family: inherit;
}

.fn-link-btn:hover { border-color: var(--fn-accent); color: var(--fn-accent); }

.fn-link.is-hidden { display: none; }

.fn-packet {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fn-accent);
  box-shadow: 0 0 8px var(--fn-accent);
  top: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.5s ease-in-out;
  z-index: 10;
  pointer-events: none;
  display: none;
}

.fn-packet.is-visible { display: block; }

.fn-cloud {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  border: 2px dashed var(--fn-border);
  border-radius: 50%;
  width: 90px;
  height: 90px;
  justify-content: center;
  background: color-mix(in srgb, var(--fn-accent) 6%, var(--fn-surface));
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fn-muted);
  z-index: 2;
}

.fn-cloud.is-hidden { display: none; }

.fn-status-bar {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  color: var(--fn-muted);
  border-top: 1px solid var(--fn-border);
  min-height: 2.4em;
  background: var(--fn-surface);
}

.fn-status-bar.is-error {
  color: var(--fn-err);
  font-weight: 600;
  background: color-mix(in srgb, var(--fn-err) 8%, var(--fn-surface));
}

/* Properties panel */
.fn-props {
  background: var(--fn-surface);
  border-left: 1px solid var(--fn-border);
  padding: 1rem;
  overflow-y: auto;
}

.fn-props h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.fn-props-empty {
  font-size: 0.85rem;
  color: var(--fn-muted);
  font-style: italic;
}

.fn-field {
  margin-bottom: 0.75rem;
}

.fn-field label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  color: var(--fn-muted);
}

.fn-field input,
.fn-field select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-family: var(--fn-mono);
  font-size: 0.88rem;
  border: 1px solid var(--fn-border);
  border-radius: 6px;
  background: var(--fn-desk);
  color: var(--fn-text);
}

.fn-field input:focus,
.fn-field select:focus {
  outline: 2px solid var(--fn-accent);
  outline-offset: 1px;
}

.fn-field input.is-invalid { border-color: var(--fn-err); }

.fn-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--fn-border);
  font-size: 0.85rem;
}

.fn-toggle-row input { width: auto; accent-color: var(--fn-accent); }

.fn-props-info {
  margin-top: 1rem;
  padding: 0.65rem;
  background: var(--fn-desk);
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--fn-muted);
  line-height: 1.45;
}

/* Terminal */
.fn-terminal-panel {
  grid-column: 2 / 4;
  display: flex;
  flex-direction: column;
  background: #0c1222;
  border-top: 1px solid var(--fn-border);
  min-height: 200px;
  max-height: 280px;
}

.fn-terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: #1a2540;
  font-size: 0.78rem;
  color: #94a3b8;
}

.fn-terminal-host select {
  font-family: inherit;
  font-size: 0.78rem;
  background: #0c1222;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
}

.fn-terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 0.75rem 0.25rem;
  font-family: var(--fn-mono);
  font-size: 0.82rem;
  line-height: 1.45;
  color: #94a3b8;
}

.fn-term-line { white-space: pre-wrap; word-break: break-all; }
.fn-term-line--cmd { color: #f8fafc; }
.fn-term-line--ok { color: #4ade80; }
.fn-term-line--err { color: #f87171; }
.fn-term-line--info { color: #93c5fd; }

.fn-terminal-input-row {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.75rem 0.65rem;
  font-family: var(--fn-mono);
  font-size: 0.82rem;
}

.fn-terminal-prompt {
  color: #64748b;
  white-space: pre;
  flex-shrink: 0;
}

.fn-terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f8fafc;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  caret-color: #f8fafc;
}

@media (max-width: 960px) {
  .fn-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto auto;
  }

  .fn-sidebar {
    grid-row: auto;
    border-right: none;
    border-bottom: 1px solid var(--fn-border);
  }

  .fn-level-tabs {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .fn-level-tab { flex: 1 1 120px; }

  .fn-props {
    border-left: none;
    border-top: 1px solid var(--fn-border);
  }

  .fn-terminal-panel { grid-column: 1; }

  .fn-canvas-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .fn-link { width: 100%; flex-direction: row; padding: 0.25rem 0; }
  .fn-link-line { width: 60%; }
}

/* ===================================================================
   Version 2 : modes, adressage complet, panneau du poste
   =================================================================== */

.fn-btn--mode {
  font-weight: 700;
  background: var(--fn-ok);
  border-color: var(--fn-ok);
  color: #fff;
}

.fn-btn--mode:hover { filter: brightness(1.08); border-color: var(--fn-ok); }

body.fn-sim-mode .fn-btn--mode {
  background: var(--fn-surface);
  border-color: var(--fn-accent);
  color: var(--fn-accent);
}

.fn-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fn-toolbar-row #fn-toolbar-hint {
  flex: 1;
  min-width: 12rem;
}

.fn-mode-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--fn-accent-soft);
  color: var(--fn-accent);
  white-space: nowrap;
}

body.fn-sim-mode .fn-mode-badge {
  background: color-mix(in srgb, var(--fn-ok) 18%, var(--fn-surface));
  color: var(--fn-ok);
}

.fn-zoom {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.fn-zoom .fn-btn { min-width: 2.1rem; }

body.fn-sim-mode .fn-canvas {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--fn-ok) 45%, transparent);
}

.fn-tool:disabled,
.fn-mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.fn-undo-bar {
  display: flex;
  gap: 0.35rem;
  margin: -0.35rem 0 1.1rem;
}

.fn-undo-bar .fn-btn { flex: 1; }

.fn-device--placed {
  touch-action: none;
}

body.fn-sim-mode .fn-device--placed { cursor: pointer; }

.fn-device.is-term-host {
  border-color: var(--fn-ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fn-ok) 30%, transparent);
}

.fn-svg-hit {
  stroke: transparent;
  stroke-width: 18;
}

/* Propriétés */
.fn-props h2 small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--fn-muted);
  margin-left: 0.25rem;
}

.fn-field-label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  color: var(--fn-muted);
}

.fn-field textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-family: var(--fn-mono);
  font-size: 0.82rem;
  border: 1px solid var(--fn-border);
  border-radius: 6px;
  background: var(--fn-desk);
  color: var(--fn-text);
  resize: vertical;
}

.fn-field input::placeholder,
.fn-field textarea::placeholder {
  color: color-mix(in srgb, var(--fn-muted) 70%, transparent);
  font-family: var(--fn-font);
}

.fn-segmented {
  display: flex;
  border: 1px solid var(--fn-border);
  border-radius: 8px;
  overflow: hidden;
}

.fn-segmented label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.4rem 0.3rem;
  font-size: 0.78rem;
  cursor: pointer;
  background: var(--fn-desk);
  color: var(--fn-text);
}

.fn-segmented label + label { border-left: 1px solid var(--fn-border); }

.fn-segmented label:has(input:checked) {
  background: var(--fn-accent-soft);
  color: var(--fn-accent);
  font-weight: 700;
}

.fn-segmented input { accent-color: var(--fn-accent); margin: 0; }

.fn-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.4rem 0 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.fn-check input { accent-color: var(--fn-accent); }

.fn-props-sub {
  margin: 1rem 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fn-muted);
}

.fn-svc-block[hidden] { display: none; }

.fn-iface {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.7rem 0.2rem;
  border: 1px solid var(--fn-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--fn-desk) 60%, var(--fn-surface));
}

.fn-iface__head {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.fn-iface__wan {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

.fn-iface__wan small { color: var(--fn-muted); }

.fn-advanced {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.8rem;
}

.fn-advanced summary {
  cursor: pointer;
  color: var(--fn-muted);
  margin-bottom: 0.5rem;
}

.fn-prop-delete { margin-top: 0.75rem; }

.fn-props code,
.fn-summary code {
  font-family: var(--fn-mono);
  font-size: 0.85em;
}

.fn-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.6rem;
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
}

.fn-summary dt { color: var(--fn-muted); }
.fn-summary dd { margin: 0; word-break: break-all; }

.fn-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

/* Aide */
.fn-help-title {
  margin: 0.9rem 0 0.5rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fn-muted);
}

.fn-help-title:first-child { margin-top: 0; }

kbd {
  font-family: var(--fn-mono);
  font-size: 0.8em;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--fn-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--fn-desk);
}

/* Fenêtres : pied et formulaire enseignant */
.fn-modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.75rem 1.15rem;
  border-top: 1px solid var(--fn-border);
  font-size: 0.8rem;
  color: var(--fn-muted);
}

.fn-teacher-form select {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  border: 1px solid var(--fn-border);
  border-radius: 6px;
  background: var(--fn-desk);
  color: var(--fn-text);
}

.fn-teacher-form textarea { font-family: var(--fn-font); }

.fn-teacher-checks {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem 0.2rem;
  border: 1px solid var(--fn-border);
  border-radius: 8px;
}

.fn-teacher-checks legend {
  padding: 0 0.3rem;
  font-size: 0.8rem;
  color: var(--fn-muted);
}

.fn-capture-actions { flex-wrap: wrap; }

/* Panneau du poste : onglets */
.fn-terminal-panel {
  max-height: 340px;
}

.fn-terminal-header {
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fn-pane-tabs {
  display: flex;
  gap: 0.25rem;
  margin-right: auto;
}

.fn-pane-tab {
  position: relative;
  padding: 0.25rem 0.65rem;
  border: 1px solid #334155;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}

.fn-pane-tab.is-active {
  background: #0c1222;
  color: #f8fafc;
  border-color: #60a5fa;
}

.fn-pane-tab.has-news::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
}

.fn-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.fn-pane[hidden] { display: none; }

.fn-browser-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: #1a2540;
  border-top: 1px solid #334155;
}

.fn-browser-scheme {
  font-family: var(--fn-mono);
  font-size: 0.8rem;
  color: #64748b;
}

.fn-browser-bar input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0c1222;
  color: #f8fafc;
  font-family: var(--fn-mono);
  font-size: 0.82rem;
}

.fn-browser-page {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: #ffffff;
  color: #1e293b;
  font-size: 0.9rem;
  line-height: 1.5;
}

.fn-browser-page h3 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.fn-browser-page p { margin: 0 0 0.5rem; }

.fn-browser-meta {
  font-family: var(--fn-mono);
  font-size: 0.72rem;
  color: #64748b;
}

.fn-browser-empty { color: #64748b; }

.fn-browser-error h3 { color: #b91c1c; }

.fn-exchanges-body {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 0.75rem 0.75rem;
}

.fn-exchanges-empty {
  margin: 0.25rem 0;
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.5;
}

.fn-exchanges-empty code { color: #e2e8f0; }

.fn-exchanges {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  color: #cbd5e1;
}

.fn-exchanges th {
  position: sticky;
  top: 0;
  background: #1a2540;
  text-align: left;
  font-weight: 600;
  padding: 0.3rem 0.45rem;
  color: #94a3b8;
}

.fn-exchanges td {
  padding: 0.25rem 0.45rem;
  border-bottom: 1px solid #1e293b;
  vertical-align: top;
}

.fn-exchanges code { font-family: var(--fn-mono); color: #e2e8f0; }

.fn-ex-group td {
  padding-top: 0.55rem;
  color: #93c5fd;
  font-weight: 600;
  border-bottom-color: #334155;
}

.fn-proto {
  display: inline-block;
  min-width: 3.2rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-family: var(--fn-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  background: #334155;
  color: #f8fafc;
}

.fn-proto--arp { background: #7c3aed; }
.fn-proto--icmp { background: #0369a1; }
.fn-proto--dns { background: #b45309; }
.fn-proto--tcp { background: #475569; }
.fn-proto--http { background: #15803d; }
.fn-proto--dhcp { background: #be185d; }

/* ===================================================================
   Interface épurée : 2 étapes, menu, panneaux allégés
   =================================================================== */

/* En-tête */
.fn-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
}

.fn-brand { font-size: 1rem; }

.fn-header-actions {
  justify-self: end;
  gap: 0.4rem;
}

.fn-steps {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem;
  background: var(--fn-desk);
  border: 1px solid var(--fn-border);
  border-radius: 999px;
}

.fn-steps__arrow {
  color: var(--fn-muted);
  font-size: 0.9rem;
}

.fn-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem 0.35rem 0.4rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-family: inherit;
  color: var(--fn-muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.fn-step:hover { color: var(--fn-text); }

.fn-step__num {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--fn-border);
  color: var(--fn-surface);
  font-weight: 700;
  font-size: 0.85rem;
}

.fn-step__text {
  display: flex;
  flex-direction: column;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.15;
}

.fn-step__text small {
  font-weight: 400;
  font-size: 0.7rem;
}

.fn-step.is-active {
  background: var(--fn-surface);
  color: var(--fn-text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.fn-step.is-active .fn-step__num { background: var(--fn-accent); }
#fn-step-test.is-active .fn-step__num { background: var(--fn-ok); }

.fn-btn--icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
}

.fn-btn--sm.fn-btn--icon {
  width: 1.9rem;
  height: 1.9rem;
  font-size: 0.85rem;
}

.fn-menu { position: relative; }

.fn-menu__list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 400;
  min-width: 15rem;
  padding: 0.35rem;
  background: var(--fn-surface);
  border: 1px solid var(--fn-border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.fn-menu__list[hidden] { display: none; }

.fn-menu__list button,
.fn-menu__list a {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--fn-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.fn-menu__list button:hover,
.fn-menu__list a:hover { background: var(--fn-desk); }

.fn-menu__list .is-danger { color: var(--fn-err); }

.fn-menu__list hr {
  margin: 0.3rem 0;
  border: none;
  border-top: 1px solid var(--fn-border);
}

/* Disposition générale */
.fn-main { grid-template-columns: 196px 1fr 280px; }

.fn-sidebar { padding: 0.9rem 0.8rem; }

.fn-sidebar h2 {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
}

.fn-side-test { display: none; }
body.fn-sim-mode .fn-side-build { display: none; }
body.fn-sim-mode .fn-side-test { display: block; }

/* Palette : tuiles compactes */
.fn-toolbox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.fn-tool {
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.55rem 0.3rem;
  border-width: 1px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  background: var(--fn-surface);
}

.fn-device-meta:empty { display: none; }

.fn-tool:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 0.5rem;
}

.fn-tool .fn-tool-icon { font-size: 1.4rem; }
.fn-tool .fn-tool-icon--img { width: 1.6rem; height: 1.6rem; }

/* Outils : trois boutons côte à côte */
.fn-mode-bar {
  flex-direction: row;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.fn-mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.2rem;
  border-width: 1px;
  font-size: 0.72rem;
  text-align: center;
}

.fn-mode-btn__icon {
  font-size: 1rem;
  line-height: 1.1rem;
}

.fn-mode-btn .fn-mode-icon--rj45 {
  margin: 0;
  width: 1.05rem;
  height: 1.05rem;
}

.fn-undo-bar { margin: 0 0 1rem; }
.fn-undo-bar .fn-btn { font-size: 0.74rem; padding: 0.3rem 0.2rem; }

/* Barre « Tester » */
.fn-side-host {
  margin: 0 0 1.1rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid color-mix(in srgb, var(--fn-ok) 45%, var(--fn-border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--fn-ok) 8%, var(--fn-surface));
  font-size: 0.82rem;
  line-height: 1.4;
}

.fn-side-host strong { display: block; }
.fn-side-host code { font-family: var(--fn-mono); font-size: 0.8rem; color: var(--fn-ok); }
.fn-side-host em { font-size: 0.75rem; color: var(--fn-warn); }

.fn-cmd-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fn-cmd-list button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--fn-border);
  border-radius: 7px;
  background: var(--fn-surface);
  font-family: var(--fn-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fn-text);
  cursor: pointer;
  text-align: left;
}

.fn-cmd-list button:hover { border-color: var(--fn-ok); }
.fn-cmd-list em { font-style: normal; color: var(--fn-muted); }

.fn-cmd-list small {
  font-family: var(--fn-font);
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--fn-muted);
}

/* Zone de travail */
.fn-workspace-toolbar {
  padding: 0;
  border-bottom: none;
  background: transparent;
  gap: 0;
}

.fn-workspace-toolbar:has(.fn-scenario-bar:not([hidden])) {
  padding: 0.6rem 0.75rem 0.5rem;
  gap: 0.45rem;
  border-bottom: 1px solid var(--fn-border);
}

.fn-scenario-bar {
  align-items: center;
  padding: 0.5rem 0.75rem;
}

.fn-scenario-bar__info { min-width: 0; }

.fn-scenario-bar__info p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fn-scenario-bar__info p:hover {
  -webkit-line-clamp: unset;
}

.fn-scenario-bar__actions { align-items: center; }

.fn-scenario-result {
  font-size: 0.78rem;
  padding: 0.45rem 0.7rem;
}

.fn-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-top: 1px solid var(--fn-border);
  background: var(--fn-surface);
}

.fn-status-row .fn-status-bar {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.8rem;
}

.fn-zoom {
  display: flex;
  gap: 0;
  margin: 0;
  border: 1px solid var(--fn-border);
  border-radius: 6px;
  overflow: hidden;
}

.fn-zoom__btn {
  min-width: 1.8rem;
  padding: 0.15rem 0.4rem;
  border: none;
  background: var(--fn-surface);
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--fn-text);
  cursor: pointer;
}

.fn-zoom__btn + .fn-zoom__btn { border-left: 1px solid var(--fn-border); }
.fn-zoom__btn:hover { background: var(--fn-desk); }
.fn-zoom__label { min-width: 3.2rem; font-variant-numeric: tabular-nums; }

/* Panneau de droite */
.fn-props { padding: 0.9rem 1rem; }

.fn-props-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--fn-border);
}

.fn-props-icon {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--fn-desk);
  font-size: 1.3rem;
}

.fn-props-icon .fn-props-icon--img { width: 1.6rem; height: 1.6rem; object-fit: contain; }

.fn-props-titles {
  flex: 1;
  min-width: 0;
}

.fn-props-titles h2 {
  margin: 0;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fn-props-titles small {
  font-size: 0.74rem;
  color: var(--fn-muted);
}

.fn-props-sub {
  margin: 1rem 0 0.5rem;
  font-size: 0.72rem;
}

.fn-props-sub small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.fn-field { margin-bottom: 0.6rem; }
.fn-field label { font-size: 0.76rem; }

.fn-segmented { margin-bottom: 0.7rem; }
.fn-segmented label { font-size: 0.76rem; padding: 0.4rem 0.2rem; }

.fn-props-mac {
  margin: 1rem 0 0;
  font-size: 0.7rem;
  color: var(--fn-muted);
}

.fn-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--fn-muted);
  cursor: pointer;
}

.fn-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fn-switch__track {
  position: relative;
  width: 2rem;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--fn-border);
  transition: background 0.15s;
}

.fn-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.1rem - 4px);
  height: calc(1.1rem - 4px);
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.fn-switch input:checked + .fn-switch__track { background: var(--fn-ok); }
.fn-switch input:checked + .fn-switch__track::after { transform: translateX(0.9rem); }
.fn-switch input:focus-visible + .fn-switch__track { outline: 2px solid var(--fn-accent); outline-offset: 2px; }

.fn-link-danger {
  display: block;
  margin: 1.1rem 0 0;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--fn-err);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fn-guide h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.fn-guide ol {
  margin: 0 0 0.8rem;
  padding-left: 1.2rem;
  font-size: 0.84rem;
  line-height: 1.55;
}

.fn-guide li + li { margin-top: 0.35rem; }

.fn-guide p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fn-muted);
  line-height: 1.5;
}

.fn-guide code {
  font-family: var(--fn-mono);
  font-size: 0.85em;
  background: var(--fn-desk);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

/* Panneau du poste : visible seulement à l'étape Tester */
.fn-terminal-panel[hidden] { display: none; }

/* Fenêtre « Activités » */
.fn-activity-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.8rem 1.15rem 0;
}

.fn-activity-tab {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--fn-border);
  border-radius: 10px;
  background: var(--fn-desk);
  font-family: inherit;
  color: var(--fn-text);
  text-align: left;
  cursor: pointer;
}

.fn-activity-tab strong { font-size: 0.92rem; }
.fn-activity-tab small { font-size: 0.74rem; color: var(--fn-muted); }

.fn-activity-tab.is-active {
  border-color: var(--fn-accent);
  background: var(--fn-accent-soft);
}

.fn-modal__body[hidden] { display: none; }

.fn-scenario-card__brief {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 960px) {
  .fn-header {
    grid-template-columns: 1fr auto;
  }

  .fn-steps {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .fn-main { grid-template-columns: 1fr; }
}

.fn-level-filter {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 1.15rem 0;
  font-size: 0.8rem;
  color: var(--fn-muted);
}

.fn-level-filter button {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--fn-border);
  border-radius: 999px;
  background: var(--fn-surface);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fn-text);
  cursor: pointer;
}

.fn-level-filter button.is-active {
  background: var(--fn-accent);
  border-color: var(--fn-accent);
  color: #fff;
}

.fn-scenario-group[hidden] { display: none; }

@media (max-width: 960px) {
  .fn-sidebar { padding: 0.6rem 0.75rem; }

  .fn-side-build {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 0.75rem;
    align-items: start;
  }

  .fn-side-build h2 { display: none; }

  .fn-toolbox {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin: 0;
  }

  .fn-tool:last-child:nth-child(odd) {
    grid-column: auto;
    flex-direction: column;
  }

  .fn-mode-bar { margin: 0; }
  .fn-mode-btn { min-width: 3.6rem; }

  .fn-undo-bar {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin: 0;
  }

  .fn-undo-bar .fn-btn { flex: 0 0 auto; padding: 0.2rem 0.6rem; }

  .fn-cmd-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .fn-cmd-list small { display: none; }
}

/* Fenêtre d'export : compacte et défilante */
.fn-modal__panel--capture { max-width: 560px; }

.fn-capture-modal__body {
  overflow-y: auto;
  min-height: 0;
  gap: 0.85rem;
}

.fn-capture-preview { max-height: 240px; }
.fn-capture-preview-wrap { flex-shrink: 0; }

.fn-capture-formats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.fn-capture-formats legend {
  grid-column: 1 / -1;
  margin-bottom: 0.4rem;
}

.fn-capture-format {
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.5rem 0.4rem;
  border-width: 1px;
  text-align: center;
}

.fn-capture-format input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fn-capture-format { position: relative; }
.fn-capture-format span { font-weight: 700; }
.fn-capture-format small { font-size: 0.74rem; }
.fn-capture-format:has(input:focus-visible) { outline: 2px solid var(--fn-accent); outline-offset: 2px; }

.fn-capture-option {
  align-items: center;
  padding: 0;
  border: none;
  font-size: 0.84rem;
}

.fn-capture-actions {
  position: sticky;
  bottom: -1.25rem;
  margin: 0 -1.15rem -1.25rem;
  padding: 0.75rem 1.15rem;
  background: var(--fn-surface);
  border-top: 1px solid var(--fn-border);
  justify-content: flex-end;
}

.fn-capture-preview[hidden],
.fn-capture-preview-loading[hidden],
.fn-capture-preview-empty[hidden] { display: none; }

/* Étape Tester : plan cadré automatiquement, sans barres de défilement */
body.fn-sim-mode .fn-canvas.is-fitted { overflow: hidden; }
