:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --accent: oklch(0.62 0.13 195);
  --accent-soft: oklch(0.95 0.04 195);
  --accent-strong: oklch(0.52 0.14 195);
  --danger: #dc2626;

  --floor: #fafaf9;
  --wall: #1f2937;
  --grid: #e5e7eb;

  --surface-fill: #ffffff;
  --surface-stroke: #4b5563;
  --chair-fill: #e5e7eb;
  --chair-stroke: #6b7280;
  --label: #1f2937;
  --label-dim: #6b7280;

  --zone-stage-fill: #fef3c7;     --zone-stage-stroke: #b45309;
  --zone-dance-fill: #ede9fe;     --zone-dance-stroke: #6d28d9;
  --zone-bar-fill: #ffe4e6;       --zone-bar-stroke: #be123c;
  --zone-dj-fill: #dbeafe;        --zone-dj-stroke: #1d4ed8;
  --zone-photo-fill: #dcfce7;     --zone-photo-stroke: #15803d;
  --zone-buffet-fill: #fee2e2;    --zone-buffet-stroke: #b91c1c;
  --zone-head-fill: #fef3c7;      --zone-head-stroke: #92400e;

  --lib-icon-fill: #f3f4f6;
  --lib-icon-stroke: #6b7280;
  --lib-icon-chair: #d1d5db;
}

[data-theme="blueprint"] {
  --bg: #0c2740;
  --panel: #0f3358;
  --border: #1f4b78;
  --border-strong: #2e6aa8;
  --text: #e3f2ff;
  --text-dim: #8fb6dc;
  --text-faint: #5d85ad;
  --accent: #7dd3fc;
  --accent-soft: #1e3a5f;
  --accent-strong: #38bdf8;

  --floor: #11385f;
  --wall: #7dd3fc;
  --grid: #1e4b75;

  --surface-fill: transparent;
  --surface-stroke: #93c5fd;
  --chair-fill: transparent;
  --chair-stroke: #93c5fd;
  --label: #e3f2ff;
  --label-dim: #93c5fd;

  --zone-stage-fill: rgba(125,211,252,0.08);    --zone-stage-stroke: #7dd3fc;
  --zone-dance-fill: rgba(125,211,252,0.08);    --zone-dance-stroke: #7dd3fc;
  --zone-bar-fill: rgba(125,211,252,0.08);      --zone-bar-stroke: #7dd3fc;
  --zone-dj-fill: rgba(125,211,252,0.08);       --zone-dj-stroke: #7dd3fc;
  --zone-photo-fill: rgba(125,211,252,0.08);    --zone-photo-stroke: #7dd3fc;
  --zone-buffet-fill: rgba(125,211,252,0.08);   --zone-buffet-stroke: #7dd3fc;
  --zone-head-fill: rgba(125,211,252,0.08);     --zone-head-stroke: #7dd3fc;

  --lib-icon-fill: transparent;
  --lib-icon-stroke: #93c5fd;
  --lib-icon-chair: #93c5fd;
}

[data-theme="warm"] {
  --bg: #f7f1e8;
  --panel: #fbf6ee;
  --border: #e8dcc8;
  --border-strong: #d4c2a4;
  --text: #3a2e1f;
  --text-dim: #7a6850;
  --text-faint: #a89a82;
  --accent: oklch(0.58 0.13 40);
  --accent-soft: oklch(0.93 0.04 40);
  --accent-strong: oklch(0.50 0.15 40);

  --floor: #fbf6ee;
  --wall: #6b563a;
  --grid: #ead9bf;

  --surface-fill: #ffffff;
  --surface-stroke: #8a6d49;
  --chair-fill: #f0e3cd;
  --chair-stroke: #8a6d49;
  --label: #3a2e1f;
  --label-dim: #7a6850;

  --lib-icon-fill: #f5ead4;
  --lib-icon-stroke: #8a6d49;
  --lib-icon-chair: #d4c2a4;
}

