
:root {
  color-scheme: light;
  --bg: #f4f6fa; --paper: #fff; --ink: #1a2540; --muted: #56637b;
  --line: #dce3ef; --soft: #ecf1ff; --accent: #283eb9; --dark: #172450;
  font: 15px/1.5 "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .52; cursor: wait; }
:focus-visible { outline: 3px solid #5672f2; outline-offset: 3px; }
[hidden] { display: none !important; }
.top { background: var(--dark); color: white; }
.top-inner, main { max-width: 1512px; margin: auto; padding-inline: clamp(16px, 3.5vw, 52px); }
.top-inner { min-height: 76px; display: flex; gap: 16px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding-block: 14px; }
.brand { display: flex; gap: 12px; align-items: center; font-size: 19px; font-weight: 800; }
.brand-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: #4058cc; }
.brand-icon span { width: 17px; height: 17px; border: 2px solid white; border-radius: 3px; border-top-width: 5px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid #cfd8e9; background: var(--paper); color: var(--ink); border-radius: 8px; padding: 8px 13px; font-weight: 700; min-height: 40px; white-space: nowrap; }
.btn:hover { background: var(--soft); color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: #20339b; color: white; }
.top .btn { border-color: #6070a1; color: white; background: #293963; }
.top .btn:hover { background: #4058cc; }
.top .primary { border-color: #657cf7; background: #455dd5; }
.status { color: #e1e8ff; font-size: 13px; }
.status::before { content: "●"; margin-right: 6px; color: #f6d080; }
.status.connected::before { color: #8ee3b8; }
main { padding-block: 25px 38px; }
.banner { background: #ecf1ff; border: 1px solid #d6e0fa; color: #263966; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.teachers { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
.teacher { border: 1px solid var(--line); background: #fff; color: #3c4b67; border-radius: 8px; padding: 9px 14px; font-weight: 700; }
.teacher:hover { background: var(--soft); }
.teacher[aria-pressed="true"] { color: white; background: var(--accent); border-color: var(--accent); }
.add-teacher { border-style: dashed; color: var(--accent); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 8px 28px #15264c08; overflow: hidden; }
.heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 20px 22px 14px; gap: 12px; }
h1, h2 { margin: 0; line-height: 1.28; letter-spacing: -.035em; }
h1 { font-size: clamp(23px, 3vw, 32px); }
h2 { font-size: 22px; }
.meta { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.table-options { padding: 0 22px 12px; justify-content: flex-end; }
.date { padding: 6px 8px; color: var(--ink); background: white; border: 1px solid #cfd8e9; border-radius: 7px; min-height: 38px; }
.weekend { font-size: 13px; color: var(--muted); white-space: nowrap; }
.weekend input { accent-color: var(--accent); vertical-align: middle; }
.table-wrap { overflow: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; min-width: 760px; }
table.seven { min-width: 1000px; }
th, td { border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
th:last-child, td:last-child { border-right: 0; }
thead th { padding: 11px 5px; background: #e9eef8; text-align: center; }
.time { width: 118px; background: #f1f4f9; text-align: center; }
thead .time, thead .note { background: #e5ebf5; }
.note { width: 108px; }
td { padding: 0; vertical-align: top; }
tr:nth-child(even) td { background: #fbfcff; }
.cell { color: var(--ink); border: 0; background: transparent; width: 100%; min-height: 62px; display: flex; flex-wrap: wrap; align-content: center; align-items: center; justify-content: center; gap: 4px; padding: 8px 5px; }
.cell:hover { background: var(--soft); }
.cell .empty { color: #667899; font-size: 19px; line-height: 1; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 5px; padding: 2px 5px; background: #e9efff; color: #243985; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.chip.mid { background: #e3f5ef; color: #145c4b; }
.chip.high { background: #f0e8ff; color: #59368b; }
.chip.graduated { background: #edf0f4; color: #475365; }
.chip small { font-size: 10px; font-weight: 700; }
.note .cell { font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tip { padding: 11px 22px; color: var(--muted); border-top: 1px solid var(--line); font-size: 13px; margin: 0; }
dialog { color: var(--ink); width: min(580px, calc(100vw - 24px)); max-height: 90vh; border: 1px solid #ced7eb; border-radius: 16px; padding: 0; box-shadow: 0 22px 90px #111a4b45; }
dialog::backdrop { background: #10193280; }
.dialog-inner { padding: 20px; }
.dialog-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.dialog-close { min-width: 38px; min-height: 36px; padding: 2px 9px; font-size: 21px; line-height: 1; }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.field { display: grid; gap: 5px; margin-block: 10px; font-weight: 700; }
.field input, .field select, .field textarea, .search { min-width: 0; width: 100%; padding: 8px 10px; border: 1px solid #cfd8e9; border-radius: 7px; color: var(--ink); background: white; font-weight: 500; }
.searchbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.searchbar .search { flex: 1 1 140px; width: auto; }
.list { max-height: min(40vh, 350px); overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.result { display: flex; align-items: center; gap: 9px; padding: 7px 10px; min-height: 37px; }
.result + .result { border-top: 1px solid #edf0f6; }
.result:hover { background: #f5f7fe; }
.result input { width: 17px; height: 17px; accent-color: var(--accent); }
.result .grow { flex: 1; }
.result .stage-label { color: var(--muted); font-size: 12px; }
.result .btn { min-height: 31px; padding: 3px 9px; font-size: 12px; }
.empty-result { margin: 0; padding: 18px 12px; color: var(--muted); }
.time-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.time-row .field { margin-block: 4px; font-size: 13px; }
.time-row .btn { margin-bottom: 4px; }
.danger { color: #9a292d; }
.danger:hover { color: #9a292d; background: #fff0f0; border-color: #efb6b8; }
.danger-primary { background: #a12732; color: #fff; border-color: #a12732; }
.danger-primary:hover { background: #811c26; color: #fff; }
.delete-details { margin: 6px 0 0; padding: 12px 14px; background: #fcefee; color: #69222b; border-radius: 8px; }
.roster-dialog { width: min(1160px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.roster-dialog .dialog-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.roster-dialog .dialog-top, .roster-dialog .dialog-foot { flex: none; }
.roster-dialog #dialog-body { display: flex; flex-direction: column; min-height: 0; }
.roster-dialog .searchbar { flex: none; justify-content: flex-start; }
.roster-dialog .searchbar .search { flex: 0 1 290px; }
.roster-dialog .roster-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 315px), 1fr));
  gap: 5px; padding: 5px; max-height: none; scrollbar-gutter: stable;
  background: #f4f6fb; overscroll-behavior: contain;
}
.roster-grid .result {
  min-height: 42px; padding: 4px 6px 4px 10px; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 7px;
}
.roster-grid .result:hover, .roster-grid .result:focus-within { border-color: #aebee3; }
.roster-grid .grow { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.roster-grid .stage-label { flex: none; padding: 2px 6px; font-size: 12px; }
.roster-grid .btn { padding-inline: 7px; }
.roster-grid .empty-result { grid-column: 1 / -1; }
.roster-dialog .dialog-foot { align-items: center; }
.roster-results { margin: 0 auto 0 0; }
.assignment-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
  gap: 10px; align-items: start; min-height: 0; overflow: auto;
  scrollbar-gutter: stable; overscroll-behavior: contain; padding: 2px 3px 4px;
}
.assignment-card { border: 1px solid var(--line); border-radius: 10px; min-width: 0; overflow: hidden; }
.assignment-head {
  display: flex; gap: 8px; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f1f4fb;
}
.assignment-head h3 { font-size: 16px; margin: 0; line-height: 1.35; overflow-wrap: anywhere; }
.assignment-head .meta { margin-top: 3px; overflow-wrap: anywhere; }
.assignment-head .btn { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.assignment-names { margin: 0; padding: 10px 12px; list-style: none; display: flex; flex-wrap: wrap; gap: 5px; }
.assignment-names li {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px 2px 7px;
  border: 1px solid #e1e7f1; border-radius: 6px; background: #fbfcff;
  color: var(--ink); font-size: 13px; font-weight: 700; overflow-wrap: anywhere;
}
.assignment-names .chip { flex: none; padding: 1px 4px; font-size: 11px; }
.assignment-empty { margin: 0; padding: 11px 12px; color: var(--muted); font-size: 13px; }
.assignment-grid > .assignment-empty { grid-column: 1 / -1; }
.assignment-tools { display: flex; flex: none; gap: 8px 12px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.assignment-tools .search { flex: 0 1 300px; }
.assignment-tools .meta { margin: 0; }
.review-list { overflow: auto; min-height: 0; display: grid; gap: 10px; overscroll-behavior: contain; }
.review-group { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.review-group h3 { margin: 0; padding: 9px 12px; background: #f1f4fb; font-size: 15px; }
.review-rows { list-style: none; padding: 0; margin: 0; }
.review-rows li { padding: 7px 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.review-rows li + li { border-top: 1px solid var(--line); }
.review-rows .btn { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.review-rows .meta { margin: 0; }
.review-rows .review-label { flex: 1; min-width: 165px; }
.review-chips { padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.review-chips .btn { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.review-callout { background: #fdf0ee; border-radius: 8px; padding: 10px 12px; color: #792e36; }
.backup-select { min-width: 0; }
.backup-select select { width: 100%; }
.message { color: #9a292d; margin: 8px 0 0; font-weight: 700; font-size: 13px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); width: max-content; border-radius: 9px; padding: 10px 15px; color: #fff; background: #172450; z-index: 3; }
@media (max-width: 700px) {
  .heading, .table-options { padding-inline: 12px; }
  .tip { padding-inline: 12px; }
  .status { display: none; }
}
@media (max-width: 480px) {
  .roster-dialog { width: calc(100vw - 16px); }
  .roster-dialog .dialog-inner { padding: 12px; }
  .roster-dialog .searchbar .search { flex: 1 0 100%; }
  .roster-results { flex-basis: 100%; }
  .assignment-tools .search { flex: 1 0 100%; }
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body, main { background: white; padding: 0; }
  .top, .banner, .teachers, .heading .actions, .table-options, .tip, dialog, .toast, .empty { display: none !important; }
  .card { border: 0; box-shadow: none; overflow: visible; }
  .heading { padding: 0 0 10px; }
  .table-wrap { overflow: visible; border-left: 1px solid #999; border-right: 1px solid #999; border-bottom: 1px solid #999; }
  table, table.seven { min-width: 0; }
  td, th { border-color: #999; }
  tr { break-inside: avoid; }
  .time, .note { width: 12%; }
  .cell { min-height: 34px; padding: 3px; }
  .chip { color: #000 !important; background: none !important; padding: 1px 2px; }
}

.login-panel { width: min(440px, calc(100% - 28px)); margin: 76px auto 30px; padding: 24px; }
.login-panel .btn { margin-top: 8px; }
.login-panel .message { min-height: 1.5em; }
.top-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media print { .login-panel { display: none; } }
