:root {
  --bg: #efe6d9;
  --bg-2: #f7f1e8;
  --paper: #fbf7f1;
  --ink: #2a2420;
  --muted: #6f6458;
  --line: #e0d4c4;
  --gold: #b08d57;
  --gold-deep: #8a6a39;
  --floor: #f2f0ec;
  --wood: #b08968;
  --wood-deep: #8b6544;
  --linen: #f3e6d4;
  --free: #cbbba4;
  --busy: #9a3f38;
  --found: #c4a35a;
  --danger: #9a3f38;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --radius: 12px;
  --control: 44px;
  --shadow:
    0 1px 1px rgba(42, 36, 32, 0.04),
    0 12px 32px rgba(42, 36, 32, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  background-image:
    radial-gradient(900px 420px at 12% -8%, #f7efe4 0%, transparent 58%),
    radial-gradient(700px 380px at 100% 0%, #e7d7c2 0%, transparent 48%),
    repeating-linear-gradient(
      0deg,
      rgba(42, 36, 32, 0.015) 0 1px,
      transparent 1px 4px
    );
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.skip {
  position: absolute;
  left: 16px;
  top: -48px;
  padding: 8px 12px;
  background: var(--gold);
  color: var(--paper);
  z-index: 20;
  border-radius: var(--radius);
}

.skip:focus {
  top: 16px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.mast {
  display: grid;
  grid-template-columns: auto minmax(200px, 1fr) auto auto;
  gap: 16px 24px;
  align-items: center;
  padding: 20px 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 420px;
}

.search svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search input,
.login-box input,
.field input {
  width: 100%;
  height: var(--control);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--ink);
  font: 500 16px/1.2 var(--sans);
}

.search input {
  padding: 0 40px 0 42px;
}

.search input::placeholder,
.login-box input::placeholder {
  color: #94877a;
}

.search input:focus,
.login-box input:focus,
.field input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-color: var(--gold-deep);
  background: var(--paper);
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: 500 20px/1 var(--sans);
  cursor: pointer;
}

.occupancy {
  min-width: 132px;
}

.occupancy-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.occupancy-num {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
}

.occupancy-unit {
  color: var(--muted);
  font-size: 13px;
}

.meter {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  background: var(--line);
  border-radius: 99px;
}

.meter i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  border-radius: inherit;
  transition: width 320ms var(--ease);
}

.auth {
  justify-self: end;
  position: relative;
}

.ghost,
.primary,
.danger,
.login-open {
  height: var(--control);
  padding: 0 16px;
  border-radius: var(--radius);
  font: 600 14px var(--sans);
  cursor: pointer;
}

.login-open,
.ghost {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.primary {
  border: 0;
  background: var(--gold);
  color: var(--ink);
}

.primary:hover,
.login-open:hover,
.ghost:hover {
  filter: brightness(0.97);
}

.danger {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  background: transparent;
  color: var(--danger);
}

.ghost:disabled,
.primary:disabled,
.danger:disabled {
  opacity: 0.55;
  cursor: wait;
}

.auth-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.who {
  color: var(--muted);
  font-size: 13px;
}

.login-box {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 48px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  z-index: 12;
  animation: rise 220ms var(--ease);
}

.login-box label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.login-box input {
  margin-top: 6px;
  padding: 0 12px;
}

.login-error,
.form-error {
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 13px;
}

.login-actions,
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

main {
  margin-top: 24px;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 11px;
  height: 14px;
  border-radius: 3px 3px 5px 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.swatch-free {
  background: linear-gradient(180deg, var(--wood) 28%, var(--free) 30%);
}

.swatch-busy {
  background: linear-gradient(180deg, #6a3a34 28%, var(--busy) 30%);
}

.swatch-found {
  background: linear-gradient(180deg, var(--gold-deep) 28%, var(--found) 30%);
}

.plan-card {
  margin: 0;
}

.plan-mat {
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.frame {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #f2f0ec;
  box-shadow: inset 0 0 0 3px #2a4068;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.hall {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.zone {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.zone-tag {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: clamp(13px, 1.5vw, 22px);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #fbf7f1;
  text-shadow: 0 1px 10px rgba(20, 12, 8, 0.45);
}

.zone-stage {
  left: 35.63%;
  top: 5.96%;
  width: 29.45%;
  height: 17.04%;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(42, 18, 22, 0.55) 0 22%, transparent 42%),
    repeating-linear-gradient(
      90deg,
      #8a6230 0 10px,
      #a0783c 10px 11px,
      #7a5528 11px 21px
    );
  box-shadow:
    inset 0 0 0 2px rgba(196, 163, 90, 0.55),
    inset 0 14px 18px rgba(20, 8, 10, 0.28),
    0 6px 16px rgba(42, 36, 32, 0.18);
}

.zone-stage::before,
.zone-stage::after {
  content: "";
  position: absolute;
  top: 0;
  width: 22%;
  height: 100%;
  pointer-events: none;
}

.zone-stage::before {
  left: 0;
  background: linear-gradient(90deg, #6b1f2c, transparent 78%);
  opacity: 0.88;
}

.zone-stage::after {
  right: 0;
  background: linear-gradient(270deg, #6b1f2c, transparent 78%);
  opacity: 0.88;
}

.zone-floor {
  left: 36.82%;
  top: 26.53%;
  width: 27.49%;
  height: 66.75%;
  border-radius: 14% / 9%;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(232, 210, 160, 0.22), transparent 42%),
    radial-gradient(ellipse at 50% 100%, rgba(12, 6, 18, 0.42), transparent 58%),
    repeating-linear-gradient(
      90deg,
      rgba(88, 42, 118, 0.28) 0 14px,
      rgba(42, 22, 58, 0.18) 14px 15px
    ),
    linear-gradient(165deg, #6a3a86 0%, #4a2466 48%, #35184c 100%);
  box-shadow:
    inset 0 0 0 2px rgba(212, 180, 131, 0.38),
    inset 0 24px 36px rgba(255, 255, 255, 0.07),
    inset 0 -28px 40px rgba(16, 8, 24, 0.28);
}

.zone-entry {
  left: 89.07%;
  top: 44%;
  width: 4.28%;
  height: 11.5%;
  border-radius: 16px 16px 4px 4px;
  background:
    linear-gradient(180deg, rgba(255, 236, 190, 0.55), transparent 38%),
    linear-gradient(90deg, #c4a35a 0 3px, #1c1410 3px calc(100% - 3px), #c4a35a calc(100% - 3px));
  box-shadow:
    0 0 18px rgba(212, 180, 131, 0.35),
    inset 0 0 0 1px rgba(196, 163, 90, 0.7);
}

.zone-entry .zone-tag {
  font-size: clamp(10px, 0.95vw, 13px);
  letter-spacing: 0.16em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.plan-loading,
.plan-error {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  color: var(--muted);
  font-size: 15px;
  z-index: 6;
}

body.is-loading .plan-loading,
.plan-error:not([hidden]) {
  display: flex;
}

.cluster-floor {
  position: absolute;
  border-radius: 28%;
  background: var(--floor);
  pointer-events: none;
  z-index: 0;
}

.table-hit {
  position: absolute;
  z-index: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  background:
    linear-gradient(145deg, #d7b48a 0%, var(--wood) 18%, #9a704c 100%);
  box-shadow:
    0 4px 10px rgba(42, 36, 32, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease);
}

.table-hit::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.55), transparent 42%),
    repeating-linear-gradient(
      90deg,
      transparent 0 10px,
      rgba(176, 141, 87, 0.07) 10px 11px
    ),
    var(--linen);
  box-shadow:
    inset 0 0 0 1px rgba(176, 141, 87, 0.22),
    inset 0 -8px 16px rgba(139, 101, 68, 0.08);
}

.table-hit:hover,
.table-hit.is-open {
  transform: translateY(-1px);
  box-shadow:
    0 8px 16px rgba(42, 36, 32, 0.16),
    0 0 0 2px color-mix(in srgb, var(--gold) 65%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.table-num {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: 2em;
  height: 1.55em;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--gold) 70%, var(--wood));
  border-radius: 8px;
  background: linear-gradient(180deg, #f3e6d0, #dcc39a);
  box-shadow:
    0 1px 2px rgba(42, 36, 32, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-family: var(--sans);
  font-size: clamp(14px, 1.35vw, 18px);
  font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  line-height: 1;
  letter-spacing: 0;
  color: #5c4631;
}

.seat {
  position: absolute;
  z-index: 3;
  width: 1.35%;
  aspect-ratio: 0.74;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  cursor: pointer;
  transition: transform 160ms var(--ease), filter 160ms var(--ease);
}

.seat::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 58%;
  width: 118%;
  height: 86%;
  transform: translate(-50%, -50%);
  background: var(--floor);
  border-radius: 50%;
}

.seat::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.chair {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 1px rgba(42, 36, 32, 0.22));
}

.chair-back,
.chair-pad {
  position: absolute;
  left: 0;
  right: 0;
}

.chair-back {
  top: 0;
  height: 30%;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #e2d0b6, var(--wood) 55%, var(--wood-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.chair-pad {
  top: 22%;
  bottom: 6%;
  left: 7%;
  right: 7%;
  border-radius: 38% 38% 44% 44%;
  background:
    radial-gradient(circle at 32% 28%, #ebe1d2, var(--free) 62%, #a8967c 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.seat.is-busy .chair-back {
  background: linear-gradient(180deg, #7a4540, #4e2723);
}

.seat.is-busy .chair-pad {
  background:
    radial-gradient(circle at 32% 28%, #c56b62, var(--busy) 62%, #6a2a26 100%);
}

.seat.is-found::before {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--found) 85%, transparent);
}

.seat.is-found .chair {
  filter: drop-shadow(0 1px 1px rgba(42, 36, 32, 0.22));
}

.seat.is-open .chair-pad {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 0 0 2px var(--ink);
}

.seat:hover {
  z-index: 5;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.1);
}

.seat:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 3px;
}

.frame.is-filtering .seat:not(.is-found) {
  opacity: 0.32;
}

.frame.is-filtering .table-hit:not(.has-found),
.frame.is-filtering .table-num:not(.has-found) {
  opacity: 0.45;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  background: rgba(42, 36, 32, 0.28);
}

.sheet:not([hidden]) {
  display: flex;
}

.sheet-card {
  width: min(380px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  padding: 24px 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: rise 280ms var(--ease);
}

.sheet-close {
  float: right;
  width: 36px;
  height: 36px;
  margin: -8px -8px 0 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
}

.sheet-card h2 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.guest-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.guest-list li + li {
  border-top: 1px solid var(--line);
}

.guest-list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: 500 15px var(--sans);
  text-align: left;
  cursor: pointer;
}

.guest-list .empty {
  padding: 8px 0 0;
  color: var(--muted);
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--gold) 18%, var(--bg-2));
  color: var(--gold-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: block;
  margin: 8px 0 16px;
  font-size: 13px;
  font-weight: 600;
}

.field input {
  margin-top: 8px;
  padding: 0 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 15;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow);
  animation: rise 220ms var(--ease);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 860px) {
  .page {
    width: calc(100% - 24px);
    padding-top: 16px;
  }

  .mast {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand auth"
      "search search"
      "stats stats";
    padding: 16px;
  }

  .brand { grid-area: brand; }
  .search { grid-area: search; max-width: none; }
  .occupancy { grid-area: stats; }
  .auth { grid-area: auth; }

  .brand h1 { font-size: 32px; }

  .sheet {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .sheet-card {
    width: 100%;
    border-radius: 12px 12px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
