/* ───────── 색상 토큰 ───────── */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --muted: #667085;
  --primary: #101828;
  --primary-ink: #ffffff;
  --accent: #0f9f6e;
  --accent-2: #0a7c56;
  --accent-soft: #e6f6ef;
  --heat: #0f9f6e;
  --cell: #ffffff;
  --grid-line: #d5dae1;
  --grid-line-soft: #eceef2;
  --hatch: rgba(16, 24, 40, 0.2);
  --mark: #f59e0b;
  --mark-soft: rgba(245, 158, 11, 0.22);
  --danger: #d92d20;
  --danger-ink: #ffffff;
  --danger-soft: #fef3f2;
  --busy: #e5484d;        /* 교수 불가 시간(빨강) */
  --busy-soft: #fde4e4;
  --busy-line: #f0a3a6;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --info: #3538cd;
  --info-soft: #eef2ff;
  --sun: #d92d20;
  --sat: #1d64d8;
  --online: #12b76a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.18);
  --radius: 12px;
  --rh: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --panel: #15181e;
    --panel-2: #1b1f26;
    --line: #262b34;
    --line-2: #363c48;
    --text: #e8eaee;
    --text-2: #b3bac6;
    --muted: #7d8696;
    --primary: #e8eaee;
    --primary-ink: #0d0f13;
    --accent: #1fb27f;
    --accent-2: #45d19e;
    --accent-soft: #11291f;
    --heat: #22c58b;
    --cell: #15181e;
    --grid-line: #2e343e;
    --grid-line-soft: #21262e;
    --hatch: rgba(255, 255, 255, 0.16);
    --danger: #f97066;
    --danger-ink: #0d0f13;
    --danger-soft: #2b1614;
    --busy: #f0605f;
    --busy-soft: #3b1b1d;
    --busy-line: #7b3336;
    --warn: #fdb022;
    --warn-soft: #2a2110;
    --info: #a4bcfd;
    --info-soft: #1d2140;
    --sun: #f97066;
    --sat: #6aa6ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

@media (pointer: coarse) {
  :root { --rh: 26px; }
}

