/* ==========================================================================
   Seating plan (loaded only on /seating-plan/)
   ========================================================================== */
.seat-stage { min-height: 0; }
.seat-stage .stage-bar { flex-wrap: wrap; }
.seat-mode { width: auto; }
.seat-mode button { white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; }
.step-no { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 0.7rem; background: var(--surface-3); color: var(--muted); }
.seat-mode button[aria-pressed='true'] .step-no { background: var(--accent); color: var(--on-accent); }
.seat-tools-end { display: flex; align-items: center; gap: 10px; }
.seat-stage .stage-bar .status { margin-left: 4px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seat-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--surface); }
.seat-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.seat-tools-end { margin-left: auto; }
.tools-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 2px; }
.tools-sep { width: 1px; height: 26px; background: var(--border); margin: 0 4px; }
.palette-item {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 10px 0 8px;
  font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; cursor: grab; touch-action: none; user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.palette-item:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.palette-item:active { cursor: grabbing; }
.pv { display: inline-block; background: var(--table-bg); border: 1.5px solid var(--table-border); }
.pv-rect { width: 22px; height: 11px; border-radius: 2px; }
.pv-long { width: 30px; height: 9px; border-radius: 2px; }
.pv-square { width: 16px; height: 16px; border-radius: 3px; }
.pv-round { width: 18px; height: 18px; border-radius: 50%; }
.pv-desk { width: 24px; height: 12px; border-radius: 2px; background: var(--desk-bg); border-color: var(--desk-border); }
.pv-seat-c { width: 15px; height: 15px; border-radius: 50%; background: var(--seat-bg); border-color: var(--seat-border); }
.pv-seat-b { width: 19px; height: 13px; border-radius: 3px; background: var(--seat-bg); border-color: var(--seat-border); }

.seat-selbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--accent-soft); }
.selbar-what { font-size: 0.85rem; font-weight: 650; color: var(--accent-text); margin-right: 4px; }
.selbar-label { width: 180px; height: 34px; padding: 0 10px; font-size: 0.85rem; }
.seat-danger:hover { color: var(--red); }

.seat-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px; gap: 10px; min-height: 0; }
.seat-title { display: none; margin: 0; font-size: 1.4rem; }

/* The room: fixed 1000 x 680 coordinate space, scaled to fit. */
.seat-stage {
  --table-bg: #e3d6c3; --table-border: #c4b092; --table-text: #6b5638;
  --desk-bg: #d5dbe6; --desk-border: #aab4c6;
  --seat-bg: var(--surface); --seat-border: var(--border-strong);
  --room-bg: var(--surface-2);
}
[data-theme='dark'] .seat-stage {
  --table-bg: #3a3226; --table-border: #5a4c38; --table-text: #d8c4a4;
  --desk-bg: #2a3346; --desk-border: #3f4b63;
  --seat-bg: var(--surface); --seat-border: #3c475c;
  --room-bg: #0d1119;
}
.room {
  position: relative; width: min(100%, calc((100vh - 260px) * 1000 / 680)); min-width: 280px; aspect-ratio: 1000 / 680;
  background: var(--room-bg); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  container-type: inline-size; touch-action: none; user-select: none; -webkit-user-select: none;
}
.mode-layout .room {
  background-image: radial-gradient(circle, color-mix(in srgb, var(--muted) 35%, transparent) 1px, transparent 1.4px);
  background-size: 2cqw 2cqw;
}
.room-items { position: absolute; inset: 0; }
.room-board {
  position: absolute; left: 30%; width: 40%; top: 0; height: 3.4cqw; border-radius: 0 0 1cqw 1cqw;
  background: var(--text-2); color: var(--surface); display: grid; place-items: center;
  font-size: 1.3cqw; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; pointer-events: none;
}
.flipped .room-board { top: auto; bottom: 0; border-radius: 1cqw 1cqw 0 0; }

.it { position: absolute; display: grid; place-items: center; touch-action: none; }
.mode-layout .it { cursor: grab; }
.mode-layout .it.dragging { cursor: grabbing; z-index: 5; }
.it-table { background: var(--table-bg); border: 0.2cqw solid var(--table-border); border-radius: 0.6cqw; color: var(--table-text); }
.it-table.shape-round { border-radius: 50%; }
.it-table.shape-desk { background: var(--desk-bg); border-color: var(--desk-border); color: var(--text-2); }
.it-label { font-size: 1.25cqw; font-weight: 650; line-height: 1.1; text-align: center; padding: 0 0.4cqw; pointer-events: none; overflow: hidden; max-width: 100%; }

