/* FKA TimeMaster — design system */
:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f6f8fc; --line: #e3e7f0; --line-2: #d4dae6;
  --ink: #0f172a; --ink-2: #4b5870; --ink-3: #8a96ac;
  --brand: #3b4fd8; --brand-2: #2f40b8; --brand-soft: #eceffe; --accent: #f5a524;
  --ok: #15803d; --warn: #b45309; --bad: #dc2626;
  --r: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -14px rgba(15, 23, 42, .22);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #0a0f1d; --surface: #111829; --surface-2: #0e1525; --line: #1e2840; --line-2: #2a3654;
    --ink: #e8edf7; --ink-2: #a7b2c9; --ink-3: #6c7a97; --brand: #7d8cff; --brand-2: #96a2ff; --brand-soft: #1a2248;
    --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #0a0f1d; --surface: #111829; --surface-2: #0e1525; --line: #1e2840; --line-2: #2a3654;
  --ink: #e8edf7; --ink-2: #a7b2c9; --ink-3: #6c7a97; --brand: #7d8cff; --brand-2: #96a2ff; --brand-soft: #1a2248;
  --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { letter-spacing: -.015em; }
.ic { flex: none; display: inline-block; vertical-align: middle; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); } .small { font-size: 13px; } .xs { font-size: 12px; }
.pre { white-space: pre-line; margin: 0; }
.row { display: flex; align-items: center; } .gap { gap: 10px; } .gap-s { gap: 6px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; } .mb { margin-bottom: 14px; } .mt { margin-top: 14px; } .r { text-align: right; white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.bad-t { color: var(--bad); } .ok-t { color: var(--ok); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 650; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; height: 46px; font-size: 15px; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent; cursor: pointer; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--bad); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.req { color: var(--bad); }
.input { height: 42px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 11px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; min-width: 0; }
select.input { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a96ac' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea.input { height: auto; padding: 10px 12px; min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.input.invalid { border-color: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 14%, transparent); }
.input.sm-input { height: 36px; font-size: 14px; }
.search { position: relative; } .search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; } .search .input { padding-left: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.hint { font-size: 12.5px; color: var(--ink-3); }
.switch { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.switch input { opacity: 0; position: absolute; inset: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sw { width: 30px; height: 30px; border-radius: 9px; border: 2px solid transparent; background: var(--c); cursor: pointer; }
.sw.on { border-color: var(--surface); box-shadow: 0 0 0 2px var(--c); }
.sw-input { width: 36px; height: 32px; border: 1px solid var(--line-2); border-radius: 9px; padding: 2px; background: var(--surface); cursor: pointer; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2, h2.sec { font-size: 16px; margin: 0 0 12px; }
.card-sub { font-size: 13px; color: var(--ink-2); margin: -8px 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line-2); font-size: 13px; font-weight: 650; white-space: nowrap; cursor: pointer; color: var(--ink-2); flex: none; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .cnt { font-size: 11.5px; opacity: .7; font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
button.badge { cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; }
.badge.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.badge.bad { background: color-mix(in srgb, var(--bad) 11%, transparent); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.badge.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #999); flex: none; display: inline-block; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 9px; font-weight: 650; font-size: 13.5px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 13px; color: #fff; background: var(--c, var(--brand)); flex: none; letter-spacing: .02em; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.empty { text-align: center; padding: 44px 16px; color: var(--ink-2); }
.empty .em-ic { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--brand-soft); color: var(--brand); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 360px; font-size: 14px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-size: 14px; }
.notice .ic { color: var(--brand); margin-top: 2px; }
.notice.warn { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); } .notice.warn .ic { color: var(--warn); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 750; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl .mono, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.tbl.alloc td { padding: 8px 12px; }

.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s var(--ease); }
.meter.warn i { background: var(--warn); } .meter.bad i { background: var(--bad); } .meter.ok i { background: var(--ok); }
.load-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 28, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; opacity: 0; transition: opacity .18s; }
.modal-back.in { opacity: 1; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 540px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); transform: translateY(10px); transition: transform .22s var(--ease); border: 1px solid var(--line); }
.modal-back.in .modal { transform: none; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 8px 20px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 6px 20px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  .modal-back { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { border-radius: 20px 20px 0 0; max-width: none; max-height: 92vh; max-height: 92dvh; transform: translateY(40px); }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}

/* Toast */
.toasts { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; gap: 9px; align-items: center; background: #151c2f; color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .45); animation: tin .25s var(--ease); transition: opacity .3s, transform .3s; }
.toast.bad { background: #b91c1c; } .toast.ok { background: #14532d; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
body.viewer .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }

.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); z-index: 150; display: grid; place-items: center; }
.overlay-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px 30px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow); text-align: center; }
.engine-spin { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 8px; animation: pulseIc 1.2s ease-in-out infinite; }
@keyframes pulseIc { 50% { transform: scale(1.06); } }

/* ---------- Admin shell ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; z-index: 60; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 16px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(140deg, var(--brand), #6d4fe0); display: grid; place-items: center; color: #fff; flex: none; }
.brand b { display: block; font-size: 15px; line-height: 1.2; } .brand small { color: var(--ink-3); font-size: 12px; font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-sec { font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 650; font-size: 14px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav a .cnt { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 700; }
.nav a .alert-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.side-foot { border-top: 1px solid var(--line); padding: 12px 4px 0; display: flex; align-items: center; gap: 10px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: 62px; padding: 0 22px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .crumb { font-weight: 750; font-size: 16px; }
.menu-btn { display: none; }
.view { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; }
.page-head p { margin: 4px 0 0; }
.side-scrim { display: none; }
.save-state { font-size: 13px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pub-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
.demo-pill { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--warn); }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 284px; transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
  .side.open { transform: none; }
  .side.open + .side-scrim { display: block; position: fixed; inset: 0; background: rgba(8, 12, 28, .4); z-index: 55; }
  .menu-btn { display: inline-grid; }
  .view { padding: 16px; }
  .topbar { padding: 0 10px 0 6px; height: 58px; }
  .page-head h1 { font-size: 22px; }
  .hide-sm { display: none !important; }
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.stat .k { font-size: 11.5px; font-weight: 750; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 15px; font-weight: 700; }
.stat .s { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; } }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.checklist li.error .ic { color: var(--bad); } .checklist li.warn .ic { color: var(--warn); } .checklist li.ok .ic { color: var(--ok); }

/* Teacher cards */
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; display: flex; flex-direction: column; gap: 12px; text-align: left; width: 100%; font: inherit; color: inherit; }
.tcard:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); box-shadow: var(--shadow); transform: translateY(-1px); }
.tcard.left { opacity: .62; }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.schip { font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 7px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: color-mix(in srgb, var(--c) 70%, var(--ink)); border: 1px solid color-mix(in srgb, var(--c) 26%, transparent); white-space: nowrap; }

