:root {
  --editor-ink: #3f2b20;
  --editor-ink-soft: #7c6758;
  --editor-paper: #f6f0e6;
  --editor-paper-deep: #eadfce;
  --editor-copper: #a9572d;
  --editor-occupied: #dc8a45;
  --editor-available: #a9d6a4;
  --editor-selected: #f3cf4c;
  --editor-shadow: 0 16px 48px rgba(37, 25, 18, .2);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
button, input { font: inherit; }

.seating-editor-body {
  overflow: hidden;
  background: #2b3c32;
  color: var(--editor-ink);
}

.seating-editor-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100svh;
}

.seating-editor-header {
  position: relative;
  z-index: 60;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  min-height: 5.1rem;
  padding: max(.75rem, env(safe-area-inset-top)) 1rem .75rem;
  border-bottom: 1px solid rgba(63,43,32,.16);
  background: rgba(246,240,230,.97);
  box-shadow: 0 7px 28px rgba(37,25,18,.13);
}

.seating-editor-header h1 { margin: 0; font-size: clamp(1.1rem, 2.4vw, 1.75rem); }
.editor-eyebrow, .panel-kicker, .summary-kicker, .dialog-kicker {
  margin: 0 0 .18rem;
  color: var(--editor-copper);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.editor-back {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 999px;
  background: var(--editor-ink);
  color: #fff;
  font-size: 1.35rem;
  text-decoration: none;
}
.editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; }
.save-status { max-width: 18rem; color: var(--editor-ink-soft); font-size: .76rem; text-align: right; }
.editor-save {
  min-height: 2.75rem;
  padding: .55rem .9rem;
  border: 1px solid var(--editor-ink);
  border-radius: .65rem;
  background: var(--editor-ink);
  color: #fff;
  font-weight: 800;
}
.editor-save:disabled { opacity: .45; }

.editor-workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 22rem);
  min-height: 0;
}

.editor-canvas {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background: #263a30;
  cursor: grab;
  touch-action: none;
}
.editor-canvas.is-panning { cursor: grabbing; }