.it-seat {
  z-index: 2; background: var(--seat-bg); border: 0.18cqw solid var(--seat-border); border-radius: 0.8cqw;
  container-type: size; box-shadow: 0 0.1cqw 0.3cqw rgba(14, 21, 37, 0.08);
}
.it-seat.shape-circle { border-radius: 50%; }
.it-seat.filled { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, var(--seat-border)); }
.mode-pupils .it-seat { cursor: pointer; }
.mode-pupils .it-seat.empty { border-style: dashed; }
.mode-pupils .it-table { opacity: 0.85; }
.seat-name {
  font-weight: 700; color: var(--accent-text); text-align: center; line-height: 1.05; letter-spacing: -0.02em;
  font-size: var(--fs, 20cqh); overflow: hidden; overflow-wrap: normal; word-break: normal; pointer-events: none; max-height: 100%;
}
.it.selected { outline: 0.3cqw solid var(--accent); outline-offset: 0.3cqw; z-index: 4; }
.it-seat.picked { outline: 0.35cqw solid var(--amber); outline-offset: 0.25cqw; z-index: 4; }
.it-seat.drop-target { border-color: var(--accent); border-style: solid; background: color-mix(in srgb, var(--accent) 22%, var(--seat-bg)); transform: scale(1.08); }
.it-seat { transition: transform 0.12s var(--ease), background 0.15s; }
.it-seat.dragging { transition: none; }
.handle {
  position: absolute; right: -1cqw; bottom: -1cqw; width: 2cqw; height: 2cqw; min-width: 14px; min-height: 14px;
  background: var(--surface); border: 2px solid var(--accent); border-radius: 50%; cursor: nwse-resize; z-index: 6; touch-action: none;
}
.room-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 1.5cqw; pointer-events: none; padding: 0 20%; }
.room-empty strong { display: block; color: var(--text); font-size: 2cqw; margin-bottom: 0.5cqw; }

/* Pupils not yet seated */
.seat-tray { border-top: 1px solid var(--border); padding: 12px 14px 14px; background: var(--surface); }
.tray-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 0.88rem; margin-bottom: 8px; }
.tray-head .num { color: var(--muted); font-weight: 600; }
.tray-head .hint { margin-left: auto; }
.tray-names { display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; padding: 4px; border-radius: 10px; transition: background 0.15s; }
.tray-names.drop-target { background: var(--accent-soft); outline: 2px dashed var(--accent); }
.tray-done { color: var(--muted); font-size: 0.88rem; padding: 6px 4px; }
.name-chip {
  font: inherit; font-size: 0.88rem; font-weight: 600; padding: 6px 12px; border-radius: 99px; cursor: grab; touch-action: none; user-select: none;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
}
.name-chip:hover { border-color: var(--accent); }
.name-chip.picked { background: var(--amber); border-color: var(--amber); color: #1b1300; }
.name-chip.dragging { opacity: 0.35; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; transform: translate(-50%, -50%);
  font-size: 0.95rem; font-weight: 700; padding: 8px 14px; border-radius: 99px; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-lg);
}
.drag-ghost.furniture { padding: 0; border-radius: 6px; background: var(--table-bg); border: 2px solid var(--table-border); opacity: 0.85; }
.drag-ghost.furniture.seat { background: var(--seat-bg); border-color: var(--accent); }
.drag-ghost.furniture.round, .drag-ghost.furniture.circle { border-radius: 50%; }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* Present mode: the room fills the screen */
body.presenting .seat-body { padding: 64px 3vw 3vh; }
body.presenting .seat-title { display: block; font-size: clamp(1.2rem, 2.4vw, 2.4rem); }
body.presenting .room { width: min(94vw, calc((100vh - 150px) * 1000 / 680)); border: 0; background-image: none; }
body.presenting .it-seat.empty { border-style: solid; opacity: 0.55; }
body.presenting .handle { display: none; }
body.presenting .it.selected, body.presenting .it-seat.picked { outline: 0; }
body.presenting .seat-stage .stage-bar .status { display: none; }
body.presenting .seat-stage .stage-bar { justify-content: flex-end; }

@media (max-width: 640px) {
  .tray-head .hint { margin-left: 0; width: 100%; }
  .seat-body { padding: 10px; }
  .room { width: 100%; }
}

/* Print: a clean landscape copy */
@page { size: landscape; margin: 10mm; }
@media print {
  body { background: #fff; display: block; min-height: 0; }
  .tool-head, .seat-toolbar, .seat-selbar, .seat-tray, .brand-mark, .ad-slot { display: none !important; }
  .tool-layout { display: block; }
  .wrap { max-width: none; padding: 0; }
  .seat-stage { border: 0; box-shadow: none; background: #fff; --room-bg: #fff; --seat-bg: #fff; --seat-border: #333; --table-bg: #eee; --table-border: #777; --table-text: #333; --desk-bg: #ddd; --desk-border: #777; }
  .seat-body { padding: 0; }
  .seat-title { display: block; color: #000; }
  .room { width: 100%; background: #fff !important; border: 1px solid #999; box-shadow: none; }
  .room-board { background: #333; color: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .it-seat, .it-seat.filled { background: #fff !important; border-color: #333 !important; box-shadow: none; }
  .seat-name { color: #000; }
  .it.selected, .it-seat.picked { outline: 0; }
  .handle { display: none; }
  .it-table { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
