/* ==========================================================================
   Waterland — Gestionnaire de Fenêtres Autonome (Style BD / Ligne Claire)
   Zéro style inline : géométrie (x, y, width, height) pilotée par <foreignObject>
   ========================================================================== */

.bd-window-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
  overflow: visible;
}

.bd-window-fo {
  pointer-events: auto;
  overflow: visible;
}

.bd-window {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  background-color: #fbf6e8;
  color: #1a1815;
  border: 3.5px solid #1a1815;
  border-radius: 22px;
  box-shadow: 7px 7px 0 #1a1815;
  font-family: "Trebuchet MS", "Comic Sans MS", sans-serif;
  min-width: 220px;
  min-height: 150px;
  user-select: none;
  overflow: hidden;
  transition: box-shadow 0.12s ease;
}

.bd-window.is-focused {
  box-shadow: 9px 9px 0 #1a1815;
}

.bd-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.45rem 0.65rem 0.45rem 0.85rem;
  background-color: #f4c552;
  border-bottom: 3.5px solid #1a1815;
  cursor: grab;
  touch-action: none;
}

.bd-window-header:active {
  cursor: grabbing;
}

.bd-window-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  pointer-events: none;
}

.bd-window-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #fbf6e8;
  border: 2.5px solid #1a1815;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #1a1815;
}

.bd-window-icon svg {
  width: 16px;
  height: 16px;
  stroke: #1a1815;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.bd-window-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #1a1815;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-window-close {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #ff6b57;
  color: #1a1815;
  border: 3px solid #1a1815;
  border-radius: 999px;
  box-shadow: 2px 2px 0 #1a1815;
  padding: 0;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
}

.bd-pod-tow-toggle {
  width: 32px;
  height: 30px;
  flex: 0 0 32px;
  padding: 3px;
  color: #1a1815;
  background-color: #fffdf6;
  border: 2.4px solid #1a1815;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #1a1815;
  font: inherit;
  cursor: pointer;
}

.bd-pod-tow-toggle svg {
  display: block;
  width: 20px;
  height: 20px;
}

.bd-pod-tow-toggle:hover,
.bd-pod-tow-toggle:focus-visible {
  background-color: #d9eee2;
  outline: none;
}

.bd-pod-tow-toggle:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1815;
}

.bd-radio-equipment-toggle {
  width: 32px;
  height: 30px;
  flex: 0 0 32px;
  padding: 3px;
  color: #1a1815;
  background-color: #fffdf6;
  border: 2.4px solid #1a1815;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #1a1815;
  cursor: pointer;
}

.bd-radio-equipment-toggle svg {
  display: block;
  width: 20px;
  height: 20px;
}

.bd-radio-equipment-toggle:hover,
.bd-radio-equipment-toggle:focus-visible {
  background-color: #d9eee2;
  outline: none;
}

.bd-radio-equipment-toggle:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1815;
}

.bd-radio-equipment-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bd-window-close:hover,
.bd-window-close:focus-visible {
  background-color: #ff8573;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1a1815;
  outline: none;
}

.bd-window-close:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 #1a1815;
}

.bd-window-close svg {
  width: 15px;
  height: 15px;
  stroke: #1a1815;
  stroke-width: 3.2;
  stroke-linecap: round;
  fill: none;
}

.bd-window-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  background-color: #fbf6e8;
  background-image: radial-gradient(rgba(26, 24, 21, 0.06) 1px, transparent 0);
  background-size: 14px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Catégorie Inventaire : div interne scrollable verticalement */
.bd-inventory-scroll {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.9rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.75rem;
}

.bd-storage-scroll {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.9rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.75rem;
}

.bd-crafted-storage-summary {
  flex: 0 0 100%;
  margin: 0 0 0.25rem;
  color: #4f554b;
  font-size: 0.78rem;
  font-weight: 800;
}

