:root {
  --bg: #ffffff;
  --text: #000000;
  --border: #000000;
  --border-light: #d0d0d0;
  --panel-bg: #f8f8f8;
  --muted: #666666;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Bandeau repris de forum.ircr.ch */
.language-bar {
  background-color: #0b1f24;
  border-bottom: dotted 2px #777;
  height: 35px;
  flex-shrink: 0;
  position: relative;
  z-index: 9999;
}

.language-bar-links {
  /*max-width: 1320px;*/
  position: relative;
  padding: 0 2em;
  padding-top: 5px;
  margin: 0 auto;
  text-align: right;
}

.language-bar-links-span a {
  color: #999;
  font-size: small;
  font-family: "Montserrat", sans-serif;
  text-decoration: none;
}

.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
}

#sidebar {
  width: 360px;
  min-width: 330px;
  max-width: 400px;
  height: 100%;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background-color: var(--panel-bg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}

.subtitle {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section {
  border: 1px solid var(--border-light);
  padding: 10px 12px;
  background: #ffffff;
  border-radius: 2px;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 3px;
}

.control-row {
  margin-bottom: 8px;
}

.control-row:last-child {
  margin-bottom: 0;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  margin-bottom: 3px;
}

.control-header label {
  font-weight: 600;
}

.val-input {
  width: 62px;
  padding: 2px 4px;
  font-size: 0.8rem;
  border: 1px solid var(--border-light);
  text-align: right;
  font-family: monospace;
}

.val-input:focus {
  outline: 1px solid var(--border);
  border-color: var(--border);
}

.select-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #ffffff;
  cursor: pointer;
}

#seed-input {
  width: 90px;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--border);
  cursor: pointer;
  border-radius: 50%;
}

.btn-row {
  display: flex;
  gap: 8px;
}

button {
  flex: 1;
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid var(--border);
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.1s;
}

button:hover {
  background: #f0f0f0;
}

button:active {
  background: #000000;
  color: #ffffff;
}

.btn-primary {
  background: #000000;
  color: #ffffff;
}

.btn-primary:hover {
  background: #333333;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 5px;
  cursor: pointer;
  user-select: none;
}

#main-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  position: relative;
}

#metrics-bar {
  border-bottom: 1px solid var(--border-light);
  padding: 0 18px;
  height: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fafafa;
  overflow-x: auto;
  white-space: nowrap;
}

.metric-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-body {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.metric-val {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric-unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
}

.metric-divider {
  width: 1px;
  height: 16px;
  background: #e2e8f0;
  flex-shrink: 0;
}

#svg-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
  background-color: #ffffff;
}

svg {
  width: 100%;
  height: 100%;
  user-select: none;
}

.svg-grid-line,
.svg-track-outline,
.svg-track-island,
.svg-centerline,
.svg-dimension-line {
  vector-effect: non-scaling-stroke;
}

.svg-grid-line {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 1px;
  stroke-dasharray: 4, 3;
  opacity: 0.85;
}

.svg-track-outline {
  fill: #f5f5f5;
  stroke: #000000;
  stroke-width: 1.8px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.svg-track-island {
  fill: #ffffff;
  stroke: #000000;
  stroke-width: 1.8px;
  stroke-linejoin: round;
}

.svg-centerline {
  fill: none;
  stroke: #666666;
  stroke-width: 1.2px;
  stroke-dasharray: 5, 4;
}

.svg-dimension-line {
  stroke: #777777;
  stroke-width: 1px;
}

.svg-text {
  font-family: monospace;
  fill: #000000;
  user-select: none;
}

#loading-indicator {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 0.72rem;
  background: #000000;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.12s;
  font-family: monospace;
  z-index: 10;
}

#loading-indicator.active {
  opacity: 1;
}

/* ==========================================================================
   MARKING NETWORK & LIAISONS VISUALIZATION
   ========================================================================== */

.svg-marking-link {
  transition: stroke-width 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.svg-marking-link:hover,
.svg-marking-link.highlighted {
  stroke-width: 0.32px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 0.25px rgba(0, 0, 0, 0.6));
}

.svg-link-label {
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease;
  display: none;
}

.svg-link-label:hover {
  transform: scale(1.15);
}

