/* ================================================================
   Grouper — styles
   Floating panels on a soft canvas, a confident teal accent,
   buttons with depth that lift when you hover them.
   ================================================================ */
:root {
  --bg: #eef1f5;
  --bg-2: #e6eaf0;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --ink: #111c27;
  --ink-2: #364352;
  --muted: #6c7785;
  --line: #e4e8ee;
  --line-2: #d4dbe3;
  --accent: #0d9488;
  --accent-2: #0f766e;
  --accent-3: #115e59;
  --accent-ink: #ffffff;
  --accent-soft: #e6f6f4;
  --accent-line: #b3e3dd;
  --glow: 0 6px 16px -4px rgba(13, 148, 136, .45);
  --danger: #c2410c;
  --danger-soft: #fff1ea;
  --select: #2563eb;
  --warn: #b45309;
  --warn-soft: #fff7e8;
  --warn-line: #f4d49c;
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(17, 28, 39, .06);
  --shadow-btn: 0 1px 2px rgba(17, 28, 39, .06), 0 1px 0 rgba(255, 255, 255, .8) inset;
  --shadow-2: 0 1px 2px rgba(17, 28, 39, .04), 0 6px 16px -6px rgba(17, 28, 39, .10);
  --shadow-panel: 0 1px 2px rgba(17, 28, 39, .04), 0 10px 30px -12px rgba(17, 28, 39, .14);
  --shadow-3: 0 24px 60px -12px rgba(17, 28, 39, .30);
  --desk-w: 92px;
  --desk-h: 50px;
  --gap: 14px;
  font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-columns: 252px 1fr 300px;
  grid-template-rows: 64px 1fr;
  grid-template-areas: "top top top" "left main right";
  column-gap: var(--gap);
  padding: 0 var(--gap) var(--gap);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(13, 148, 136, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(37, 99, 235, .05), transparent 60%),
    var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
@media (max-width: 1180px) { body { grid-template-columns: 224px 1fr 272px; --gap: 10px; } }

/* ---------- Controls ---------- */
button, select, input, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line-2);
  background: linear-gradient(#fff, #fbfcfd);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 550;
  color: var(--ink-2);
  box-shadow: var(--shadow-btn);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .12s, color .15s;
}
button:hover:not(:disabled) {
  border-color: var(--accent-line); color: var(--ink);
  box-shadow: 0 4px 12px -4px rgba(17, 28, 39, .15); transform: translateY(-1px);
}
button:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-1); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