.bd-item-preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.bd-storage-count {
  position: absolute;
  right: -0.3rem;
  bottom: -0.3rem;
  min-width: 1.35rem;
  padding: 0.08rem 0.2rem;
  color: #fffdf6;
  background-color: #355259;
  border: 2px solid #1a1815;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.bd-storage-empty {
  align-self: center;
  justify-self: center;
  width: 100%;
  margin: 0;
  color: #4f554b;
  font-weight: 700;
  text-align: center;
}

.bd-atelier-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 0.72rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bd-atelier-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.58rem;
  color: #34443a;
  background: #e7ead7;
  border: 1px solid #9a9b75;
  border-radius: 8px;
  font-size: 0.78rem;
}

.bd-atelier-summary-count {
  color: #704c29;
  font-variant-numeric: tabular-nums;
}

.bd-recipe-card {
  min-width: 0;
  padding: 0.65rem;
  background: #fffdf5;
  border: 1px solid #b2a787;
  border-radius: 10px;
  box-shadow: 2px 2px 0 rgba(26, 24, 21, 0.18);
}

.bd-recipe-heading {
  display: flex;
  align-items: center;
  gap: 0.62rem;
}

.bd-recipe-output-icon {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 3px;
  background: #eee5cc;
  border: 1px solid #b2a787;
  border-radius: 9px;
}

.bd-recipe-output-icon svg,
.bd-recipe-output-icon canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bd-recipe-title-group {
  min-width: 0;
}

.bd-recipe-title {
  margin: 0;
  color: #2b3e36;
  font-size: 0.91rem;
  line-height: 1.25;
}

.bd-recipe-description {
  margin: 0.2rem 0 0;
  color: #5a5d50;
  font-size: 0.74rem;
  line-height: 1.35;
}

.bd-recipe-ingredients-title {
  margin: 0.62rem 0 0.32rem;
  color: #66563d;
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.bd-recipe-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bd-recipe-ingredient {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 30px;
  padding: 0.18rem 0.38rem;
  color: #293d35;
  background: #e8eddd;
  border: 1px solid #9aab8a;
  border-radius: 7px;
  font-size: 0.7rem;
}

.bd-recipe-ingredient.is-missing {
  color: #77766d;
  background: #e5e2d9;
  border-color: #aaa69a;
  filter: grayscale(0.8);
}

.bd-recipe-ingredient svg {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
}

.bd-recipe-ingredient-name {
  white-space: nowrap;
}

.bd-recipe-ingredient-quantity {
  color: #66563d;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bd-recipe-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.58rem;
}

.bd-recipe-status {
  color: #68675f;
  font-size: 0.68rem;
}

.bd-recipe-craft-button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0.3rem 0.7rem;
  color: #fff9e9;
  background: #48674f;
  border: 1px solid #263c2e;
  border-radius: 7px;
  box-shadow: 2px 2px 0 #1a1815;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.bd-recipe-craft-button:hover:not(:disabled),
.bd-recipe-craft-button:focus-visible:not(:disabled) {
  background: #5a795c;
}

.bd-recipe-craft-button:focus-visible {
  outline: 3px solid #c98f40;
  outline-offset: 2px;
}

.bd-recipe-craft-button:disabled {
  color: #77766d;
  background: #d8d5ca;
  border-color: #a9a398;
  box-shadow: none;
  cursor: not-allowed;
}

.bd-pod-window-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 0.8rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

.bd-pod-summary,
.bd-pod-water-label {
  margin: 0;
  color: #3f493d;
  font-size: 0.8rem;
  font-weight: 800;
}

.bd-pod-water-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.bd-pod-transfer-hint {
  margin: 0;
  color: #596056;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
}

.bd-pod-inventory-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 0.45rem;
}

.bd-pod-inventory-cell {
  min-height: 58px;
  padding: 0.35rem 0.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  color: #596056;
  background-color: #f3ead7;
  border: 2px dashed #8b887d;
  border-radius: 9px;
  font-size: 0.68rem;
  font-weight: 800;
  font-family: inherit;
  cursor: grab;
  touch-action: manipulation;
}

.bd-pod-inventory-cell.is-filled {
  color: #1a1815;
  background-color: #e3f4f4;
  border: 2.2px solid #1a1815;
  box-shadow: 2px 2px 0 #1a1815;
}

