.layout-dialog {
  width:100vw;
  height:100dvh;
  max-width:none;
  max-height:none;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:var(--paper);
}
.layout-dialog[open] {
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
}
.layout-topbar {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:14px 22px;
  border-bottom:1px solid var(--line);
  background:var(--surface);
}
.layout-topbar h2 { font-size:20px; }
.layout-topbar .eyebrow { margin-bottom:3px; }
.layout-top-actions,.layout-button-row { display:flex; flex-wrap:wrap; gap:7px; }
.layout-body { display:grid; grid-template-columns:300px minmax(0,1fr); min-height:0; }
.layout-controls { overflow-y:auto; border-right:1px solid var(--line); background:var(--surface); }
.layout-section { padding:18px; border-bottom:1px solid var(--line); }
.layout-section h3 { margin-bottom:14px; font-size:13px; }
.layout-field-pair { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.layout-controls input,.layout-controls select,.layout-controls textarea { margin:5px 0 11px; }
.layout-controls input[type=color] { display:block; width:100%; }
.layout-controls textarea {
  display:block;
  width:100%;
  border:1px solid var(--line);
  border-radius:6px;
  background:var(--surface);
  padding:9px 10px;
  color:var(--ink);
  font:inherit;
  resize:vertical;
}
.layout-check { display:flex; align-items:center; gap:8px; }
.layout-check input { margin:0; }
.layout-add-row { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.layout-add-row select { margin:0; }
.layout-item-list { display:grid; grid-template-columns:1fr 1fr; gap:5px; margin-bottom:12px; }
.layout-object-button { padding:7px; font-size:10px; border:1px solid var(--line); background:var(--surface); border-radius:5px; text-align:left; }
.layout-object-button.is-selected { color:var(--accent); background:var(--accent-soft); border-color:#de8591; }
.layout-viewport { min-width:0; overflow:auto; padding:24px; display:flex; background:#e9e5e4; }
.layout-paper-wrap { position:relative; flex-shrink:0; margin:auto; }
.layout-paper {
  position:absolute;
  left:0;
  top:0;
  transform-origin:top left;
  background:#fff;
  color:#30292b;
  box-shadow:0 4px 24px #30292b24;
  overflow:hidden;
  touch-action:none;
  font-family:"Segoe UI","Myanmar Text",Arial,sans-serif;
}
.layout-paper.show-grid {
  background-image:linear-gradient(#a88c8e1a 1px,transparent 1px),linear-gradient(90deg,#a88c8e1a 1px,transparent 1px);
  background-size:2mm 2mm;
}
.layout-item { position:absolute; cursor:move; line-height:1.25; }
.layout-item.is-selected { outline:2px solid #cb2d3a; outline-offset:1px; }
.layout-item-content { width:100%; height:100%; overflow:hidden; }
.layout-item[data-kind=map] .layout-item-content { border:0.3mm solid #5a5254; }
.layout-map-image { width:100%; height:100%; display:block; object-fit:cover; }
.layout-map-empty { font-size:11pt; padding:10mm; color:#776c6f; }
.layout-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.layout-item[data-kind=title] .layout-text { font-weight:700; }
.layout-selection-handle { display:none; position:absolute; left:0; top:-17px; padding:1px 5px; background:#cb2d3a; color:#fff; font:9px "Segoe UI",Arial,sans-serif; pointer-events:none; white-space:nowrap; }
.layout-item.is-selected>.layout-selection-handle { display:block; }
.layout-item>.layout-resize-handle { top:auto; left:auto; bottom:-5px; right:-5px; width:10px; height:10px; padding:0; border:1px solid #fff; pointer-events:auto; cursor:nwse-resize; }
.layout-logo { width:100%; height:100%; object-fit:contain; display:block; }
.layout-north { display:flex; align-items:center; flex-direction:column; gap:4px; height:100%; }
.layout-north strong { flex-shrink:0; }
.layout-north-arrow { display:block; flex-shrink:0; max-width:100%; }
.layout-export-feedback { flex-basis:100%; margin:0; padding:8px 12px; border-radius:6px; background:var(--accent-soft); color:var(--ink); font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.layout-export-feedback.is-error { color:var(--accent); border:1px solid var(--accent); }
#layout-download-link { max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.layout-legend-title { display:block; margin-bottom:2mm; }
.layout-legend-group { margin-bottom:2mm; }
.layout-legend-heading { display:block; margin-bottom:1mm; }
.layout-legend-row { display:flex; align-items:center; gap:2mm; margin:0.7mm 0; }
.layout-legend-row>span:last-child { flex:1; min-width:0; overflow-wrap:anywhere; }
.layout-legend-symbol { display:block; width:5mm; height:3mm; border:1px solid; flex-shrink:0; }
.layout-legend-symbol.point { border-radius:50%; width:3mm; }
.layout-legend-symbol.line { border:0; }
.layout-scale-bar { display:flex; height:1.8mm; border:0.2mm solid #30292b; }
.layout-scale-bar span { flex:1; background:#fff; }
.layout-scale-bar span:nth-child(odd) { background:#30292b; }
.layout-scale-labels { display:flex; justify-content:space-between; margin-top:0.7mm; line-height:1.1; }
.layout-scale-ratio { margin-top:0.6mm; }
.layout-attribution { position:absolute; left:6mm; right:6mm; bottom:1mm; height:4mm; font-size:7pt; line-height:1.2; color:#5a5254; z-index:500; overflow:hidden; }
.layout-status { border-top:1px solid var(--line); padding:8px 18px; color:var(--muted); background:var(--surface); font-size:11px; }
.layout-busy { position:absolute; inset:0; z-index:1000; display:grid; place-items:center; background:#f7f4f3bb; }
.layout-busy>div { padding:24px 32px; border:1px solid var(--line); border-radius:10px; background:var(--surface); text-align:center; box-shadow:var(--shadow); }
.layout-busy p { margin-top:12px; }
@media (max-width:850px) {
  .layout-topbar { align-items:flex-start; flex-wrap:wrap; padding:12px; gap:10px; }
  .layout-top-actions { width:100%; }
  .layout-top-actions .button { font-size:11px; padding:8px; }
  .layout-body { grid-template-columns:240px minmax(0,1fr); }
  .layout-section { padding:14px; }
}
@media (max-width:600px) {
  .layout-body { grid-template-columns:1fr; grid-template-rows:minmax(0,1fr) minmax(100px,38%); }
  .layout-viewport { grid-row:1; padding:16px; }
  .layout-controls { grid-row:2; border-right:0; border-top:1px solid var(--line); }
  .layout-status { font-size:10px; padding:6px 12px; }
}
.layout-item.is-locked { cursor:default; }
.layout-item.is-locked .layout-resize-handle { display:none; }
.layout-legend-columns { column-gap:3mm; }
.layout-legend-group { break-inside:avoid; }
.layout-legend-row { break-inside:avoid; }
.legend-edit-group { margin:12px 0; }
.legend-edit-row { display:flex; gap:4px; align-items:center; margin:5px 0; }
.legend-edit-row[data-category]:not([data-category=""]) { margin-left:12px; }
.legend-edit-row input[type="text"] { flex:1; min-width:0; }
.legend-edit-row input[type="checkbox"] { width:auto; flex-shrink:0; }
.legend-edit-row .button { padding:5px; flex-shrink:0; }
.layout-map-tools { display:flex; gap:6px; }
.layout-map-tools .button { flex:1; justify-content:center; }
.layout-map-tools [aria-pressed=true] { background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }
.layout-map-zoom-row { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:12px; }
.layout-map-zoom-row span { color:var(--muted); font-size:11px; }
.layout-map-zoom-row button { min-width:34px; justify-content:center; font-size:16px; }
.layout-map-exact-zoom { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin-top:10px; }
.layout-map-exact-zoom label { flex-basis:100%; margin:0; }
.layout-map-exact-zoom input { flex:1; width:80px; min-width:60px; margin:0; }
.layout-map-exact-zoom button { flex-shrink:0; }
.layout-paper.move-map-mode [data-kind=map]:not(.is-locked) { cursor:grab; }
.layout-paper.move-map-mode [data-kind=map]>.layout-resize-handle { display:none; }
.layout-paper.move-map-mode [data-kind=map] .layout-map-image { user-select:none; }
.layout-paper.is-panning-map [data-kind=map] { cursor:grabbing; }
.layout-item[data-kind=map] .layout-item-content { background:#eee9e8; }
