.layout-editor {
  padding: 0;
  width: min(68rem, calc(100vw - 3rem));
  max-width: none;
  max-height: calc(100dvh - 3rem);
  margin: auto;
  border: 1px solid #b5c4b9;
  border-radius: 1.25rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1.4rem 6rem #122b2540;
}
.layout-editor[open] { display: flex; flex-direction: column; }
.layout-editor::backdrop { background: #13292291; }
body:has(.layout-editor[open]) { overflow: hidden; }
.le-head, .le-footer { padding: 1rem clamp(.9rem, 2.6vw, 1.8rem); background: #fff; }
.le-head { border-bottom: 1px solid var(--line); }
.le-head h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
.le-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(17.5rem, 1fr);
  align-items: start;
  gap: clamp(1rem, 2.6vw, 1.8rem);
  padding: clamp(.9rem, 2.6vw, 1.8rem);
}
.le-board { background: #eaf1f2; border: 1px solid #c5d4d4; border-radius: .9rem; padding: .65rem; }
.le-board-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .35rem; margin: .12rem .2rem .65rem; }
.le-board-head h3 { color: #294c56; }
.le-board-head span, #le-instruction, .le-footer p { font-size: .87rem; }
.le-board-head span, #le-instruction { color: #425f68; }
#le-instruction { margin: .65rem .2rem .15rem; }
.le-grid {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 24/16;
  overflow: hidden;
  outline: 1px solid #b6c8ca;
  border-radius: .2rem;
  background-color: #f8fbfa;
  background-image: linear-gradient(90deg, #bccdd0 1px, transparent 1px), linear-gradient(#bccdd0 1px, transparent 1px);
  background-size: calc(100% / 24) calc(100% / 16);
  touch-action: none;
}
.le-grid:focus-visible { outline: 3px solid #336da8; }
.le-tile, .le-pin, .le-resize { position: absolute; touch-action: none; user-select: none; }
.le-tile {
  display: grid; place-items: center; overflow: hidden; min-width: 0; min-height: 0; margin: 0; padding: .12rem;
  border: 2px solid #527078; border-radius: 0; background: #edf3f1; color: #274752;
  font: 600 clamp(.66rem, 1.2vw, .95rem)/1.1 "DM Sans", system-ui, sans-serif; overflow-wrap: anywhere; cursor: grab;
}
.le-tile[aria-pressed="true"] { background: #dce9b4; border-color: #324f3c; }
.le-pin { z-index: 1; transform: translate(-50%,-50%); display: grid; place-items: center; border: 1px solid #7e8662; color: #304a30; background: #fbf8d7; border-radius: 50%; padding: .12rem; width: 1.55rem; height: 1.55rem; }
.le-pin[aria-pressed="true"] { outline: 2px solid #355b3e; }
.le-pin svg { width: .95rem; height: .95rem; pointer-events: none; }
.le-resize { z-index: 2; transform: translate(-85%,-85%); width: 1.7rem; height: 1.7rem; padding: 0; border: 1px solid white; border-radius: .35rem; background: var(--ink); color: white; cursor: nwse-resize; font: 650 1rem/1 system-ui; }
.le-ghost { position: absolute; z-index: 3; pointer-events: none; border: 2px dashed #355b3e; background: #c2e0b185; }
.le-ghost[data-valid="false"] { border-color: #a53c2f; background: #ecb09a85; }
.le-cursor { position: absolute; z-index: 3; pointer-events: none; outline: 2px solid #2d6876; outline-offset: -2px; background: #c4edf280; }
.le-grid:not([data-mode=""]), .le-grid:not([data-mode=""]) button { cursor: crosshair; }
.le-tools, .le-tools form, .le-tools label, #le-room-tools, .le-lamps, #le-new-lamp-fields { display: grid; gap: .65rem; min-width: 0; }
.le-tools { align-content: start; }
.le-tools label { gap: .28rem; font-size: .9rem; font-weight: 620; }
.le-tools input:not([type="checkbox"]), .le-tools select {
  width: 100%; min-width: 0; min-height: 2.75rem; padding: .5rem .65rem;
  font: inherit; color: var(--ink); border: 1px solid #b3c2b6; background: white; border-radius: .5rem;
}
.le-tools input:focus-visible, .le-tools select:focus-visible { outline: 3px solid #336da8; outline-offset: 1px; }
.le-select-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: .5rem; }
.le-tools button, .le-footer button {
  min-height: 2.75rem; border: 1px solid #b6c5b9; background: white; color: var(--ink); padding: .45rem .75rem; border-radius: .6rem;
  font: 620 .91rem/1.25 "DM Sans", system-ui, sans-serif;
}
.le-tools button:hover, .le-footer button:hover { border-color: var(--ink); }
.le-tools button:disabled { opacity: .48; cursor: default; }
.le-tools .le-primary, .le-footer .le-primary { background: var(--ink); color: white; border-color: var(--ink); }
.le-tools form { border: 1px solid var(--line); padding: .75rem; border-radius: .65rem; background: white; }
.le-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.le-tools details { border-top: 1px solid var(--line); }
.le-tools summary { padding: .7rem 0; font-weight: 630; }
.le-adjustments { display: grid; gap: .32rem; margin-bottom: .6rem; }
.le-adjustments > div { display: grid; grid-template-columns: minmax(0,1fr) 2.75rem 2.45rem 2.75rem; align-items: center; gap: .26rem; font-size: .92rem; }
.le-adjustments output { text-align: center; font-variant-numeric: tabular-nums; }
.le-lamps { padding-top: .8rem; border-top: 1px solid var(--line); }
.le-lamps .le-checkbox { display: flex; align-items: center; gap: .5rem; min-height: 2.5rem; }
.le-checkbox input { accent-color: var(--ink); }
#le-associated { display: flex; flex-wrap: wrap; gap: .45rem; }
#le-associated select { flex-basis: 100%; }
.le-footer { border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.le-footer p { color: #405d4c; min-width: 0; }
.le-footer .le-actions { flex-shrink: 0; }
@media (max-width: 720px) {
  .layout-editor { width: min(100%, 34rem); max-height: 100dvh; border-radius: .9rem; }
  .le-scroll { display: block; padding: .85rem; }
  .le-tools { margin-top: .9rem; }
  .le-board-head h3 { font-size: 1rem; }
  .le-board-head span { font-size: .77rem; }
  .le-grid { max-height: none; }
  .le-footer { flex-wrap: wrap; padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
  .le-footer p:empty { display: none; }
  .le-footer .le-actions { margin-left: auto; }
}
@media (max-width: 400px) { .layout-editor { border-radius: 0; } }
