:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #18211d;
  --muted: #66736d;
  --line: #dfe5e1;
  --green: #1f6f50;
  --green-soft: #e4f1ea;
  --gold: #b27a24;
  --danger: #b33a3a;
  --shadow: 0 18px 50px rgba(26, 41, 34, .09);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 20%, #dcece2, transparent 35%), #f3f0e9; }
.login-card { width: min(430px, 100%); padding: 42px; border-radius: 28px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.login-card h1 { margin: 6px 0; font-size: 42px; }
.login-card label { display: grid; gap: 8px; margin: 26px 0 12px; font-weight: 700; }
.login-card input, .search-wrap input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; background: #fff; }
.login-card button, .primary { width: 100%; border: 0; border-radius: 12px; padding: 14px; background: var(--green); color: #fff; font-weight: 800; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 900; letter-spacing: .15em; }
.error { color: var(--danger); min-height: 20px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #111b17; color: white; padding: 28px 18px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 30px; font-size: 22px; }
.brand span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #d5a44f; color: #111b17; font-weight: 900; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar button { border: 0; padding: 12px 14px; border-radius: 10px; background: transparent; color: #b9c7c0; text-align: left; }
.sidebar nav button.active, .sidebar button:hover { background: rgba(255,255,255,.1); color: white; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 5px; }
main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; height: 74px; display: flex; align-items: center; gap: 20px; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(245,243,238,.9); backdrop-filter: blur(14px); }
#menu-button { display: none; border: 0; background: transparent; font-size: 22px; }
.search-wrap { position: relative; width: min(520px, 60vw); }
.search-results { position: absolute; inset: 52px 0 auto; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; }
.search-result { display: block; width: 100%; padding: 12px 15px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; }
#connection { margin-left: auto; color: var(--green); font-size: 13px; font-weight: 800; }
.notification-button { margin-left: auto; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: white; }
#notification-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: white; font-size: 11px; }
.notification-panel { position: absolute; right: 110px; top: 62px; width: min(390px, calc(100vw - 24px)); max-height: 520px; overflow: auto; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.notification-item { display: block; width: 100%; padding: 14px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; }
.notification-item.unread { background: var(--green-soft); }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.calendar > div { min-height: 110px; padding: 8px; background: white; }
.calendar .calendar-head { min-height: auto; background: #eef2ef; font-weight: 800; text-align: center; }
.calendar .outside { background: #f5f6f5; color: #9aa49f; }
.calendar-event { display: block; margin-top: 5px; padding: 4px 6px; border-radius: 6px; background: var(--green-soft); color: var(--green); font-size: 11px; }
.calendar-event.pass { background: #dff3e7; }
.calendar-event.review { background: #fff1cf; color: #8b641c; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.calendar-toolbar h2 { margin: 0; }
#view { padding: 34px; max-width: 1440px; margin: 0 auto; }
.page-title h1 { margin: 0 0 8px; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.04em; }
.page-title p { color: var(--muted); margin: 0 0 28px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: 0 5px 20px rgba(24,33,29,.03); }
.stat b { display: block; font-size: 28px; margin-top: 7px; }
.stat span { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.card h2, .card h3 { margin-top: 0; }
.lesson-list { display: grid; gap: 10px; }
.lesson-row { width: 100%; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: left; }
.lesson-row:disabled { opacity: .48; cursor: not-allowed; }
.lesson-index { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 900; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #edf0ee; color: var(--muted); font-size: 11px; font-weight: 900; }
.badge.PASSED { background: var(--green-soft); color: var(--green); }
.badge.NEEDS_REVIEW { background: #f8e8e5; color: var(--danger); }
.badge.STUDYING, .badge.SUBMITTED { background: #fff1cf; color: #8b641c; }
.course-card { margin-bottom: 16px; }
.course-card summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 15px; }
.course-card summary h2 { margin: 0; }
.course-code { color: var(--green); font-weight: 900; }
.lesson-shell { position: relative; }
.lesson-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.lesson-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lesson-actions button, .canvas-toolbar button, .modal button, .card button { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: white; }
.lesson-content { position: relative; max-width: 850px; background: white; border-radius: 22px; padding: clamp(22px, 4vw, 54px); box-shadow: var(--shadow); }
.lesson-content h2 { margin-top: 42px; font-size: 26px; }
.lesson-content h3 { margin-top: 30px; }
.lesson-content p, .lesson-content li { line-height: 1.8; }
.callout { padding: 18px; border-left: 4px solid var(--green); border-radius: 8px; background: var(--green-soft); margin: 20px 0; }
.source-box { border-top: 1px solid var(--line); margin-top: 42px; padding-top: 24px; }
.source-box a { color: var(--green); }
.assignment { margin-top: 24px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfb; }
.assignment textarea { min-height: 180px; margin: 12px 0; resize: vertical; }
.assignment-actions { display: flex; gap: 8px; }
.assignment-actions .primary { width: auto; }
.overlay-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; touch-action: none; pointer-events: none; background: transparent !important; }
.overlay-canvas.active { pointer-events: auto; }
.canvas-toolbar { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; padding: 10px; background: #f4f6f5; border-radius: 12px; }
.canvas-toolbar button.active { background: var(--green); color: white; border-color: var(--green); }
.canvas-toolbar input[type=color] { width: 36px; height: 34px; border: 0; background: transparent; }
.save-status { color: var(--muted); font-size: 12px; margin-left: auto; }
.lesson-note-help, .submission-help { color: var(--muted); font-size: 13px; line-height: 1.6; }
.submission-message { padding: 10px 12px; margin-top: 10px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 700; }
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(5,12,9,.66); display: grid; place-items: center; padding: 18px; }
.modal-card { width: min(1100px, 100%); max-height: 94vh; border-radius: 20px; background: white; overflow: hidden; display: flex; flex-direction: column; }
.modal-card header, .modal-card footer { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-card header h2 { margin: 0 auto 0 0; }
.modal-card header > div { margin-right: auto; }
.modal-card header > div h2 { margin: 0; }
.modal-card header > div small { color: var(--muted); }
.modal-card footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.notebook-stage { min-height: 550px; overflow: auto; padding: 16px; background: #d8ddda; }
#notebook-canvas { display: block; width: 794px; height: 1123px; max-width: 100%; margin: auto; background: white; box-shadow: 0 10px 40px rgba(0,0,0,.15); touch-action: none; }
.note-item { border-bottom: 1px solid var(--line); padding: 15px 0; white-space: pre-wrap; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.progress-bar { height: 9px; background: #e6ebe8; border-radius: 999px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; transition: left .2s; width: 250px; }
  .sidebar.open { left: 0; }
  #menu-button { display: block; }
  .topbar { padding: 0 16px; }
  #view { padding: 22px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .span-8, .span-4 { grid-column: span 12; }
  #connection { display: none; }
  .notification-button { margin-left: 0; white-space: nowrap; }
  .notification-panel { right: 12px; top: 65px; }
  .search-wrap { width: 100%; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 15px; }
  .lesson-header { display: block; }
  .lesson-actions { margin-top: 15px; }
  .calendar > div { min-height: 72px; padding: 5px; }
  .calendar-event { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
