body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 14px; height: 58px; flex: none; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 30; }
.topbar .logo { font-size: 1.35rem; }
.project-name { max-width: 260px; border-color: transparent !important; background: transparent !important; font-weight: 600 !important; font-size: 1rem !important; }
.project-name:hover, .project-name:focus { border-color: var(--line) !important; background: var(--surface) !important; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; padding: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn[disabled] { opacity: .35; cursor: default; background: transparent; }
.icon-btn svg, svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg circle { fill: currentColor; stroke: none; }
.stage-bar .icon-btn svg circle { fill: none; stroke: currentColor; }
.btn.pro-on { background: var(--accent-soft); color: var(--accent-dark); }

.menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; z-index: 40; }
.menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: .92rem; background: none; border: 0; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

@media (max-width: 960px) {
  .topbar .btn span, .logo-text { display: none; }
  .topbar .btn { padding: .45em .65em; }
  .project-name { max-width: 150px; }
}
@media (max-width: 520px) {
  .topbar { gap: 6px; padding: 0 8px; }
  #undoBtn, #redoBtn { display: none; }
}

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
.panel { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); min-height: 0; }
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
@media (max-width: 760px) {
  body.app { height: auto; overflow: auto; }
  .layout { flex-direction: column-reverse; }
  .panel { width: 100%; border-right: 0; border-top: 1px solid var(--line); }
  .stage { height: 62vh; flex: none; }
  .guest-list { max-height: none !important; }
}

.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; font: inherit; font-weight: 600; font-size: .92rem; padding: 12px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--ink-3); cursor: pointer; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; color: var(--ink-2); margin-left: 4px; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px; gap: 10px; overflow: hidden; }
.pane[hidden] { display: none; }
#pane-rules:not([hidden]) { overflow-y: auto; display: block; }
.quick-add { display: flex; gap: 6px; }
.quick-add input:first-child { flex: 1.3; }
.quick-add input { flex: 1; min-width: 0; }
.pane-actions { display: flex; gap: 6px; }
.pane-actions .btn { flex: 1; }
.search-row { display: flex; gap: 6px; }
.search-row select { width: 110px; flex: none; }