[data-theme="dark"] {
  --bg: #0e1014;
  --panel: #161a21;
  --border: #262c36;
  --border-strong: #3a424f;
  --text: #e5e7eb;
  --text-dim: #9ca3af;
  --text-faint: #6b7280;
  --accent: oklch(0.72 0.15 165);
  --accent-soft: oklch(0.30 0.06 165);
  --accent-strong: oklch(0.78 0.18 165);

  --floor: #1a1f27;
  --wall: #4b5563;
  --grid: #232934;

  --surface-fill: #232934;
  --surface-stroke: #6b7280;
  --chair-fill: #2d3441;
  --chair-stroke: #6b7280;
  --label: #e5e7eb;
  --label-dim: #9ca3af;

  --zone-stage-fill: #3a2e10;     --zone-stage-stroke: #f59e0b;
  --zone-dance-fill: #2a1f4a;     --zone-dance-stroke: #a78bfa;
  --zone-bar-fill: #3a1620;       --zone-bar-stroke: #f87171;
  --zone-dj-fill: #102448;        --zone-dj-stroke: #60a5fa;
  --zone-photo-fill: #103820;     --zone-photo-stroke: #4ade80;
  --zone-buffet-fill: #3a1414;    --zone-buffet-stroke: #fb7185;
  --zone-head-fill: #3a2e10;      --zone-head-stroke: #fbbf24;

  --lib-icon-fill: #232934;
  --lib-icon-stroke: #9ca3af;
  --lib-icon-chair: #4b5563;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 72px 1fr 56px;
  background: var(--bg);
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 360px;
}
.brand-names { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.venue-name {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  font-family: inherit;
}
.venue-name:hover { border-color: var(--border-strong); }
.venue-name:focus { border-color: var(--accent); background: var(--panel); }
.venue-name::placeholder { color: var(--accent-strong); font-weight: 500; letter-spacing: 0; text-transform: none; opacity: 0.7; }

.brand-logo-add {
  display: flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 10px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  color: var(--accent-strong);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.brand-logo-add:hover { background: var(--accent); color: white; }
.brand-logo-mark { font-size: 14px; }

.brand-logo-wrap {
  position: relative;
  height: 32px;
  width: 32px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.brand-logo-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}
.brand-logo-clear {
  position: absolute;
  top: -6px; right: -6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text);
  color: var(--panel);
  border: none;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.brand-logo-wrap:hover .brand-logo-clear { opacity: 1; }

.brand-divider {
  width: 1px; height: 22px;
  background: var(--border);
  margin: 0 2px;
}

.event-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 5px;
  outline: none;
}
.event-name:hover { border-color: var(--border); }
.event-name:focus { border-color: var(--accent); background: var(--bg); }

.toolbar-center {
  display: flex; align-items: center; gap: 4px;
  flex: 1;
  justify-content: center;
}

.tool-group { display: flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 7px; padding: 3px; }
.tool-divider { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }

.tool-btn {
  height: 26px;
  min-width: 28px;
  padding: 0 8px;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.12s;
}
.tool-btn:hover:not(:disabled) { background: var(--panel); color: var(--text); }
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-btn.active { background: var(--accent); color: white; }
.tool-btn.wide { min-width: 90px; }
.tool-btn.small { font-size: 10px; }

.zoom-display {
  min-width: 44px;
  text-align: center;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-weight: 500;
}

.tool-dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  min-width: 180px;
  padding: 4px;
  z-index: 100;
}
.dropdown-item {
  display: block; width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  text-align: left;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  border-radius: 5px;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 500; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

.toolbar-right { display: flex; align-items: center; gap: 8px; }
.btn-primary {
  height: 32px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { background: var(--accent-strong); }

/* Workspace */
.workspace {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  overflow: hidden;
  min-height: 0;
}

.panel {
  background: var(--panel);
  overflow-y: auto;
  font-size: 12px;
}
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }
.panel-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 14px 8px;
  position: sticky; top: 0;
  background: var(--panel);
  z-index: 2;
}
.panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.panel-hint { font-size: 10.5px; color: var(--text-faint); }

/* Library */
.lib-group { padding: 8px 10px 14px; }
.lib-group-title {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 4px 8px;
  font-weight: 600;
}
.lib-items { display: flex; flex-direction: column; gap: 2px; }
.lib-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: 12px;
  transition: all 0.12s;
}
.lib-item:hover {
  background: var(--bg);
  border-color: var(--border);
}
.lib-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 5px;
  flex-shrink: 0;
}
.lib-label { flex: 1; }

/* Properties */
.empty-state {
  padding: 32px 18px;
  text-align: center;
  color: var(--text-dim);
}
.empty-icon { font-size: 28px; opacity: 0.3; margin-bottom: 6px; }
.empty-title { font-weight: 500; color: var(--text); margin-bottom: 4px; font-size: 12.5px; }
.empty-body { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; }

