:root {
  --ink: #1f2a44;
  --ink-2: #4a5470;
  --muted: #7b8299;
  --bg: #faf6ee;
  --card: #ffffff;
  --line: #e9e3d6;
  --bell: #f2b632;
  --bell-soft: #fdf0cf;
  --coral: #e4572e;
  --ok: #2a9d8f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 68, .06), 0 6px 20px rgba(31, 42, 68, .05);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--sans); color: var(--ink); background: var(--bg); display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 .6em; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.spacer { flex: 1; }

/* ---------- shell ---------- */
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--ink); color: #e8eaf2; padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px var(--serif); text-decoration: none; color: inherit; margin-bottom: 18px; }
.nav p { margin: 18px 10px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8d95b0; }
.nav a { display: block; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: #d5d9e6; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.active { background: var(--bell); color: var(--ink); }
.topbar { display: none; }
main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }

/* ---------- page parts ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--coral); font-weight: 600; margin: 0 0 4px; }
.head-actions, .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { margin-bottom: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack > .card { margin-bottom: 18px; }
.banner { background: var(--bell-soft); border: 1px solid var(--bell); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note { background: var(--bell-soft); padding: 10px 12px; border-radius: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font: 700 26px var(--serif); }
.stat span { color: var(--muted); font-size: 13px; }
.stat-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat-dark span { color: #b8bfd3; }
.small-stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.small-stats .stat b { font-size: 20px; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; padding: 8px 16px; font: 600 14px var(--sans); cursor: pointer; text-decoration: none; background: none; color: var(--ink); white-space: nowrap; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2c3a5e; }
.btn-ghost { border-color: var(--line); background: #fff; }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-warn { background: var(--bell); color: var(--ink); }
.btn-danger { background: #fff; color: #b3261e; border-color: #f0c8c4; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--bell); border-color: var(--bell); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 38px; }
.invalid { border-color: var(--coral); }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field small { color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 6px; margin: 0; }
.field.inline span { margin: 0; }
.field.inline input { width: 70px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.toolbar select, .head-actions select, .head-actions input { width: auto; }
.inline-add { display: flex; gap: 8px; margin-top: 10px; align-items: flex-start; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; }
.seg a { padding: 7px 14px; text-decoration: none; font-weight: 600; font-size: 14px; }
.seg a.on { background: var(--ink); color: #fff; }

/* custom tick */
.tick { position: relative; display: inline-flex; flex: none; }
.tick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.tick span { width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 6px; display: inline-block; }
.tick input:checked + span { background: var(--ok); border-color: var(--ok); }
.tick input:checked + span::after { content: '✓'; color: #fff; font-size: 13px; display: block; text-align: center; line-height: 16px; }
.tick input:focus-visible + span { outline: 2px solid var(--bell); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 2px 10px 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, white); color: color-mix(in srgb, var(--c) 75%, black); }
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); cursor: default; font-family: inherit; }
button.pill { cursor: pointer; }
.res-row { display: flex; gap: 6px; flex-wrap: wrap; }
.res { font-size: 12.5px; text-decoration: none; padding: 1px 8px; border-radius: 6px; background: var(--bell-soft); }

