:root {
  color-scheme: light;
  --ink: #1f2940;
  --muted: #667085;
  --line: #d8dce5;
  --paper: #ffffff;
  --background: #f5f3ee;
  --cream: #f6ead7;
  --cream-dark: #8a5d2e;
  --mint: #ccebdc;
  --mint-dark: #39735a;
  --coral: #f7cbc3;
  --coral-dark: #9c3e35;
  --sky: #d8ebf7;
  --shadow: 0 12px 30px rgba(31, 41, 64, .08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.045em; }
h2 { margin-bottom: 12px; font-size: 1.08rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 28px clamp(18px, 4vw, 56px); background: var(--paper); border-bottom: 1px solid var(--line); }
.eyebrow { margin-bottom: 7px; color: var(--coral-dark); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.subtitle, .muted { color: var(--muted); }
.subtitle { margin-bottom: 0; }
main { padding: 24px clamp(14px, 3vw, 44px) 48px; }

.controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
label { display: grid; gap: 6px; font-size: .9rem; font-weight: 700; }
select, textarea, input { border: 1px solid var(--line); border-radius: 8px; background: var(--paper); padding: 10px 12px; }
select { min-width: 150px; }
textarea { width: 100%; resize: vertical; line-height: 1.45; }
input { width: 100%; }

.button { min-height: 42px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-weight: 750; text-align: center; }
.button:hover { background: var(--cream); }
.button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, .seat:focus-visible { outline: 3px solid rgba(57, 115, 90, .35); outline-offset: 2px; }
.button.primary { border-color: var(--mint-dark); background: var(--mint); }
.button.danger { color: var(--coral-dark); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button.full { width: 100%; margin-top: 10px; }

.status { min-height: 24px; margin: 8px 0 14px; color: var(--mint-dark); font-weight: 700; }
.status.error { color: var(--coral-dark); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.paper, .panel { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); }
.paper { min-width: 0; padding: 22px; }
.panel { padding: 17px; }
.panel.compact { box-shadow: none; }
.sidebar { display: grid; gap: 14px; }
.plan-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.plan-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.selection-help { min-height: 24px; margin: 10px 0; color: var(--cream-dark); font-weight: 700; }
.map-scroll { overflow-x: auto; }
.room-plan { display: block; width: 100%; min-width: 700px; max-height: 74vh; }
.seat { cursor: grab; touch-action: none; }
.seat:active { cursor: grabbing; }
.seat.dragging { opacity: .42; }
.seat.drag-over .seat-fill { stroke: var(--coral-dark); stroke-width: 5px; }
.seat:hover .seat-fill { stroke: var(--cream-dark); stroke-width: 3px; }
.quick-add { margin-bottom: 13px; }
.quick-add > div { display: flex; gap: 8px; }
.quick-add input { min-width: 0; }
.student-list { display: grid; min-height: 96px; gap: 7px; max-height: 330px; padding: 6px; overflow-y: auto; border: 1px dashed var(--line); border-radius: 8px; }
.student-row { display: flex; gap: 6px; }
.student-button { flex: 1; overflow-wrap: anywhere; }
.student-button { cursor: grab; touch-action: none; }
.student-button:active { cursor: grabbing; }
.student-button.dragging { opacity: .45; }
.student-list.drag-over-list { outline: 3px dashed var(--mint-dark); outline-offset: 5px; background: rgba(204, 235, 220, .35); }
.remove-button { width: 42px; min-width: 42px; color: var(--coral-dark); }
.count { display: inline-grid; place-items: center; min-width: 28px; min-height: 28px; margin-left: 5px; border-radius: 999px; background: var(--cream); font-size: .86rem; }
.empty { align-self: center; margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.4; }
.file-button { display: inline-grid; place-items: center; }
.help { margin: 10px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.4; }
#import-input, #roster-file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.print-title, .print-note { display: none; }

dialog { width: min(420px, calc(100vw - 30px)); border: 1px solid var(--line); border-radius: 12px; padding: 22px; color: var(--ink); }
dialog::backdrop { background: rgba(31, 41, 64, .45); }
.dialog-actions { justify-content: flex-end; margin-top: 18px; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar .compact { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .sidebar { grid-template-columns: 1fr; }
  .sidebar .compact { grid-column: auto; }
  .paper { padding: 14px; }
  .plan-heading { display: block; }
  .plan-actions { justify-content: flex-start; margin-bottom: 12px; }
}

@media print {
  @page { size: A4 landscape; margin: 5mm; }
  body { background: white; }
  .no-print { display: none !important; }
  main { padding: 0; }
  .workspace { display: block; }
  .paper { display: flex; height: 200mm; flex-direction: column; border: 0; box-shadow: none; padding: 0; }
  .plan-heading { display: block; flex: 0 0 auto; margin: 0 0 2mm; }
  .plan-heading h2, .plan-heading > .button { display: none; }
  .print-title { display: block; margin: 0; font-size: 13pt; font-weight: 800; }
  .map-scroll { display: flex; min-height: 0; flex: 1 1 auto; align-items: center; justify-content: center; overflow: visible; }
  .room-plan { width: 100%; height: 100%; min-width: 0; max-height: none; margin: auto; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-note { display: block; flex: 0 0 auto; margin: 1mm 0 0; text-align: center; font-size: 7pt; }
}