.prop-section {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.prop-section:first-of-type { border-top: 1px solid var(--border); }
.prop-row { display: flex; gap: 8px; }
.prop-row.tight { gap: 6px; align-items: center; }
.prop-row .prop-section { flex: 1; padding: 0; border: none; }
.prop-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.prop-sub { font-weight: 400; color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.prop-input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.prop-input.small { width: 56px; }
.prop-input:focus { border-color: var(--accent); }
.prop-input:disabled { opacity: 0.5; }
.prop-slider { flex: 1; accent-color: var(--accent); }
.prop-rot-quick { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.chip {
  font-size: 10.5px;
  padding: 3px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.step-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 5px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.step-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.seat-display {
  flex: 1; text-align: center;
  font-size: 14px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.guest-seats { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.guest-seat {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 11.5px;
}
.guest-num {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 600;
  flex-shrink: 0;
}
.guest-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.guest-x {
  width: 16px; height: 16px;
  border: none; background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: 3px;
}
.guest-x:hover { background: var(--border); color: var(--danger); }
.guest-select {
  flex: 1;
  height: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 11px;
  font-family: inherit;
}

.prop-mini { display: flex; align-items: center; gap: 4px; flex: 1; }
.prop-mini > span:first-child { font-size: 10.5px; color: var(--text-faint); font-weight: 600; }
.unit { font-size: 10px; color: var(--text-faint); }

.prop-actions {
  display: flex; gap: 6px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.btn-secondary, .btn-danger {
  flex: 1;
  height: 30px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

/* Canvas */
.canvas-wrap {
  position: relative;
  overflow: auto;
  background:
    radial-gradient(circle at 20% 20%, rgba(0,0,0,0.02), transparent 60%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
[data-theme="dark"] .canvas-wrap, [data-theme="blueprint"] .canvas-wrap {
  background: var(--bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas {
  max-width: 100%;
  max-height: 100%;
  width: 92%;
  height: 92%;
  user-select: none;
  filter: drop-shadow(0 8px 24px rgba(15, 23, 42, 0.06));
}
[data-theme="blueprint"] .canvas { filter: none; }

.obj { transition: opacity 0.12s; }
.obj:hover { opacity: 0.92; }

.canvas-hint {
  position: absolute;
  bottom: 12px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.canvas-hint kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: ui-monospace, monospace;
  font-size: 10px;
  margin-right: 2px;
}

/* Stats bar */
.statsbar {
  display: flex;
  align-items: stretch;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0 14px;
  gap: 0;
}
.stat {
  flex: 1;
  padding: 8px 16px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  justify-content: center;
}
.stat:last-child { border-right: none; }
.stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-sub {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 1px;
}
.stat.accent .stat-value { color: var(--accent-strong); }

/* Editable hall stat */
.stat.hall-stat { position: relative; padding: 0; }
.hall-stat-btn {
  all: unset;
  display: flex; flex-direction: column; justify-content: center;
  width: 100%; height: 100%;
  padding: 8px 16px;
  cursor: default;
  box-sizing: border-box;
}
.stat.hall-stat.editable .hall-stat-btn { cursor: pointer; }
.stat.hall-stat.editable .hall-stat-btn:hover { background: var(--accent-soft); }
.stat.hall-stat.editable .hall-stat-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hall-edit-hint {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 3px;
  text-transform: uppercase;
}
.hall-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px;
  z-index: 1000;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  padding: 12px;
}
.hall-popover-title {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.hall-popover-row {
  display: flex; align-items: flex-end; gap: 8px;
}
.hall-popover-row label {
  flex: 1;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
}
.hall-popover-row input {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.hall-popover-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.hall-popover-x {
  font-size: 14px; color: var(--text-faint); padding-bottom: 8px;
}
.hall-popover-presets {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 10px;
}
.hall-preset {
  padding: 4px 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
}
.hall-preset:hover { border-color: var(--border-strong); color: var(--text); }
.hall-preset.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.hall-popover-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.hall-popover-done {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  background: var(--text);
  color: var(--panel);
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.hall-popover-done:hover { background: var(--accent-strong); }

/* Don't let the SVG canvas hijack page scroll on touch devices */
.canvas { touch-action: none; }

/* Fullscreen toggle in toolbar */
.fullscreen-btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.fullscreen-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.fullscreen-btn-label { white-space: nowrap; }

/* Mobile-only collapse toggle (hidden by default on desktop) */
.panel-mtoggle { display: none; }

/* ---------- Mobile / narrow screens ---------- */
@media (max-width: 900px) {
  body, html { overflow: auto; }
  .app {
    height: 100dvh;
    min-height: 100vh;
    grid-template-rows: auto 1fr auto;
  }

  /* Toolbar wraps onto multiple rows; everything stays tappable */
  .toolbar {
    flex-wrap: wrap;
    padding: 8px;
    gap: 6px;
    row-gap: 6px;
  }
  .brand { min-width: 0; flex: 1 1 100%; }
  .brand-divider { display: none; }
  .toolbar-center {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }
  .tool-divider { display: none; }
  .toolbar-right { flex: 0 0 auto; margin-left: auto; }
  .tool-btn { min-height: 34px; min-width: 34px; }
  .tool-btn.wide { min-width: 80px; }
  .btn-primary { min-height: 36px; }

  /* Workspace: collapsed-tab Library on top, big canvas, collapsed Properties below */
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  /* Show the toggle bar; hide the panel body unless the panel is open */
  .panel-mtoggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    padding: 0 14px;
    background: var(--panel);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }
  .panel-mtoggle:disabled { opacity: 0.6; cursor: default; }
  .panel-mtoggle-label { flex: 0 0 auto; }
  .panel-mtoggle-hint {
    flex: 1;
    color: var(--text-faint);
    font-size: 11.5px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .panel-mtoggle-chev {
    flex: 0 0 auto;
    transition: transform 0.18s ease;
    color: var(--text-dim);
  }
  .panel-mtoggle-chev.open { transform: rotate(180deg); }

  .panel-left, .panel-right {
    border-left: none;
    border-right: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .panel-left .panel-body,
  .panel-right .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.22s ease;
  }
  .panel-left.m-open .panel-body,
  .panel-right.m-open .panel-body {
    max-height: 50vh;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }
  .panel-right .panel-mtoggle { border-bottom: none; border-top: 1px solid var(--border); }

  /* Inside the open library panel, keep the original vertical list layout */
  .panel-left .panel-header { display: none; }
  .panel-left .lib-group { padding: 8px 12px 12px; }
  .panel-left .lib-items { flex-direction: column; gap: 2px; }
  .panel-left .lib-item {
    flex-direction: row;
    gap: 10px;
    min-width: 0;
    padding: 8px 10px;
    text-align: left;
  }
  .panel-left .lib-label { font-size: 12.5px; }
  .panel-left .lib-icon { width: 36px; height: 36px; }

  .panel-right .empty-state { padding: 18px 14px; }

  /* Hide keyboard-shortcut hint and the floating tweaks helper on mobile */
  .canvas-hint { display: none; }
  .tweaks-panel-floating { display: none !important; }

  /* Compact stats bar */
  .statsbar { padding: 0 8px; }
  .stat { padding: 6px 10px; }
  .stat-value { font-size: 14px; }
  .stat-sub { font-size: 10px; }

  /* Hall popover: keep it on-screen */
  .hall-popover { width: min(280px, calc(100vw - 32px)); left: 8px; right: auto; }
}

/* Extra-tight (phones in portrait) */
@media (max-width: 480px) {
  .brand { gap: 6px; }
  .brand-names .venue-name,
  .brand-names .event-name { font-size: 12px; padding: 5px 7px; }
  .brand-logo-add { padding: 0 8px; font-size: 11px; }
  .toolbar-right .btn-primary { padding: 0 10px; font-size: 12px; }
  .fullscreen-btn-label { display: none; }
  .fullscreen-btn { padding: 0 8px; }
}

/* Print */
.print-header { display: none; }
@media print {
  @page { margin: 0.5in; }
  body, html { background: white; overflow: visible; }
  .toolbar, .panel-left, .panel-right, .statsbar, .canvas-hint, .tweaks-panel-floating { display: none !important; }
  .app { display: block; height: auto; }
  .workspace { display: block; }
  .canvas-wrap { background: white !important; padding: 0; }
  .canvas { width: 100% !important; height: auto !important; transform: none !important; filter: none !important; }
  .canvas .grid-layer,
  .canvas .measurements-layer { display: none !important; }
  .floor-watermark { opacity: 0.18 !important; }

  /* Print header — appears at top of every printed page */
  .print-header {
    display: block !important;
    padding: 0;
    margin: 0 0 18px 0;
    page-break-after: avoid;
  }
  .print-letterhead {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 0 0 14px 0;
    border-bottom: 3px double #111;
  }
  .print-letterhead-text { line-height: 1.2; }
  .print-logo { height: 56px; width: auto; }
  .print-venue {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #111;
  }
  .print-venue-empty { color: #aaa; font-style: italic; font-weight: 500; }
  .print-tagline {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #666;
    margin-top: 4px;
  }
  .print-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: #222;
    text-align: right;
    line-height: 1.45;
  }
  .print-meta div { display: flex; gap: 10px; justify-content: flex-end; align-items: baseline; }
  .print-meta span {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #888;
    font-size: 9.5px;
    min-width: 38px;
    text-align: right;
  }
  .print-eventbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 0 0;
  }
  .print-stats { display: flex; gap: 18px; font-size: 11px; color: #444; }
  .print-stats strong { color: #111; font-weight: 600; }
}