button.primary, button.accent {
  background: linear-gradient(180deg, #14b8a6 0%, var(--accent) 45%, var(--accent-2) 100%);
  border-color: var(--accent-2); color: var(--accent-ink); font-weight: 650;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.25);
  text-shadow: 0 1px 0 rgba(0,0,0,.08);
}
button.primary:hover:not(:disabled), button.accent:hover:not(:disabled) {
  color: #fff; border-color: var(--accent-3);
  background: linear-gradient(180deg, #2dd4bf 0%, #0fa597 45%, var(--accent-2) 100%);
  box-shadow: 0 10px 22px -6px rgba(13, 148, 136, .55), inset 0 1px 0 rgba(255,255,255,.3);
}
button.primary.big { padding: 13px 16px; font-size: 15.5px; border-radius: 13px; letter-spacing: -.005em; }
button.primary.big .ico { width: 18px; height: 18px; }
button.primary-soft {
  background: linear-gradient(180deg, #f0fbf9, var(--accent-soft)); border-color: var(--accent-line); color: var(--accent-2); font-weight: 650;
}
button.primary-soft:hover:not(:disabled) { color: var(--accent-3); border-color: var(--accent); background: linear-gradient(180deg, #e7f8f5, #d8f1ed); }
button.danger { color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: #f2c3ab; color: var(--danger); }
button.link {
  border: none; background: none; padding: 4px 6px; color: var(--muted); box-shadow: none; border-radius: 8px;
}
button.link:hover:not(:disabled) { color: var(--ink); background: var(--bg); transform: none; box-shadow: none; }
button.icon-btn { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; }
button.with-icon { display: flex; align-items: center; gap: 9px; text-align: left; }
.btn-group { display: inline-flex; box-shadow: var(--shadow-btn); border-radius: var(--radius-sm); }
.btn-group > button { border-radius: 0; box-shadow: none; }
.btn-group > button:hover:not(:disabled) { transform: none; box-shadow: none; background: var(--panel-2); }
.btn-group > button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group > button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }

select, input[type=number], input[type=text], input[type=search], textarea {
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 11px; background: #fff; width: 100%;
  transition: border-color .15s, box-shadow .15s; box-shadow: inset 0 1px 2px rgba(17, 28, 39, .04);
}
select { cursor: pointer; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(13, 148, 136, .14); }

/* ---------- Icons ---------- */
.ico { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.ico.sm { width: 13px; height: 13px; vertical-align: -2px; }
button:has(> .ico), .tab, .saved { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
button.with-icon, .class-list button { justify-content: flex-start; }
.logo .ico { width: 18px; height: 18px; }
.stepper .ico { width: 18px; height: 18px; }
.saved .ico { width: 13px; height: 13px; }
button.link .ico { width: 15px; height: 15px; }

/* ---------- Top bar ---------- */
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 18px;
  padding: 0 4px; position: relative; z-index: 2;
}
.brand { font-weight: 750; font-size: 18px; display: flex; align-items: center; gap: 10px; min-width: 238px; letter-spacing: -.02em; }
.logo {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, #2dd4bf, var(--accent) 50%, var(--accent-3)); color: #fff;
  box-shadow: 0 6px 14px -4px rgba(13, 148, 136, .6), inset 0 1px 0 rgba(255,255,255,.3);
}
.header-class { display: none; }
.tabs {
  display: flex; background: rgba(255,255,255,.65); border-radius: 13px; padding: 4px; gap: 3px;
  border: 1px solid var(--line); box-shadow: var(--shadow-1); backdrop-filter: blur(6px);
}
.tab { border: none; background: transparent; padding: 7px 16px; border-radius: 10px; box-shadow: none; color: var(--muted); font-weight: 600; }
.tab:hover:not(:disabled) { background: rgba(255,255,255,.9); color: var(--ink); border: none; box-shadow: none; transform: none; }
.tab.active { background: #fff; box-shadow: var(--shadow-2); color: var(--accent-2); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.saved { color: var(--muted); font-size: 12px; min-width: 56px; justify-content: flex-end; transition: color .3s; }
.saved.flash { color: var(--accent); }
#eyeBtn { border-radius: 999px; padding: 7px 15px; }
#eyeBtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.topbar button, .toolbar button, .board-head button { white-space: nowrap; }
@media (max-width: 1100px) { .topbar { gap: 10px; } .brand { min-width: 0; } .top-actions { gap: 6px; } .saved { display: none; } }

/* ---------- Side panels: floating cards ---------- */
.left, .right {
  background: var(--panel); overflow-y: auto; padding: 8px 16px 20px;
  border: 1px solid rgba(17, 28, 39, .06); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.left { grid-area: left; }
.right { grid-area: right; }
section { padding: 16px 0; border-bottom: 1px solid var(--line); }
section:last-child { border-bottom: none; }
h3 { margin: 0 0 11px; font-size: 12.5px; font-weight: 700; letter-spacing: .01em; color: var(--ink-2); }
h3 .count, .sec-head .count {
  font-weight: 650; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 1px 8px; margin-left: 5px; font-size: 11.5px;
}
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sec-head h3 { margin: 0; }
.sec-head .icon-btn { width: 28px; height: 28px; border-radius: 9px; color: var(--accent-2); }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 0; line-height: 1.45; }
.hint.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 > button { font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* Fold-away sections */
.fold { border-bottom: 1px solid var(--line); }
.fold:last-child { border-bottom: none; }
.fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px; margin: 4px -8px; user-select: none; border-radius: 10px; transition: background .15s;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { background: var(--panel-2); }
.fold > summary h3 { margin: 0; }
.chev { width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .2s; margin-right: 4px; }
.fold[open] > summary .chev { transform: rotate(45deg); }
.fold-body { display: flex; flex-direction: column; gap: 9px; padding: 4px 0 16px; }

/* Class list */
.class-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.class-list button {
  width: 100%; text-align: left; border: 1px solid transparent; background: none; box-shadow: none;
  padding: 9px 10px 9px 14px; display: flex; align-items: center; gap: 10px; border-radius: 11px;
  font-weight: 550; color: var(--ink-2); position: relative;
}
.class-list button:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; box-shadow: none; transform: translateX(2px); }
.class-list button.active {
  background: linear-gradient(90deg, var(--accent-soft), #f3fbfa); border-color: var(--accent-line); color: var(--accent-3); font-weight: 700;
}
.class-list button.active::before {
  content: ""; position: absolute; left: 5px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent);
}
.class-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-list .meta {
  color: var(--muted); font-weight: 600; font-size: 11.5px; min-width: 26px; text-align: center;
  background: var(--bg); border-radius: 999px; padding: 1px 7px;
}
.class-list button.active .meta { background: #fff; color: var(--accent-2); }
#roster { height: 220px; resize: vertical; line-height: 1.6; }

.absent-btn { padding: 11px 13px; border-radius: 12px; }
.absent-btn .ico { color: var(--muted); }
button.has-absent { border-color: var(--warn-line); background: linear-gradient(180deg, #fffaf0, var(--warn-soft)); color: var(--warn); }
button.has-absent .ico { color: var(--warn); }
.pill-count { margin-left: auto; font-size: 11px; font-weight: 700; background: #f59e0b; color: #fff; border-radius: 999px; padding: 2px 9px; }

/* Segmented control & stepper */
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; border: none; background: transparent; box-shadow: none; font-size: 12.5px; padding: 7px 6px;
  border-radius: 9px; color: var(--muted); white-space: nowrap; font-weight: 600;
}
.seg button:hover:not(:disabled) { background: rgba(255,255,255,.75); border: none; box-shadow: none; transform: none; }
.seg button.on { background: #fff; color: var(--accent-2); box-shadow: var(--shadow-2); }
.stepper {
  display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 13px; overflow: hidden; background: #fff;
  box-shadow: var(--shadow-btn);
}
.stepper button { border: none; border-radius: 0; box-shadow: none; width: 48px; padding: 0; color: var(--accent-2); background: var(--panel-2); }
.stepper button:hover:not(:disabled) { background: var(--accent-soft); transform: none; box-shadow: none; }
.stepper input { border: none; border-radius: 0; text-align: center; font-size: 22px; font-weight: 750; padding: 7px 0; -moz-appearance: textfield; box-shadow: none; letter-spacing: -.02em; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { box-shadow: none; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(13, 148, 136, .14); }

/* ---------- Main area ---------- */
.main { grid-area: main; overflow: auto; padding: 8px 6px 6px; }
.board-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; flex-wrap: wrap; }
.board-head h2 { margin: 0 8px 0 0; font-size: 25px; font-weight: 750; letter-spacing: -.03em; }
.h-sub { color: var(--muted); font-weight: 550; font-size: 15px; margin-left: 6px; letter-spacing: -.01em; }
.meta-pill {
  font-size: 12px; font-weight: 600; color: var(--ink-2); background: rgba(255,255,255,.8);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; box-shadow: var(--shadow-1);
}
.board-head .spacer { flex: 1; }
.muted { color: var(--muted); }
.empty {
  border: 2px dashed var(--line-2); border-radius: var(--radius-lg); padding: 56px; text-align: center; color: var(--muted); background: rgba(255,255,255,.55);
}
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

/* ---------- Groups ---------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 16px; }
.group-card {
  --h: 190;
  background: var(--panel); border: 1px solid rgba(17, 28, 39, .07); border-radius: var(--radius-lg);
  padding: 14px; min-height: 132px; box-shadow: var(--shadow-2); position: relative; overflow: hidden;
  transition: border-color .15s, box-shadow .2s, transform .2s;
}
.group-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: hsl(var(--h) 62% 52%); }
.group-card:hover { box-shadow: var(--shadow-panel); }
.group-card.over, .dropzone.over { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(13, 148, 136, .16); }
.group-title { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.group-num {
  width: 28px; height: 28px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-weight: 750; font-size: 13px; background: hsl(var(--h) 60% 45%); color: #fff;
  box-shadow: 0 3px 8px -3px hsl(var(--h) 60% 40% / .6);
}
.group-name { border: 1px solid transparent !important; font-weight: 700; font-size: 15.5px; padding: 3px 6px !important; background: transparent !important; box-shadow: none !important; letter-spacing: -.01em; }
.group-name:hover { border-color: var(--line) !important; }
.group-name:focus { border-color: var(--accent) !important; background: #fff !important; }
.group-title .count { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; min-height: 36px; align-content: flex-start; }
/* Student names are neutral; inside a group they take a faint tint of that group's color. */
.chip {
  background: #fff; border: 1px solid var(--line-2); color: var(--ink);
  padding: 6px 12px; border-radius: 10px; cursor: grab; user-select: none; font-weight: 600;
  box-shadow: 0 1px 2px rgba(17, 28, 39, .05);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.chip:hover { box-shadow: 0 6px 14px -6px rgba(17, 28, 39, .25); transform: translateY(-2px); border-color: #b9c4cf; }
.group-card .chip { background: hsl(var(--h) 60% 97.5%); border-color: hsl(var(--h) 40% 88%); }
.group-card .chip:hover { border-color: hsl(var(--h) 50% 70%); box-shadow: 0 6px 14px -6px hsl(var(--h) 50% 35% / .35); }
/* Rule conflicts only show while the eye is on, and never while presenting. */
body.show-rules:not(.presenting) .chip.conflict,
body.show-rules:not(.presenting) .desk.conflict { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.chip.dragging, .seat-name.dragging { opacity: .4; }
.unassigned { margin-top: 20px; background: rgba(255,255,255,.7); border: 1.5px dashed var(--line-2); border-radius: var(--radius-lg); padding: 14px; }
.unassigned h4 { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); font-weight: 650; }
.add-group-card {
  border: 2px dashed var(--line-2); border-radius: var(--radius-lg); background: rgba(255,255,255,.4); color: var(--muted);
  min-height: 132px; box-shadow: none; font-weight: 650;
}
.add-group-card:hover:not(:disabled) { color: var(--accent-2); border-color: var(--accent); background: rgba(230, 246, 244, .7); box-shadow: none; }

/* ---------- Seating ---------- */
.toolbar {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; min-height: 50px;
  background: rgba(255,255,255,.85); border: 1px solid rgba(17, 28, 39, .07); border-radius: 14px; padding: 7px;
  box-shadow: var(--shadow-2); backdrop-filter: blur(6px);
}
.toolbar button { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.toolbar .sel-hint { color: var(--muted); font-size: 12.5px; margin-left: 8px; }
.toolbar .sel-tools { display: none; align-items: center; gap: 6px; margin-left: auto; padding-left: 10px; border-left: 1px solid var(--line); }
.toolbar.has-sel .sel-tools { display: flex; animation: pop .16s ease-out; }
.toolbar.has-sel .sel-hint { display: none; }
.toolbar .sel-count { font-size: 12.5px; font-weight: 650; color: var(--select); background: #eef3ff; border: 1px solid #d3defb; border-radius: 999px; padding: 4px 11px; margin-right: 2px; }
@keyframes pop { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.canvas {
  position: relative; background: #fff; border: 1px solid rgba(17, 28, 39, .07); border-radius: var(--radius-lg);
  background-image: radial-gradient(#e2e7ed 1.1px, transparent 1.1px); background-size: 22px 22px;
  user-select: none; box-shadow: var(--shadow-panel);
}
.front {
  position: absolute; left: 50%; transform: translateX(-50%); top: 9px;
  width: 340px; height: 30px; display: grid; place-items: center;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2);
  border-radius: 999px; font-weight: 750; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; pointer-events: none;
}
.desk {
  position: absolute; width: var(--desk-w); height: var(--desk-h);
  background: #fff; border: 1.5px solid var(--line-2); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; cursor: move; color: var(--ink);
  padding: 8px 4px 4px; font-size: 13px; font-weight: 650;
  box-shadow: 0 2px 5px -2px rgba(17, 28, 39, .16);
  transition: box-shadow .15s, border-color .15s;
}
.desk::before {
  content: ""; position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 2px; background: var(--line-2);
}
.desk:hover { border-color: #b3bfcc; box-shadow: 0 6px 12px -5px rgba(17, 28, 39, .25); }
/* Open seat: on, but nobody in it — lighter, so taken seats read as the "full" ones */
.desk.open { background: var(--panel-2); border-color: var(--line); box-shadow: none; }
.desk.open::before { background: var(--line); }
.desk.over { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(13, 148, 136, .18); }
.desk.selected { border-color: var(--select); box-shadow: 0 0 0 4px rgba(37, 99, 235, .18); }
.desk.inactive {
  background: repeating-linear-gradient(45deg, #f4f6f8, #f4f6f8 6px, #ebeef2 6px, #ebeef2 12px);
  border-style: dashed; border-color: #ccd4dc; color: var(--muted); font-weight: 500; font-size: 11px; box-shadow: none;
}
.desk.inactive::before { display: none; }
.desk.inactive.selected { border-color: var(--select); border-style: solid; }
.seat-name {
  cursor: grab; padding: 3px 6px; border-radius: 7px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat-name:hover { background: rgba(17, 28, 39, .05); }
.marquee { position: absolute; border: 1.5px solid var(--select); background: rgba(37, 99, 235, .08); pointer-events: none; border-radius: 6px; }
.pool { min-height: 64px; display: flex; flex-wrap: wrap; gap: 7px; align-content: flex-start; border: 1.5px dashed var(--line-2); border-radius: 13px; padding: 10px; background: var(--panel-2); }
.needs-seat .pool { border-color: var(--warn-line); background: var(--warn-soft); }
.needs-seat h3 { color: var(--warn); }
.off-mark { text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 750; }

/* Room layout card */
.layout-card { display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.row.tight > button:not(.icon-btn) { flex: 1; }
.row.tight > .icon-btn { flex: none; width: 40px; height: auto; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(17, 28, 39, .94); color: #fff; padding: 12px 20px; border-radius: 14px; opacity: 0; max-width: min(640px, 90vw);
  transition: opacity .2s, transform .25s cubic-bezier(.2,.9,.3,1.2); pointer-events: none; z-index: 30; box-shadow: var(--shadow-3); font-weight: 550;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Present mode ---------- */
.exit-present { display: none; }
body.presenting { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "main"; background: #fff; padding: 0; }
body.presenting .topbar, body.presenting .left, body.presenting .right, body.presenting .toolbar,
body.presenting .group-title button, body.presenting .add-group-card, body.presenting .meta-pill { display: none; }
body.presenting .exit-present { display: inline-flex; position: fixed; top: 14px; right: 14px; z-index: 5; opacity: .45; }
body.presenting .exit-present:hover { opacity: 1; }
body.presenting .main { padding: 36px 44px; }
body.presenting .board-head h2 { font-size: 40px; }
body.presenting .h-sub { font-size: 22px; }
body.presenting .chip { font-size: 22px; padding: 10px 17px; border-radius: 14px; }
body.presenting .group-name { font-size: 25px; }
body.presenting .group-num { width: 38px; height: 38px; font-size: 18px; border-radius: 11px; }
body.presenting .group-grid { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 22px; }
body.presenting .group-card { padding: 20px; }
body.presenting .group-card::before { height: 6px; }
body.presenting .desk.selected { border-color: var(--line-2); box-shadow: 0 2px 5px -2px rgba(17, 28, 39, .16); }
body.presenting .desk.open.selected { border-color: var(--line); box-shadow: none; }
body.presenting .desk.inactive { opacity: .3; }
body.presenting .off-mark { display: none; }

@media print {
  body { display: block; background: #fff; padding: 0; }
  .topbar, .left, .right, .toolbar, .toast, .exit-present, .add-group-card, .group-title button, .private, .modal-back, .meta-pill, .drawer-back, .teacher-only { display: none !important; }
  .chip.conflict, .desk.conflict { background: inherit !important; border-color: inherit !important; color: inherit !important; }
  .main { overflow: visible; padding: 0; }
  .canvas-wrap { overflow: visible; }
  .group-card, .canvas { box-shadow: none; }
  .chip, .desk, .group-num, .group-card::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .desk.inactive { opacity: .3; }
  .off-mark { display: none; }
}

/* Seating chart fits its panel — no scrollbars. The canvas is scaled in JS (fitCanvas). */
body[data-view="seats"] .main { display: flex; flex-direction: column; overflow: hidden; }
body[data-view="seats"] .board-head, body[data-view="seats"] .toolbar, body[data-view="seats"] .pick-banner { flex: none; }
.canvas-wrap { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; justify-content: center; align-items: flex-start; }
.canvas-wrap[hidden] { display: none; }
.canvas-sizer { position: relative; flex: none; }
.canvas { transform-origin: 0 0; position: absolute; top: 0; left: 0; }

/* ================= Rules, labels, privacy ================= */

/* Anything marked .private (badges, rule checks, absent markers) is hidden unless the
   eye is on — and always hidden in Present mode, so students never see it. */
body:not(.show-rules) .private, body.presenting .private { display: none !important; }
body.presenting .drawer-back, body.presenting .teacher-only { display: none !important; }

button.small { padding: 6px 11px; font-size: 13px; }
button.small.active { background: var(--select); border-color: var(--select); color: #fff; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 12px; box-shadow: none; }

.badges { display: inline-flex; gap: 2px; margin-left: 5px; vertical-align: middle; }
.badges i {
  font-style: normal; font-size: 9px; font-weight: 750; line-height: 1; padding: 2px 4px; border-radius: 5px;
  background: hsl(var(--h) 65% 45%); color: #fff; letter-spacing: .02em;
}
.badges i.absent { background: #8a96a3; }
.seat-name .badges { margin-left: 3px; }

#addRule {
  margin-bottom: 12px; font-weight: 650; color: var(--accent-2); border-color: var(--accent-line);
  background: linear-gradient(180deg, #f0fbf9, var(--accent-soft)); cursor: pointer; padding: 10px 12px;
}
.rule-list { display: flex; flex-direction: column; gap: 9px; }
.rule-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; display: flex; flex-direction: column; gap: 9px;
  background: #fff; box-shadow: var(--shadow-2);
}
.rule-head { display: flex; align-items: center; gap: 6px; }
/* The rule's name works as an on/off switch: a small switch sits in front of it. */
.rule-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left; position: relative;
  border: none; background: none; padding: 2px 0 2px 42px; font-size: 13.5px; color: var(--ink); cursor: pointer; box-shadow: none;
}
.rule-toggle:hover:not(:disabled) { background: none; border: none; box-shadow: none; transform: none; }
.rule-toggle::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 32px; height: 19px; border-radius: 999px; background: var(--accent); transition: background .2s;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12);
}
.rule-toggle::after {
  content: ""; position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .2s cubic-bezier(.3,.9,.4,1.2);
}
.rule-toggle b { font-weight: 650; }
.rule-toggle .count { color: var(--muted); font-weight: 600; font-size: 12px; margin-left: 2px; }
.rule-toggle .dot {
  font-style: normal; font-size: 9px; font-weight: 750; line-height: 1; padding: 3px 5px; border-radius: 5px;
  background: hsl(var(--h) 65% 45%); color: #fff;
}
.rule-toggle:hover b { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.rule-card.off { background: var(--panel-2); border-style: dashed; box-shadow: none; }
.rule-card.off .rule-toggle::before { background: #c8d0d9; }
.rule-card.off .rule-toggle::after { left: 2px; }
.rule-card.off .rule-toggle b { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.rule-card.off .rule-toggle .dot { filter: grayscale(1); opacity: .5; }
.rule-card.off .scope { opacity: .5; }
.scope { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--bg); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pairs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pairs li { display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px 3px 3px 10px; font-size: 13px; font-weight: 550; }
.pairs b { color: var(--muted); font-weight: 600; margin: 0 4px; display: inline-flex; vertical-align: middle; }
.names { margin: 0; font-size: 13px; }
.rule-card .hint { margin: 0; }
.rule-card .seg button.on { color: #fff; background: linear-gradient(180deg, #14b8a6, var(--accent-2)); }

.rule-report { font-size: 13px; border-radius: 12px; padding: 7px 13px; max-width: 520px; border: 1px solid transparent; box-shadow: var(--shadow-1); }
.rule-report.ok { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); }
.rule-report.warn { background: var(--danger-soft); color: var(--danger); border-color: #f6cdb8; }
.rule-report summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 6px; }
.rule-report summary::marker { content: ""; }
.rule-report summary::-webkit-details-marker { display: none; }
.rule-report summary .ico { width: 15px; height: 15px; }
.rule-report ul { margin: 4px 0 2px; padding-left: 16px; color: var(--ink); font-weight: 400; }
.rule-report .rule-lines { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.rule-lines > li { display: flex; gap: 8px; align-items: flex-start; }
.rule-lines .icon { width: 14px; flex: none; display: grid; place-items: center; height: 18px; }
.rule-lines .icon .ico { width: 14px; height: 14px; }
.rule-lines li.good .icon { color: var(--accent); }
.rule-lines li.bad .icon { color: var(--danger); }
.rule-lines li.soft .icon { color: var(--muted); }
.rule-lines ul { color: var(--danger); }
.rule-lines li.soft ul { color: var(--muted); }
.rule-report .not-here { margin: 6px 0 0; font-weight: 400; font-size: 12px; }
.rule-report.in-drawer { margin: 0 0 16px; max-width: none; }

.pick-banner {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: linear-gradient(180deg, #f3f6ff, #eaf0ff); border: 1px solid #c9d7fb; color: #1e3a8a;
  border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; font-weight: 550; box-shadow: var(--shadow-1);
}
body.picking #main .chip, body.picking #main .seat-name, body.picking .pool .chip { cursor: pointer; outline: 2px dashed rgba(37, 99, 235, .45); outline-offset: 2px; }

/* ---------- Popup ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(17, 28, 39, .40); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 40; animation: fade .15s ease-out; }
.modal {
  background: #fff; border-radius: 22px; width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; gap: 12px; padding: 24px 26px; box-shadow: var(--shadow-3);
  animation: rise .2s cubic-bezier(.2,.9,.3,1.1);
}
.modal h2 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.modal .hint { margin: 0; }
.checklist-tools { display: flex; gap: 6px; }
.checklist-tools input { flex: 1; }
.checklist { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 5px; padding: 2px; }
.check-item { flex-direction: row; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 10px; color: var(--ink); font-size: 14px; font-weight: 550; cursor: pointer; border: 1px solid transparent; transition: background .12s; }
.check-item:hover { background: var(--panel-2); border-color: var(--line); }
.check-item:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-3); }
.check-item[hidden] { display: none; }
.check-item input { width: 16px; height: 16px; accent-color: var(--accent); }
.check-item small { color: var(--muted); margin-left: auto; }
.modal footer { display: flex; gap: 8px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); }
.modal footer .spacer { flex: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Private rules panel ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(17, 28, 39, .30); backdrop-filter: blur(2px); z-index: 20; display: flex; justify-content: flex-end; padding: 12px; }
.drawer-back.opening { animation: fade .15s ease-out; }
.drawer-back.opening .drawer { animation: slide .22s cubic-bezier(.2,.9,.3,1.05); }
.drawer {
  width: 390px; max-width: 92vw; height: 100%; overflow-y: auto; background: #fff; padding: 22px 18px 28px;
  border-radius: 20px; box-shadow: var(--shadow-3); position: relative;
}
.drawer h3 { margin-top: 0; }
.drawer section { padding-top: 4px; }
.drawer-close { position: absolute; top: 16px; right: 16px; }
@keyframes slide { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Public edition: retained desktop layout and a stacked narrow layout. */
body { grid-template-rows: 64px auto minmax(0, 1fr); grid-template-areas: "top top top" "note note note" "left main right"; }
.local-notice { grid-area: note; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; font-size: 12px; color: var(--muted); padding: 0 4px 8px; }
.local-notice a { color: var(--accent-2); font-weight: 700; white-space: nowrap; }
.brand-name small { display: block; font-size: 10px; font-weight: 650; color: var(--muted); letter-spacing: .025em; }
body.presenting .local-notice { display: none; }
@media (max-width: 850px) {
  body:not(.presenting) { height: auto; min-height: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "top" "note" "left" "right" "main"; row-gap: 8px; }
  .topbar, .top-actions { flex-wrap: wrap; }
  .topbar { padding: 8px 2px 0; }
  .top-actions { margin-left: 0; }
  .top-actions button { padding-inline: 7px; }
  .left, .right, .main { min-width: 0; overflow: visible; }
  body[data-view="seats"] .main { min-height: 390px; }
  body.presenting .main { padding: 16px; }
  body.presenting .group-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
}
@media print { .local-notice { display: none !important; } }