.svg-turn-marker {
  cursor: default;
  user-select: none;
}

/* Panneau de table des liaisons */
#marking-table-panel {
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: none;   /* table des liaisons masquée */
  flex-direction: column;
}

#marking-table-panel.collapsed .marking-table-wrapper {
  display: none;
}

.marking-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.78rem;
}

.marking-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.marking-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

.marking-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.marking-summary-pill {
  background: #e2e8f0;
  color: #334155;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

.btn-sm {
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-sm:hover {
  background: #000000;
  color: #ffffff;
}

.marking-table-wrapper {
  overflow-y: auto;
  max-height: 180px;
}

.marking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  text-align: left;
}

.marking-table th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: #475569;
  padding: 5px 12px;
  font-weight: 700;
  border-bottom: 1px solid #cbd5e1;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
}

.marking-table td {
  padding: 5px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.marking-table tr:hover {
  background: #f8fafc;
  cursor: pointer;
}

.marking-table tr.active-row {
  background: #e0f2fe !important;
}

.pill-id {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 800;
  color: #ffffff;
  font-family: monospace;
  font-size: 0.72rem;
}

.pill-180 {
  display: inline-block;
  background: #ea580c;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 3px;
}

.pill-90 {
  display: inline-block;
  background: #0284c7;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 3px;
}

.pill-radius {
  display: inline-block;
  background: #fef08a;
  color: #713f12;
  border: 1px solid #fde047;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-right: 3px;
}

.svg-balisage-bar {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.svg-balisage-bar:hover rect {
  fill: #38bdf8 !important;
  stroke: #ffffff !important;
  stroke-width: 0.05 !important;
  filter: drop-shadow(0px 0px 0.15px rgba(14, 165, 233, 0.8));
}
/* Poignées d'édition des rayons de virage */
.radius-handle .radius-dot { fill: #ffffff; stroke: #e11d48; stroke-width: 0.06; }
.radius-handle.edited .radius-dot { fill: #e11d48; }
.radius-arrow { cursor: pointer; stroke: #ffffff; stroke-width: 0.03; }
.radius-arrow.radius-up { fill: #16a34a; }
.radius-arrow.radius-down { fill: #dc2626; }
.radius-arrow:hover { opacity: 0.75; }
.radius-handle.limited .radius-up { fill: #94a3b8; cursor: not-allowed; }
.radius-label { font-size: 0.26px; font-weight: bold; fill: #0f172a; paint-order: stroke; stroke: #ffffff; stroke-width: 0.06px; font-family: sans-serif; pointer-events: none; }

/* Réglages inaccessibles (ex. dimensions du cadre en mode IRCR) */
.section.is-disabled { opacity: 0.45; }
.section.is-disabled input,
.section.is-disabled label { cursor: not-allowed; }

[hidden] { display: none !important; }

/* ------------------------------------------------------------------
   Menu de gauche compact : tient sans défilement
   ------------------------------------------------------------------ */
#sidebar { padding: 12px; gap: 8px; }
.header-title { font-size: 1rem; padding-bottom: 4px; }
.subtitle { font-size: 0.68rem; margin-top: 2px; }
.btn-row button { padding: 5px 8px; }
.section { padding: 6px 10px; }
.section-title { margin-bottom: 4px; padding-bottom: 2px; font-size: 0.7rem; }

/* Réglage sur une ligne : libellé | curseur | valeur */
.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 52px;
  align-items: center;
  column-gap: 8px;
  margin-bottom: 4px;
}
.control-row .control-header { display: contents; font-size: 0.76rem; }
.control-row .control-header label { grid-column: 1; grid-row: 1; font-size: 0.76rem; line-height: 1.15; }
.control-row input[type="range"] { grid-column: 2; grid-row: 1; }
.control-row .val-input { grid-column: 3; grid-row: 1; width: 52px; }
.control-row .select-input { grid-column: 2 / 4; grid-row: 1; padding: 3px 6px; }

/* Cases d'affichage sur deux colonnes */
.section-display { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; }
.section-display .section-title { grid-column: 1 / 3; }
.checkbox-row { margin-bottom: 3px; font-size: 0.76rem; }
