@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@100..900&display=swap');

:root {
  --ink: #1E1B4B;
  --muted: #5B5678;
  --muted-deep: #433E68;
  --purple: #4F46E5;
  --purple-dark: #3730A3;
  --purple-soft: #EEF2FF;
  --orange: #F97316;
  --orange-dark: #EA580C;
  --orange-soft: #FFF7ED;
  --teal: #14B8A6;
  --teal-soft: #CCFBF1;
  --yellow: #FBBF24;
  --paper: #FFFEFB;
  --line: #E0E7FF;
  --shadow: 0 18px 45px rgba(55, 49, 116, 0.08);
  --shadow-hover: 0 20px 44px rgba(74, 69, 148, 0.15);
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: #EEF2FF;
  background-image:
    radial-gradient(circle at 9% 10%, rgba(251, 191, 36, 0.18), transparent 19rem),
    radial-gradient(circle at 96% 22%, rgba(20, 184, 166, 0.14), transparent 22rem),
    linear-gradient(125deg, #EEF2FF 0%, #F5F3FF 44%, #FFF7ED 100%);
  font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button, input { font: inherit; }
button { border: 0; }
button, [draggable="true"] { cursor: pointer; }
button:focus-visible, input:focus-visible, [draggable="true"]:focus-visible {
  outline: 3px solid rgba(91, 91, 214, 0.28);
  outline-offset: 3px;
}

.app-shell { position: relative; width: min(100% - 52px, 1540px); margin: 0 auto; padding: 24px 0 18px; }
.topbar, .hero-row, .metric-row, .workspace-grid, .app-footer { position: relative; z-index: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 50px; color: #fff; background: var(--purple); border: 3px solid #fff; border-radius: 16px 16px 16px 5px; box-shadow: 0 6px 0 #4545ac; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -0.06em; transform: rotate(-3deg); }
.brand-copy { display: flex; flex-direction: column; gap: 0; }
.brand-copy strong { font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 17px; letter-spacing: 0.075em; line-height: 1; }
.brand-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.sync-status { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--muted-deep); background: rgba(255,255,255,.65); border: 1px solid rgba(222,220,243,.9); border-radius: 100px; font-size: 12px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; background: var(--yellow); border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,217,104,.2); }
.sync-status[data-state="ready"] .status-dot { background: var(--teal); box-shadow: 0 0 0 4px rgba(82,184,168,.16); }
.sync-status[data-state="offline"] .status-dot { background: var(--orange); box-shadow: 0 0 0 4px rgba(255,143,80,.16); }
.sync-status[data-state="saving"] .status-dot { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; color: var(--muted-deep); background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 12px; transition: background .2s, color .2s, border-color .2s; }
.icon-button:hover { color: var(--purple); background: #fff; border-color: #cbc9f3; }
.icon-button svg, .ghost-button svg, .save-button svg, .board-note svg, .search-wrap svg, .metric-icon svg, .floating-card svg, .modal-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.random-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 12px; color: #fff; background: var(--orange); border: 1px solid var(--orange); border-radius: 12px; box-shadow: 0 3px 0 #dc6e34; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 12px; font-weight: 800; text-decoration: none; transition: transform .2s, box-shadow .2s, background .2s, border-color .2s; }
.random-link:hover { background: var(--orange-dark); border-color: var(--orange-dark); box-shadow: 0 1px 0 #dc6e34; transform: translateY(2px); }
.random-link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.race-nav-link { color: var(--purple-dark); background: rgba(255,255,255,.72); border-color: var(--line); box-shadow: 0 3px 0 #d9d7ed; }
.race-nav-link:hover { color: var(--purple); background: var(--purple-soft); border-color: #c8c6ef; box-shadow: 0 1px 0 #d9d7ed; }
.table-nav-link { color: #278f81; background: rgba(255,255,255,.72); border-color: #cdece5; box-shadow: 0 3px 0 #c5e7df; }
.table-nav-link:hover { color: #207c70; background: var(--teal-soft); border-color: #a9ddd2; box-shadow: 0 1px 0 #c5e7df; }
.admin-nav-link { color: #4747b9; background: var(--purple-soft); border-color: #d6d5f6; box-shadow: 0 3px 0 #c9c7ed; }
.admin-nav-link:hover { color: #36369e; background: #e3e2ff; border-color: #bebbeb; box-shadow: 0 1px 0 #c9c7ed; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; color: var(--purple-dark); background: var(--yellow); border: 3px solid #fff; border-radius: 50%; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 13px; font-weight: 800; box-shadow: 0 3px 0 #e6bd41; }

.hero-row { display: flex; align-items: center; justify-content: space-between; min-height: 255px; padding: 36px 7% 16px 4%; }
.hero-copy { max-width: 590px; }
.eyebrow, .section-kicker { color: var(--purple); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.eyebrow { display: flex; align-items: center; gap: 8px; }
.eyebrow-line { display: inline-block; width: 25px; height: 3px; background: var(--orange); border-radius: 10px; }
h1, h2, p { margin: 0; }
h1 { margin-top: 10px; font-family: 'Lobster Two', cursive; font-size: clamp(42px, 4.1vw, 65px); font-weight: 700; letter-spacing: -.01em; line-height: .97; }
h1 span { color: var(--orange); }
.hero-copy p { max-width: 500px; margin-top: 17px; color: var(--muted-deep); font-size: 16px; }
.hero-illustration { position: relative; width: 275px; height: 210px; margin-right: 2%; }
.planet { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.planet-main { top: 46px; left: 89px; width: 111px; height: 111px; color: #fff; background: var(--purple); border: 7px solid #fff; border-radius: 50%; box-shadow: 0 11px 0 rgba(72, 69, 178, .22), inset -8px -4px 0 rgba(44, 43, 130, .14); transform: rotate(-8deg); }
.planet-main::before, .planet-main::after { position: absolute; content: ''; background: #7777e8; border-radius: 50%; }
.planet-main::before { top: 19px; left: 19px; width: 11px; height: 11px; }
.planet-main::after { right: 18px; bottom: 20px; width: 18px; height: 8px; }
.planet-main span { position: relative; z-index: 1; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 38px; font-weight: 800; line-height: .8; }
.planet-main small { position: relative; z-index: 1; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 16px; font-weight: 700; }
.orbit { position: absolute; border: 2px dashed #b6b5e9; border-radius: 50%; transform: rotate(-24deg); }
.orbit-one { top: 51px; left: 25px; width: 235px; height: 99px; }
.orbit-two { top: 56px; left: 66px; width: 160px; height: 107px; border-color: #ffc68a; transform: rotate(52deg); }
.floating-card { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border: 3px solid #fff; border-radius: 13px; box-shadow: 0 6px 0 rgba(68, 63, 132, .13); }
.floating-card svg { width: 23px; height: 23px; stroke-width: 1.6; }
.card-ruler { top: 33px; left: 17px; color: #d77934; background: #ffdca6; transform: rotate(-16deg); }
.card-flask { top: 17px; right: 10px; color: #278f81; background: #b9ece0; transform: rotate(13deg); }
.card-shape { right: 18px; bottom: 22px; color: var(--purple); background: #dddcff; transform: rotate(11deg); }
.card-atom { left: 72px; bottom: 8px; color: #0f766e; background: #ccfbf1; transform: rotate(-18deg); width: 38px; height: 38px; }

.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(180px, .85fr); gap: 14px; margin-bottom: 24px; }
.metric-card { position: relative; display: flex; align-items: center; gap: 13px; min-height: 91px; padding: 16px 17px; overflow: hidden; background: rgba(255,255,255,.79); border: 1px solid rgba(231,229,245,.95); border-radius: 20px; box-shadow: 0 7px 20px rgba(70, 63, 131, .045); }
.metric-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 14px; }
.metric-icon svg { width: 23px; height: 23px; stroke-width: 1.7; }
.metric-student .metric-icon { color: var(--purple); background: var(--purple-soft); }
.metric-seat .metric-icon { color: #d47037; background: var(--orange-soft); }
.metric-zone .metric-icon { color: #278f81; background: var(--teal-soft); }
.metric-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin-top: -3px; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 28px; line-height: 1; }
.metric-card strong small { color: var(--muted); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 13px; font-weight: 700; }
.metric-bubble { position: absolute; right: -19px; bottom: -24px; width: 72px; height: 72px; border-radius: 50%; opacity: .65; }
.bubble-lavender { background: #e6e4ff; }
.metric-progress { position: absolute; right: 14px; bottom: 14px; width: 52px; height: 5px; overflow: hidden; background: #f2dfd5; border-radius: 10px; }
.metric-progress i { display: block; width: 0; height: 100%; background: var(--orange); border-radius: inherit; transition: width .3s ease; }
.metric-spark { display: flex !important; align-items: end; gap: 3px; margin-left: auto; padding-top: 15px; }
.metric-spark i { width: 4px; background: #77cfc2; border-radius: 5px; }
.metric-spark i:nth-child(1) { height: 9px; }.metric-spark i:nth-child(2) { height: 17px; }.metric-spark i:nth-child(3) { height: 13px; }.metric-spark i:nth-child(4) { height: 23px; }.metric-spark i:nth-child(5) { height: 29px; }
.primary-button, .secondary-button, .ghost-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 17px; border-radius: 13px; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 14px; font-weight: 700; cursor: pointer; transition: transform .2s, box-shadow .2s, background .2s, border-color .2s; }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .7; transform: none; }
.primary-button { color: #fff; background: var(--purple); box-shadow: 0 5px 0 #4444ab; }
.primary-button:hover { background: var(--purple-dark); box-shadow: 0 3px 0 #4444ab; transform: translateY(2px); }
.secondary-button { color: var(--purple-dark); background: #fff; border: 1px solid #dcdaf3; box-shadow: 0 3px 8px rgba(68, 63, 132, .05); }
.secondary-button:hover { background: var(--purple-soft); border-color: #c9c7ef; }
.ghost-button { color: var(--muted-deep); background: transparent; }
.ghost-button:hover { color: var(--orange-dark); background: var(--orange-soft); }
.button-plus { font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 21px; font-weight: 400; line-height: .6; }
.hero-action { min-height: 91px; padding: 0 23px; border-radius: 20px; font-size: 16px; }
.hero-action .button-plus { display: grid; place-items: center; width: 25px; height: 25px; color: var(--purple); background: #fff; border-radius: 8px; }

.workspace-grid { display: grid; grid-template-columns: 304px minmax(0, 1fr); align-items: start; gap: 18px; }
.panel-card { background: rgba(255,255,255,.88); border: 1px solid rgba(232,230,244,.95); border-radius: 24px; box-shadow: var(--shadow); }
.roster-panel { min-height: 640px; padding: 24px 18px 18px; }
.panel-heading, .board-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
h2 { margin-top: 2px; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 25px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; }
.count-pill { display: grid; place-items: center; min-width: 29px; height: 27px; padding: 0 9px; color: var(--purple); background: var(--purple-soft); border-radius: 99px; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 14px; font-weight: 800; }
.search-wrap { position: relative; margin-top: 19px; }
.search-wrap svg { position: absolute; top: 12px; left: 13px; width: 17px; height: 17px; color: #a3a1bf; }
.search-wrap input { width: 100%; height: 41px; padding: 0 13px 0 39px; color: var(--ink); background: #faf9ff; border: 1px solid #e9e7f2; border-radius: 12px; outline: 0; }
.search-wrap input::placeholder { color: #aaa8c2; }
.search-wrap input:focus { background: #fff; border-color: #aaa8ed; box-shadow: 0 0 0 4px rgba(91,91,214,.1); }
.roster-hint { display: flex; align-items: center; gap: 9px; margin: 16px 0 12px; padding: 10px 11px; color: #737193; background: #fff8ee; border: 1px dashed #ffd6ae; border-radius: 12px; font-size: 12px; line-height: 1.2; }
.hint-icon { display: grid; place-items: center; flex: 0 0 25px; width: 25px; height: 25px; color: var(--orange-dark); background: #ffe5ca; border-radius: 8px; }
.hint-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.roster-list { display: flex; flex-direction: column; gap: 8px; min-height: 160px; max-height: 412px; overflow-y: auto; padding: 6px 3px 8px 0; border: 1px dashed transparent; border-radius: 14px; scrollbar-width: thin; scrollbar-color: #d8d6ef transparent; }
.roster-list.is-drop-target { background: #fff7ed; border-color: #fdba74; }
.student-item { display: flex; align-items: center; gap: 9px; min-height: 54px; padding: 7px 7px 7px 9px; background: #fff; border: 1px solid #efedf6; border-radius: 14px; transition: background .2s, border-color .2s, box-shadow .2s, opacity .2s; }
.student-item:hover, .student-item.is-selected { background: #faf9ff; border-color: #c9c8f2; box-shadow: 0 4px 13px rgba(91,91,214,.09); }
.student-item.is-seated { background: #f3fcf9; border-color: #d7f0ea; }
.student-item.is-dragging { opacity: .42; }
.student-avatar { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; color: var(--purple-dark); background: var(--purple-soft); border-radius: 11px; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 15px; font-weight: 800; }
.student-item.is-seated .student-avatar { color: #278f81; background: var(--teal-soft); }
.student-meta { min-width: 0; flex: 1; }
.student-name { display: block; overflow: hidden; color: var(--ink); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.student-role { display: block; overflow: hidden; color: var(--orange-dark); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.student-seat-status { display: block; color: var(--muted); font-size: 11px; }
.student-item.is-seated .student-seat-status { color: #319788; }
.remove-student { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; color: #6B6588; background: transparent; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) {
  .remove-student { opacity: 0; transition: opacity .2s, color .2s, background .2s; }
  .student-item:hover .remove-student, .student-item:focus-within .remove-student { opacity: 1; }
}
.remove-student:hover { color: #d15e45; background: #fff0ed; }
.remove-student:disabled { cursor: not-allowed; opacity: .35; }
.remove-student svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.roster-empty { padding: 23px 10px; color: var(--muted); text-align: center; }
.roster-empty strong { display: block; margin-bottom: 3px; color: var(--ink); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 16px; }
.full-width { width: 100%; margin-top: 15px; }

.board-panel { min-width: 0; padding: 24px 24px 19px; }
.board-actions { display: flex; align-items: center; gap: 7px; }
.save-button svg { width: 18px; height: 18px; }
.selection-bar { display: flex; align-items: center; gap: 8px; min-height: 0; max-height: 0; margin-top: 0; padding: 0 13px; overflow: hidden; color: var(--purple-dark); background: var(--purple-soft); border-radius: 12px; opacity: 0; transition: max-height .2s, margin .2s, padding .2s, opacity .2s; }
.selection-bar[data-visible="true"] { max-height: 50px; margin-top: 17px; padding-top: 9px; padding-bottom: 9px; opacity: 1; }
.selection-dot { width: 8px; height: 8px; flex: 0 0 8px; background: var(--orange); border-radius: 50%; }
.selection-bar span:not(.selection-dot) { flex: 1; font-size: 12px; }
.selection-bar button { padding: 0; color: var(--purple); background: transparent; font-size: 12px; font-weight: 700; text-decoration: underline; }
.classroom-board { position: relative; margin-top: 20px; padding: 28px 14px 18px; background: #f5f5ff; border: 1px solid #e5e4f6; border-radius: 18px; }
.classroom-board::before { position: absolute; inset: 0; content: ''; pointer-events: none; opacity: .46; background-image: radial-gradient(#d7d6ed .75px, transparent .75px); background-size: 13px 13px; border-radius: inherit; }
.board-edge-label { position: absolute; z-index: 1; color: #a09fbd; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.edge-front { top: 9px; left: 50%; transform: translateX(-50%); }
.zones { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0,1fr) 34px minmax(0,1fr); gap: 13px; align-items: stretch; }
.board-footer-row { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr); gap: 13px; margin-top: 14px; align-items: center; }
.zone { min-width: 0; padding: 12px 11px 13px; background: rgba(255,255,255,.58); border: 1px solid #e7e6f5; border-radius: 15px; }
.zone-heading { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin: 0 1px 12px; }
.zone-title { display: flex; align-items: center; gap: 6px; color: var(--purple-dark); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 14px; font-weight: 800; }
.zone-title::before { width: 8px; height: 8px; content: ''; background: var(--orange); border-radius: 50%; }
.zone-right .zone-title::before { background: var(--teal); }
.zone-meta { color: #9b99b5; font-size: 10px; font-weight: 700; }
.zone-grid { display: grid; grid-template-columns: minmax(var(--desk-col-1-min, 0px), 1fr) minmax(var(--desk-col-2-min, 0px), 1fr) minmax(var(--desk-col-3-min, 0px), 1fr) minmax(var(--desk-col-4-min, 0px), 1fr); min-width: 100%; gap: 10px 8px; }
.desk-wrap { position: relative; min-width: 0; }
.row-label { position: absolute; top: -8px; left: -8px; z-index: 2; display: grid; place-items: center; width: 20px; height: 20px; color: var(--muted); background: #fff; border: 1px solid #e6e4f1; border-radius: 50%; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 9px; font-weight: 800; transform: translate(-50%, -50%); }
.desk { display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; width: 100%; min-height: 92px; padding: 8px 7px 7px; color: var(--muted-deep); background: #fff; border: 1px solid #e5e3ef; border-radius: 16px; box-shadow: 0 3px 0 #dfddec; text-align: left; transition: border-color .2s, box-shadow .2s, background .2s, transform .2s; }
.desk.is-occupied { cursor: grab; }
.desk.is-dragging { opacity: .45; cursor: grabbing; }
.desk-chibi { display: none; align-self: center; width: 28px; height: 28px; margin: 2px 0 4px; color: #fff; background: linear-gradient(180deg, #818CF8, #4F46E5); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 2px 0 #C7D2FE; }
.desk.is-occupied .desk-chibi { display: grid; place-items: center; }
.chibi-face { position: relative; width: 16px; height: 12px; }
.chibi-eye { position: absolute; top: 2px; width: 3px; height: 4px; background: #1E1B4B; border-radius: 50%; }
.chibi-eye:first-child { left: 2px; }
.chibi-eye:nth-child(2) { right: 2px; }
.chibi-blush { position: absolute; top: 6px; width: 3px; height: 2px; background: #FDBA74; border-radius: 50%; opacity: .85; }
.chibi-blush:nth-child(3) { left: 0; }
.chibi-blush:nth-child(4) { right: 0; }
.chibi-smile { position: absolute; left: 5px; bottom: 0; width: 6px; height: 3px; border-bottom: 2px solid #1E1B4B; border-radius: 0 0 8px 8px; }
.desk:hover { border-color: #b6b5eb; box-shadow: 0 4px 0 #c6c4ec; transform: translateY(-1px); }
.desk.is-drop-target { background: #fff8ef; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,143,80,.18), 0 4px 0 #f0b28b; }
.desk.is-occupied { background: #fff9f2; border-color: #ffdcbf; }
.desk.is-selected-seat { background: #f4f2ff; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(91,91,214,.15), 0 4px 0 #c8c7ee; }
.desk-topline { display: flex; align-items: center; justify-content: space-between; gap: 3px; }
.desk-number { color: #a5a3bd; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 10px; font-weight: 800; }
.desk-chair { display: block; width: 13px; height: 9px; margin: 1px auto 5px; border: 1.5px solid #d4d2e4; border-top: 0; border-radius: 0 0 4px 4px; }
.desk.is-occupied .desk-chair { border-color: #f4b07e; }
.desk-student { display: block; min-height: 22px; overflow: visible; color: var(--muted); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 11px; font-weight: 700; line-height: 1.05; text-overflow: clip; white-space: nowrap; }
.desk-student::before { display: inline-block; width: 5px; height: 5px; margin: 0 4px 2px 0; content: ''; background: #d9d7e8; border-radius: 50%; }
.desk.is-occupied .desk-student { color: var(--orange-dark); }
.desk.is-occupied .desk-student::before { background: var(--orange); }
.aisle { position: relative; display: flex; align-items: stretch; justify-content: center; }
.aisle::before { width: 2px; content: ''; background: repeating-linear-gradient(to bottom, #d6d5ed 0 7px, transparent 7px 14px); border-radius: 5px; }
.aisle-label { position: absolute; top: 50%; color: #b0afd0; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 9px; font-weight: 800; letter-spacing: .12em; writing-mode: vertical-rl; transform: translateY(-50%) rotate(180deg); }
.teacher-desk { position: relative; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 120px; height: 35px; min-width: 110px; max-width: 130px; min-height: 35px; max-height: 35px; gap: 5px; padding: 0 6px; color: #5b4a12; background: #ffe08a; border: 1px solid #e1bb43; border-radius: 4px; box-shadow: 0 2px 0 #e6c24a; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 9px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; overflow: hidden; }
.teacher-dot { width: 6px; height: 6px; flex: 0 0 6px; background: #fff; border: 1px solid #d4a017; border-radius: 50%; }

/* Cá»­a ra vÃ o: Ä‘á»‘i diá»‡n bÃªn trÃ¡i bÃ n giÃ¡o viÃªn */
.classroom-door { position: relative; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 120px; height: 35px; min-width: 110px; max-width: 130px; min-height: 35px; max-height: 35px; gap: 6px; padding: 0 8px; color: #0f766e; background: #ccfbf1; border: 1px solid #99f6e4; border-radius: 4px; box-shadow: 0 2px 0 #5eead4; font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 9px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; overflow: hidden; }
.classroom-door svg { width: 15px; height: 15px; flex: 0 0 15px; stroke: currentColor; }

.board-footer-left {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.board-footer-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.board-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 13px 19px; padding: 16px 5px 0; color: var(--muted); font-size: 11px; }
.board-legend > span:not(.board-note) { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.swatch-empty { background: #fff; border: 1px solid #d5d3e3; }
.swatch-filled { background: #ffd9ba; border: 1px solid #f5b27f; }
.swatch-selected { background: #dcdcff; border: 1px solid #9291e0; }
.board-note { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: #9290ad; }
.board-note svg { width: 14px; height: 14px; stroke-width: 1.6; }

.app-footer { display: flex; justify-content: space-between; gap: 20px; padding: 17px 5px 0; color: #aaa8bf; font-size: 11px; }

/* Math Doodles background decorations */
.math-doodle { position: fixed; z-index: 0; color: rgba(79,70,229,.14); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-weight: 800; pointer-events: none; user-select: none; }
.doodle-sigma { top: 29%; left: 1.5%; font-size: 62px; transform: rotate(-17deg); }
.doodle-pi { right: 1.4%; bottom: 9%; font-size: 67px; color: rgba(249,115,22,.16); transform: rotate(15deg); }
.doodle-triangle { top: 4%; right: 21%; width: 37px; color: rgba(20,184,166,.28); transform: rotate(18deg); }
.doodle-flask { right: 3%; top: 52%; width: 37px; color: rgba(79,70,229,.16); transform: rotate(-13deg); }
.doodle-molecule { left: 4%; bottom: 18%; width: 64px; color: rgba(20,184,166,.22); transform: rotate(-12deg); }
.doodle-molecule svg { width: 100%; fill: currentColor; stroke: currentColor; stroke-width: 3; }
.doodle-plus { top: 16%; left: 18%; font-size: 42px; color: rgba(249,115,22,.16); transform: rotate(12deg); }
.doodle-sqrt { bottom: 28%; left: 8%; font-size: 36px; color: rgba(79,70,229,.14); transform: rotate(-8deg); }
.doodle-hex { top: 62%; left: 46%; width: 44px; color: rgba(249,115,22,.12); transform: rotate(22deg); }
.doodle-hex svg { width: 100%; stroke: currentColor; stroke-width: 4; stroke-linejoin: round; }

/* Modal & Toast */
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(35,32,77,.38); backdrop-filter: blur(5px); }
.modal-backdrop[hidden] { display: none; }
.modal-card { position: relative; width: min(100%, 430px); padding: 32px; background: var(--paper); border: 1px solid #e8e5f1; border-radius: 25px; box-shadow: 0 25px 80px rgba(38,34,95,.25); animation: modal-in .22s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-close { position: absolute; top: 16px; right: 16px; }
.modal-sticker { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 15px; color: var(--orange-dark); background: var(--orange-soft); border: 1px solid #ffd6bc; border-radius: 15px; transform: rotate(-7deg); }
.modal-sticker svg { width: 31px; height: 31px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.placement-confirm-card { width: min(100%, 480px); }.placement-sticker { color: #278f81; background: var(--teal-soft); border-color: #cdece5; }.placement-confirm-card > p { max-width: 390px; color: var(--muted-deep); font-size: 15px; line-height: 1.55; }.placement-confirm-card .modal-actions { margin-top: 22px; }
.modal-card h2 { margin-top: 5px; font-size: 30px; }
.modal-card > p { margin-top: 5px; color: var(--muted); font-size: 14px; }
.modal-card form { margin-top: 21px; }
.modal-card label { display: block; margin-bottom: 6px; color: var(--muted-deep); font-family: 'Google Sans Flex', 'Google Sans', sans-serif; font-size: 13px; font-weight: 700; }
.modal-card form > label:not(:first-child) { margin-top: 14px; }
.field-hint { color: var(--muted); font-family: inherit; font-size: 11px; font-weight: 500; }
.modal-card input, .modal-card select { width: 100%; height: 46px; padding: 0 13px; color: var(--ink); background: #faf9ff; border: 1px solid #dddbee; border-radius: 12px; outline: 0; }
.modal-card select { margin-bottom: 16px; font: inherit; cursor: pointer; }
.modal-card input:focus, .modal-card select:focus { background: #fff; border-color: #9796e8; box-shadow: 0 0 0 4px rgba(91,91,214,.1); }
.custom-role-field { margin-top: 0; }
.custom-role-field[hidden] { display: none; }
.modal-card input::placeholder { color: #afadc2; }
.form-error { min-height: 20px; margin-top: 6px; color: #c95d4f; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 9px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(360px, calc(100% - 48px)); padding: 12px 17px; color: #fff; background: #2f2b66; border: 1px solid rgba(255,255,255,.16); border-radius: 13px; box-shadow: 0 12px 35px rgba(45, 42, 100, .25); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .22s, transform .22s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast[data-type="error"] { background: #be564c; }

.app-container { position: relative; width: 100%; min-height: 100vh; }

/* ============================================================
   GIAO DIá»†N DÃ€NH CHO LAPTOP VÃ€ MÃ€N HÃŒNH Vá»ªA (1025px - 1366px)
   - Tá»‘i Æ°u khÃ´ng gian vá»«a váº·n cho mÃ n hÃ¬nh laptop 13-15 inch
   ============================================================ */
@media screen and (min-width: 901px) and (max-width: 1366px) {
  .app-shell {
    width: min(100% - 32px, 1280px);
    padding: 18px 0 20px;
  }

  .hero-row {
    min-height: 200px;
    padding: 16px 2% 12px 0;
  }

  .hero-illustration {
    transform: scale(0.88);
    transform-origin: right center;
  }

  .metric-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(160px, .85fr);
    gap: 12px;
    margin-bottom: 20px;
  }

  .workspace-grid {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
  }

  .roster-panel {
    min-height: 600px;
    padding: 20px 16px 16px;
  }

  .board-panel {
    padding: 20px 20px 16px;
  }

  .classroom-board {
    margin-top: 16px;
    padding: 24px 12px 16px;
  }

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

  .board-footer-row {
    grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    gap: 10px;
    margin-top: 12px;
  }

  .zone {
    padding: 10px 8px 11px;
  }

  .zone-grid {
    gap: 8px 6px;
  }

  .desk {
    min-height: 84px;
    padding: 7px 5px 6px;
  }

  .desk-student {
    font-size: 10.5px;
  }
}

/* ============================================================
   ORIENTATION GUARD (MÃ€N HÃŒNH NHáº®C XOAY NGANG ÄIá»†N THOáº I)
   - Chá»‰ xuáº¥t hiá»‡n khi cáº§m Ä‘iá»‡n thoáº¡i á»Ÿ cháº¿ Ä‘á»™ dá»c (portrait)
   - Tá»± Ä‘á»™ng biáº¿n máº¥t ngay khi ngÆ°á»i dÃ¹ng xoay ngang Ä‘iá»‡n thoáº¡i
   - KhÃ´ng bao giá» xuáº¥t hiá»‡n trÃªn Desktop / PC / Laptop
   ============================================================ */
.orientation-guard {
  display: none;
}

@media screen and (max-width: 900px) and (orientation: portrait) {
  .orientation-guard {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(26, 23, 68, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #fff;
    text-align: center;
  }

  .orientation-guard-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 340px;
    padding: 32px 24px 28px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  }

  .rotate-phone-anim {
    position: relative;
    width: 80px;
    height: 80px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
  }

  .phone-device {
    width: 36px;
    height: 60px;
    background: #4F46E5;
    border: 3px solid #fff;
    border-radius: 9px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.45);
    animation: rotatePhone 2.6s infinite ease-in-out;
    transform-origin: center center;
    position: relative;
  }

  .phone-screen {
    position: absolute;
    inset: 4px;
    background: #EEF2FF;
    border-radius: 5px;
  }

  .phone-notch {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
  }

  .rotate-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: #F97316;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.4);
  }

  .rotate-badge svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
  }

  @keyframes rotatePhone {
    0%, 15% { transform: rotate(0deg); }
    45%, 75% { transform: rotate(90deg); }
    100% { transform: rotate(0deg); }
  }

  .orientation-guard-card h2 {
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    line-height: 1.2;
  }

  .orientation-guard-card p {
    font-size: 13.5px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.82);
    margin: 0 0 20px;
  }

  .guard-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 100px;
    font-family: 'Google Sans Flex', 'Google Sans', sans-serif;
    font-size: 11.5px;
    font-weight: 700;
    color: #ffd29d;
    letter-spacing: 0.05em;
  }
}

/* ============================================================
   GIAO DIá»†N RIÃŠNG DÃ€NH CHO ÄIá»†N THOáº I KHI XOAY NGANG (MOBILE LANDSCAPE)
   - Chá»‰ kÃ­ch hoáº¡t trÃªn thiáº¿t bá»‹ cáº£m á»©ng mÃ n hÃ¬nh nhá» (Touch mobile) khi xoay ngang
   - Tuyá»‡t Ä‘á»‘i khÃ´ng áº£nh hÆ°á»Ÿng Ä‘áº¿n PC / Laptop
   ============================================================ */
@media screen and (max-width: 900px) and (orientation: landscape) and (hover: none),
       screen and (max-height: 500px) and (orientation: landscape) and (hover: none) {
  .orientation-guard {
    display: none !important;
  }

  .app-shell {
    width: calc(100% - 16px);
    max-width: 100%;
    padding: 8px 0 16px;
    margin: 0 auto;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 4px;
  }

  .brand-mark {
    width: 44px;
    height: 38px;
    font-size: 17px;
    border-radius: 12px 12px 12px 4px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .brand-copy small {
    display: none;
  }

  .hero-row {
    min-height: auto;
    padding: 4px 6px 6px;
  }

  .hero-illustration {
    display: none;
  }

  .hero-copy h1 {
    font-size: 20px;
    line-height: 1.1;
    margin-top: 0;
  }

  .hero-copy p {
    display: none;
  }

  .metric-row {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 8px;
    margin-bottom: 8px;
  }

  .metric-card {
    min-height: 40px;
    padding: 4px 10px;
    gap: 6px;
    border-radius: 12px;
  }

  .metric-icon {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .metric-icon svg {
    width: 14px;
    height: 14px;
  }

  .metric-card strong {
    font-size: 15px;
  }

  .hero-action {
    min-height: 40px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 12px;
  }

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

  .roster-panel {
    min-height: auto;
    padding: 10px;
    border-radius: 16px;
  }

  .roster-heading h2 {
    font-size: 18px;
  }

  .roster-list {
    max-height: calc(100vh - 170px);
    min-height: 170px;
  }

  .board-panel {
    padding: 10px 12px;
    border-radius: 16px;
  }

  .board-header h2 {
    font-size: 18px;
  }

  .classroom-board {
    margin-top: 8px;
    padding: 18px 6px 12px;
    border-radius: 14px;
    overflow: visible;
  }

  .zones {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
    gap: 6px;
    align-items: stretch;
  }

  .board-footer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
    gap: 6px;
    margin-top: 8px;
    align-items: center;
  }

  .board-footer-left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

  .classroom-door {
    width: 95px;
    height: 28px;
    min-height: 28px;
    max-height: 28px;
    font-size: 7.5px;
    border-radius: 4px;
    gap: 4px;
  }

  .classroom-door svg {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
  }

  .board-footer-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .aisle {
    display: flex;
  }

  .zone {
    padding: 6px 4px 8px;
  }

  .zone-grid {
    gap: 5px 3px;
  }

  .desk {
    min-height: 60px;
    padding: 4px 3px;
    border-radius: 10px;
  }

  .desk-number {
    font-size: 8.5px;
  }

  .desk-student {
    font-size: 9px;
    min-height: 18px;
  }

  .desk-chibi {
    width: 20px;
    height: 20px;
  }

  .row-label {
    width: 15px;
    height: 15px;
    font-size: 7.5px;
    left: -4px;
  }

  .teacher-desk {
    width: 95px;
    height: 28px;
    min-height: 28px;
    max-height: 28px;
    font-size: 7.5px;
    border-radius: 4px;
  }

  .board-legend {
    gap: 8px 12px;
    padding: 8px 4px 0;
    font-size: 10px;
  }

  .app-footer {
    padding: 10px 4px 14px;
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Keep long student names readable; scroll the classroom board only when needed. */
.classroom-board { overflow-x: auto; }

/* Let each zone grow with its four desk columns; the board scrolls only on narrow screens. */
.zones { width: max-content; min-width: 100%; grid-template-columns: minmax(max-content, 1fr) 34px minmax(max-content, 1fr); }
.zone { min-width: max-content; }
.zone-grid { width: max-content; min-width: 100%; }

@media (max-width: 1366px) and (min-width: 901px) {
  .zones { grid-template-columns: minmax(max-content, 1fr) 28px minmax(max-content, 1fr); }
}

@media (max-width: 900px) and (orientation: landscape) {
  .zones { grid-template-columns: minmax(max-content, 1fr) 22px minmax(max-content, 1fr); }
}

@media (max-width: 620px) {
  .random-link { width: 38px; padding-right: 0; padding-left: 0; }
  .random-link span { display: none; }
}