.bd-pod-inventory-cell:focus-visible {
  outline: 3px solid #24738a;
  outline-offset: 2px;
}

.bd-pod-inventory-cell.is-selected {
  background-color: #f4c552;
  outline: 3px solid #1a1815;
  outline-offset: 1px;
}

.bd-pod-inventory-cell.is-transfer-target {
  border: 2.5px solid #24738a;
  background-color: #d9eee2;
  cursor: copy;
}

.bd-pod-inventory-cell.is-dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.bd-pod-inventory-cell svg {
  width: 21px;
  height: 21px;
}

.bd-pod-fill-action:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

/* Icône d'objet carrée plus compacte avec bords arrondis (Style BD) */
.bd-item-tile {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #fffdf6;
  border: 2.8px solid #1a1815;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #1a1815;
  padding: 5px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
}

.bd-item-tile:hover,
.bd-item-tile:focus-visible {
  background-color: #fef3c7;
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #1a1815;
  outline: none;
}

.bd-item-tile:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #1a1815;
}

.bd-item-tile svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Catégorie Fiche d'Objet (petite fenêtre BD au clic sur une icône) */
.bd-item-detail-scroll {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.75rem 0.85rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bd-detail-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  background-color: #fde68a;
  color: #1a1815;
  border: 2.2px solid #1a1815;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #1a1815;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 800;
}

.bd-detail-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.38;
  color: #27241f;
}

