/* Mr Kon Classroom — colourful, friendly, tidy. Works on phones, tablets and computers. */
:root {
  --bg: #f5f4ff; --card: #ffffff; --ink: #1f2440; --muted: #666b8c; --line: #e4e3f6; --soft: #f1f0fb;
  --accent: #5b5bd6; --accent-d: #4444b8; --accent-soft: #e9e8ff;
  --green: #16a34a; --red: #dc2626; --shadow: 0 6px 22px rgba(60, 50, 140, .08);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, "PingFang HK", "Microsoft JhengHei", sans-serif;
}
[data-theme="dark"] {
  --bg: #13152a; --card: #1d2040; --ink: #eef0ff; --muted: #a6abcc; --line: #30345f; --soft: #262a50;
  --accent-soft: #2c2f63; --shadow: 0 6px 22px rgba(0, 0, 0, .35);
}
body[data-page="classroom"] { --accent: #f97316; --accent-d: #d85d08; --accent-soft: #ffeedd; }
body[data-page="homework"] { --accent: #3b82f6; --accent-d: #2563eb; --accent-soft: #e1edff; }
body[data-page="behavior"] { --accent: #ec4899; --accent-d: #d02c7f; --accent-soft: #ffe3f1; }
body[data-page="attendance"] { --accent: #16a34a; --accent-d: #12833c; --accent-soft: #dcf7e6; }
body[data-page="lessons"] { --accent: #0d9488; --accent-d: #0b7a70; --accent-soft: #d6f5f1; }
body[data-page="students"] { --accent: #8b5cf6; --accent-d: #7140e6; --accent-soft: #ece4ff; }
body[data-page="settings"] { --accent: #64748b; --accent-d: #4d5b70; --accent-soft: #e8ecf2; }
[data-theme="dark"] body[data-page] { --accent-soft: #2c2f63; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin: 0; }
h4 { font-size: .95rem; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--accent-d); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ic { display: inline-flex; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; justify-content: center; } .right { text-align: right; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
#side { position: sticky; top: 0; height: 100vh; padding: 18px 14px; background: var(--card); border-right: 2px solid var(--line); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { border-radius: 12px; }
.brand b { display: block; font-size: 1.15rem; line-height: 1.1; } .brand span { color: var(--muted); font-weight: 700; font-size: .9rem; }
#side-nav { display: grid; gap: 6px; }
.side-link { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 14px; background: none; font-weight: 700; text-align: left; min-height: 48px; }
.side-link:hover { background: var(--soft); }
.side-link.on { background: var(--accent-soft); }
.nav-ic { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: #fff; flex: none; }
.n-home { background: #5b5bd6; } .n-classroom { background: #f97316; } .n-homework { background: #3b82f6; } .n-behavior { background: #ec4899; }
.n-attendance { background: #16a34a; } .n-lessons { background: #0d9488; } .n-students { background: #8b5cf6; } .n-settings { background: #64748b; }

#top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 22px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 2px solid var(--line); }
#title { display: flex; align-items: center; gap: 10px; flex: none; } #title h1 { font-size: 1.35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#classes { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; padding: 4px 2px; scrollbar-width: none; } #classes::-webkit-scrollbar { display: none; }
.class-chip { flex: none; padding: 7px 14px; min-height: 40px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font-weight: 800; }
.class-chip::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cc); margin-right: 7px; }
.class-chip.on { background: var(--cc); border-color: var(--cc); color: #fff; } .class-chip.on::before { background: #fff; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.status { font-size: .82rem; font-weight: 700; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.status.ok { background: #dcf7e6; color: #11703a; } .status.busy { background: #fff0c2; color: #7a5300; } .status.warn { background: #ffe1d6; color: #a23b12; }
#page { padding: 22px; padding-bottom: 40px; max-width: 1240px; margin: 0 auto; }
#tabs { display: none; }

.stack { display: grid; gap: 16px; min-width: 0; } .stack.center { justify-items: center; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; } .row.end { justify-content: flex-end; } .row.center { justify-content: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tip { color: var(--muted); font-size: .9rem; }

/* ---------- pieces ---------- */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; } .card-head h3 { font-size: 1.1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-weight: 800; box-shadow: 0 3px 0 var(--line); transition: transform .06s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-d); }
.btn.danger { background: #fff; border-color: #f3b4b4; color: #c21f1f; box-shadow: 0 3px 0 #f3b4b4; } [data-theme="dark"] .btn.danger { background: #3a1d2a; color: #ffb4b4; border-color: #7a3040; box-shadow: none; }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.mini { min-height: 36px; padding: 4px 12px; border-radius: 12px; font-size: .9rem; box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--soft); color: var(--ink); }
.link { border: 0; background: none; color: var(--accent-d); font-weight: 700; padding: 6px; text-decoration: underline; } [data-theme="dark"] .link { color: #c9c6ff; }
.input { width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 16px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar .input[type="search"] { width: 220px; max-width: 100%; margin-left: auto; }
textarea.input { resize: vertical; }
.field { display: grid; gap: 5px; } .field-label { font-weight: 800; font-size: .9rem; } .hint { color: var(--muted); font-size: .8rem; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 700; min-height: 40px; } .checkline input { width: 22px; height: 22px; accent-color: var(--accent); }
.cols { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; color: var(--muted); } .cols select { width: auto; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.c-green { background: #dcf7e6; color: #11703a; } .c-orange { background: #ffe6d2; color: #9a4208; } .c-red { background: #ffe0e0; color: #b01e1e; }
.c-blue { background: #e1edff; color: #1d4fc4; } .c-yellow { background: #fff0c2; color: #7a5300; } .c-teal { background: #d6f5f1; color: #0a6b62; } .c-purple { background: #ece4ff; color: #5a2fd0; }

.face { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-size: 24px; line-height: 1; flex: none; }
.face.sm { width: 34px; height: 34px; font-size: 19px; } .face.lg { width: 58px; height: 58px; font-size: 32px; }
.face.xl { width: 76px; height: 76px; font-size: 42px; } .face.xxl { width: 150px; height: 150px; font-size: 84px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed var(--line); } .list li:last-child { border-bottom: 0; }
.list .icon-btn { margin-left: auto; width: 34px; height: 34px; } .medal { font-size: 1.4rem; }

.empty { text-align: center; padding: 34px 16px; display: grid; gap: 10px; justify-items: center; }
.empty-emoji { font-size: 56px; line-height: 1; } .empty p { color: var(--muted); max-width: 420px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tiles.small { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 2px; text-align: left; padding: 16px; border: 0; border-radius: 20px; color: #fff; box-shadow: var(--shadow); }
.tile b { font-size: 2rem; line-height: 1.1; } .tile span { font-weight: 700; font-size: .9rem; }
.tiles.small .tile { padding: 10px; text-align: center; } .tiles.small .tile b { font-size: 1.4rem; } .tiles.small .tile span { font-size: .75rem; }
.t-purple { background: linear-gradient(135deg, #8b5cf6, #6d42e0); } .t-yellow { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #45300a; }
.t-blue { background: linear-gradient(135deg, #4f95ff, #2f6fe8); } .t-green { background: linear-gradient(135deg, #2fc468, #16a34a); } .t-orange { background: linear-gradient(135deg, #ff9a52, #f97316); }

.hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 24px; border-radius: 26px; color: #fff; background: linear-gradient(120deg, #5b5bd6 0%, #8b5cf6 55%, #ec4899 110%); box-shadow: var(--shadow); }
.hero h1 { font-size: 1.8rem; } .hero p { opacity: .92; font-weight: 700; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero .btn { background: rgba(255, 255, 255, .95); border-color: transparent; color: #2a2460; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }

/* ---------- classroom ---------- */
.goal { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 14px 18px; display: grid; gap: 8px; }
.goal-text { display: flex; justify-content: space-between; gap: 10px; font-size: 1.05rem; } .goal-text span { color: var(--muted); font-weight: 700; }
.bar { height: 16px; border-radius: 999px; background: var(--soft); overflow: hidden; } .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #fbbf24, #f97316); transition: width .4s; }
.bar.thin { height: 8px; } .bar.thin i { background: var(--accent); }
.board { text-align: center; padding: 8px; border-radius: 12px; background: #1f2a56; color: #dfe6ff; font-weight: 700; font-size: .85rem; letter-spacing: .04em; }
.seats { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 12px; }
.seat { position: relative; display: grid; justify-items: center; gap: 6px; padding: 14px 6px 12px; border-radius: 20px; border: 2px solid var(--line); background: var(--card); box-shadow: 0 4px 0 var(--line); cursor: pointer; user-select: none; -webkit-user-select: none; min-width: 0; }
.seat:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.seat-no { position: absolute; top: 8px; left: 10px; font-size: .78rem; font-weight: 800; color: var(--muted); }
.seat-more { position: absolute; top: 2px; right: 2px; width: 40px; height: 40px; border: 0; border-radius: 12px; background: none; color: var(--muted); display: grid; place-items: center; }
.seat-name { font-weight: 800; font-size: .95rem; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.seat-stars, .seat-tag { font-size: .85rem; font-weight: 800; padding: 2px 10px; border-radius: 999px; background: #fff0c2; color: #7a5300; }
.seat-stars.zero { background: var(--soft); color: var(--muted); } .seat-tag { background: var(--soft); color: var(--muted); } .seat-tag.bath { background: #e1edff; color: #1d4fc4; }
.seat.away { opacity: .5; } .seat.away .face { filter: grayscale(1); }
.seat.chosen { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.seat.arranging { border-style: dashed; }
.seat.pop .face { animation: pop .45s; } .seat.pop .seat-stars { animation: pop .45s .08s; }
@keyframes pop { 40% { transform: scale(1.35) rotate(-6deg); } 100% { transform: scale(1); } }
.sheet-top { display: flex; align-items: center; gap: 14px; } .sheet-top div { display: grid; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { min-height: 42px; padding: 6px 14px; border-radius: 999px; border: 2px solid; font-weight: 800; background: var(--card); }
.tag.pos { border-color: #9be3b5; color: #11703a; } .tag.neg { border-color: #ffc59a; color: #9a4208; }
[data-theme="dark"] .tag.pos { color: #9bf0b9; } [data-theme="dark"] .tag.neg { color: #ffc59a; }
.tag.pos.on { background: #16a34a; border-color: #16a34a; color: #fff; } .tag.neg.on { background: #f97316; border-color: #f97316; color: #fff; }
.pick-stage { display: grid; justify-items: center; gap: 10px; min-height: 230px; align-content: center; }
.pick-name { font-size: 1.6rem; font-weight: 900; text-align: center; } .pick-stage.final .face { animation: pop .6s; } .pick-stage.final .pick-name { font-size: 2.2rem; color: var(--accent-d); }
[data-theme="dark"] .pick-stage.final .pick-name { color: #ffd27a; }
.timer-face { font-size: clamp(64px, 20vw, 120px); font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; padding: 10px 0; }
.timer-face.done { color: #dc2626; animation: pop .6s 3; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.group { display: grid; gap: 6px; padding: 12px; border-radius: 16px; border: 2px solid var(--gc); border-top-width: 8px; background: var(--card); } .group span { display: flex; align-items: center; gap: 8px; font-weight: 700; }

/* ---------- tables, homework, attendance ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; } .table th { text-align: left; font-size: .8rem; color: var(--muted); padding: 6px 8px; white-space: nowrap; }
.table td { padding: 8px; border-top: 1px solid var(--line); vertical-align: middle; } .table tbody tr[data-name] { cursor: pointer; } .table tbody tr[data-name]:hover { background: var(--soft); }
.who { display: flex; align-items: center; gap: 10px; min-width: 130px; } .who div { display: grid; } .who small { color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 40px; padding: 5px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-weight: 800; font-size: .88rem; color: var(--muted); }
.seg.big button { min-height: 48px; font-size: 1rem; padding: 8px 18px; }
.seg .on { color: #fff; } .seg-submitted.on, .seg-present.on { background: #16a34a; border-color: #16a34a; } .seg-missing.on, .seg-absent.on { background: #dc2626; border-color: #dc2626; }
.seg-late.on { background: #f59e0b; border-color: #f59e0b; color: #3d2a00; } .seg-excused.on, .seg-leave.on { background: #8b5cf6; border-color: #8b5cf6; } .seg-sick.on { background: #3b82f6; border-color: #3b82f6; }
.input.score { width: 84px; text-align: center; }
.att-extra { display: grid; gap: 4px; min-width: 180px; }
.hw { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.hw-list { display: grid; gap: 10px; }
.hw-item { display: grid; gap: 5px; text-align: left; padding: 12px 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); } .hw-item.on { border-color: var(--accent); background: var(--accent-soft); } .hw-item small { color: var(--muted); font-weight: 700; }
.pickers { display: flex; flex-wrap: wrap; gap: 8px; }
.picker { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 5px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); font-weight: 700; }
.picker.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.lessons { display: grid; gap: 10px; }
.lesson { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; align-items: start; text-align: left; padding: 14px; border-radius: 16px; border: 2px solid var(--line); border-left: 8px solid var(--accent); background: var(--card); }
.lesson-date { display: grid; } .lesson-date span { color: var(--muted); font-size: .85rem; } .lesson-main { display: grid; gap: 3px; } .lesson-main p { white-space: pre-line; font-size: .92rem; }
.class-cards { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 8px; }
.class-card { flex: none; width: 168px; display: grid; gap: 2px; text-align: left; padding: 14px; border-radius: 20px; border: 2px solid var(--line); border-top: 10px solid var(--cc); background: var(--card); box-shadow: var(--shadow); }
.class-card b { font-size: 1.15rem; } .class-card span { color: var(--muted); font-weight: 700; min-height: 1.4em; } .class-card small { font-weight: 800; }
.class-card.on { border-color: var(--cc); } .class-card.add { place-items: center; text-align: center; border: 2px dashed var(--line); color: var(--muted); box-shadow: none; }
.swatches, .faces { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; } .swatches .on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--card) inset; }
.faces button { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 22px; } .faces .on { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- pop-ups, toasts, confetti ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(20, 18, 50, .5); animation: fade .15s; }
.modal { width: 100%; max-width: 540px; max-height: 92vh; display: flex; flex-direction: column; background: var(--card); border-radius: 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: rise .2s; }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 8px; } .modal-head h2 { font-size: 1.25rem; }
.modal-body { padding: 8px 18px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ask-text { margin-bottom: 16px; }
.more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.more-item { display: grid; justify-items: center; gap: 8px; padding: 16px; border-radius: 18px; border: 2px solid var(--line); background: var(--card); font-weight: 800; } .more-item .nav-ic { width: 48px; height: 48px; border-radius: 16px; }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { transform: translateY(16px) scale(.98); opacity: 0; } }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 999px; background: #1f2440; color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: rise .2s; transition: opacity .3s; max-width: 100%; }
.toast.warn { background: #a23b12; } .toast.bye { opacity: 0; }
.toast button { border: 0; border-radius: 999px; padding: 6px 12px; min-height: 34px; background: #fbbf24; color: #3d2a00; font-weight: 800; }
.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(40px); } }

/* ---------- sign-in ---------- */
#login { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; overflow: auto; background: linear-gradient(135deg, #5b5bd6, #8b5cf6 50%, #ec4899); }
.blob { position: absolute; border-radius: 50%; opacity: .35; animation: float 9s ease-in-out infinite alternate; }
.b1 { width: 260px; height: 260px; background: #ffc93c; top: -60px; left: -60px; } .b2 { width: 200px; height: 200px; background: #5eead4; bottom: -40px; right: 8%; animation-delay: -3s; } .b3 { width: 120px; height: 120px; background: #ff8a3d; top: 16%; right: -30px; animation-delay: -6s; }
@keyframes float { to { transform: translate(20px, 26px) scale(1.08); } }
#login-form { position: relative; width: 100%; max-width: 400px; }
#login-card { display: grid; gap: 12px; justify-items: stretch; text-align: center; padding: 30px 26px; border-radius: 30px; background: #fff; color: #1f2440; box-shadow: 0 24px 70px rgba(30, 10, 90, .35); }
#login-card img { margin: 0 auto; border-radius: 22px; } #login-card h1 { font-size: 1.7rem; } #login-card p { color: #666b8c; }
#login-card label { text-align: left; font-weight: 800; font-size: .9rem; margin-top: 6px; }
#login-card input { min-height: 52px; padding: 10px 14px; border-radius: 16px; border: 2px solid #e4e3f6; font-size: 17px; background: #fff; color: #1f2440; }
#login-card input:focus { outline: none; border-color: #5b5bd6; box-shadow: 0 0 0 4px #e9e8ff; }
#login-btn { min-height: 54px; border: 0; border-radius: 16px; background: #5b5bd6; color: #fff; font-weight: 900; font-size: 1.1rem; box-shadow: 0 4px 0 #4444b8; }
#login-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4444b8; } #login-btn:disabled { opacity: .55; }
#login-msg { min-height: 1.4em; color: #c21f1f; font-weight: 700; }
.shake { animation: shake .35s; } @keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- tablets ---------- */
@media (max-width: 1100px) {
  #app { grid-template-columns: 76px minmax(0, 1fr); }
  #side { padding: 14px 8px; } .brand div, .side-link .nav-label { display: none; } .brand { justify-content: center; padding: 4px 0 14px; } .side-link { justify-content: center; padding: 8px 0; }
  .hw { grid-template-columns: 230px minmax(0, 1fr); }
}
/* ---------- phones ---------- */
@media (max-width: 720px) {
  #app { display: block; } #side { display: none; }
  #top { flex-wrap: wrap; gap: 8px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
  #title { flex: 1; min-width: 0; } #title h1 { font-size: 1.15rem; } #title .nav-ic { width: 32px; height: 32px; }
  .top-right { margin-left: auto; } #classes { order: 3; flex-basis: 100%; }
  .status { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  #page { padding: 14px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  #tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 2px solid var(--line); }
  .tab { display: grid; justify-items: center; gap: 2px; border: 0; background: none; padding: 4px 0; min-height: 54px; font-size: .68rem; font-weight: 800; color: var(--muted); }
  .tab .nav-ic { width: 34px; height: 30px; border-radius: 11px; opacity: .55; } .tab.on { color: var(--ink); } .tab.on .nav-ic { opacity: 1; transform: translateY(-2px) scale(1.08); }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .grid2, .hw { grid-template-columns: minmax(0, 1fr); } .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tiles.small { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 18px; } .hero h1 { font-size: 1.45rem; } .hero-actions .btn { flex: 1 1 44%; }
  .card { padding: 14px; border-radius: 18px; }
  .seats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .seat .face.lg { width: 48px; height: 48px; font-size: 27px; } .seat-name { font-size: .85rem; }
  .hw-list { grid-auto-flow: column; grid-auto-columns: 210px; overflow-x: auto; padding-bottom: 6px; } .hw-list > .btn { align-self: stretch; }
  .hide-sm { display: none; } .toolbar .input[type="search"] { width: 100%; margin-left: 0; }
  .lesson { grid-template-columns: minmax(0, 1fr); } .table td { padding: 8px 4px; } .who { min-width: 0; }
  .modal-wrap { place-items: end center; padding: 0; } .modal, .modal.wide { max-width: none; border-radius: 26px 26px 0 0; max-height: 90vh; } .modal-body { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .seg button { padding: 5px 9px; font-size: .82rem; }
}
/* Homework and attendance rows stack neatly on narrow phones */
@media (max-width: 560px) {
  .table.table thead { display: none; }
  .table tbody tr:not([data-name]) { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
  .table tbody tr:not([data-name]) td { border: 0; padding: 0 2px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } .confetti { display: none; } }
/* ---------- printable reports ---------- */
#print { display: none; }
html.preview-print #print { display: block; background: #fff; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff !important; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; }
}
.report { color: #111; background: #fff; font-size: 11pt; display: grid; gap: 12px; page-break-after: always; break-after: page; }
.report:last-child { page-break-after: auto; break-after: auto; }
.rp-head { display: flex; align-items: center; gap: 14px; padding-bottom: 10px; border-bottom: 3px solid #5b5bd6; }
.rp-face { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; font-size: 30px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.rp-head h1 { font-size: 20pt; } .rp-head p { color: #444; font-weight: 700; }
.rp-meta { margin-left: auto; text-align: right; display: grid; } .rp-meta span { color: #444; font-size: 9.5pt; }
.rp-boxes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.rp-box { display: grid; text-align: center; padding: 8px 2px; border: 1.5px solid #bbb; border-radius: 10px; } .rp-box b { font-size: 15pt; } .rp-box span { font-size: 7.5pt; color: #444; }
.report h2 { font-size: 12pt; margin-bottom: 4px; color: #33308f; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 10pt; } .rp-table th { text-align: left; border-bottom: 1.5px solid #888; padding: 3px 6px; font-size: 9pt; }
.rp-table td { border-bottom: 1px solid #ddd; padding: 3px 6px; vertical-align: top; } .rp-table tr { page-break-inside: avoid; break-inside: avoid; }
.rp-none { color: #555; font-style: italic; }
.rp-comment { min-height: 78px; border: 1.5px solid #bbb; border-radius: 10px; padding: 8px 10px; white-space: pre-line; }
.rp-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 26px; page-break-inside: avoid; break-inside: avoid; } .rp-sign span { border-top: 1.5px solid #555; padding-top: 4px; font-size: 9pt; color: #444; }
[data-theme="dark"] a { color: #c9c6ff; }
/* ---------- scan handbook ---------- */
.scan-thumb { max-width: 100%; max-height: 260px; border-radius: 14px; border: 2px solid var(--line); object-fit: contain; }
.scan-check { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.scan-check .scan-thumb { max-height: 420px; position: sticky; top: 0; }
.scan-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px; border: 2px solid var(--line); border-radius: 16px; }
.scan-row > input[type="checkbox"] { width: 24px; height: 24px; margin-top: 10px; accent-color: var(--accent); }
.stack.tight { gap: 8px; }
.scan-error { color: #c21f1f; font-weight: 700; } [data-theme="dark"] .scan-error { color: #ffb4b4; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 720px) { .scan-check { grid-template-columns: minmax(0, 1fr); } .scan-check .scan-thumb { max-height: 200px; position: static; justify-self: center; } }
/* ---------- subjects ---------- */
.subject-bar { display: flex; }
.hw-item .chip, .lesson-main .chip { justify-self: start; }