/* ---------- today ---------- */
.schedule { list-style: none; padding: 0; margin: 0; }
.sched-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px 0 12px 12px; border-left: 4px solid var(--c); border-bottom: 1px solid var(--line); }
.sched-row time { font-weight: 700; font-size: 14px; }
.sched-row time small { display: block; font-weight: 400; color: var(--muted); }
.sched-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.sched-break { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 6px 0 6px 16px; color: var(--muted); font-size: 13px; background: repeating-linear-gradient(-45deg, transparent 0 6px, #f4efe4 6px 12px); }
.lesson { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.lesson.done .link, .done > .link, li.done .grow { text-decoration: line-through; color: var(--muted); }
.due { padding: 10px 0; border-bottom: 1px solid var(--line); }
.due:last-child { border: 0; }
.tasklist { list-style: none; padding: 0; margin: 0; }
.tasklist li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.tasklist select { width: 110px; font-size: 12px; padding: 4px; }

/* ---------- week grid ---------- */
.grid-wrap { overflow-x: auto; }
.weekgrid { width: 100%; border-collapse: separate; border-spacing: 4px; min-width: 640px; }
.weekgrid th { font-size: 13px; text-align: left; font-weight: 600; vertical-align: top; padding: 4px; }
.weekgrid th small { display: block; color: var(--muted); font-weight: 400; }
.weekgrid th.is-today { color: var(--coral); }
.weekgrid td { background: var(--bg); border-radius: 8px; padding: 8px; vertical-align: top; font-size: 13px; min-height: 54px; height: 54px; position: relative; }
.weekgrid td.has { background: color-mix(in srgb, var(--c) 12%, white); border-left: 3px solid var(--c); }
.weekgrid tr.brk td { background: none; height: 10px; padding: 0; }
.weekgrid tr.brk th { color: var(--muted); font-weight: 400; }
.cell-lesson { display: block; font-size: 12.5px; margin-top: 2px; }
.cell-lesson.done { color: var(--muted); text-decoration: line-through; }
.add-cell { position: absolute; right: 6px; bottom: 6px; border: 1px dashed var(--ink-2); background: #fff; border-radius: 6px; width: 22px; height: 22px; cursor: pointer; opacity: .5; }
.add-cell:hover { opacity: 1; }
.tt-cell { cursor: pointer; }
.tt-cell:hover { outline: 2px solid var(--bell); }
.tt-cell b, .tt-cell small { display: block; }
.seq { padding-left: 20px; }
.seq li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.seq-date { display: block; font-size: 12px; color: var(--muted); }
.periods { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.periods li { background: var(--bg); padding: 8px 12px; border-radius: 8px; display: flex; flex-direction: column; }

/* ---------- lists ---------- */
.classlist, .rowlist { list-style: none; padding: 0; margin: 0; }
.classlist a, .rowlist a { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 10px; border-radius: 10px; text-decoration: none; }
.classlist a:hover, .rowlist a:hover, .classlist li.on a, .rowlist li.on a { background: var(--bg); }
.classlist .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.classlist a .muted, .rowlist a .muted { width: 100%; }
.roster { columns: 2; padding-left: 22px; }
.roster li { break-inside: avoid; }
.roster li span { margin-right: 4px; }
.checkgrid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.scores { width: 100%; border-collapse: collapse; margin-top: 10px; }
.scores td, .scores th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.scores input[type=number] { width: 90px; }
.units { list-style: none; padding: 0; }
.units li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.log-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-2); }
.empty h3 { font-size: 18px; }

/* ---------- grading bars ---------- */
.bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; height: 220px; align-items: end; padding-top: 20px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-fill { width: 100%; max-width: 64px; background: var(--ink); border-radius: 8px 8px 2px 2px; min-height: 3px; }
.bar.hot .bar-fill { background: var(--coral); }
.bar-val { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.bar-label { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- seating ---------- */
.seating-wrap { overflow-x: auto; background: var(--bg); border-radius: 12px; padding: 12px; }
svg.seating { width: 100%; max-width: 760px; height: auto; display: block; margin: 0 auto; font-family: var(--sans); }
svg.seating .board { fill: var(--ink); }
svg.seating .board-t { fill: #fff; font-size: 10px; letter-spacing: .1em; font-weight: 700; }
svg.seating .table { fill: #e8dcc4; }
svg.seating .desk rect { fill: #fff; stroke: #cfc6b2; stroke-width: 1.5; }
svg.seating .desk.taken rect { fill: #fffaf0; stroke: var(--ink-2); }
svg.seating .desk.sel rect { stroke: var(--coral); stroke-width: 3; }
svg.seating .desk[data-act] { cursor: pointer; }
svg.seating .desk text { font-size: 11px; fill: var(--ink); font-weight: 600; pointer-events: none; }
.unseated { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- sub plan ---------- */
.sp-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--ink); margin-bottom: 14px; padding-bottom: 8px; }
.sp-brand { font: 700 14px var(--serif); color: var(--muted); }
.sp-info { background: var(--bell-soft); padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.sp-table { width: 100%; border-collapse: collapse; }
.sp-table th, .sp-table td { text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); padding: 10px 8px; }
.sp-table td:first-child { width: 110px; white-space: nowrap; }
.sp-table td:nth-child(2) { width: 170px; }
.sp-table tr.brk td { color: var(--muted); background: var(--bg); padding: 4px 8px; }
.sp-table p { margin: 4px 0; }
.sp-class { margin-top: 22px; break-inside: avoid; }
.sp-class svg { max-width: 560px; }

/* ---------- welcome ---------- */
.welcome { max-width: 640px; margin: 30px auto; padding: 32px; }
.choice { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.choice legend { font-weight: 600; margin-bottom: 8px; }
.choice label { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--ink); background: var(--bell-soft); }
.choice small { grid-column: 2; color: var(--muted); }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(31, 42, 68, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-actions { display: flex; gap: 8px; margin-top: 8px; }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; width: max-content; max-width: calc(100% - 32px); }
.toast { transform: translateY(20px); opacity: 0; transition: .25s; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; display: flex; gap: 12px; align-items: center; }
.toast.show { opacity: 1; transform: none; }
.toast .btn { color: #fff; border-color: rgba(255, 255, 255, .3); background: transparent; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .cols { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar .brand { margin: 0; font-size: 18px; }
  .topbar .btn { color: #fff; background: transparent; border-color: rgba(255, 255, 255, .25); }
  main { padding: 18px 16px 60px; }
  h1 { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
  .roster { columns: 1; }
  .bars { gap: 6px; height: 180px; }
}

/* ---------- print (sub plans, seating) ---------- */
@media print {
  body { display: block; background: #fff; font-size: 12px; }
  .sidebar, .topbar, .no-print, .toast, .head-actions, .toolbar { display: none !important; }
  main { padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .seating-wrap { background: none; }
  a { text-decoration: none; }
}

/* ---------- motion ---------- */
@keyframes grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bar-fill { transform-origin: bottom; animation: grow-up .7s cubic-bezier(.2, .8, .2, 1) both; }
.bar:nth-child(2) .bar-fill { animation-delay: .06s; } .bar:nth-child(3) .bar-fill { animation-delay: .12s; }
.bar:nth-child(4) .bar-fill { animation-delay: .18s; } .bar:nth-child(5) .bar-fill { animation-delay: .24s; }
.bar:nth-child(6) .bar-fill { animation-delay: .3s; }
.modal { animation: fade-up .18s ease-out; }
@media (prefers-reduced-motion: reduce) { .bar-fill, .modal { animation: none; } }