.bd-detail-action {
  align-self: flex-start;
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  color: #1a1815;
  background-color: #f4c552;
  border: 2.5px solid #1a1815;
  border-radius: 9px;
  box-shadow: 2px 2px 0 #1a1815;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.bd-detail-action.equipment-repair-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.bd-detail-action .equipment-repair-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bd-detail-action:hover,
.bd-detail-action:focus-visible {
  background-color: #f7d77c;
  outline: 2px solid #355259;
  outline-offset: 2px;
}

.equipment-upgrade-trigger {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 38px;
  min-height: 30px;
  padding: 0.18rem 0.35rem;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: #fbf6e8;
  color: #1a1815;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.equipment-upgrade-trigger:hover,
.equipment-upgrade-trigger:focus-visible,
.equipment-upgrade-trigger[aria-expanded="true"] {
  background: #fff2c9;
  outline: 2px solid #355259;
  outline-offset: 2px;
}

.equipment-upgrade-trigger-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.equipment-upgrade-level {
  min-width: 0.7rem;
  text-align: center;
}

.bd-window-header .equipment-upgrade-trigger {
  box-shadow: 2px 2px 0 #1a1815;
}

.inspector-header .equipment-upgrade-trigger,
.inspector-item-title .equipment-upgrade-trigger {
  background: var(--panel-surface);
  color: var(--brass-bright);
  border-color: var(--brass);
}

.inspector-header .equipment-upgrade-trigger:hover,
.inspector-header .equipment-upgrade-trigger:focus-visible,
.inspector-header .equipment-upgrade-trigger[aria-expanded="true"],
.inspector-item-title .equipment-upgrade-trigger:hover,
.inspector-item-title .equipment-upgrade-trigger:focus-visible,
.inspector-item-title .equipment-upgrade-trigger[aria-expanded="true"] {
  background: #2f564a;
  outline-color: var(--brass-bright);
}

.equipment-upgrade-panel {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: 100%;
  padding: 0.55rem 0.65rem;
  border: 2px solid #1a1815;
  border-radius: 10px;
  background: #fff8e8;
  color: #1a1815;
  box-shadow: 3px 3px 0 #1a1815;
  user-select: text;
}

.equipment-upgrade-panel[hidden] {
  display: none;
}

.equipment-upgrade-panel-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
}

.equipment-upgrade-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.equipment-upgrade-resource {
  display: flex;
  min-width: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid rgba(26, 24, 21, 0.3);
  border-radius: 7px;
  background: rgba(244, 197, 82, 0.2);
}

.equipment-upgrade-resource.is-missing {
  filter: grayscale(1);
  opacity: 0.5;
}

.equipment-upgrade-resource-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.equipment-upgrade-resource-count {
  font-size: 0.7rem;
  line-height: 1;
}

.equipment-upgrade-confirm {
  align-self: flex-start;
}

.bd-window .equipment-upgrade-confirm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.inspector-panel .equipment-upgrade-panel {
  width: fit-content;
  border-color: var(--brass);
  background: var(--panel-surface);
  color: var(--parchment);
  box-shadow: 3px 3px 0 rgba(8, 16, 14, 0.55);
}

.inspector-panel .equipment-upgrade-resource {
  border-color: rgba(224, 183, 94, 0.45);
  background: rgba(15, 29, 25, 0.5);
}

.inspector-item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.inspector-item-title h3 {
  flex: 1 1 auto;
  min-width: 0;
}

/* Catégorie Options / Tableau de Bord / Radio : organisation verticale et sous-sections style BD */
.bd-options-scroll,
.bd-dashboard-scroll,
.bd-radio-scroll {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.85rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.bd-radio-status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  background-color: #bbf7d0;
  color: #1a1815;
  border: 2.2px solid #1a1815;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #1a1815;
  padding: 0.2rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bd-radio-status.is-offline {
  background-color: #fecaca;
}

.bd-radio-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bd-radio-card {
  background-color: #fffdf6;
  border: 2.6px solid #1a1815;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #1a1815;
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.bd-radio-freq {
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #92400e;
}

.bd-radio-msg {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.38;
  color: #1a1815;
  font-weight: 600;
}

.bd-equipment-window-scroll {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.75rem;
  overflow: auto;
}

.bd-equipment-preview-wrap {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  padding: 4px;
  background: #fffdf6;
  border: 2px solid #1a1815;
  border-radius: 12px;
  box-shadow: 2px 2px 0 #1a1815;
}

.bd-equipment-summary,
.bd-equipment-description,
.bd-equipment-warning {
  width: 100%;
  margin: 0;
  text-align: center;
}

.bd-equipment-summary {
  color: #4f554b;
  font-size: 0.78rem;
  font-weight: 800;
}

.bd-equipment-description {
  color: #1a1815;
  font-size: 0.82rem;
  line-height: 1.35;
  font-weight: 600;
}

.bd-equipment-warning {
  color: #8b3e25;
  font-size: 0.74rem;
  line-height: 1.3;
  font-weight: 700;
}

.bd-equipment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
}

.bd-subsection {
  background-color: #fffdf6;
  border: 2.8px solid #1a1815;
  border-radius: 14px;
  box-shadow: 3px 3px 0 #1a1815;
  padding: 0.65rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bd-subsection-title {
  margin: 0;
  display: inline-block;
  align-self: flex-start;
  background-color: #fde68a;
  color: #1a1815;
  border: 2.2px solid #1a1815;
  border-radius: 7px;
  box-shadow: 2px 2px 0 #1a1815;
  padding: 0.12rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bd-field {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.bd-field-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #1a1815;
}

.bd-select {
  width: 100%;
  background-color: #fbf6e8;
  color: #1a1815;
  border: 2.4px solid #1a1815;
  border-radius: 9px;
  box-shadow: 2px 2px 0 #1a1815;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.bd-select:focus-visible {
  background-color: #fef3c7;
  outline: none;
}

.bd-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.bd-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  background-color: #e5e0d0;
  color: #1a1815;
  border: 2.4px solid #1a1815;
  border-radius: 9px;
  box-shadow: 2px 2px 0 #1a1815;
  padding: 0.3rem 0.65rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
}

.bd-toggle-btn.is-on {
  background-color: #86efac;
}

.bd-toggle-btn:hover,
.bd-toggle-btn:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1a1815;
  outline: none;
}

.bd-toggle-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #1a1815;
}

/* Poignées de redimensionnement sur les bords et coins */
.bd-resize-handle {
  position: absolute;
  z-index: 5;
  touch-action: none;
}

.bd-resize-n {
  top: 0;
  left: 16px;
  right: 16px;
  height: 7px;
  cursor: ns-resize;
}

.bd-resize-s {
  bottom: 0;
  left: 16px;
  right: 22px;
  height: 8px;
  cursor: ns-resize;
}

.bd-resize-e {
  top: 16px;
  right: 0;
  bottom: 22px;
  width: 8px;
  cursor: ew-resize;
}

.bd-resize-w {
  top: 16px;
  left: 0;
  bottom: 16px;
  width: 7px;
  cursor: ew-resize;
}

.bd-resize-se {
  right: 0;
  bottom: 0;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
}

.bd-resize-se svg {
  width: 14px;
  height: 14px;
  stroke: #1a1815;
  stroke-width: 2.6;
  stroke-linecap: round;
}

.bd-resize-sw {
  left: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nesw-resize;
}

.bd-resize-ne {
  right: 0;
  top: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
}

.bd-resize-nw {
  left: 0;
  top: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

/* Barre verticale d'icônes de fenêtres en bas à droite */
.bd-window-dock {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right, 0px));
  bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  z-index: 65;
  pointer-events: auto;
}