.editor-frame {
  position: relative;
  width: min(100%, calc((100svh - 5.1rem) * 4 / 3));
  aspect-ratio: 4 / 3;
  transform-origin: 0 0;
}
.editor-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}
.editor-world { position: absolute; }
.editor-object {
  position: absolute;
  transform-origin: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.editor-stage-object {
  background: linear-gradient(135deg, #9c6034, #d49b5d);
  border: 1px solid rgba(54,31,18,.6);
  box-shadow: 0 3px 10px rgba(30,22,16,.25);
}
.editor-bar-object { background: #9b6338; box-shadow: 0 3px 8px rgba(30,22,16,.22); }
.editor-lounge-object {
  border: 2px solid rgba(255,255,255,.86);
  border-radius: 7px;
  background: rgba(201,177,151,.43);
}

.editor-table {
  z-index: 5;
  width: 2.5%;
  height: 13.333%;
  min-width: 5px;
  border: 1px solid rgba(74,49,31,.75);
  border-radius: 3px;
  background: linear-gradient(90deg, #f8f1e6, #fff 50%, #eee2d2);
  box-shadow: 0 2px 6px rgba(25,35,26,.36);
  cursor: pointer;
  transition: filter 180ms ease, box-shadow 180ms ease;
}
.editor-table::after {
  content: "";
  position: absolute;
  inset: -8% -85%;
  border-radius: 7px;
  pointer-events: none;
}
.editor-table.is-drop-target,
.editor-world:not(.is-dragging-guest) .editor-table:hover {
  z-index: 16;
  filter: brightness(1.12);
  box-shadow: 0 0 0 3px rgba(169,87,45,.8), 0 0 20px rgba(169,87,45,.46);
}
.editor-table.is-focused {
  z-index: 17;
  box-shadow: 0 0 0 4px rgba(246,240,230,.94), 0 0 26px 9px rgba(169,87,45,.58);
}

.editor-table-number {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 95%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--table-rotation)));
  border-radius: 999px;
  background: #74503a;
  color: #fff;
  font-size: clamp(.42rem, .7vw, .68rem);
  font-weight: 850;
}

.table-fill {
  display: none;
  position: absolute;
  left: 50%;
  top: -15%;
  z-index: 5;
  min-width: 2.55rem;
  padding: .18rem .34rem;
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--table-rotation)));
  border: 1px solid rgba(255,255,255,.78);
  border-radius: 999px;
  background: rgba(63,43,32,.9);
  color: #fff;
  font-size: clamp(.46rem, .62vw, .64rem);
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
}
.table-fill.is-full { background: #7c3e2d; }

.editor-chair {
  position: absolute;
  z-index: 6;
  width: 48%;
  height: 10%;
  border: 1px solid rgba(67,43,25,.7);
  border-radius: 2px 2px 35% 35%;
  background: #b9854d;
  cursor: pointer;
}
.editor-chair::before {
  content: "";
  position: absolute;
  inset: -65%;
}
.editor-chair.left { left: -58%; }
.editor-chair.right { right: -58%; }
.editor-chair.is-drop-target { box-shadow: none; }
.seat-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: .42rem;
  height: .42rem;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(63,43,32,.72);
  border-radius: 999px;
  background: #74503a;
  box-shadow: 0 0 0 1px rgba(255,255,255,.75);
  opacity: .72;
}
.editor-world.has-active-guest .editor-chair .seat-dot { background: var(--editor-available); }
.editor-world.has-active-guest .editor-chair.is-occupied .seat-dot { background: var(--editor-occupied); }
.editor-world.has-active-guest .editor-chair.is-selected-guest-seat .seat-dot { background: #74503a; }
.editor-chair.is-drop-target {
  z-index: 40;
}
.editor-chair.is-drop-target .seat-dot,
.editor-world.has-active-guest .editor-chair.is-drop-target .seat-dot {
  z-index: 8;
  background: var(--editor-selected);
  border-color: #65451b;
  box-shadow: 0 0 0 2px #fff, 0 0 12px 5px rgba(244,200,77,.82);
  opacity: 1;
}
.seat-letter {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 9;
  display: grid;
  place-items: center;
  width: .31rem;
  height: .31rem;
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--table-rotation)));
  border-radius: 999px;
  background: #503528;
  color: #fff;
  font-size: clamp(.27rem, .36vw, .44rem);
  font-weight: 900;
  text-shadow: 0 1px 2px #3f2b20;
  opacity: 1;
}
.editor-world.has-active-guest .editor-chair .seat-letter { background: #79ae78; }
.editor-world.has-active-guest .editor-chair.is-occupied .seat-letter { background: var(--editor-occupied); }
.editor-world.has-active-guest .editor-chair.is-selected-guest-seat .seat-letter { background: #503528; }
.editor-world.has-active-guest .editor-chair.is-drop-target .seat-letter {
  background: var(--editor-selected);
  color: #4b351a;
  text-shadow: none;
}
.editor-table.is-focused .seat-letter { width: .39rem; height: .39rem; }
.editor-table.is-focused .seat-dot { width: .52rem; height: .52rem; opacity: 1; }

.canvas-help {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  z-index: 30;
  margin: 0;
  padding: .45rem .7rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(63,43,32,.84);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}
.canvas-help::selection { background: transparent; color: inherit; }

.guest-panel {
  position: relative;
  z-index: 45;
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid rgba(63,43,32,.16);
  background: var(--editor-paper);
  box-shadow: -10px 0 30px rgba(37,25,18,.12);
}
.guest-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: 1rem 1rem .65rem;
}
.guest-panel-header h2 { margin: 0; font-size: 1.25rem; }
.show-all-control {
  display: flex;
  align-items: center;
  gap: .42rem;
  color: var(--editor-ink);
  font-size: .8rem;
  font-weight: 750;
}
.show-all-control input { width: 1.05rem; height: 1.05rem; accent-color: var(--editor-copper); }
.guest-counts {
  display: flex;
  gap: .55rem;
  padding: 0 1rem .75rem;
  color: var(--editor-ink-soft);
  font-size: .75rem;
}
.guest-counts span {
  padding: .28rem .45rem;
  border-radius: 999px;
  background: var(--editor-paper-deep);
}
.guest-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 .7rem max(1rem, env(safe-area-inset-bottom));
}
.guest-row {
  position: relative;
  display: grid;
  grid-template-columns: .22rem minmax(0,1fr) auto;
  gap: .65rem;
  align-items: center;
  width: 100%;
  min-height: 3.4rem;
  margin: 0 0 .45rem;
  padding: .58rem .68rem .58rem .45rem;
  border: 1px solid rgba(63,43,32,.12);
  border-radius: .7rem;
  background: #fffaf2;
  color: var(--editor-ink);
  box-shadow: 0 5px 14px rgba(63,43,32,.07);
  text-align: left;
  cursor: grab;
}
.guest-row:active { cursor: grabbing; }
.guest-row::before {
  content: "";
  align-self: stretch;
  width: .22rem;
  border-radius: 999px;
  background: var(--editor-available);
}
.guest-row.is-seated::before { background: var(--editor-occupied); }
.guest-row.is-selected .guest-name { color: var(--editor-copper); }
.guest-name { min-width: 0; font-size: .86rem; font-weight: 780; }
.guest-name small {
  display: block;
  overflow: hidden;
  margin-top: .12rem;
  color: var(--editor-ink-soft);
  font-size: .68rem;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guest-seat {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--editor-copper);
  font-size: .7rem;
  font-weight: 850;
  white-space: nowrap;
}
.guest-chair-badge {
  display: grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .22rem;
  border-radius: .35rem;
  background: #503528;
  color: #fff;
  font-weight: 900;
}
.guest-list-empty {
  margin: 2rem .8rem;
  color: var(--editor-ink-soft);
  font-size: .85rem;
  line-height: 1.5;
  text-align: center;
}

