:root {
  --paper: #fbf7ef;
  --paper-strong: #fffdf8;
  --ink: #2a2118;
  --muted: #867866;
  --line: #e1d5c4;
  --gold: #a77f38;
  --gold-dark: #7d5f2a;
  --gold-soft: #ead8b8;
  --green: #5fa670;
  --green-soft: #dff1e2;
  --yellow: #d6a530;
  --yellow-soft: #f7e8bd;
  --red: #c9615f;
  --red-soft: #f4d8d5;
  --shadow: 0 24px 70px rgba(58, 44, 26, 0.18);
  font-family: "Assistant", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 8%, rgba(255, 255, 255, 0.92), transparent 34%),
    linear-gradient(135deg, #f8f1e7, #eee2d1 48%, #f9f3ea);
}

button,
input,
select {
  font: inherit;
}

button,
label,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

.studio-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 6px 18px;
  border-bottom: 1px solid rgba(167, 127, 56, 0.25);
  background: rgba(255, 252, 246, 0.9);
  backdrop-filter: blur(18px);
  direction: ltr;
}

.brand {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  color: var(--gold-dark);
  text-align: center;
  white-space: nowrap;
  direction: ltr;
}

.brand strong {
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-size: 1.55rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.brand span {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand span::before {
  content: "|";
  display: inline-block;
  margin-inline: 2px 8px;
  color: var(--line);
  letter-spacing: 0;
}

.topbar-status {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-self: end;
  gap: 8px;
  direction: rtl;
}

.topbar-status > #buildBadge {
  flex: 0 0 auto;
  justify-self: end;
  width: max-content;
  margin: 0;
  padding: 2px 8px;
  border-radius: 999px;
  color: #256b37;
  background: var(--green-soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.topbar-stats {
  grid-template-columns: repeat(4, max-content);
  gap: 0;
}

.topbar-stats article {
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.topbar-stats strong {
  font-size: 1.1rem;
}

.topbar-stats span {
  font-size: 0.64rem;
  white-space: nowrap;
}

.top-nav,
.map-actions,
.assign-actions,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.topbar > .top-nav {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  flex-wrap: nowrap;
  gap: 6px;
  direction: rtl;
}

.topbar > .top-nav > .ghost-button,
.topbar > .top-nav > .file-button {
  min-height: 34px;
  height: 34px;
  padding-inline: 11px;
  font-size: 0.86rem;
}

.topbar > .top-nav .event-picker select {
  min-height: 34px;
  height: 34px;
  padding-inline: 10px;
}

.event-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.event-picker select,
.assign-actions select,
.inspector-grid input,
.inspector-grid select,
.event-fields input,
.manual-grid input,
.search-box input {
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.event-picker select,
.assign-actions select {
  min-height: 42px;
  padding: 0 14px;
}

.ghost-button,
.primary-button,
.danger-button,
.mode-button,
.filter-row button,
.file-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.ghost-button,
.primary-button,
.danger-button,
.mode-button,
.filter-row button {
  padding: 0 16px;
}

.ghost-button:hover,
.danger-button:hover,
.mode-button:hover,
.filter-row button:hover,
.file-button:hover {
  border-color: rgba(167, 127, 56, 0.62);
}

.primary-button,
.mode-button.is-active,
.filter-row button.is-active {
  border-color: transparent;
  color: #fffaf1;
  background: linear-gradient(135deg, #b9914e, #84642d);
}

.danger-button {
  border-color: rgba(201, 97, 95, 0.35);
  color: #9a3e3b;
  background: rgba(244, 216, 213, 0.62);
}

.file-button {
  position: relative;
  display: grid;
  padding: 0 16px;
  place-items: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 420px;
  gap: 14px;
  height: calc(100vh - 64px);
  min-height: 0;
  padding: 12px;
}

body.has-table-editor .studio-layout {
  height: calc(100vh - 188px);
}

.map-section,
.side-panel section {
  border: 1px solid rgba(167, 127, 56, 0.2);
  background: rgba(255, 253, 247, 0.78);
  box-shadow: var(--shadow);
}

.map-section {
  display: flex;
  min-height: 0;
  height: 100%;
  border-radius: 18px;
  flex-direction: column;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(167, 127, 56, 0.18);
  background: rgba(255, 252, 246, 0.76);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-weight: 500;
}

h1 {
  font-size: clamp(2rem, 3.25vw, 3.6rem);
}

h2 {
  font-size: 1.5rem;
}

.hall-wrap {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 0;
  padding: 12px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.5), rgba(244, 233, 218, 0.4)),
    #efe4d4;
}

.map-tools-menu {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 6;
  direction: rtl;
}

.map-tools-menu > summary {
  display: flex;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 12px 28px rgba(65, 48, 24, 0.12);
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.map-tools-panel #mapZoomControls,
.map-tools-panel #mapZoomControls[hidden],
.map-tools-panel #sketchBuilder[hidden] {
  display: none;
}

.map-canvas-actions {
  position: absolute;
  top: 22px;
  left: 104px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  direction: rtl;
}

.map-canvas-actions button {
  min-height: 42px;
  height: 42px;
  padding-inline: 13px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(65, 48, 24, 0.1);
}

.map-tools-menu > summary::-webkit-details-marker {
  display: none;
}

.map-tools-menu[open] > summary {
  border-color: rgba(167, 127, 56, 0.62);
  color: #fffaf1;
  background: linear-gradient(135deg, #b9914e, #84642d);
}

.map-tools-panel {
  position: absolute;
  top: 50px;
  left: 0;
  display: grid;
  width: 280px;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(167, 127, 56, 0.28);
  border-radius: 14px;
  background: rgba(255, 252, 246, 0.96);
  box-shadow: var(--shadow);
}

.tool-block {
  display: grid;
  gap: 8px;
}

.map-mode-actions {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.map-mode-actions button {
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.tool-title {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.tool-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tool-row button,
.tool-layout-button,
.tool-danger-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
}

.tool-layout-button {
  display: flex;
  padding: 8px 10px;
  align-items: center;
  justify-content: space-between;
  text-align: right;
}

.tool-layout-button span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.tool-layout-button strong {
  color: var(--gold-dark);
  font-size: 0.95rem;
}

.tool-danger-button {
  width: 100%;
  color: #8f3030;
  background: rgba(255, 245, 243, 0.82);
}

.sketch-builder {
  border: 1px solid rgba(167, 127, 56, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.46);
}

.sketch-builder summary {
  min-height: 38px;
  padding: 0 10px;
  color: var(--gold-dark);
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.sketch-builder summary::-webkit-details-marker {
  display: none;
}

.sketch-grid {
  display: grid;
  gap: 9px;
  padding: 0 10px 10px;
}

.sketch-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.sketch-grid input {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.sketch-grid .primary-button {
  width: 100%;
  min-height: 40px;
}

.hall-canvas {
  position: relative;
  width: min(100%, 1260px);
  height: min(100%, 700px);
  min-height: 0;
  margin: 0;
  border: 1px solid rgba(115, 89, 49, 0.28);
  border-radius: 16px;
  overflow: hidden;
  transform-origin: top center;
  background:
    radial-gradient(circle at 8% 18%, rgba(83, 123, 60, 0.15), transparent 10%),
    radial-gradient(circle at 92% 78%, rgba(83, 123, 60, 0.16), transparent 12%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.25) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.25) 1px, transparent 1px),
    linear-gradient(135deg, #eadcc6, #f8efe1);
  background-size: auto, auto, 96px 96px, 96px 96px, auto;
  box-shadow: inset 0 0 0 18px rgba(103, 79, 45, 0.1), 0 26px 70px rgba(82, 61, 31, 0.24);
}

.hall-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 95px, rgba(120, 90, 45, 0.08) 96px),
    linear-gradient(180deg, transparent 95px, rgba(120, 90, 45, 0.08) 96px);
  background-size: 96px 96px;
}

.stage {
  position: absolute;
  top: 28px;
  left: 50%;
  z-index: 2;
  display: grid;
  width: 360px;
  height: 74px;
  border: 1px solid rgba(151, 115, 54, 0.38);
  border-radius: 0 0 18px 18px;
  place-items: center;
  color: var(--gold-dark);
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.9), rgba(229, 207, 177, 0.82));
  transform: translateX(-50%);
}

.stage strong {
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-size: 1.6rem;
}

.stage span {
  margin-top: -18px;
  color: var(--muted);
}

.hall-canvas.layout-horizontal .stage {
  top: 50%;
  right: 24px;
  left: auto;
  width: 128px;
  height: 280px;
  border-radius: 18px 0 0 18px;
  align-content: center;
  gap: 6px;
  transform: translateY(-50%);
}

.hall-canvas.layout-horizontal .stage strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 1.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hall-canvas.layout-horizontal .stage span {
  margin-top: 0;
  writing-mode: horizontal-tb;
}

.tables-layer {
  position: absolute;
  inset: 0;
}

.table-node {
  position: absolute;
  z-index: 3;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 2px;
  padding: 11px 4px 3px;
  min-width: 70px;
  min-height: 62px;
  border: 1px solid rgba(112, 84, 43, 0.46);
  border-radius: 10px;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf8, #efe0cb);
  box-shadow: 0 12px 26px rgba(91, 64, 30, 0.2);
  transform: translate(-50%, -50%);
  cursor: grab;
  user-select: none;
}

.table-node::before,
.table-node::after {
  position: absolute;
  inset: -10px 9px;
  z-index: -1;
  border: 8px solid rgba(173, 132, 61, 0.42);
  border-right-width: 0;
  border-left-width: 0;
  border-radius: 14px;
  content: "";
}

.table-node::after {
  inset: 9px -10px;
  border: 8px solid rgba(173, 132, 61, 0.42);
  border-top-width: 0;
  border-bottom-width: 0;
}

.table-node.is-selected {
  z-index: 4;
  outline: 3px solid rgba(167, 127, 56, 0.42);
  outline-offset: 6px;
}

.table-node:hover,
.table-node:focus-visible {
  z-index: 5;
}

.table-node.is-over {
  border-color: rgba(196, 76, 70, 0.75);
  box-shadow: 0 0 0 4px rgba(196, 76, 70, 0.14), 0 12px 26px rgba(91, 64, 30, 0.2);
}

.table-node.is-drop-ready {
  border-color: rgba(95, 166, 112, 0.9);
  box-shadow: 0 0 0 6px rgba(95, 166, 112, 0.18), 0 16px 30px rgba(91, 64, 30, 0.22);
}

.table-node.is-drop-blocked {
  border-color: rgba(196, 76, 70, 0.82);
  box-shadow: 0 0 0 6px rgba(196, 76, 70, 0.16), 0 16px 30px rgba(91, 64, 30, 0.22);
  opacity: 0.72;
}

.table-number {
  position: absolute;
  top: -13px;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 58px;
  max-width: calc(100% + 12px);
  height: 26px;
  padding: 0 8px;
  border: 2px solid #fffaf1;
  border-radius: 20px;
  color: #fff;
  background: #705622;
  box-shadow: 0 2px 5px rgba(58, 44, 26, 0.2);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.table-number small {
  font-size: 0.6rem;
  font-weight: 600;
}

.table-label {
  display: -webkit-box;
  width: 100%;
  min-width: 0;
  max-height: 2.5em;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.table-count {
  direction: ltr;
  font-size: 0.75rem;
  font-weight: 700;
  unicode-bidi: isolate;
}

.table-badge {
  position: absolute;
  bottom: -10px;
  right: -5px;
  display: inline-flex;
  min-height: 18px;
  align-items: center;
  padding: 0 5px;
  border-radius: 8px;
  color: #fff8ed;
  background: linear-gradient(135deg, #c29c55, #8a682d);
  font-size: 0.6rem;
  font-weight: 800;
}

.table-hover-guests {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  z-index: 8;
  display: grid;
  width: max-content;
  min-width: 132px;
  max-width: 220px;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid rgba(167, 127, 56, 0.24);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.76);
  box-shadow: 0 14px 32px rgba(58, 44, 26, 0.16);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 6px);
  transition: 140ms ease;
  backdrop-filter: blur(10px);
}

.table-hover-guests span,
.table-hover-guests small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-hover-guests small {
  color: var(--muted);
  font-size: 0.72rem;
}

.table-node:hover .table-hover-guests,
.table-node:focus-visible .table-hover-guests {
  opacity: 1;
  transform: translate(-50%, 0);
}

.side-panel {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding-left: 2px;
}

.side-panel section {
  padding: 14px;
  border-radius: 16px;
}

.event-card {
  display: grid;
  gap: 12px;
}

.event-fields,
.manual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.event-fields label,
.inspector-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.event-fields input,
.manual-grid input,
.inspector-grid input,
.inspector-grid select,
.search-box input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stats-grid article {
  display: grid;
  min-height: 78px;
  border: 1px solid rgba(167, 127, 56, 0.2);
  border-radius: 12px;
  place-items: center;
  background: rgba(255, 255, 255, 0.55);
}

.stats-grid strong {
  font-family: "Frank Ruhl Libre", Georgia, serif;
  font-size: 1.85rem;
  line-height: 1;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.import-summary strong,
.import-summary span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  font-weight: 800;
}

.import-summary strong {
  color: var(--gold-dark);
}

.import-summary span {
  padding: 0 12px;
  color: #356946;
  background: rgba(223, 241, 226, 0.72);
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 38px;
}

.search-box span {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--muted);
  transform: translateY(-50%);
}

.filter-row button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.86rem;
}

.panel-title {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.panel-title span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.assign-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
}

.table-suggestions {
  display: grid;
  gap: 8px;
}

.suggestions-disclosure > summary {
  margin-bottom: 0;
  cursor: pointer;
  list-style: none;
}

.suggestions-disclosure > summary::-webkit-details-marker {
  display: none;
}

.suggestions-disclosure > summary::before {
  content: "◂";
  color: var(--gold-dark);
}

.suggestions-disclosure > summary h2 {
  flex: 1;
}

.suggestions-disclosure[open] > summary {
  margin-bottom: 12px;
}

.suggestions-disclosure[open] > summary::before {
  content: "▾";
}

.suggestion-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(95, 166, 112, 0.28);
  border-radius: 12px;
  background: rgba(223, 241, 226, 0.42);
}

.suggestion-item strong,
.suggestion-item span,
.suggestion-item small,
.suggestion-item em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-item strong {
  font-size: 1.02rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.suggestion-item span {
  color: #356946;
  font-weight: 800;
}

.suggestion-item .suggestion-summary {
  white-space: normal;
  overflow-wrap: anywhere;
}

.suggestion-item small,
.suggestion-item em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.suggestion-item .primary-button {
  min-width: 92px;
}

.suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.existing-table-assign {
  display: grid;
  min-width: 220px;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 6px;
}

.existing-table-assign select {
  min-height: 38px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
}

.suggestion-actions button {
  min-width: 92px;
}

.manual-card summary {
  color: var(--gold-dark);
  cursor: pointer;
  font-weight: 800;
}

.manual-grid {
  margin-top: 12px;
}

.manual-grid .primary-button {
  grid-column: 1 / -1;
}

.guest-list-card {
  min-height: 260px;
}

.table-inspector {
  border-color: rgba(167, 127, 56, 0.38);
  background: rgba(255, 251, 242, 0.92);
}

.top-table-editor {
  position: sticky;
  top: 64px;
  z-index: 16;
  display: grid;
  grid-template-columns: minmax(140px, 190px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 12px 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(167, 127, 56, 0.28);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 14px 36px rgba(58, 44, 26, 0.14);
  backdrop-filter: blur(16px);
}

.top-table-editor[hidden] {
  display: none;
}

.top-table-editor .panel-title {
  display: grid;
  gap: 2px;
  align-self: center;
  justify-content: start;
  margin: 0;
}

.top-table-editor .panel-title h2 {
  font-size: 1.35rem;
}

.top-table-editor .panel-title span {
  font-size: 0.92rem;
}

.top-table-editor .inspector-grid {
  grid-template-columns: repeat(6, minmax(92px, 1fr));
  align-items: end;
  gap: 8px;
}

.top-table-editor .inspector-grid label {
  gap: 4px;
  font-size: 0.78rem;
}

.top-table-editor .wide-field {
  grid-column: span 2;
}

.table-size-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.table-size-field label {
  display: flex;
  justify-content: space-between;
}

.table-size-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  direction: ltr;
}

.table-size-controls input[type="range"] {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0;
}

.table-size-controls button {
  flex: 0 0 36px;
  padding: 0;
  font-size: 1.2rem;
}

.top-table-editor .table-type-actions {
  grid-template-columns: repeat(3, max-content);
  align-items: end;
  gap: 8px;
  margin: 0;
}

.top-table-editor .table-type-actions .danger-button {
  grid-column: auto;
}

.top-table-editor .table-guest-list {
  display: none;
}

.guest-list {
  display: grid;
  gap: 7px;
}

.guest-row {
  display: grid;
  grid-template-columns: auto 42px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.guest-row.is-draggable {
  cursor: grab;
}

.guest-row.is-draggable:active,
.guest-row.is-dragging {
  cursor: grabbing;
}

.guest-row.is-dragging {
  border-color: rgba(95, 166, 112, 0.72);
  background: rgba(223, 241, 226, 0.58);
  opacity: 0.68;
}

.guest-row.is-selected {
  border-color: rgba(167, 127, 56, 0.72);
  background: rgba(236, 217, 181, 0.38);
}

.guest-row input {
  width: 18px;
  height: 18px;
}

.guest-count {
  display: grid;
  width: 34px;
  height: 30px;
  border-radius: 999px;
  place-items: center;
  color: var(--gold-dark);
  background: var(--gold-soft);
  font-weight: 800;
}

.guest-main {
  min-width: 0;
}

.guest-main strong,
.guest-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guest-name-button {
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-weight: 700;
  text-align: start;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.guest-name-button:hover {
  color: var(--gold-dark);
  text-decoration: underline;
}

.guest-name-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 3px;
}

.guest-editor {
  width: min(360px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.guest-editor::backdrop {
  background: rgba(42, 33, 24, 0.3);
}

.guest-editor form {
  display: grid;
  gap: 12px;
}

.guest-editor p {
  margin: 0;
}

.guest-editor input {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.guest-editor-error {
  color: #99413f;
  font-size: 0.9rem;
}

.guest-editor-identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.guest-editor-status {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 24px;
}

.guest-editor-status select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.guest-editor-status:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.guest-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guest-main span {
  color: var(--muted);
  font-size: 0.86rem;
}

.status-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
}

.status-chip.confirmed {
  color: #256b37;
  background: var(--green-soft);
}

.status-chip.pending {
  color: #8c6410;
  background: var(--yellow-soft);
}

.status-chip.declined {
  color: #99413f;
  background: var(--red-soft);
}

.inspector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wide-field {
  grid-column: 1 / -1;
}

.table-guest-list {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.table-type-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.table-type-actions .danger-button {
  grid-column: 1 / -1;
}

.table-guest-item {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.64);
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 18px;
  border: 1px solid rgba(167, 127, 56, 0.35);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 252, 246, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  body.has-table-editor .studio-layout,
  .studio-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 64px);
  }

  .top-table-editor {
    position: static;
    grid-template-columns: 1fr;
  }

  .top-table-editor .inspector-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .top-table-editor .table-type-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .map-section {
    min-height: 680px;
    height: auto;
  }

  .side-panel {
    height: auto;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    grid-template-columns: minmax(60px, 1fr) auto minmax(60px, 1fr);
    grid-template-rows: auto auto auto;
    gap: 6px;
    align-items: center;
    min-height: 0;
    padding: 7px 10px;
  }

  .topbar > .brand {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    gap: 4px;
  }

  .topbar > .brand strong {
    font-size: 1.2rem;
  }

  .topbar > .brand span {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
  }

  .topbar > .brand span::before {
    margin-inline: 1px 4px;
  }

  .topbar-status {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  .topbar-stats article {
    padding-inline: 5px;
  }

  .topbar-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: min(100%, 420px);
  }

  .topbar-stats span {
    font-size: 0.58rem;
  }

  .topbar-status > #buildBadge {
    font-size: 0.6rem;
  }

  .topbar > .top-nav {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: stretch;
    justify-content: center;
    flex-wrap: wrap;
  }

  .studio-layout {
    padding: 10px;
  }

  .map-section {
    min-height: 640px;
  }

  .hall-canvas {
    width: 960px;
    height: 620px;
  }

  .event-fields,
  .manual-grid,
  .inspector-grid,
  .assign-actions,
  .suggestion-item,
  .top-table-editor .inspector-grid,
  .top-table-editor .table-type-actions,
  .table-type-actions {
    grid-template-columns: 1fr;
  }

  .top-table-editor {
    margin: 10px 10px 0;
  }

  .top-table-editor .wide-field {
    grid-column: 1;
  }

  .suggestion-actions {
    justify-content: stretch;
  }

  .existing-table-assign {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .suggestion-actions button {
    flex: 1;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Guest-focused sidebar and event management panel. */
.map-toolbar {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto auto;
  gap: 12px;
}

.map-toolbar > div:first-child {
  min-width: 0;
}

.map-toolbar h1 {
  font-size: clamp(1.55rem, 2vw, 2.5rem);
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-toolbar .stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0;
}

.map-toolbar .stats-grid article {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 24px;
  gap: 4px;
  padding: 0 5px;
  border: 0;
  border-inline-start: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.map-toolbar .stats-grid strong {
  font-size: 1.12rem;
}

.map-toolbar .stats-grid span {
  font-size: 0.66rem;
  white-space: nowrap;
}

.map-toolbar .map-actions {
  gap: 6px;
}

.map-toolbar .map-actions button {
  min-height: 34px;
  height: 34px;
  padding-inline: 10px;
}

.side-panel {
  overflow: hidden;
}

.side-panel > .quick-actions,
.side-panel > .manual-card {
  flex: 0 0 auto;
}

.side-panel > .guest-list-card {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.guest-list-card > .panel-title {
  flex: 0 0 auto;
}

.side-panel .guest-list {
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.event-management-panel {
  position: fixed;
  inset: 78px auto auto 20px;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 96px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.event-management-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-strong);
}

.event-management-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.event-management-body > section,
.event-management-body > details {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-strong);
}

.event-management-body .assign-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-management-body .assign-actions select {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}

.import-history > summary {
  color: var(--gold-dark);
  font-weight: 800;
  cursor: pointer;
}

.import-history .import-summary {
  margin-top: 12px;
  font-size: 0.85rem;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
  }

  .topbar > .brand {
    grid-column: 1;
    justify-self: start;
  }

  .topbar-status {
    grid-column: 2;
    grid-row: 1;
  }

  .topbar > .top-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    flex-wrap: wrap;
  }

  .side-panel .guest-list {
    max-height: 65vh;
  }
}

@media (max-width: 760px) {
  .map-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .map-toolbar .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .map-toolbar .stats-grid article {
    min-width: 0;
    min-height: 45px;
    padding-inline: 4px;
    flex-direction: column;
  }

  .event-management-panel {
    inset: 16px auto auto 16px;
    max-height: calc(100dvh - 32px);
  }

  .map-tools-menu {
    top: 12px;
    left: 12px;
  }

  .map-canvas-actions {
    top: 12px;
    left: 84px;
    right: 12px;
    gap: 5px;
  }

  .map-canvas-actions button {
    min-height: 36px;
    height: 36px;
    padding-inline: 8px;
    font-size: 0.78rem;
  }
}

/* Fit the workspace to the actual header and table editor height. */
html,
body {
  height: 100%;
  overflow: hidden;
}

.studio-shell {
  display: flex;
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.studio-shell > .topbar {
  flex: 0 0 auto;
}

.workspace-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  flex: 0 0 auto;
  padding: 8px 12px 0;
  direction: rtl;
}

.workspace-control-row > .top-table-editor {
  grid-column: 1;
  grid-row: 1;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  height: 124px;
  margin: 0;
  max-height: 40dvh;
  overflow: auto;
}

body:not(.has-table-editor) .workspace-control-row {
  display: none;
}

.studio-shell > .studio-layout,
body.has-table-editor .studio-layout {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

@media (max-width: 1180px) {
  .workspace-control-row,
  body.has-table-editor .workspace-control-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-control-row > .top-table-editor {
    grid-column: 1;
    grid-row: auto;
  }

  .workspace-control-row > .top-table-editor {
    height: min(260px, 40dvh);
  }

  .studio-shell > .studio-layout,
  body.has-table-editor .studio-layout {
    overflow: auto;
  }
}

/* Compact selected-table controls with an independently scrolling guest list. */
.studio-shell > .top-table-editor {
  height: 124px;
  grid-template-columns: 88px minmax(0, 1fr) minmax(300px, 30%);
  align-items: stretch;
  overflow: hidden;
}

.top-table-editor .table-editor-controls {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: auto 32px;
  align-content: center;
  gap: 6px;
}

.top-table-editor .inspector-grid {
  display: contents;
}

.top-table-editor .inspector-grid label {
  min-width: 0;
  gap: 3px;
  font-size: 0.72rem;
}

.top-table-editor .inspector-grid input,
.top-table-editor .inspector-grid select {
  min-height: 30px;
  height: 30px;
  padding-inline: 7px;
  font-size: 0.8rem;
}

.top-table-editor .table-size-field {
  grid-column: span 2;
  align-self: end;
}

.top-table-editor .table-size-controls button {
  min-height: 30px;
  height: 30px;
  flex-basis: 28px;
}

.top-table-editor .table-type-actions {
  grid-column: 3 / -1;
  grid-row: 2;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.top-table-editor .table-type-actions button {
  min-width: 0;
  min-height: 30px;
  padding-inline: 5px;
  font-size: 0.75rem;
}

.table-guests-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 5px;
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--line);
}

.table-guests-panel h3 {
  margin: 0;
  color: var(--gold-dark);
  font-size: 0.85rem;
}

.top-table-editor .table-guest-list {
  display: grid;
  min-height: 0;
  margin: 0;
  gap: 4px;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.top-table-editor .table-guest-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 5px;
  align-items: center;
  padding: 3px 4px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
}

.table-guest-item strong {
  overflow-wrap: anywhere;
}

.table-guest-remove {
  min-height: 26px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #99413f;
  background: var(--paper-strong);
  font-size: 0.72rem;
  cursor: pointer;
}

.top-table-editor .table-guest-list .empty-state {
  padding: 12px;
  font-size: 0.8rem;
}

@media (max-width: 1180px) {
  .workspace-control-row > .top-table-editor {
    height: min(260px, 40dvh);
    grid-template-columns: minmax(0, 1fr) minmax(250px, 38%);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .top-table-editor > .panel-title {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .table-guests-panel {
    grid-column: 2;
    grid-row: 1 / 3;
  }
}

@media (max-width: 760px) {
  .workspace-control-row > .top-table-editor {
    overflow: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(110px, 1fr);
  }

  .table-guests-panel {
    grid-column: 1;
    grid-row: 3;
    min-height: 110px;
    padding-inline-start: 0;
    border-inline-start: 0;
  }
}

/* Short size control below the fields; more room for table occupants. */
@media (min-width: 1181px) {
  .workspace-control-row > .top-table-editor {
    grid-template-columns: 88px minmax(420px, 560px) minmax(0, 1fr);
    padding-block: 10px;
  }
}

.top-table-editor .table-editor-controls {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: auto 30px;
  gap: 4px 6px;
}

.top-table-editor .table-size-field {
  display: flex;
  grid-column: 1 / 3;
  grid-row: 2;
  align-items: center;
  gap: 6px;
}

.top-table-editor .table-size-field > label {
  max-width: 92px;
  gap: 2px;
  flex-wrap: wrap;
  font-size: 0.62rem;
  line-height: 1.1;
}

.top-table-editor .table-size-controls {
  min-width: 0;
  max-width: 150px;
  flex: 1;
  gap: 4px;
}

.top-table-editor .table-size-controls button {
  flex-basis: 22px;
}

.top-table-editor .table-type-actions {
  grid-column: 3 / -1;
  grid-row: 2;
  grid-template-columns: 1fr;
}

.top-table-editor .table-type-actions button {
  min-height: 28px;
}

.top-table-editor .table-guest-list {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.top-table-editor .table-guest-list .empty-state {
  grid-column: 1 / -1;
}

@media (min-width: 761px) and (max-width: 1180px) {
  .workspace-control-row > .top-table-editor {
    grid-template-columns: minmax(0, 1fr) minmax(250px, 46%);
  }
}

/* Full backup controls belong only to the standalone studio management panel. */
.full-backup-tools > summary {
  color: var(--gold-dark);
  font-weight: 800;
  cursor: pointer;
}

.full-backup-tools p {
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.full-backup-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.full-backup-actions > * {
  min-width: 0;
  text-align: center;
  font-size: 0.85rem;
}

.full-backup-tools #fullBackupStatus:empty {
  display: none;
}

/* Shared-workspace controls are scoped to the standalone studio. */
.studio-cloud-alert[hidden],
.studio-cloud-tools [hidden] { display: none; }
.studio-cloud-alert { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 18px; background: #fff0ce; color: #6e4e13; font-size: 0.85rem; }
.studio-cloud-alert span { flex: 1; }
.studio-cloud-alert button { min-height: 32px; }

#coupleAccessGate:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f7f5ef;
}
#coupleAccessGate form {
  width: min(100%, 460px);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid #d8c9a8;
  border-radius: 18px;
  background: #fffdf8;
  box-shadow: 0 20px 80px rgb(0 0 0 / 20%);
}
#coupleAccessGate input {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #c8b37e;
  border-radius: 10px;
  font: inherit;
  letter-spacing: .12em;
}
#studioCoupleAccessManager ul { display: grid; gap: 8px; padding-inline-start: 20px; }
#studioCoupleAccessManager li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
#studioCoupleCodeResult { overflow-wrap: anywhere; }
.studio-cloud-tools h3 { margin: 0 0 8px; color: var(--gold-dark); font-size: 1rem; }
.studio-cloud-tools p { color: var(--muted); font-size: 0.85rem; }
.studio-cloud-tools input { width: 100%; min-height: 38px; margin: 6px 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
#studioCloudConflict button { width: 100%; margin-top: 8px; }
#buildBadge[data-sync-state="offline"],
#buildBadge[data-sync-state="conflict"],
#buildBadge[data-sync-state="error"] { background: #fff0ce; color: #6e4e13; }
.studio-field-conflict { padding: 10px 0; border-bottom: 1px solid var(--line); }
.studio-field-conflict p { margin: 4px 0; }
.studio-field-conflict button { min-height: 32px; margin: 4px; }

/* Keep the header slim while keeping the live counts easy to scan. */
.topbar { min-height: 48px; padding-block: 4px; }
.topbar-status { gap: 5px; }
.topbar-status > #buildBadge { padding: 1px 7px; font-size: 0.62rem; }
.topbar-stats article {
  display: flex;
  min-height: 30px;
  padding-inline: 7px;
  border-radius: 0;
  background: transparent;
}
.topbar-stats strong { font-size: 1rem; }
.topbar-stats span { font-size: 0.6rem; }

@media (min-width: 761px) {
  .hall-canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
  }
}

/* Match the roomy 80% browser view while the browser itself remains at 100%. */
@media (min-width: 761px) {
  .studio-shell {
    zoom: 0.8;
    width: 125vw;
    height: 125dvh;
  }
}