.bd-dock-btn {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #fbf6e8;
  color: #1a1815;
  border: 3px solid #1a1815;
  border-radius: 13px;
  box-shadow: 4px 4px 0 #1a1815;
  padding: 0;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
}

.bd-dock-btn:hover,
.bd-dock-btn:focus-visible {
  background-color: #fef3c7;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #1a1815;
  outline: none;
}

.bd-dock-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #1a1815;
}

.bd-dock-btn.is-active {
  background-color: #f4c552;
}

.bd-dock-btn svg {
  width: 22px;
  height: 22px;
  stroke: #1a1815;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

@media (max-width: 760px), (pointer: coarse) {
  .bd-window {
    min-width: 0;
    min-height: 135px;
    border-width: 2.5px;
    border-radius: 16px;
    box-shadow: 4px 4px 0 #1a1815;
  }

  .bd-window.is-focused {
    box-shadow: 5px 5px 0 #1a1815;
  }

  .bd-window-header {
    min-height: 38px;
    gap: 0.3rem;
    padding: 0.25rem 0.4rem;
    border-bottom-width: 2.5px;
  }

  .bd-window-brand {
    gap: 0.38rem;
  }

  .bd-window-icon {
    width: 23px;
    height: 23px;
    border-width: 2px;
    border-radius: 6px;
    box-shadow: 1px 1px 0 #1a1815;
  }

  .bd-window-icon svg {
    width: 14px;
    height: 14px;
  }

  .bd-window-title {
    font-size: 0.84rem;
  }

  .bd-window-close {
    width: 25px;
    height: 25px;
    border-width: 2px;
    box-shadow: 1px 1px 0 #1a1815;
  }

  .bd-window-close svg {
    width: 13px;
    height: 13px;
  }

  .bd-radio-equipment-toggle,
  .bd-pod-tow-toggle {
    width: 27px;
    height: 26px;
    flex-basis: 27px;
    border-width: 2px;
    border-radius: 7px;
    box-shadow: 1px 1px 0 #1a1815;
  }

  .bd-radio-equipment-toggle svg,
  .bd-pod-tow-toggle svg {
    width: 17px;
    height: 17px;
  }

  .bd-window-header .equipment-upgrade-trigger {
    min-width: 30px;
    min-height: 26px;
    gap: 0.1rem;
    padding: 0.12rem 0.22rem;
    font-size: 0.7rem;
  }

  .bd-window-header .equipment-upgrade-trigger-icon {
    width: 12px;
    height: 12px;
  }

  .bd-item-tile {
    width: 44px;
    height: 44px;
    padding: 4px;
    border-width: 2.2px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 #1a1815;
  }

  .bd-radio-scroll,
  .bd-options-scroll,
  .bd-dashboard-scroll {
    padding: 0.6rem;
  }

  .bd-window-dock {
    right: calc(0.55rem + env(safe-area-inset-right, 0px));
    bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    gap: 0.35rem;
  }

  .bd-dock-btn {
    width: 40px;
    height: 40px;
    border-width: 2.5px;
    border-radius: 10px;
    box-shadow: 2px 2px 0 #1a1815;
  }

  .bd-dock-btn svg {
    width: 18px;
    height: 18px;
  }
}

.bd-electrical-scroll {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 0.8rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.bd-electrical-diagram {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.bd-electrical-section-title {
  margin: 0 0 0.45rem;
  color: #66563d;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bd-electrical-sources,
.bd-electrical-loads {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 0.55rem;
}

.bd-electrical-cable {
  align-self: center;
  background: #8d7449;
  border: 1px solid #473b2c;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.bd-electrical-cable.is-live {
  background: #c38d35;
  box-shadow: 0 0 5px rgba(195, 141, 53, 0.58);
}

.bd-electrical-cable-main,
.bd-electrical-cable-branches {
  width: 4px;
  height: 18px;
  border-radius: 3px;
}

.bd-electrical-bus {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.58rem;
  color: #f9f1dc;
  background: #405950;
  border: 2px solid #1a1815;
  border-radius: 9px;
  box-shadow: 3px 3px 0 #1a1815;
  text-align: center;
}

.bd-electrical-bus.is-live {
  background: #48674f;
}

.bd-electrical-bus-title {
  font-size: 0.84rem;
  letter-spacing: 0.08em;
}

.bd-electrical-bus-caption {
  color: #e5d7b5;
  font-size: 0.68rem;
}

.bd-electrical-loads {
  position: relative;
  padding-top: 0.2rem;
}

.bd-electrical-loads::before {
  position: absolute;
  top: -0.35rem;
  left: 12%;
  right: 12%;
  height: 3px;
  content: "";
  background: #8d7449;
  border: 1px solid #473b2c;
  border-radius: 3px;
}

.bd-power-device {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.52rem;
  min-width: 0;
  padding: 0.52rem;
  color: #2b3e36;
  background: #fffdf5;
  border: 1px solid #a99b7c;
  border-radius: 9px;
}

.bd-power-device-source {
  border-color: #839575;
  background: #edf0df;
}

.bd-power-device-load::before {
  position: absolute;
  top: -0.5rem;
  left: 50%;
  width: 3px;
  height: 0.5rem;
  content: "";
  background: #8d7449;
  border: 1px solid #473b2c;
  transform: translateX(-50%);
}

.bd-power-device > svg {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 3px;
  color: #72552e;
  background: #f5e6bd;
  border: 1px solid #b59b67;
  border-radius: 7px;
}

.bd-power-device-details {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.17rem;
  min-width: 0;
}

.bd-power-device-name {
  font-size: 0.75rem;
  line-height: 1.25;
}

.bd-power-device-status {
  color: #68675f;
  font-size: 0.67rem;
  line-height: 1.25;
}

.bd-power-charge-meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  background-color: #d5d0bd;
  border: 1px solid #66563d;
  border-radius: 99px;
}

.bd-power-charge-fill {
  display: block;
  height: 100%;
  background-color: #55956c;
  transition: width 0.25s ease;
}

.bd-power-charge-meter.is-disabled .bd-power-charge-fill {
  background-color: #8a8170;
}

.bd-electrical-empty,
.bd-electrical-note {
  margin: 0;
  color: #68675f;
  font-size: 0.72rem;
  line-height: 1.4;
}

.bd-electrical-empty {
  padding: 0.55rem;
  background: #eee8d7;
  border: 1px dashed #a99b7c;
  border-radius: 8px;
}

.bd-electrical-note {
  padding: 0.62rem 0.8rem 0.75rem;
}

.bd-power-charge-label {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 520px), (pointer: coarse) {
  .bd-electrical-scroll {
    padding: 0.58rem;
  }

  .bd-electrical-sources,
  .bd-electrical-loads {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.45rem;
  }

  .bd-electrical-section-title {
    font-size: 0.68rem;
  }

  .bd-power-device {
    padding: 0.42rem;
  }
}