/* ───────── 기본 ───────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-y: scroll; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { letter-spacing: -0.01em; }
svg { flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  overflow-wrap: anywhere;
}
code.pw { font-weight: 700; letter-spacing: 0.05em; color: var(--text); }
.boot { min-height: 100vh; display: grid; place-content: center; gap: 12px; text-align: center; color: var(--text-2); }

/* ───────── 버튼 · 입력 ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { opacity: 0.88; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn.danger:hover { opacity: 0.88; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.ghost.danger, .btn.danger-ghost { color: var(--danger); background: transparent; border-color: transparent; }
.btn.danger-ghost:hover, .btn.ghost.danger:hover { background: var(--danger-soft); }
.btn.copied { color: var(--accent-2); border-color: var(--accent); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; height: 42px; font-size: 14px; }
.link { border: 0; background: none; padding: 0; color: var(--text-2); text-decoration: underline; cursor: pointer; font-size: 13px; }
.icon-btn {
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
textarea[maxlength="500"] { font-family: inherit; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
select:disabled { opacity: 0.55; cursor: not-allowed; }
select.sm { height: 30px; width: auto; font-size: 12.5px; padding-left: 10px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; cursor: pointer; }

/* ───────── 폼 ───────── */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 13px; font-weight: 600; }
.form-error:empty { display: none; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline > input, .inline > select { flex: 1; min-width: 0; }
label.inline { gap: 6px; }
.row-between { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.preview { padding: 9px 12px; border-radius: 8px; background: var(--panel-2); color: var(--text-2); font-size: 13px; }
.preview.bad { background: var(--danger-soft); color: var(--danger); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day-toggle {
  width: 42px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-weight: 700;
  cursor: pointer;
}
.day-toggle.sun { color: var(--sun); }
.day-toggle.sat { color: var(--sat); }
.day-toggle.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; align-self: flex-start; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: inline-block; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; }
.seg-opt input:checked + span { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); }

/* ───────── 로그인 ───────── */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(900px 480px at 50% -8%, var(--accent-soft), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-card h1 { margin: 6px 0 0; font-size: 21px; }
.auth-card > p { margin: -8px 0 0; font-size: 13.5px; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted); }

/* ───────── 상단바 · 레이아웃 ───────── */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; color: var(--text); text-decoration: none; }
.logo { display: inline-flex; width: 28px; height: 28px; }
.logo svg { width: 100%; height: 100%; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.top-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); margin-right: 6px; white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn.live i { background: var(--online); animation: live 2.4s ease-in-out infinite; }
.conn.connecting i, .conn.reconnecting i { background: #f79009; }
.conn.down { color: var(--danger); }
.conn.down i { background: var(--danger); }
.me { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; margin: 0 6px; min-width: 0; }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.role { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); white-space: nowrap; }
.role.professor { background: var(--info-soft); color: var(--info); }
.role.student.optional { background: var(--panel-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

/* 서버가 예전 버전일 때 교수에게만 보이는 안내 줄 */
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; font-size: 13px; font-weight: 600; text-align: center; border-bottom: 1px solid var(--line); }

/* 교수 알림 (종 모양 버튼 · 알림 창) */
.bell { position: relative; padding: 0 8px; }
.bell-count { position: absolute; top: 0; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--busy); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 16px; text-align: center; }
.notice-list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.notice-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; background: var(--panel); }
.notice-item:hover { background: var(--panel-2); }
.notice-item.new { background: var(--accent-soft); border-color: transparent; }
.notice-text { min-width: 0; }
.notice-time { white-space: nowrap; margin-top: 2px; }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 16px 12px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 4px 8px; }
.side-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.side-list { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  min-width: 0;
}
.side-item:hover { background: var(--panel-2); }
.side-item.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 700; }
.side-title { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.side-item .badge { pointer-events: none; }
.side-empty { color: var(--muted); font-size: 13px; padding: 2px 8px; margin: 0; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

.main { min-width: 0; padding: 24px 28px 56px; }
.page { max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 2px 0 0; }

/* ───────── 카드 · 배지 · 칩 ───────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3, .card-title { margin: 0; font-size: 14.5px; display: inline-flex; align-items: center; gap: 6px; }
.card-title { margin-bottom: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}
.badge.ok { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.lock { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.opt { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.proj { color: var(--text-2); font-weight: 500; }
.roster-opt { margin: 8px 0 0; }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.dot.on { background: var(--online); box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.16); }
.chips-group { margin-top: 10px; }
.chips-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12.5px; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); }
.chip.yes { background: var(--accent-soft); border-color: transparent; color: var(--accent-2); font-weight: 700; }
.chip.none { background: transparent; border-style: dashed; color: var(--muted); }

/* ───────── 빈 화면 · 환영 ───────── */
.empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; margin-bottom: 8px; }
.empty h2 { margin: 0; font-size: 17px; }
.empty p { margin: 0 0 12px; max-width: 420px; }
.welcome { padding: 28px; }
.welcome h1 { margin: 0 0 4px; font-size: 22px; }
.welcome > p { margin: 0; }
.steps { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.step { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
.step-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--panel-2); border: 1px solid var(--line); }
.step.done .step-num { background: var(--accent); border-color: transparent; color: #fff; }
.step h3 { margin: 0; font-size: 15px; }
.step p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.share { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.share-item { display: flex; flex-direction: column; gap: 4px; }
.share-label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.share-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-row code { font-size: 13.5px; padding: 4px 9px; }
.share p { margin: 0; }

/* ───────── 표 ───────── */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table-scroll { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.cell-name { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.errors { padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }
.big-pw { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.big-pw code { font-size: 20px; padding: 6px 12px; }

/* ───────── 일정 머리 ───────── */
.sched-head { display: flex; flex-direction: column; gap: 14px; }
.sched-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 16px; flex-wrap: wrap; }
.sched-info { min-width: 0; flex: 1 1 320px; }
.sched-title h1 { margin: 0 0 2px; font-size: 22px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sched-title p { margin: 0; }
.desc { margin-top: 8px !important; white-space: pre-wrap; color: var(--text); padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs { display: inline-flex; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; align-self: flex-start; box-shadow: var(--shadow); }
.tab { border: 0; background: transparent; padding: 6px 16px; border-radius: 7px; font-weight: 700; color: var(--text-2); cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--primary); color: var(--primary-ink); }

/* ───────── 화면 배치 ───────── */
.overview { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.side-panel { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; }
.paint-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.paint-layout.single { grid-template-columns: minmax(0, 760px); }
.private-note { display: flex; align-items: center; gap: 6px; margin: 0; }
.hint { margin: -4px 0 12px; font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.hint.locked { color: var(--danger); font-weight: 600; }
.save-status { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.save-status.saved { color: var(--accent-2); font-weight: 600; }
.save-status.saved::before { content: "✓"; font-weight: 800; }
.save-status.saving::before { content: ""; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.save-status.error { color: var(--danger); font-weight: 600; }

/* ───────── 시간표 격자 ───────── */
.grid-wrap { overflow-x: auto; overscroll-behavior-x: contain; padding: 10px 2px 2px 0; }
.grid {
  display: grid;
  grid-template-columns: 46px repeat(var(--cols), minmax(36px, 1fr));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-variant-numeric: tabular-nums;
}
.g-corner { position: sticky; left: 0; z-index: 3; background: var(--panel); }
.g-head { text-align: center; padding: 0 1px 7px; font-size: 12.5px; color: var(--text); line-height: 1.25; white-space: nowrap; overflow-wrap: normal; }
.g-head b { font-weight: 700; display: inline-block; min-width: 22px; padding: 1px 4px; border-radius: 6px; }
.g-head small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.grid .g-head small.g-month { min-height: 14px; margin: 0 0 1px; font-weight: 700; color: var(--text-2); }
.g-head.sun b, .g-head.sun small { color: var(--sun); }
.g-head.sat b, .g-head.sat small { color: var(--sat); }
.g-head.today b { background: var(--primary); color: var(--primary-ink); }
.g-time { position: sticky; left: 0; z-index: 3; background: var(--panel); height: var(--rh); }
.g-time span { position: absolute; right: 8px; top: 0; transform: translateY(-50%); font-size: 11px; line-height: 1; color: var(--muted); white-space: nowrap; }
.g-time.end { height: 8px; }
.g-endfill { height: 8px; }
.g-cell {
  position: relative;
  height: var(--rh);
  background: var(--cell);
  border-left: 1px solid var(--grid-line);
  border-top: 1px solid var(--grid-line-soft);
}
.g-cell.hour { border-top-color: var(--grid-line); }
.g-cell.lc { border-right: 1px solid var(--grid-line); }
.g-cell.lr { border-bottom: 1px solid var(--grid-line); }

/* 내 시간 칠하기 */
.grid-paint .g-cell { cursor: pointer; touch-action: none; transition: background-color 0.06s; }
.grid-paint .g-cell.on { background: var(--accent); border-top-color: rgba(255, 255, 255, 0.22); }
.grid-paint .g-cell.on.hour { border-top-color: rgba(255, 255, 255, 0.45); }
@media (hover: hover) {
  .grid-paint:not(.locked):not(.dragging) .g-cell:hover { background: var(--accent-soft); }
  .grid-paint:not(.locked):not(.dragging) .g-cell.on:hover { background: var(--accent-2); }
}
.grid-paint.adding, .grid-paint.adding .g-cell { cursor: cell; }
.grid-paint.removing, .grid-paint.removing .g-cell { cursor: not-allowed; }
.grid-paint.locked .g-cell { cursor: not-allowed; touch-action: auto; }
.grid-paint.locked .g-cell.on { opacity: 0.55; }

/* 교수가 '내가 안 되는 시간'을 빨강으로 칠하는 격자 */
.grid-paint.v-blocked .g-cell.on { background: var(--busy); border-top-color: rgba(255, 255, 255, 0.3); }
.grid-paint.v-blocked .g-cell.on.hour { border-top-color: rgba(255, 255, 255, 0.5); }
@media (hover: hover) {
  .grid-paint.v-blocked:not(.locked):not(.dragging) .g-cell:hover { background: var(--busy-soft); }
  .grid-paint.v-blocked:not(.locked):not(.dragging) .g-cell.on:hover { background: var(--busy); filter: brightness(0.9); }
}

/* 학생 화면: 교수 불가(빨강)·수정 마감(회색) 칸은 칠할 수 없다 */
.grid-paint .g-cell.blocked,
.grid-paint .g-cell.blocked.on {
  background: repeating-linear-gradient(135deg, var(--busy) 0 2px, var(--busy-soft) 2px 6px);
  cursor: not-allowed;
  touch-action: auto;
}
.grid-paint .g-cell.frozen {
  background: repeating-linear-gradient(135deg, var(--hatch) 0 1.5px, var(--panel-2) 1.5px 6px);
  cursor: not-allowed;
  touch-action: auto;
}
.grid-paint .g-cell.frozen.on { background: var(--accent); opacity: 0.5; } /* 이미 골라 둔 칸이 잠겼을 때: 선택은 남기고 흐리게 */
@media (hover: hover) {
  .grid-paint:not(.locked):not(.dragging) .g-cell.blocked:hover,
  .grid-paint:not(.locked):not(.dragging) .g-cell.blocked.on:hover {
    background: repeating-linear-gradient(135deg, var(--busy) 0 2px, var(--busy-soft) 2px 6px);
  }
  .grid-paint:not(.locked):not(.dragging) .g-cell.frozen:hover {
    background: repeating-linear-gradient(135deg, var(--hatch) 0 1.5px, var(--panel-2) 1.5px 6px);
  }
  .grid-paint:not(.locked):not(.dragging) .g-cell.frozen.on:hover { background: var(--accent); }
}

/* 전체 현황 히트맵 */
.grid-heat .g-cell { z-index: 0; cursor: pointer; }
.grid-heat .g-cell::before {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--heat);
  opacity: var(--p, 0);
  pointer-events: none;
  transition: opacity 0.25s;
}
.grid-heat .g-cell.blocked::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: repeating-linear-gradient(135deg, var(--busy) 0 2px, var(--busy-soft) 2px 6px);
  pointer-events: none;
}
.grid-heat .g-cell .n {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text);
  pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .grid-heat .g-cell .n { color: var(--text-2); }
  .grid-heat .g-cell.ink .n { color: #fff; }
  .grid-heat .g-cell.ink2 .n { color: #0d0f13; }
}
.grid-heat .g-cell.full .n { text-decoration: underline; text-underline-offset: 2px; }
@media (hover: hover) {
  .grid-heat .g-cell:hover .n { box-shadow: inset 0 0 0 2px var(--text); }
}
.grid-heat .g-cell.mark .n { box-shadow: inset 0 0 0 2px var(--mark); }
.grid-heat .g-cell.flash .n { animation: flash 1.2s ease-out; }

/* ───────── 범례 · 상세 · 추천 · 명단 ───────── */
.legend { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend-scale { display: inline-flex; align-items: center; gap: 6px; }
.scale-bar { width: 96px; height: 10px; border-radius: 3px; border: 1px solid var(--line); background: linear-gradient(90deg, var(--cell), var(--heat)); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.solo-tag { color: var(--warn); font-weight: 700; }
.sw { display: inline-block; width: 16px; height: 11px; border-radius: 2px; border: 1px solid var(--line-2); }
.sw.hatch { background: repeating-linear-gradient(135deg, var(--hatch) 0 1.5px, transparent 1.5px 5px); }
.sw.busy { background: repeating-linear-gradient(135deg, var(--busy) 0 2px, var(--busy-soft) 2px 5px); border-color: var(--busy-line); }
.sw.mine { background: var(--accent); border-color: var(--accent); }
.sw.past { background: repeating-linear-gradient(135deg, var(--hatch) 0 1.5px, var(--panel-2) 1.5px 5px); }
.paint-legend { margin: 0 0 8px; }

.detail h3 { margin: 0; font-size: 14px; }
.detail p { margin: 6px 0 0; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.detail-count { margin-top: 6px; display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; color: var(--text-2); }
.detail-count b { font-size: 22px; color: var(--text); line-height: 1.1; }
.detail-count .badge { margin-left: 6px; align-self: center; }
.inline-detail { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }

.best-list { display: flex; flex-direction: column; gap: 6px; }
.best-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}
.best-item:hover { background: var(--panel-2); border-color: var(--line-2); }
.best-item.active { border-color: var(--mark); box-shadow: 0 0 0 3px var(--mark-soft); }
.best-rank { flex: none; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); margin-top: 1px; }
.best-item.all .best-rank { background: var(--accent); border-color: transparent; color: #fff; }
.best-text { display: flex; flex-direction: column; min-width: 0; }
.best-when { font-size: 13.5px; }
.best-who { font-size: 12px; color: var(--text-2); }
.best-who .ok { color: var(--accent-2); font-weight: 700; }
.best p { margin: 4px 0 0; }

.roster-tools { display: flex; align-items: center; gap: 2px 4px; flex-wrap: wrap; margin: -4px 0 6px; }
.roster-tools .xs { margin-left: auto; }
.roster-list { list-style: none; margin: 0; padding: 0; }
.roster-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 6px 6px; border-radius: 8px; }
.roster-row:hover { background: var(--panel-2); }
.roster-row.dim .name-btn, .roster-row.dim .r-status { opacity: 0.4; }
.roster-row.solo { background: var(--warn-soft); }
.name-btn { border: 0; background: none; padding: 0; text-align: left; font-weight: 600; cursor: pointer; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-btn:hover { text-decoration: underline; }
.r-status { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.r-status.none { color: var(--warn); }
.r-status.editing { color: var(--accent-2); font-weight: 700; }
.r-status.editing::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 0.9s ease-in-out infinite; }
.solo-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; margin-bottom: 6px; }

/* ───────── 모달 · 토스트 ───────── */
dialog.modal {
  border: 0;
  padding: 0;
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  width: min(540px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow: hidden;
}
dialog.modal.wide { width: min(720px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(16, 24, 40, 0.5); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 20px 4px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 12px 20px 6px; overflow-y: auto; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
.confirm-msg { line-height: 1.6; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1000; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: var(--primary); color: var(--primary-ink); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600; animation: toast-in 0.2s ease-out; transition: opacity 0.25s, transform 0.25s; }
.toast.error { background: var(--danger); color: var(--danger-ink); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ───────── 애니메이션 ───────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes live { 0%, 100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.45); } 50% { box-shadow: 0 0 0 4px rgba(18, 183, 106, 0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes flash { 0% { box-shadow: inset 0 0 0 2px var(--mark); background: var(--mark-soft); } 100% { box-shadow: inset 0 0 0 2px transparent; background: transparent; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ───────── 반응형 ───────── */
@media (max-width: 1200px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
  .side-panel { position: static; max-height: none; overflow: visible; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
}
@media (max-width: 1000px) {
  .paint-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 6px;
  }
  .side-head { padding: 0; flex: none; }
  .side-label { display: none; }
  .side-list { flex-direction: row; gap: 6px; }
  .side-item { flex: none; border: 1px solid var(--line); padding: 6px 10px; max-width: 240px; }
  .side-foot { margin: 0; padding: 0; border: 0; flex: none; }
  .side-empty { white-space: nowrap; }
  .main { padding: 16px 12px 48px; }
  .topbar { padding: 0 12px; }
  .hide-sm { display: none; }
  .conn { padding: 6px; margin-right: 2px; }
  .step { grid-template-columns: 34px minmax(0, 1fr); }
  .step > :last-child { grid-column: 2; justify-self: start; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .sched-title h1, .page-head h1, .welcome h1 { font-size: 19px; }
}
@media (max-width: 420px) {
  .me-name { display: none; }
  .welcome, .card { padding: 14px; }
  .grid { grid-template-columns: 40px repeat(var(--cols), minmax(34px, 1fr)); }
}