.ugrid { display: grid; gap: 4px; margin-top: 6px; }
.ugrid button { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12px; font-weight: 750; cursor: pointer; color: var(--ink-3); }
.ugrid button.off { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.ugrid .lab { font-size: 12px; font-weight: 750; color: var(--ink-2); }
.ugrid button.lab { background: transparent; border-color: transparent; color: var(--ink-2); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.stepper button:hover { color: var(--ink); background: var(--line); }
.stepper b { min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; }

/* Bell builder */
.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-item { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); }
.tl-item.break { background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 7px, var(--surface) 7px, var(--surface) 14px); border-style: dashed; }
.tl-item .t { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 13px; }
.tl-item .mini { width: 72px; height: 34px; text-align: center; padding: 0 6px; }
.brk-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 96px 38px; gap: 8px; align-items: end; margin-top: 8px; }
@media (max-width: 520px) { .brk-row { grid-template-columns: minmax(0, 1fr) 92px 74px 38px; } }

/* ---------- Timetable grid ---------- */
.tt-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); -webkit-overflow-scrolling: touch; }
table.tt { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 760px; table-layout: fixed; }
.tt th { font-size: 11px; color: var(--ink-3); font-weight: 700; padding: 6px 2px 4px; text-align: center; }
.tt th b { display: block; color: var(--ink-2); font-size: 12px; }
.tt th small { font-weight: 600; font-variant-numeric: tabular-nums; }
.tt th.corner, .tt th.dayh { width: 52px; }
.tt th.dayh { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; font-size: 13px; color: var(--ink); padding: 0 6px; font-weight: 750; }
.tt tr.today th.dayh { color: var(--brand); }
.tt th.brk-h { width: 24px; }
.tt td { height: 64px; padding: 0; vertical-align: top; }
.tt td.brk { width: 24px; background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 6px, transparent 6px, transparent 12px); border-radius: 8px; vertical-align: middle; text-align: center; }
.tt td.brk span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 10.5px; font-weight: 750; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.cell { display: flex; flex-direction: column; justify-content: center; height: 100%; min-height: 64px; width: 100%; padding: 6px 8px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 11%, var(--surface)); text-align: left; position: relative; overflow: hidden; color: var(--ink); font: inherit; margin: 0; }
.cell b { font-size: 12.5px; line-height: 1.2; color: color-mix(in srgb, var(--c) 68%, var(--ink)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell small { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cell.empty { --c: var(--line); background: transparent; border: 1.5px dashed var(--line-2); color: var(--ink-3); font-size: 12px; align-items: center; font-weight: 650; }
button.cell { cursor: pointer; }
button.cell:hover { box-shadow: 0 4px 12px -4px rgba(0, 0, 0, .18); }
.cell .lk { position: absolute; top: 4px; right: 4px; color: var(--ink-3); }
.cell.sel { outline: 3px solid var(--brand); outline-offset: 1px; z-index: 1; }
.cell.tgt-ok { box-shadow: inset 0 0 0 2px var(--ok); }
.cell.tgt-ok.empty { background: color-mix(in srgb, var(--ok) 9%, transparent); border-color: var(--ok); color: var(--ok); }
.cell.tgt-bad { box-shadow: inset 0 0 0 2px var(--warn); }
.cell.tgt-bad.empty { border-color: var(--warn); }
.cell.tgt-no { opacity: .35; }
.cell.clash { box-shadow: inset 0 0 0 2px var(--bad); }
.cell.clash::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.cell.now { box-shadow: 0 0 0 3px var(--accent); }
.tt.compact td { height: 50px; } .tt.compact .cell { min-height: 50px; padding: 4px 6px; }
table.master { min-width: 900px; }
.master th.cname { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; font-size: 13px; color: var(--ink); width: 86px; padding: 0 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.actbar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111827; color: #f8fafc; border-radius: 16px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 8px; z-index: 40; box-shadow: 0 20px 50px -10px rgba(0, 0, 0, .45); width: max-content; max-width: calc(100vw - 20px); animation: tin .2s var(--ease); }
.actbar .info { font-size: 13px; line-height: 1.3; min-width: 0; }
.actbar .info span { opacity: .7; }
.actbar .btn { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .22); }
.actbar .btn:hover { background: rgba(255, 255, 255, .08); }
.engine-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.dirtybar { position: sticky; bottom: 14px; margin-top: 16px; background: #111827; color: #f8fafc; border-radius: 14px; padding: 10px 10px 10px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 14px 40px -12px rgba(0, 0, 0, .45); z-index: 20; flex-wrap: wrap; }
.dirtybar .btn { background: transparent; color: inherit; border-color: rgba(255, 255, 255, .25); }
.dirtybar .btn.primary { background: #fff; color: #111827; border-color: #fff; }
.rem-list { display: flex; flex-direction: column; gap: 6px; }
.rem-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; border-left: 4px solid var(--c); }
.pick:hover { border-color: var(--c); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; } .kv dt { color: var(--ink-3); font-weight: 650; } .kv dd { margin: 0; }
.check-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.check-list label:last-child { border-bottom: 0; }
.check-list input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art { background: radial-gradient(120% 80% at 0% 0%, rgba(255, 255, 255, .14), transparent 55%), linear-gradient(150deg, #1b2470 0%, #3b4fd8 55%, #6d4fe0 100%); color: #fff; padding: 44px 52px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.auth-art .brand b, .auth-art .brand small { color: #fff; } .auth-art .brand small { opacity: .75; }
.auth-art .brand-mark { background: rgba(255, 255, 255, .16); }
.auth-art h1 { font-size: 46px; line-height: 1.04; letter-spacing: -.035em; margin: 0 0 14px; max-width: 520px; }
.auth-art p { font-size: 16.5px; opacity: .85; max-width: 440px; margin: 0; }
.mock-tt { display: grid; grid-template-columns: 34px repeat(6, 1fr); gap: 6px; max-width: 460px; }
.mock-tt i { height: 34px; border-radius: 8px; background: rgba(255, 255, 255, .1); font-style: normal; font-size: 10px; font-weight: 800; display: grid; place-items: center; letter-spacing: .04em; }
.mock-tt i.d { background: transparent; opacity: .7; }
.mock-tt i.f { background: var(--mc); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.auth-points { display: flex; flex-wrap: wrap; gap: 18px; font-size: 14px; font-weight: 600; opacity: .92; }
.auth-points span { display: inline-flex; align-items: center; gap: 8px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 26px; margin: 0 0 4px; }
.roles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 18px; }
.role { border: 1.5px solid var(--line-2); background: var(--surface); border-radius: 14px; padding: 12px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--ink-2); transition: border-color .15s, background .15s, color .15s; }
.role:hover { border-color: var(--ink-3); }
.role.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.pw-wrap { position: relative; } .pw-wrap .input { padding-right: 46px; } .pw-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }
.demo-box { margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.form-err { color: var(--bad); font-size: 13.5px; font-weight: 600; min-height: 20px; margin: 8px 0 0; }
@media (max-width: 880px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 22px 20px 24px; gap: 14px; }
  .auth-art h1 { font-size: 28px; margin-bottom: 6px; }
  .auth-art p { font-size: 14.5px; }
  .mock-tt, .auth-points { display: none; }
  .auth-form { align-items: flex-start; padding: 24px 18px 40px; }
}

/* ---------- Viewer portals ---------- */
body.viewer { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.app-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.app-bar .in { max-width: 880px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.app-bar .who { min-width: 0; flex: 1; } .app-bar .who b { display: block; font-size: 15px; line-height: 1.25; } .app-bar .who small { color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.vwrap { max-width: 880px; margin: 0 auto; padding: 16px; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav .in { display: flex; max-width: 520px; margin: 0 auto; }
.bottom-nav button { flex: 1; border: 0; background: transparent; padding: 10px 0 11px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 750; color: var(--ink-3); cursor: pointer; }
.bottom-nav button.on { color: var(--brand); }
.daybar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(58px, 1fr); gap: 6px; margin: 2px 0 14px; overflow-x: auto; padding-bottom: 2px; }
.daybtn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 14px; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; font-weight: 750; font-size: 14px; color: var(--ink); }
.daybtn small { font-size: 11.5px; color: var(--ink-3); font-weight: 650; }
.daybtn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.daybtn.on small { color: rgba(255, 255, 255, .82); }
.daybtn.today:not(.on) { border-color: var(--brand); color: var(--brand); }
.hero { --hc: var(--brand); border-radius: 22px; padding: 20px; color: #fff; background: linear-gradient(135deg, var(--hc), color-mix(in srgb, var(--hc) 58%, #0b1020)); margin-bottom: 16px; position: relative; overflow: hidden; box-shadow: 0 18px 40px -20px color-mix(in srgb, var(--hc) 80%, transparent); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.hero.calm { --hc: #334155; }
.hero .lab { font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; opacity: .88; display: flex; align-items: center; gap: 8px; }
.hero .ttl { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; line-height: 1.12; position: relative; }
.hero .sub { opacity: .92; font-weight: 600; font-size: 14.5px; position: relative; }
.hero .bar { height: 6px; background: rgba(255, 255, 255, .25); border-radius: 99px; margin-top: 14px; overflow: hidden; position: relative; }
.hero .bar i { display: block; height: 100%; background: #fff; border-radius: 99px; }
.hero .next { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .22); font-size: 14px; display: flex; gap: 8px; align-items: center; position: relative; }
.live { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .7); } 100% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); } }
.tl { display: flex; flex-direction: column; gap: 8px; }
.tl-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; align-items: stretch; }
.tl-time { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px; padding-top: 11px; text-align: right; }
.tl-time small { display: block; font-weight: 600; color: var(--ink-3); font-size: 12px; }
.tl-card { border-radius: 16px; padding: 11px 14px; background: color-mix(in srgb, var(--c) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 24%, transparent); border-left: 5px solid var(--c); display: flex; align-items: center; gap: 12px; min-height: 64px; min-width: 0; }
.tl-card .sb { width: 42px; height: 42px; border-radius: 12px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12.5px; flex: none; letter-spacing: .02em; }
.tl-card b { display: block; font-size: 15px; line-height: 1.25; }
.tl-card small { color: var(--ink-2); font-size: 13px; }
.tl-row.break .tl-time { padding-top: 7px; }
.tl-row.break .tl-card { --c: var(--ink-3); background: transparent; border: 1.5px dashed var(--line-2); min-height: 38px; padding: 7px 14px; color: var(--ink-2); font-weight: 700; font-size: 13px; gap: 8px; }
.tl-row.free .tl-card { --c: var(--line-2); background: var(--surface); border-style: dashed; color: var(--ink-3); font-weight: 650; }
.tl-row.past { opacity: .5; }
.tl-row.now .tl-card { box-shadow: 0 0 0 3px var(--accent), 0 10px 24px -14px rgba(0, 0, 0, .35); }
.nowpill { margin-left: auto; background: var(--accent); color: #1a1205; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; letter-spacing: .05em; flex: none; }
.kids { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.kid { display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 6px; border-radius: 99px; border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 700; flex: none; color: var(--ink); text-align: left; }
.kid small { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 650; }
.kid .avatar { width: 34px; height: 34px; font-size: 12px; }
.kid.on { border-color: var(--brand); background: var(--brand-soft); }
.daybars { display: grid; grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); gap: 8px; align-items: end; height: 90px; margin-top: 8px; }
.daybars div { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.daybars i { width: 100%; max-width: 34px; border-radius: 7px 7px 3px 3px; background: var(--brand); display: block; min-height: 4px; }
.menu-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.menu-list button, .menu-list a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-weight: 650; cursor: pointer; text-align: left; text-decoration: none; color: var(--ink); font-size: 15px; }
.menu-list > :last-child { border-bottom: 0; }
.menu-list .ic.chev { margin-left: auto; color: var(--ink-3); }
.menu-list .danger { color: var(--bad); }

/* Student theme: brighter and friendlier */
body.role-student { --brand: #0284c7; --brand-2: #0369a1; --accent: #facc15; }
body.role-student .hero { border-radius: 26px; }
body.role-student .tl-card { border-radius: 18px; }
body.role-parent { --brand: #0f766e; --brand-2: #115e59; }
@media (prefers-color-scheme: light) { body.role-student { --bg: #f0f8ff; --brand-soft: #e0f2fe; } body.role-parent { --brand-soft: #e6f6f4; } }
@media (prefers-color-scheme: dark) { body.role-student { --brand: #38bdf8; } body.role-parent { --brand: #2dd4bf; } }

/* Skeleton */
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* Print */
.print-only { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; color: #000; padding: 0 !important; }
  body.printing .shell, body.printing .app-bar, body.printing .vwrap, body.printing .bottom-nav { display: none !important; }
  .no-print, .toasts, .actbar, .bottom-nav, .app-bar, .topbar, .side { display: none !important; }
  .print-only { display: block !important; }
  .print-page { page-break-after: always; break-after: page; }
  .print-page:last-child { page-break-after: auto; }
  .print-page h2 { margin: 0 0 2px; font-size: 18px; }
  .print-page p { margin: 0 0 8px; font-size: 12px; color: #444; }
  .tt-scroll { border: 0; overflow: visible; }
  table.tt { min-width: 0; border-spacing: 2px; }
  .tt td { height: 46px; }
  .cell { min-height: 46px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tt td.brk { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.spinning .ic { animation: spin .8s linear infinite; }
.cell .code { display: none; }
@media (max-width: 640px) {
  table.tt { min-width: 560px; border-spacing: 3px; }
  .tt td { height: 54px; } .cell { min-height: 54px; padding: 5px 6px; border-left-width: 3px; }
  .cell .full { display: none; } .cell .code { display: inline; font-size: 13px; letter-spacing: .02em; }
  .cell small { font-size: 11px; }
  .tt th.corner, .tt th.dayh { width: 40px; } .tt th.dayh { font-size: 12px; padding: 0 4px; }
  .tt th.brk-h, .tt td.brk { width: 18px; }
  table.master { min-width: 640px; } .master th.cname { width: 64px; font-size: 12px; }
}
@media print { .cell .full { display: inline !important; } .cell .code { display: none !important; } }
.modal h2 { font-size: 15px; }
@media (max-width: 640px) {
  .tbl.alloc thead { display: none; }
  .tbl.alloc tr { display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "s s s d" "t t t t" "p x . ."; gap: 8px 14px; padding: 12px; border-bottom: 1px solid var(--line); align-items: center; }
  .tbl.alloc tr:last-child { border-bottom: 0; }
  .tbl.alloc td { padding: 0; border: 0; }
  .tbl.alloc td:nth-child(1) { grid-area: s; } .tbl.alloc td:nth-child(2) { grid-area: t; } .tbl.alloc td:nth-child(3) { grid-area: p; } .tbl.alloc td:nth-child(4) { grid-area: x; } .tbl.alloc td:nth-child(5) { grid-area: d; }
  .tbl.alloc td:nth-child(3)::before { content: "Periods / week"; display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 4px; }
  .tbl.alloc td:nth-child(4)::before { content: "Double"; display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-3); margin-bottom: 4px; }
  .tbl.alloc tbody tr:hover td { background: transparent; }
}

/* ---------- Messaging ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat-host { container-type: inline-size; }
.chat { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); height: 100%; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 0; gap: 10px; }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.chat-list-head h2 { margin: 0; font-size: 18px; }
.chat-seg { width: 100%; } .chat-seg button { flex: 1; }
.chat-items { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 10px; margin: 0 -4px; }
.chat-item { display: flex; gap: 11px; align-items: center; width: 100%; border: 0; background: transparent; padding: 10px; border-radius: 12px; cursor: pointer; text-align: left; color: var(--ink); font: inherit; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.on { background: var(--brand-soft); }
.chat-item .avatar { width: 44px; height: 44px; }
.avatar.grp { color: #fff; }
.ci-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ci-top, .ci-bot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ci-title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.ci-time { font-size: 12px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.ci-prev { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink-2); }
.ci-prev b { font-weight: 650; }
.ci-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; }
.chat-item.unread .ci-title { font-weight: 800; } .chat-item.unread .ci-prev { color: var(--ink); } .chat-item.unread .ci-time { color: var(--brand); font-weight: 700; }
.chat-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface-2); }
.th-empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-3); text-align: center; padding: 20px; }
.th-empty b { color: var(--ink-2); }
.th-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); min-height: 62px; }
.th-head .avatar { width: 40px; height: 40px; }
.th-title b { display: block; font-size: 15px; } .th-title small { display: block; color: var(--ink-3); font-size: 12.5px; font-weight: 600; }
.th-back { display: none; }
.th-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.th-loading { margin: auto; color: var(--ink-3); }
.th-more { display: flex; justify-content: center; margin-bottom: 8px; }
.th-hello { margin: auto; color: var(--ink-3); font-size: 14px; text-align: center; padding: 20px; }
.th-day { display: flex; justify-content: center; margin: 12px 0 8px; }
.th-day span { font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); padding: 3px 11px; border-radius: 99px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: min(78%, 560px); margin-top: 8px; }
.msg.cont { margin-top: 0; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-name { font-size: 12px; font-weight: 750; color: color-mix(in srgb, var(--c) 75%, var(--ink)); margin: 0 0 3px 12px; }
.bubble { position: relative; padding: 8px 12px 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(15, 23, 42, .04); }
.msg:not(.mine) .bubble { border-top-left-radius: 6px; } .msg.cont:not(.mine) .bubble { border-top-left-radius: 16px; }
.msg.mine .bubble { background: var(--brand); border-color: var(--brand); color: #fff; border-top-right-radius: 6px; }
.msg.mine.cont .bubble { border-top-right-radius: 16px; }
.bubble a { color: inherit; text-decoration: underline; }
.bubble[role=button] { cursor: pointer; }
.bubble.del { font-style: italic; color: var(--ink-3); background: transparent; display: inline-flex; align-items: center; gap: 5px; }
.msg.mine .bubble.del { color: var(--ink-3); background: transparent; border-color: var(--line-2); }
.bubble.failed { opacity: .65; }
.msg-time { display: inline-block; font-size: 11px; margin-left: 10px; opacity: .65; vertical-align: bottom; font-variant-numeric: tabular-nums; white-space: nowrap; float: right; margin-top: 6px; line-height: 1; }
.xs-spin { width: 10px; height: 10px; border-width: 1.5px; display: inline-block; vertical-align: middle; }
.th-foot { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 12px; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { min-height: 44px; height: 44px; max-height: 140px; resize: none; padding: 11px 14px; border-radius: 22px; line-height: 1.4; }
.send-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send-btn:hover { background: var(--brand-2); }
.th-note { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink-2); padding: 4px 2px; }
.ct-list { display: flex; flex-direction: column; }
.ct-sec { font-size: 11.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); padding: 12px 4px 6px; }
.ct-row { display: flex; align-items: center; gap: 11px; padding: 9px 6px; border-radius: 10px; cursor: pointer; min-width: 0; }
.ct-row:hover { background: var(--surface-2); }
.ct-row b { display: block; font-size: 14.5px; } .ct-row small { display: block; color: var(--ink-3); font-size: 12.5px; }
.ct-row input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.check-list .ct-row { border-bottom: 1px solid var(--line); border-radius: 0; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; }
.bn-badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.bottom-nav button { position: relative; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; flex: none; }
.live-dot.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.live-dot.connecting { background: var(--warn); } .live-dot.error { background: var(--bad); }
@container (max-width: 700px) {
  .chat { grid-template-columns: minmax(0, 1fr); border-radius: 0; border-left: 0; border-right: 0; }
  .chat-list { border-right: 0; }
  .chat.has-active .chat-list { display: none; }
  .chat:not(.has-active) .chat-thread { display: none; }
  .th-back { display: inline-grid; margin-left: -6px; }
  .msg { max-width: 86%; }
}
/* Admin: chat fills the content area */
.view.chat-view { max-width: none; padding: 16px 24px; height: calc(100dvh - 62px); display: flex; flex-direction: column; }
.view.chat-view .chat-host { flex: 1; min-height: 0; }
@media (max-width: 980px) { .view.chat-view { padding: 0; height: calc(100dvh - 58px); } }
/* Viewer portals: chat fills the screen between the app bar and the bottom nav */
.vwrap.chat-view { max-width: 980px; padding: 0; }
.vwrap.chat-view .chat-host { height: calc(100dvh - 63px - 66px - env(safe-area-inset-bottom)); }
@media (min-width: 720px) { .vwrap.chat-view { padding: 16px; } .vwrap.chat-view .chat-host { height: calc(100dvh - 63px - 66px - 32px - env(safe-area-inset-bottom)); } }
/* Setup checklist */
.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.setup-steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.setup-steps .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.setup-steps li.done .num { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup-steps li.next { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.setup-steps li.next .num { background: var(--brand); border-color: var(--brand); color: #fff; }
.setup-steps b { display: block; font-size: 14.5px; } .setup-steps small { color: var(--ink-2); font-size: 13px; }
.ver { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cell.off { --c: transparent; background: repeating-linear-gradient(-45deg, transparent, transparent 5px, color-mix(in srgb, var(--line) 70%, transparent) 5px, color-mix(in srgb, var(--line) 70%, transparent) 6px); border: 1px dashed var(--line); }
.tt td.off-brk { background: transparent; }
/* School day editor */
.bell-head, .bell-row { display: grid; grid-template-columns: 26px minmax(140px, 1.4fr) 136px 136px 60px minmax(210px, auto) 108px; gap: 8px; align-items: center; }
.bell-head { font-size: 11.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px; }
.bell-rows { display: flex; flex-direction: column; gap: 6px; }
.bell-row { padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.bell-row.break { background: repeating-linear-gradient(-45deg, var(--surface-2), var(--surface-2) 7px, var(--surface) 7px, var(--surface) 14px); border-style: dashed; }
.bell-row .field { gap: 0; }
.bell-row .input { padding: 0 8px; }
.bell-kind { color: var(--ink-3); display: grid; place-items: center; }
.bell-row.lesson .bell-kind { color: var(--brand); }
.bell-len { font-size: 12.5px; color: var(--ink-2); text-align: right; }
.bell-days { display: flex; gap: 3px; flex-wrap: wrap; }
.dchip { min-width: 30px; height: 30px; padding: 0 4px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-3); font-size: 11.5px; font-weight: 800; cursor: pointer; }
.dchip.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, transparent); color: var(--brand); }
.bell-acts { display: flex; justify-content: flex-end; }
.bell-acts .icon-btn { width: 34px; height: 34px; }
.bell-acts .icon-btn:nth-child(1) .ic, .bell-acts .icon-btn:nth-child(2) .ic { transform: rotate(90deg); }
.bell-acts .icon-btn[disabled] { opacity: .3; pointer-events: none; }
.bell-gap { font-size: 12px; color: var(--warn); font-weight: 700; padding: 0 12px; }
details.card summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
details.card summary::-webkit-details-marker { display: none; }
.ugrid .na { background: repeating-linear-gradient(-45deg, transparent, transparent 4px, var(--line) 4px, var(--line) 5px); border-radius: 8px; }
@media (max-width: 1180px) {
  .bell-head { display: none; }
  .bell-row { grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "k n n a" ". s e l" ". d d d"; row-gap: 8px; }
  .bell-kind { grid-area: k; } .bell-name { grid-area: n; } .bell-row .field:nth-of-type(2) { grid-area: s; } .bell-row .field:nth-of-type(3) { grid-area: e; }
  .bell-len { grid-area: l; } .bell-days { grid-area: d; } .bell-acts { grid-area: a; }
}
.sd-top { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.sd-top h2 { margin-bottom: 10px; }
@media (max-width: 1100px) { .sd-top { grid-template-columns: 1fr; } }
.sd-top > * { min-width: 0; }
.sd-top .kv dd { overflow-wrap: anywhere; }
.sd-top .chips { flex-wrap: wrap; overflow: visible; }
@media (max-width: 1180px) {
  .bell-row { grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) auto; grid-template-areas: "k n n a" "s s e e" "d d d l"; }
  .bell-row input[type=time] { min-width: 0; width: 100%; }
}
@media (max-width: 600px) { .kv { grid-template-columns: 110px minmax(0, 1fr); } }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; font-weight: 650; }
.seg button .ic { margin-right: 2px; vertical-align: -3px; }
.upd-list { margin: 0 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.chg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chg-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.chg-list .when { display: block; font-weight: 700; font-size: 12px; color: var(--ink-2); margin-bottom: 1px; }
.chg-list .what { display: block; font-weight: 650; color: var(--ink); }
.chg-list li { align-items: center; }
.chg-list .tag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 99px; flex: none; }
.chg-list .tag.new { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chg-list .tag.gone { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.chg-list .tag.mod { background: var(--brand-soft); color: var(--brand); }
.chg-kid { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 10px 0 4px; }
.spinning .ic { animation: spin .8s linear infinite; }
body.noscroll .toasts { bottom: auto; top: calc(14px + env(safe-area-inset-top)); }
.daybars { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* ---------- Press feedback and button states ---------- */
.btn, .icon-btn, .chip, .seg button, .daybtn, .bottom-nav button, .role, .kid, .pick, .chat-item, .dchip, .tcard, .menu-list button, .send-btn, .sw {
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .15s, filter .15s, opacity .15s;
}
.btn:active:not([disabled]), .icon-btn:active:not([disabled]), .chip:active, .seg button:active, .daybtn:active, .role:active, .kid:active, .pick:active, .dchip:active, .send-btn:active, .menu-list button:active { transform: scale(.96); filter: brightness(.94); }
.bottom-nav button:active { transform: scale(.92); }
.tcard:active, .chat-item:active { transform: scale(.99); }
.btn:focus-visible, .icon-btn:focus-visible { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }
.btn.is-busy, .icon-btn.is-busy { opacity: 1; cursor: progress; pointer-events: none; }
.btn.primary.is-busy { background: color-mix(in srgb, var(--brand) 82%, #000); }
.btn.is-done { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn[disabled]:not(.is-busy) { opacity: .5; }
.seg button.on, .chip.on, .dchip.on { transition: background .2s, color .2s; }
.icon-btn .spin { width: 16px; height: 16px; }

/* ---------- Refresh overlay ---------- */
.refresh-overlay { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; background: color-mix(in srgb, #0b1020 55%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; transition: opacity .2s; }
.refresh-overlay.in { opacity: 1; }
.refresh-box { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 26px 30px; min-width: 220px; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5); }
.refresh-icon .ring { display: block; width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.refresh-icon .ok, .refresh-icon .bad { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; animation: popIn .35s var(--ease); }
.refresh-icon .ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.refresh-icon .bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.refresh-msg { font-size: 16px; } .refresh-sub { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }

/* ---------- Update pill (drops in from the top) ---------- */
.upd-pop { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, -160%); z-index: 350; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 8px 8px 8px 16px; border-radius: 99px; background: #111a3a; color: #fff; box-shadow: 0 14px 36px -10px rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .14); transition: transform .45s cubic-bezier(.2, 1.2, .3, 1); }
.upd-pop.show { transform: translate(-50%, 0); }
.upd-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.upd-txt b { font-size: 14px; white-space: nowrap; } .upd-txt small { font-size: 11.5px; opacity: .75; }
.upd-pop button { border: 0; cursor: pointer; font: inherit; font-weight: 750; font-size: 13px; border-radius: 99px; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; white-space: nowrap; }
.upd-more { background: transparent; color: #c7d2fe; }
.upd-go { background: #fff; color: #111a3a; }
.upd-x { background: transparent; color: #fff; width: 34px; padding: 0 !important; justify-content: center; opacity: .75; }
@media (max-width: 480px) { .upd-more { display: none !important; } .upd-txt small { display: none; } }

/* ---------- Confirmation pop ---------- */
.pop-done { position: fixed; inset: 0; z-index: 380; display: grid; place-items: center; pointer-events: auto; background: transparent; }
.pop-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px 28px; min-width: 220px; max-width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; box-shadow: 0 26px 70px -18px rgba(0, 0, 0, .45); transform: scale(.85); opacity: 0; transition: transform .25s var(--ease), opacity .2s; }
.pop-done.in .pop-card { transform: none; opacity: 1; }
.pop-tick { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; margin-bottom: 4px; }
.pop-card b { font-size: 16.5px; } .pop-card span { color: var(--ink-2); font-size: 13.5px; }
.ver-tag { font-size: 11px; font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }

/* ---------- Fit every screen without zooming (as in the FKA Student portal) ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: manipulation; overflow-x: hidden; }
img, svg, video { max-width: 100%; }
@media (max-width: 640px) {
  /* inputs at 16px so phones never zoom in when typing */
  .input, select.input, textarea.input, .composer textarea { font-size: 16px; }
  /* the week timetable shrinks to the screen instead of scrolling sideways */
  .tt-scroll { overflow-x: visible; border-radius: 12px; }
  table.tt, table.tt.master { min-width: 0; width: 100%; border-spacing: 2px; table-layout: fixed; }
  .tt th { font-size: 9.5px; padding: 4px 0 3px; letter-spacing: -.01em; }
  .tt th b { font-size: 10.5px; }
  .tt th small { font-size: 8.5px; display: block; white-space: nowrap; overflow: hidden; }
  .tt th.corner, .tt th.dayh { width: 30px; }
  .tt th.dayh { font-size: 11px; padding: 0 2px; }
  .master th.cname { width: 46px; font-size: 10.5px; padding: 0 2px; white-space: normal; line-height: 1.15; }
  .tt th.brk-h, .tt td.brk { width: 9px; padding: 0; }
  .tt td.brk span { display: none; }
  .tt td { height: 46px; }
  .cell, .tt.compact .cell { min-height: 46px; padding: 3px 2px; border-radius: 7px; border-left-width: 3px; align-items: center; text-align: center; }
  .cell b { font-size: 10.5px; letter-spacing: -.01em; -webkit-line-clamp: 1; }
  .cell .code { font-size: 10.5px; }
  .cell small { font-size: 8.5px; margin-top: 1px; max-width: 100%; }
  .cell.empty { font-size: 9px; }
  .cell .lk { top: 1px; right: 1px; }
  .cell .lk .ic { width: 9px; height: 9px; }
  .cell.clash::after { top: 2px; right: 2px; width: 6px; height: 6px; }
  /* tables scroll inside their own card, never the page */
  .table-wrap { max-width: 100%; }
  .page-head .row.gap.wrap { width: 100%; }
}
@media (max-width: 360px) {
  .cell small { display: none; }
  .tt th small { display: none; }
}
.topbar .crumb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar > .grow { min-width: 0; }
@media (max-width: 420px) {
  .topbar { gap: 4px; padding-right: 8px; }
  #pubBtn span { display: none; }
  #pubBtn { padding: 0 11px; }
  .topbar .crumb { font-size: 15px; }
}
/* the week grid always fits its container; cells share the width */
table.tt, table.tt.master { min-width: 0 !important; width: 100%; table-layout: fixed; }
@media (min-width: 641px) and (max-width: 1100px) {
  .tt th.corner, .tt th.dayh { width: 40px; }
  .tt th.brk-h, .tt td.brk { width: 16px; }
  .tt td.brk span { font-size: 9px; }
  .cell { padding: 5px 5px; border-left-width: 3px; }
  .cell b { font-size: 11.5px; }
  .cell small { font-size: 10.5px; }
  .master th.cname { width: 64px; font-size: 12px; }
}
.schip { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
.tgrid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }

/* 12-hour times in the week header: am/pm drops under the time on narrow screens instead of being cut off */
table.tt thead small .ap { font-style: normal; }
@media (max-width: 640px) { table.tt thead small .ap { display: block; line-height: 1.1; } }