.guest-list { flex: 1; overflow-y: auto; margin: 0 -14px; padding: 0 8px 12px; }
.list-head { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 12px 8px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.list-drop { min-height: 40px; border-radius: 10px; transition: background .15s; }
.list-drop.hot { background: var(--accent-soft); }
.guest { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: grab; user-select: none; -webkit-user-select: none; }
.guest:hover { background: var(--surface-2); }
.guest.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.guest .dot { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: .72rem; font-weight: 700; background: var(--blush-soft); color: #8a4f43; }
.guest.seated .dot { background: var(--accent-soft); color: var(--accent-dark); }
.guest .who { flex: 1; min-width: 0; line-height: 1.25; }
.guest .who b { display: block; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guest .who span { display: block; font-size: .78rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; flex: none; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.pill.tbl { background: var(--accent-soft); color: var(--accent-dark); }
.pill.warn { background: var(--danger-soft); color: var(--danger); }
.guest .edit { opacity: 0; }
.guest:hover .edit, .guest.selected .edit { opacity: 1; }
@media (hover: none) { .guest .edit { opacity: 1; } }
.list-empty { color: var(--ink-3); font-size: .9rem; text-align: center; padding: 24px 12px; }

.panel-foot { flex: none; border-top: 1px solid var(--line); padding: 10px 14px; font-size: .82rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.panel-foot b { color: var(--ink); }
.limit-bar { width: 100%; display: flex; align-items: center; gap: 8px; }
.limit-bar .track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.limit-bar .fill { height: 100%; background: var(--gold); }
.limit-bar a { font-weight: 600; cursor: pointer; }

.rule-help p { font-size: .88rem; color: var(--ink-2); margin-bottom: 10px; }
#pane-rules h4 { margin: 18px 0 2px; font-size: .95rem; }
.muted { color: var(--ink-3); }
.small { font-size: .84rem; }
.apart-form { display: flex; gap: 6px; margin: 10px 0; }
.apart-form select { min-width: 0; flex: 1; }
.apart-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: .9rem; }
.apart-item span { flex: 1; }
.apart-item.bad { border-color: var(--danger); background: var(--danger-soft); }

/* Stage */
.stage-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.stage-bar .spacer { flex: 1; }
.zoom-label { font: inherit; font-size: .82rem; font-weight: 600; min-width: 54px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; color: var(--ink-2); }
.canvas-wrap { flex: 1; overflow: auto; position: relative; background-color: var(--bg); background-image: radial-gradient(circle, #e2d9cd 1px, transparent 1px); background-size: 24px 24px; }
.canvas-sizer { position: relative; }
.canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; pointer-events: none; }
.empty > * { pointer-events: auto; }
.empty p { color: var(--ink-2); max-width: 420px; margin: 0 auto 20px; }
.empty .cta-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Tables */
.table { position: absolute; touch-action: none; }
.table .body { position: absolute; display: grid; place-content: center; text-align: center; background: var(--surface); border: 2px solid #d9cfc2; box-shadow: 0 2px 10px rgba(43,38,34,.08); cursor: move; padding: 4px; user-select: none; -webkit-user-select: none; }
.table.round .body { border-radius: 50%; }
.table.rect .body { border-radius: 10px; }
.table .body .tname { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; line-height: 1.1; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .body .tcount { font-size: .75rem; color: var(--ink-3); }
.table .body .tedit { position: absolute; top: 50%; right: -6px; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: none; place-items: center; cursor: pointer; padding: 0; color: var(--ink-2); }
.table.round .body .tedit { top: auto; bottom: 6px; right: 50%; transform: translateX(50%); }
.table:hover .tedit, .table.focus .tedit { display: grid; }
@media (hover: none) { .table .tedit { display: grid !important; } }
.table .tedit svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.table.full .body { border-color: var(--accent); }
.table.conflict .body { border-color: var(--danger); background: var(--danger-soft); }
.table.drop-hot .body { box-shadow: 0 0 0 4px rgba(109,138,116,.35); }
.table.moving { z-index: 5; }
.table.moving .body { box-shadow: 0 10px 30px rgba(43,38,34,.2); }

.seat { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 1.5px dashed #c9bdae; background: var(--surface); display: grid; place-items: center; font-size: .68rem; font-weight: 700; color: var(--ink-2); cursor: pointer; user-select: none; -webkit-user-select: none; }
.seat:hover { border-color: var(--accent); }
.seat.taken { border: 0; background: var(--blush); color: #6f3c32; cursor: grab; }
.seat.taken.g1 { background: #d9e4f0; color: #36506b; }
.seat.taken.g2 { background: #e7e0f2; color: #57467a; }
.seat.taken.g3 { background: #f3e5c8; color: #74592a; }
.seat.taken.g4 { background: #d8ebe2; color: #2f5d48; }
.seat.taken.g5 { background: #f0d9e5; color: #7a3b5b; }
.seat.selected { box-shadow: 0 0 0 3px var(--ink); }
.seat.conflict { box-shadow: 0 0 0 2px var(--danger); }
.seat.drop-hot { box-shadow: 0 0 0 3px var(--accent); background: var(--accent-soft); }
.seat-label { position: absolute; font-size: 11px; line-height: 1.15; color: var(--ink); white-space: nowrap; pointer-events: none; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.seat-label.l { text-align: left; }
.seat-label.r { text-align: right; }
.seat-label.c { text-align: center; }

.drag-ghost { position: fixed; z-index: 100; pointer-events: none; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .85rem; font-weight: 600; box-shadow: var(--shadow); transform: translate(-50%, -130%); white-space: nowrap; }
body.dragging, body.dragging * { cursor: grabbing !important; }

.selbar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 6px 6px 18px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); z-index: 10; max-width: calc(100% - 24px); font-size: .9rem; }
.selbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selbar button { font: inherit; font-size: .82rem; font-weight: 600; background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.selbar button:hover { background: rgba(255,255,255,.25); }

/* Modal */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); background: var(--surface); }
.modal::backdrop { background: rgba(43, 38, 34, .45); }
.modal-inner { padding: 24px; }
.modal h2 { font-size: 1.8rem; margin-bottom: .3em; }
.modal .lead { color: var(--ink-2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .left { margin-right: auto; }
.modal .x { position: absolute; top: 12px; right: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; font-weight: 500; color: var(--ink); font-size: .95rem; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.check small { display: block; color: var(--ink-3); font-weight: 400; }
.check.locked { opacity: .75; }
.lock { font-size: .7rem; font-weight: 700; background: var(--gold); color: #fff; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.3em; margin: 6px 0 0; }
.ok-box { background: var(--accent-soft); padding: 14px; border-radius: 10px; }
.upgrade-list { list-style: none; padding: 0; margin: 14px 0; }
.upgrade-list li { padding: 5px 0 5px 26px; position: relative; color: var(--ink-2); }
.upgrade-list li::before { content: ""; position: absolute; left: 3px; top: 11px; width: 12px; height: 7px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: .82rem; margin: 18px 0 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.preview-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: 10px; }
.preview-table th, .preview-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.help-list { padding-left: 1.2em; color: var(--ink-2); }
.help-list li { margin-bottom: 8px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 12px 10px 18px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 200; box-shadow: var(--shadow); font-size: .92rem; max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }
.toast button { font: inherit; font-weight: 600; font-size: .85rem; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; }

/* Print */
.print-root { display: none; }
@media print {
  @page { margin: 0.5in; }
  body.app { height: auto; overflow: visible; display: block; background: #fff; }
  .no-print, .modal, .toast { display: none !important; }
  .print-root { display: block; color: #000; }
  .pr-page { page-break-after: always; break-after: page; }
  .pr-page:last-child { page-break-after: auto; break-after: auto; }
  .seat, .seat.taken, .table .body, .pr-card { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.pr-title { font-family: var(--serif); font-size: 26pt; text-align: center; margin: 0 0 4pt; }
.pr-sub { text-align: center; color: #555; margin: 0 0 16pt; font-size: 10pt; }
.pr-plan { position: relative; margin: 0 auto; overflow: hidden; }
.pr-plan .canvas { position: absolute; }
.pr-plan .tedit { display: none !important; }
.pr-tables { columns: 2; column-gap: 24pt; font-size: 10pt; }
.pr-table { break-inside: avoid; margin-bottom: 14pt; border: 1px solid #ccc; border-radius: 6pt; padding: 8pt 10pt; }
.pr-table h3 { font-size: 14pt; margin: 0 0 4pt; display: flex; justify-content: space-between; align-items: baseline; }
.pr-table h3 small { font-family: var(--sans); font-size: 8pt; color: #666; font-weight: 500; }
.pr-table ol { margin: 0; padding-left: 16pt; }
.pr-table li { margin: 1pt 0; }
.pr-table li em { color: #666; font-style: normal; font-size: 8.5pt; }
.pr-meals { font-size: 8.5pt; color: #444; margin-top: 4pt; border-top: 1px dashed #ccc; padding-top: 4pt; }
.pr-escort { columns: 2; column-gap: 28pt; font-size: 10.5pt; }
.pr-escort div { display: flex; justify-content: space-between; gap: 8pt; border-bottom: 1px dotted #bbb; padding: 3pt 0; break-inside: avoid; }
.pr-escort div b { font-weight: 500; }
.pr-cards { display: grid; grid-template-columns: 3.5in 3.5in; grid-auto-rows: 2.3in; justify-content: center; gap: 0; }
.pr-card { border: 1px dashed #bbb; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 10pt; break-inside: avoid; }
.pr-card .n { font-family: var(--serif); font-size: 24pt; font-weight: 600; line-height: 1.1; }
.pr-card .t { font-size: 9pt; letter-spacing: .2em; text-transform: uppercase; color: #6d8a74; margin-top: 8pt; }
.pr-card .m { font-size: 8pt; color: #888; margin-top: 4pt; }
.pr-watermark { text-align: center; font-size: 9pt; color: #777; margin-top: 14pt; border-top: 1px solid #ddd; padding-top: 6pt; }
.pr-plan .pr-wm-diag { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 40pt; color: rgba(0,0,0,.07); transform: rotate(-20deg); pointer-events: none; white-space: nowrap; }

/* Small-screen fixes */
.topbar .btn, .topbar .logo { flex: none; }
.project-name { flex: 1 1 auto; min-width: 0; width: 0; }
.toast { width: max-content; }
@media (max-width: 420px) {
  .hide-sm { display: none; }
  .topbar .logo svg { width: 24px; height: 24px; }
  .stage-bar { gap: 4px; padding: 8px; }
}
