:root {
  color-scheme: light;
  --navy-950: #08122d;
  --navy-900: #0b1739;
  --navy-800: #14244b;
  --blue-600: #315be8;
  --blue-100: #eaf0ff;
  --teal-600: #087e79;
  --teal-100: #ddf6f3;
  --amber-600: #a85f00;
  --amber-100: #fff0d5;
  --ink: #172033;
  --muted: #687087;
  --line: #e3e7ef;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(20, 36, 75, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 7px; color: var(--blue-600); font-size: .72rem; font-weight: 800; letter-spacing: .13em; }

.flash-stack { position: fixed; z-index: 100; top: 18px; left: 50%; width: min(92vw, 520px); transform: translateX(-50%); }
.flash { padding: 13px 16px; border: 1px solid #ffd2ce; border-radius: 12px; color: var(--danger); background: #fff4f3; box-shadow: var(--shadow); font-size: .92rem; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 15% 15%, #e7edff 0, transparent 31%), radial-gradient(circle at 85% 85%, #ddf5f3 0, transparent 28%), var(--canvas); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 440px); padding: clamp(28px, 6vw, 46px); border: 1px solid rgba(227, 231, 239, .9); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 28px 90px rgba(11, 23, 57, .13); }
.login-mark, .brand-mark { display: grid; place-items: center; color: white; background: var(--navy-900); }
.login-mark { width: 54px; height: 54px; margin-bottom: 30px; border-radius: 16px; }
.login-card h1 { margin: 0; color: var(--navy-950); font-size: clamp(1.75rem, 6vw, 2.35rem); line-height: 1.08; letter-spacing: -.04em; }
.login-intro { margin: 14px 0 28px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 8px; font-size: .84rem; font-weight: 700; }
.login-form input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #ccd2df; border-radius: 11px; color: var(--ink); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.login-form input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 4px rgba(49,91,232,.12); }
.login-form .primary-button { margin-top: 18px; }
.login-footnote { margin: 24px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }

.primary-button, .secondary-button { min-height: 44px; padding: 0 18px; border-radius: 10px; font-weight: 750; border: 1px solid transparent; }
.primary-button { color: #fff; background: var(--blue-600); box-shadow: 0 8px 20px rgba(49,91,232,.22); }
.primary-button:hover { background: #254bd0; }
.secondary-button { color: var(--ink); border-color: var(--line); background: #fff; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 10px max(20px, calc((100vw - 1260px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy-950); text-decoration: none; font-weight: 850; letter-spacing: -.02em; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.class-picker select { height: 40px; min-width: 105px; padding: 0 34px 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--navy-950); background: #fff; font-weight: 750; }
.icon-text-button, .user-button, .close-button { border: 0; color: var(--ink); background: transparent; }
.icon-text-button { height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 10px; font-size: .88rem; font-weight: 700; }
.icon-text-button:hover, .user-button:hover { background: var(--canvas); }
.user-button { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 4px; border-radius: 12px; }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--navy-800); font-size: .8rem; font-weight: 800; }
.user-name { max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; font-weight: 700; }

.main-content { width: min(1260px, calc(100% - 40px)); margin: 0 auto; padding: 24px 0 58px; }
.sync-banner { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: rgba(255,255,255,.72); font-size: .82rem; }
.sync-banner p { flex: 1; margin: 0; }
.sync-banner a { color: var(--blue-600); font-weight: 700; text-decoration: none; }
.sync-banner a:hover { text-decoration: underline; }
.sync-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 99px; background: #98a2b3; box-shadow: 0 0 0 4px rgba(152,162,179,.13); }
.sync-dot--ready { background: var(--teal-600); box-shadow: 0 0 0 4px rgba(8,126,121,.13); }
.sync-dot--wait { background: #d38312; box-shadow: 0 0 0 4px rgba(211,131,18,.14); }
.sync-dot--error { background: var(--danger); box-shadow: 0 0 0 4px rgba(180,35,24,.12); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 30px 0 20px; }
.page-heading h1 { margin: 0; color: var(--navy-950); font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.045em; }
.view-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.view-switch button { min-width: 78px; height: 34px; padding: 0 13px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: .86rem; font-weight: 750; }
.view-switch button.active { color: #fff; background: var(--navy-900); box-shadow: 0 4px 12px rgba(11,23,57,.18); }

.focus-card { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: center; min-height: 170px; margin-bottom: 18px; padding: clamp(24px, 4vw, 38px); border-radius: 20px; color: #fff; background: linear-gradient(130deg, var(--navy-950), #142c67); box-shadow: var(--shadow); }
.focus-card::after { content: ""; position: absolute; right: -100px; top: -135px; width: 330px; height: 330px; border: 68px solid rgba(255,255,255,.05); border-radius: 50%; }
.focus-copy, .focus-room { position: relative; z-index: 1; }
.focus-kicker { display: flex; align-items: center; gap: 8px; margin: 0 0 9px; color: #aebfe9; font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.focus-kicker span { width: 7px; height: 7px; border-radius: 50%; background: #5de1d5; box-shadow: 0 0 0 5px rgba(93,225,213,.12); }
.focus-card h2 { margin: 0; font-size: clamp(1.65rem, 5vw, 2.7rem); line-height: 1.08; letter-spacing: -.04em; }
.focus-meta { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 15px 0 0; color: #d7def1; font-size: .94rem; }
.focus-meta strong { color: #fff; }
.focus-room { min-width: 118px; padding: 18px 20px; border: 1px solid rgba(255,255,255,.16); border-radius: 16px; background: rgba(255,255,255,.09); text-align: center; backdrop-filter: blur(8px); }
.focus-room small { display: block; margin-bottom: 4px; color: #afbee1; font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.focus-room strong { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.03em; }
.focus-card--next { background: linear-gradient(130deg, #3a2607, #77500d); }
.focus-card--next .focus-kicker { color: #ffe0aa; }
.focus-card--next .focus-kicker span { background: #ffc563; box-shadow: 0 0 0 5px rgba(255,197,99,.13); }
.focus-card--quiet { min-height: 120px; background: linear-gradient(130deg, #263044, #3f4b62); }

.day-tabs { display: flex; gap: 8px; margin: 0 0 14px; overflow-x: auto; scrollbar-width: none; }
.day-tabs::-webkit-scrollbar { display: none; }
.day-tabs button { min-width: 92px; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fff; font-size: .84rem; font-weight: 750; }
.day-tabs button.active { color: var(--blue-600); border-color: #b9c7f9; background: var(--blue-100); }
.day-tabs button.today::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 7px; border-radius: 50%; vertical-align: 2px; background: var(--blue-600); }

.schedule-panel { min-height: 260px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 8px 32px rgba(20,36,75,.045); }
.loading-state, .empty-state { min-height: 300px; display: grid; place-content: center; justify-items: center; gap: 13px; padding: 32px; color: var(--muted); text-align: center; }
.loading-state { grid-auto-flow: column; }
.spinner { width: 18px; height: 18px; border: 2px solid #d9deea; border-top-color: var(--blue-600); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state h2 { margin: 0; color: var(--navy-950); font-size: 1.25rem; }
.empty-state p { max-width: 470px; margin: 0; line-height: 1.55; }
.empty-state button { margin-top: 4px; }

.day-view { padding: 6px 24px 16px; }
.lesson-row { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.lesson-row:last-child { border-bottom: 0; }
.period-time { padding-top: 4px; color: var(--muted); font-size: .76rem; line-height: 1.3; }
.period-time strong { display: block; margin-bottom: 4px; color: var(--navy-950); font-size: .98rem; }
.period-time span { display: block; }
.lesson-stack { display: grid; gap: 9px; }
.lesson-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 15px 14px 17px; border: 1px solid var(--line); border-left: 4px solid var(--lesson-color, #9eb1e8); border-radius: 12px; background: #fbfcff; }
.lesson-card.is-current { border-color: #9bd8d3; border-left-color: var(--teal-600); background: var(--teal-100); }
.lesson-card h3 { margin: 0; overflow: hidden; color: var(--navy-950); font-size: 1rem; line-height: 1.25; text-overflow: ellipsis; }
.lesson-details { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; color: var(--muted); font-size: .8rem; }
.room-badge { min-width: 58px; padding: 7px 9px; border-radius: 9px; color: var(--navy-800); background: #edf0f7; text-align: center; font-size: .88rem; font-weight: 850; }
.is-current .room-badge { color: #075d59; background: #c4ebe7; }
.parallel-note { color: var(--amber-600); font-size: .76rem; font-weight: 700; }

.week-scroll { overflow-x: auto; }
.week-grid { min-width: 980px; display: grid; grid-template-columns: 74px repeat(5, minmax(176px, 1fr)); }
.week-cell { min-height: 88px; padding: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.week-cell:nth-child(6n) { border-right: 0; }
.week-header { min-height: 52px; position: sticky; top: 0; z-index: 2; display: flex; align-items: center; color: var(--navy-950); background: #f8f9fc; font-size: .8rem; font-weight: 800; }
.week-header.today { color: var(--blue-600); background: var(--blue-100); }
.week-period { color: var(--muted); background: #fafbfc; font-size: .7rem; line-height: 1.35; }
.week-period strong { display: block; color: var(--navy-950); font-size: .9rem; }
.week-lesson { margin-bottom: 6px; padding: 8px 9px; border-left: 3px solid var(--lesson-color, #9eb1e8); border-radius: 8px; background: #f5f7fb; }
.week-lesson:last-child { margin-bottom: 0; }
.week-lesson.is-current { border-left-color: var(--teal-600); background: var(--teal-100); }
.week-lesson strong { display: block; overflow: hidden; color: var(--navy-950); font-size: .78rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.week-lesson span { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.week-room { color: var(--navy-800) !important; font-weight: 800; }

.settings-dialog { width: min(620px, calc(100% - 28px)); max-height: min(780px, calc(100vh - 34px)); padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: #fff; box-shadow: 0 40px 120px rgba(8,18,45,.3); }
.settings-dialog::backdrop { background: rgba(8,18,45,.56); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; justify-content: space-between; gap: 18px; padding: 26px 26px 17px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; color: var(--navy-950); font-size: 1.55rem; letter-spacing: -.03em; }
.dialog-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.close-button { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 9px; color: var(--muted); font-size: 1.7rem; line-height: 1; }
.close-button:hover { background: var(--canvas); }
.selection-tools { display: flex; gap: 9px; padding: 14px 26px; border-bottom: 1px solid var(--line); }
.selection-tools button { padding: 6px 0; border: 0; color: var(--blue-600); background: transparent; font-size: .78rem; font-weight: 750; }
.selection-tools button + button { margin-left: 12px; }
.selection-list { max-height: 470px; overflow-y: auto; padding: 8px 26px; }
.selection-option { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start; padding: 13px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.selection-option:last-child { border-bottom: 0; }
.selection-option input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue-600); }
.selection-option strong { display: block; color: var(--navy-950); font-size: .9rem; }
.selection-option span { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 17px 26px 23px; border-top: 1px solid var(--line); background: #fafbfc; }
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(390px, calc(100% - 44px)); padding: 12px 15px; border-radius: 11px; color: #fff; background: var(--navy-900); box-shadow: var(--shadow); font-size: .84rem; }
.toast.error { background: var(--danger); }
.noscript { margin: 20px; color: var(--danger); text-align: center; }

@media (max-width: 700px) {
  .topbar { min-height: auto; flex-wrap: wrap; padding: 10px 14px; }
  .brand { order: 1; }
  .topbar-actions { order: 2; flex: 1; justify-content: flex-end; }
  .icon-text-button span, .user-name, .user-button svg { display: none; }
  .icon-text-button { width: 40px; justify-content: center; padding: 0; }
  .class-picker select { max-width: 116px; }
  .main-content { width: min(100% - 24px, 1260px); padding-top: 13px; }
  .sync-banner { align-items: flex-start; }
  .sync-dot { margin-top: 5px; }
  .page-heading { align-items: center; margin-top: 24px; }
  .view-switch button { min-width: 64px; }
  .focus-card { grid-template-columns: 1fr; gap: 19px; padding: 23px; }
  .focus-room { justify-self: start; min-width: 100px; padding: 12px 17px; text-align: left; }
  .focus-room small { margin-bottom: 1px; }
  .day-tabs { margin-right: -12px; padding-right: 12px; }
  .schedule-panel { border-radius: 15px; }
  .day-view { padding: 3px 15px 10px; }
  .lesson-row { grid-template-columns: 58px minmax(0, 1fr); gap: 10px; padding: 14px 0; }
  .lesson-card { padding: 12px; }
  .lesson-details { display: grid; gap: 3px; }
  .dialog-heading, .selection-tools, .selection-list { padding-left: 19px; padding-right: 19px; }
  .dialog-actions { padding: 15px 19px 19px; }
}

@media (max-width: 430px) {
  .brand > span:last-child { display: none; }
  .topbar-actions { gap: 4px; }
  .class-picker select { width: 104px; }
  .page-heading { gap: 10px; }
  .page-heading h1 { font-size: 1.55rem; }
  .view-switch button { min-width: 56px; padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