.table-summary {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 50;
  width: min(18rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,.76);
  border-radius: 1rem;
  background: rgba(246,240,230,.96);
  box-shadow: var(--editor-shadow);
}
.table-summary h2 { margin: 0; font-size: 1.5rem; }
.summary-close {
  position: absolute;
  right: .65rem;
  top: .65rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: var(--editor-paper-deep);
  color: var(--editor-ink);
  font-size: 1.2rem;
}
.summary-numbers { margin: .3rem 0 .8rem; color: var(--editor-copper); font-weight: 850; }
.summary-guests { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.summary-guests li {
  display: flex;
  justify-content: space-between;
  gap: .7rem;
  padding: .42rem 0;
  border-top: 1px solid rgba(63,43,32,.12);
  font-size: .77rem;
}
.summary-guests b { color: var(--editor-copper); }
.summary-help { margin: .8rem 0 0; color: var(--editor-ink-soft); font-size: .7rem; }

.seat-conflict {
  width: min(30rem, calc(100vw - 2rem));
  padding: 1.2rem;
  border: 1px solid rgba(63,43,32,.2);
  border-radius: 1rem;
  background: var(--editor-paper);
  color: var(--editor-ink);
  box-shadow: var(--editor-shadow);
}
.seat-conflict::backdrop { background: rgba(27,20,16,.6); backdrop-filter: blur(3px); }
.seat-conflict h2 { margin: 0; }
.seat-conflict p:not(.dialog-kicker) { color: var(--editor-ink-soft); line-height: 1.45; }
.conflict-actions { display: grid; gap: .55rem; margin-top: 1rem; }
.conflict-actions button {
  min-height: 2.8rem;
  padding: .55rem .7rem;
  border-radius: .65rem;
  font-weight: 780;
}
.dialog-secondary { border: 1px solid rgba(63,43,32,.25); background: #fff; color: var(--editor-ink); }
.dialog-warning { border: 1px solid #995f3f; background: #fff1e8; color: #713b25; }
.dialog-primary { border: 1px solid var(--editor-ink); background: var(--editor-ink); color: #fff; }

@media (max-width: 900px) {
  .seating-editor-header { grid-template-columns: auto 1fr; }
  .editor-actions { grid-column: 1 / -1; justify-content: space-between; }
  .save-status { max-width: none; text-align: left; }
  .editor-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(48svh, 1fr) minmax(15rem, 37svh); }
  .guest-panel { border-top: 1px solid rgba(63,43,32,.16); border-left: 0; }
  .editor-frame { width: min(100%, calc(48svh * 4 / 3)); }
  .table-summary { top: .55rem; left: .55rem; max-height: calc(100% - 1.1rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
