:root {
  --paper: #f7f3ea;
  --ink: #221f1b;
  --muted: #756f64;
  --line: #d7cbb9;
  --lacquer: #9d1f1f;
  --jade: #0d7c66;
  --gold: #c9962f;
  --guest: #315d91;
  --host-card: #e3f2ec;
  --guest-card: #e5edf7;
  --shadow: 0 20px 55px rgba(49, 35, 18, 0.16);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(90deg, rgba(157, 31, 31, 0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(157, 31, 31, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

button,
textarea,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 100vh;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  color: var(--lacquer);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-family: "STSong", "SimSun", serif;
  font-size: clamp(30px, 4vw, 58px);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0;
}

h2 {
  font-size: 16px;
  margin-bottom: 0;
}

.actions,
.section-title {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-action,
.ghost-button,
.icon-button {
  border-radius: 8px;
  min-height: 42px;
}

.primary-action {
  background: var(--lacquer);
  box-shadow: 0 10px 22px rgba(157, 31, 31, 0.22);
  color: #fffaf0;
  font-weight: 800;
  padding: 0 18px;
}

.ghost-button {
  background: #fffaf0;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  padding: 0 14px;
}

.download-action {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  white-space: nowrap;
}

.download-action span {
  color: var(--lacquer);
  font-size: 19px;
  line-height: 1;
}

.icon-button {
  align-items: center;
  background: #fffaf0;
  border: 1px solid var(--line);
  color: var(--lacquer);
  display: inline-flex;
  font-size: 22px;
  justify-content: center;
  width: 42px;
}

.wide {
  width: 100%;
}

.table-stage {
  flex: 1;
  margin-top: 28px;
  min-height: 620px;
  position: relative;
}

.round-table {
  aspect-ratio: 1;
  background:
    radial-gradient(circle, rgba(255, 250, 240, 0.96) 0 42%, transparent 43%),
    repeating-radial-gradient(circle, rgba(201, 150, 47, 0.2) 0 2px, transparent 2px 16px),
    linear-gradient(135deg, #d23b2e, #7e1717 60%, #551010);
  border: 14px solid #fff8e8;
  border-radius: 50%;
  box-shadow: var(--shadow), inset 0 0 0 7px rgba(201, 150, 47, 0.55);
  left: 50%;
  max-width: 650px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(74vw, 64vh, 650px);
}

.table-stage.long-mode .round-table {
  aspect-ratio: auto;
  background: #8f1c1c;
  border-radius: 24px;
  height: min(30vh, 250px);
  max-width: none;
  width: min(70vw, 760px);
}

.table-stage.long-mode .table-center {
  display: none;
}

.table-center {
  align-items: center;
  background: rgba(255, 250, 240, 0.9);
  border: 1px solid rgba(201, 150, 47, 0.55);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 32%;
  justify-content: center;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 32%;
}

.table-center strong {
  font-family: "STSong", "SimSun", serif;
  font-size: 30px;
}

.table-center span {
  color: var(--muted);
  font-size: 13px;
}

.direction {
  background: rgba(255, 250, 240, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 8px 13px;
  position: absolute;
  z-index: 4;
}

.north {
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
}

.east {
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
}

.legend {
  bottom: 0;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  left: 0;
  position: absolute;
}

.legend span {
  align-items: center;
  display: inline-flex;
  font-size: 13px;
  gap: 7px;
}

.dot {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.host-dot {
  background: var(--jade);
}

.guest-dot {
  background: var(--guest);
}

.couple-dot {
  background: var(--gold);
}

.seat-card {
  align-items: center;
  background: var(--host-card);
  border: 2px solid var(--jade);
  border-radius: 8px;
  box-shadow: 0 12px 26px rgba(34, 31, 27, 0.16);
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  min-height: 58px;
  padding: 7px 10px;
  position: absolute;
  text-align: center;
  touch-action: none;
  transform: translate(-50%, -50%);
  transition: box-shadow 160ms ease, border-color 160ms ease;
  user-select: none;
  width: 124px;
  z-index: 8;
}

.seat-card.guest {
  background: var(--guest-card);
  border-color: var(--guest);
}

.seat-card.host .seat-meta {
  color: #08614f;
}

.seat-card.guest .seat-meta {
  color: #294f7b;
}

.seat-card.couple {
  box-shadow: 0 0 0 4px rgba(201, 150, 47, 0.22), 0 12px 26px rgba(34, 31, 27, 0.16);
}

.seat-card.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 40px rgba(34, 31, 27, 0.28);
  z-index: 20;
}

.table-stage.long-mode .seat-card {
  min-height: 118px;
  padding: 7px 6px;
  width: 46px;
}

.table-stage.long-mode .seat-name,
.table-stage.long-mode .seat-meta,
.table-stage.long-mode .seat-tag {
  writing-mode: vertical-rl;
}

.table-stage.long-mode .seat-name {
  max-height: 72px;
}

.table-stage.long-mode .seat-tags {
  align-items: center;
  flex-direction: column;
  max-height: 104px;
}

.seat-name {
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.seat-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.seat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  margin-top: 3px;
  max-width: 100%;
}

.seat-tag {
  border: 1px solid transparent;
  border-radius: 4px;
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 2px 4px;
}

.seat-tag.diet {
  background: #f6e7c3;
  border-color: #d2aa52;
  color: #6a4908;
}

.seat-tag.language {
  background: #dfeaf6;
  border-color: #7ea2c8;
  color: #234f79;
}

.seat-tag.note {
  background: #ece9e2;
  border-color: #bbb4a8;
  color: #504a42;
}

.control-panel {
  background: rgba(255, 250, 240, 0.92);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(49, 35, 18, 0.08);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.panel-section {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  padding-bottom: 18px;
}

.panel-section.compact {
  border-bottom: 0;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea,
input,
select {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 40px;
  min-width: 0;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 150, 47, 0.18);
}

.field-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.rule-input {
  min-height: 72px;
}

.check-row {
  align-items: center;
  display: flex;
  gap: 9px;
}

.check-row input {
  accent-color: var(--lacquer);
  min-height: 18px;
  width: 18px;
}

.check-row span {
  color: var(--ink);
}

.result-section {
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.status-badge {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}

.status-badge.error {
  background: #f8dddd;
  color: #8a1818;
}

.status-badge.warning {
  background: #f6e9c9;
  color: #72500d;
}

.status-badge.clear {
  background: #dcefe9;
  color: #08604f;
}

.review-list {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 7px;
  line-height: 1.55;
  margin: 0;
  padding-left: 19px;
}

.couple-list {
  display: grid;
  gap: 9px;
}

.couple-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr 34px;
}

.couple-input {
  min-width: 0;
  padding: 8px 9px;
}

.remove-couple {
  background: #f4ead9;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--lacquer);
  font-size: 18px;
  font-weight: 900;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .table-stage {
    min-height: 540px;
  }
}

@media (max-width: 480px) {
  .workspace,
  .control-panel {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    flex-wrap: wrap;
  }

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

  .seat-card {
    min-height: 48px;
    padding: 5px 6px;
    width: 82px;
  }

  .seat-name {
    font-size: 12px;
  }

  .seat-meta {
    font-size: 9px;
  }

  .seat-tag {
    font-size: 8px;
    padding: 1px 3px;
  }

  .direction {
    font-size: 10px;
    padding: 6px 8px;
  }

  .table-stage.long-mode .round-table {
    height: calc(100% - 170px);
    max-height: none;
    width: 42%;
  }

  .table-stage.long-mode .table-center {
    height: 24%;
    width: 68%;
  }

  .table-stage.long-mode .table-center strong {
    font-size: 16px;
  }

  .table-stage.long-mode .seat-card {
    min-height: 48px;
    padding: 5px 6px;
    width: 82px;
  }

  .table-stage.long-mode .seat-name,
  .table-stage.long-mode .seat-meta,
  .table-stage.long-mode .seat-tag {
    writing-mode: horizontal-tb;
  }

  .table-stage.long-mode .seat-tags {
    flex-direction: row;
    max-height: none;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body {
    background: #fff;
  }

  .control-panel,
  .actions,
  .legend {
    display: none !important;
  }

  .app-shell,
  .workspace {
    display: block;
    min-height: auto;
    padding: 0;
  }

  .topbar {
    justify-content: center;
    margin: 0 0 5mm;
    text-align: center;
  }

  h1 {
    font-size: 20pt;
  }

  .table-stage {
    height: 175mm;
    margin: 0 auto;
    min-height: 0;
    overflow: visible;
    width: 260mm;
  }

  .round-table {
    border-width: 4mm;
    width: 120mm;
  }

  .table-stage.long-mode .round-table {
    height: 48mm;
    width: 190mm;
  }

  .seat-card {
    border-width: 0.6mm;
    box-shadow: none;
    min-height: 15mm;
    padding: 1.8mm 2.4mm;
    print-color-adjust: exact;
    width: 32mm;
    -webkit-print-color-adjust: exact;
  }

  .seat-name {
    font-size: 10pt;
  }

  .seat-meta {
    font-size: 7pt;
  }

  .seat-tag {
    font-size: 6.5pt;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .table-stage.long-mode .seat-card {
    min-height: 28mm;
    width: 11mm;
  }

  .table-stage.long-mode .seat-name {
    font-size: 9pt;
    max-height: 20mm;
  }

  .table-stage.long-mode .seat-name,
  .table-stage.long-mode .seat-meta,
  .table-stage.long-mode .seat-tag {
    writing-mode: vertical-rl;
  }
}
