/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f5f8;
  --header: rgba(255, 255, 255, .82);
  --surface: #ffffff;
  --surface-2: #eceef3;
  --surface-3: #f8f9fb;
  --fg: #0f1720;
  --fg-2: #4a5568;
  --fg-3: #647084;
  --line: #e3e6ec;
  --line-2: #cbd2dc;
  --accent: #2f5bea;
  --accent-fg: #ffffff;
  --accent-soft: rgba(47, 91, 234, .10);
  --today: rgba(245, 158, 11, .14);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
  --shadow-lift: 0 8px 20px -12px rgba(16, 24, 40, .28);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 20px 48px -20px rgba(16, 24, 40, .28);
  --k-lecture: #2f5bea;
  --k-practice: #17914f;
  --k-seminar: #17914f;
  --k-lab: #7c3aed;
  --k-exam: #dc2626;
  --k-consult: #d97706;
  --k-other: #6b7280;
  --r: 10px;
  --r-sm: 7px;
}
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e12;
  --header: rgba(12, 14, 18, .82);
  --surface-3: #101319;
  --shadow-card: none;
  --shadow-lift: 0 10px 24px -14px rgba(0, 0, 0, .7);
  --surface: #14171d;
  --surface-2: #1c2028;
  --fg: #e9ecf1;
  --fg-2: #aab3c0;
  --fg-3: #909baa;
  --line: #22272f;
  --line-2: #323844;
  --accent: #7aa2ff;
  --accent-fg: #0b1020;
  --accent-soft: rgba(122, 162, 255, .14);
  --today: rgba(245, 158, 11, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -20px rgba(0, 0, 0, .7);
  --k-lecture: #7aa2ff;
  --k-practice: #4ade80;
  --k-seminar: #4ade80;
  --k-lab: #b48cff;
  --k-exam: #f87171;
  --k-consult: #fbbf24;
  --k-other: #8b95a5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e12;
    --header: rgba(12, 14, 18, .82);
    --surface-3: #101319;
    --shadow-card: none;
    --shadow-lift: 0 10px 24px -14px rgba(0, 0, 0, .7);
    --surface: #14171d;
    --surface-2: #1c2028;
    --fg: #e9ecf1;
    --fg-2: #aab3c0;
    --fg-3: #909baa;
    --line: #22272f;
    --line-2: #323844;
    --accent: #7aa2ff;
    --accent-fg: #0b1020;
    --accent-soft: rgba(122, 162, 255, .14);
    --today: rgba(245, 158, 11, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -20px rgba(0, 0, 0, .7);
    --k-lecture: #7aa2ff;
    --k-practice: #4ade80;
    --k-seminar: #4ade80;
    --k-lab: #b48cff;
    --k-exam: #f87171;
    --k-consult: #fbbf24;
    --k-other: #8b95a5;
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14.5px/1.5 var(--font);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
  transition: background-color .15s ease, color .15s ease;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body:has(dialog[open]) { overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { display: none; }
.metrika-pixel { position: absolute; left: -9999px; }
.muted { color: var(--fg-3); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:root { --ease: cubic-bezier(.2, .7, .2, 1); --dur: .28s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-8deg); } 100% { transform: scale(1); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------------ header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--header);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top { transition: box-shadow .2s ease; }
.top.scrolled { box-shadow: 0 8px 24px -18px rgba(0, 0, 0, .35); }
.btn:active, .iconbtn:active, .segbtn:active, .toggle:active, .who:active { transform: scale(.97); }
.btn, .iconbtn, .segbtn, .toggle, .who { transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease, transform .1s ease; }
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 20px 8px; }
.who {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
  background: none; border: 0; padding: 4px 8px 4px 6px; margin-left: -6px; border-radius: 9px; text-align: left; color: inherit;
  transition: background-color .12s ease;
}
.who:hover { background: var(--surface-2); }
.who .icon { color: var(--fg-3); }
.who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.who-label { font-size: 18px; font-weight: 650; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-kind { font-size: 12px; color: var(--fg-3); }
.field input, .codeinput, .btn, .iconbtn {
  height: 32px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.field { position: relative; flex: 1; min-width: 0; }
.field .icon { position: absolute; left: 10px; top: 8px; color: var(--fg-3); pointer-events: none; }
.field input { width: 100%; padding: 0 10px 0 32px; -webkit-appearance: none; appearance: none; }
.field input::placeholder { color: var(--fg-3); }
.field input:focus, .codeinput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-head { padding: 12px 12px 12px 16px; gap: 10px; }
.search-head .field { flex: 1; }
.field.big input { height: 38px; font-size: 15px; padding-left: 36px; }
.field.big .icon { top: 11px; }
.results { list-style: none; margin: 0; padding: 0; max-height: min(60vh, 520px); overflow: auto; }
.results li { display: flex; align-items: center; gap: 6px; border-radius: 8px; }
.results li:hover, .results li.active { background: var(--surface-2); }
.results .row { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; background: none; border: 0; text-align: left; color: inherit; line-height: 1.3; }
.results .row b { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.results .row small { color: var(--fg-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.results .act { background: none; border: 0; padding: 8px; margin-right: 4px; color: var(--fg-3); display: inline-flex; border-radius: 6px; }
.results .act:hover { color: var(--k-consult); background: var(--surface); }
.results .act.on { color: var(--k-consult); }
.results .act.on .icon { fill: currentColor; }
.hint { color: var(--fg-3); font-size: 13px; margin: 6px 0 0; }
.hint:empty { display: none; }
.hint.err { color: var(--k-exam); }
.hint.ok { color: var(--k-practice); }
.search-loading { padding: 16px 8px 4px; animation: fade .2s ease both; }
.search-loading[hidden], #search-hint[hidden] { display: none; }
.search-loading-intro { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 12px 20px; }
.search-orbit { position: relative; display: grid; place-items: center; width: 48px; height: 48px; margin: 8px 0 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.search-orbit::before, .search-orbit::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid var(--accent-soft); }
.search-orbit::after { border-color: transparent; border-top-color: var(--accent); border-right-color: var(--accent); animation: spin 2.4s linear infinite; }
.search-orbit .icon { width: 23px; height: 23px; animation: search-scan 2.4s ease-in-out infinite; }
@keyframes search-scan { 0%, 100% { transform: translate(-2px, 1px); } 50% { transform: translate(2px, -1px); } }
.search-loading-intro strong { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.search-loading-intro #search-progress { min-height: 3em; max-width: 32ch; margin: 8px 0 0; color: var(--fg-3); font-size: 13px; line-height: 1.5; text-wrap: pretty; }
.search-placeholders { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.search-placeholders::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(100deg, transparent 20%, var(--surface-3) 50%, transparent 80%); opacity: .7; transform: translateX(-100%); animation: search-sweep 2.4s ease-in-out infinite; }
@keyframes search-sweep { to { transform: translateX(100%); } }
.search-placeholder { display: flex; align-items: center; gap: 12px; padding: 16px; }
.search-placeholder + .search-placeholder { border-top: 1px solid var(--line); }
.search-placeholder i { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-2); }
.search-placeholder > span { flex: 1; display: grid; gap: 9px; }
.search-placeholder b, .search-placeholder em { display: block; height: 9px; width: 76%; border-radius: 4px; background: var(--surface-2); }
.search-placeholder em { width: 43%; height: 7px; }
.search-placeholder:nth-child(2) b { width: 90%; }
.search-placeholder:nth-child(2) em { width: 56%; }
.search-placeholder:nth-child(3) b { width: 63%; }
.search-placeholder:nth-child(3) em { width: 34%; }
.search-loading .search-loading-tip { margin: 16px 8px 0; color: var(--fg-3); font-size: 12px; line-height: 1.5; text-align: center; }
@media (prefers-reduced-motion: reduce) { .search-placeholders::after { display: none; } }
.nav { display: flex; align-items: center; gap: 10px; padding: 2px 20px 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 9px; }
.segbtn {
  border: 0; background: none; height: 26px; padding: 0 12px; border-radius: 6px; color: var(--fg-2); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; transition: background-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.segbtn:hover { color: var(--fg); }
.segbtn.on { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .10); }
.seg-icons .segbtn { padding: 0 8px; }
.seg-icons .segbtn.on { color: var(--accent); }
.weeknav { display: flex; align-items: center; gap: 6px; }
.weeknav[hidden] { display: none; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 32px; padding: 0; color: var(--fg-2); }
.iconbtn[hidden] { display: none; }
.iconbtn:hover, .btn:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--fg); }
.textbtn { width: auto; padding: 0 10px; gap: 6px; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.btn:disabled, .iconbtn:disabled { opacity: .5; cursor: default; transform: none; background: var(--surface); border-color: var(--line); color: inherit; }
.iconbtn.spinning .icon { animation: spin .9s linear infinite; }
.status.ok { color: var(--k-practice); }
.btn { padding: 0 12px; font-weight: 500; }
.range { font-weight: 600; margin-left: 6px; letter-spacing: -.01em; }
.status { font-size: 13px; color: var(--fg-3); }
.status:empty { display: none; }
.status.err { color: var(--k-exam); }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tools-secondary, .theme-control { display: flex; align-items: center; gap: 8px; }
#more-open, .mobile-label, #mobile-navigation { display: none; }

/* ------------------------------------------------------------------ content */
main.wrap { padding: 20px 20px 48px; }
main.animate .lesson, main.animate .gap, main.animate .day > h2, main.animate h2.section, main.animate .toggle,
main.animate .panel > .empty, main.animate .nextptr, main.animate .grid, main.animate .emptystate, main.animate .past-block {
  animation: rise var(--dur) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
main.animate .panel { animation: fade var(--dur) ease both; }
.skeleton { display: grid; gap: 8px; }
.skeleton .bone {
  height: 76px; border-radius: var(--r); border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
.skeleton .bone.head { height: 18px; width: 180px; border: 0; border-radius: 6px; margin: 4px 0 6px; }
.loading, .empty { color: var(--fg-3); margin: 0; }
.empty { padding: 4px 0 0 2px; }
.emptystate { padding: 72px 0; text-align: center; color: var(--fg-3); max-width: 440px; margin: 0 auto; }
h2.section { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-3); margin: 28px 0 10px; }
.day { margin-bottom: 22px; }
.day h2 { font-size: 15px; font-weight: 600; margin: 0 0 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; letter-spacing: -.01em; }
.day h2 .dow { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-3); }
.day.today h2, .day.today h2 .dow { color: var(--accent); }
.tag { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; background: var(--today); color: var(--fg-2); }
.panel { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 8px; background: var(--surface); box-shadow: var(--shadow-card); }
.panel h2 { font-size: 17px; }
.panel .lesson { background: var(--surface-3); }
.nextptr { display: flex; align-items: center; gap: 8px; margin: 6px 0 6px; color: var(--fg-2); }
.nextptr .icon { color: var(--accent); }

.toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 8px; margin: 0 0 16px;
  font-size: 13px; color: var(--fg-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-card);
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.toggle:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--fg); }
.toggle .icon { width: 15px; height: 15px; transition: transform .15s ease; }
.toggle.open .icon { transform: rotate(90deg); }
.past-block { border-left: 2px solid var(--line); padding-left: 14px; margin: 0 0 14px; }
.past-block .lesson { opacity: .55; }

/* lesson card */
.lesson {
  display: grid; grid-template-columns: 84px 1fr; gap: 14px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--k); border-radius: var(--r);
  transition: border-color .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.lesson { transition: border-color .12s ease, box-shadow .16s ease, opacity .12s ease, transform .16s ease; }
.lesson { box-shadow: var(--shadow-card); }
.lesson:hover { border-color: var(--line-2); border-left-color: var(--k); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.lesson.now:hover { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lift); }
.lesson.now { border-color: var(--accent); border-left-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lesson.past { opacity: .55; }
.time { display: flex; flex-direction: column; line-height: 1.3; font-variant-numeric: tabular-nums; }
.time-range { display: flex; flex-direction: column; }
.time b { font-weight: 600; font-size: 15px; }
.time span { color: var(--fg-2); }
.time small { color: var(--fg-3); font-size: 12px; margin-top: 3px; }
.time .rel { color: var(--accent); font-weight: 600; }
.body { min-width: 0; }
.title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; line-height: 1.35; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.subject, .note > span, .nextptr > span { min-width: 0; overflow-wrap: anywhere; }
.lesson-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.lesson-badges:empty { display: none; }
.badge { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; padding: 2px 7px; border-radius: 999px; color: var(--k); background: color-mix(in srgb, var(--k) 12%, transparent); }
.badge.now { color: var(--accent-fg); background: var(--accent); animation: pulse 2.6s ease-in-out infinite; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 5px; color: var(--fg-2); font-size: 13.5px; }
.meta > span, .meta > a { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 5px; min-width: 0; }
.meta > span > span, .meta > span > a { min-width: 0; overflow-wrap: anywhere; }
.meta > .meta-people, .meta > .meta-place { flex-wrap: nowrap; align-items: flex-start; }
.meta-people > .icon, .meta-place > .icon { margin-top: 3px; }
.place-details { display: inline-flex; flex-wrap: wrap; gap: 4px 5px; }
.meta > span > a.maplink { flex: 0 1 auto; white-space: normal; }
.meta .icon { width: 14px; height: 14px; color: var(--fg-3); }
.meta .sep { color: var(--line-2); }
.meta .floor { font-weight: 600; color: var(--fg); }
.prof, .maplink { color: inherit; border-bottom: 1px dotted var(--line-2); transition: color .12s ease, border-color .12s ease; }
.prof:hover, .maplink:hover { color: var(--accent); border-bottom-color: var(--accent); }
.note { margin-top: 6px; font-size: 13.5px; color: var(--fg-2); display: flex; gap: 6px; align-items: flex-start; }
.note .icon { width: 14px; height: 14px; margin-top: 3px; color: var(--fg-3); }
.progress { height: 4px; background: var(--line); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); border-radius: 2px; transform-origin: left; transition: width .6s ease; }
main.animate .progress div { animation: grow .9s var(--ease) both; animation-delay: .15s; }
.kind-lecture { --k: var(--k-lecture); }
.kind-practice { --k: var(--k-practice); }
.kind-seminar { --k: var(--k-seminar); }
.kind-lab { --k: var(--k-lab); }
.kind-exam { --k: var(--k-exam); }
.kind-consult { --k: var(--k-consult); }
.kind-other { --k: var(--k-other); }

/* the rule between two classes: the break and where to go */
.gap { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 12.5px; color: var(--fg-3); }
.gap::before, .gap::after { content: ""; flex: 1; border-top: 1px dashed var(--line-2); }
.gap.inner { margin: 8px 0 0; }
.gap.inner::before { flex: 0 0 0; }
.gap .gaptext { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px 6px; text-align: center; }
.gap .dot { color: var(--line-2); }
.gap .chg { display: inline-flex; align-items: center; }
.gap .chg .icon { width: 14px; height: 14px; margin-right: 4px; }
.gap.room .chg { color: var(--k-consult); }
.gap.building .chg { color: var(--k-exam); }
.gap .routelink { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--accent); }
.gap .routelink .icon { width: 14px; height: 14px; }

/* install offer (Android Chrome) */
.pwa {
  display: flex; align-items: center; gap: 12px; margin: 16px 0 4px; padding: 12px 12px 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-card);
  animation: rise var(--dur) var(--ease) both;
}
.pwa[hidden] { display: none; }
.pwa-icon { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.pwa-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.pwa-text b { font-weight: 600; }
.pwa-text span { color: var(--fg-2); font-size: 13.5px; }
.pwa-hint { font-size: 12.5px !important; color: var(--fg-3) !important; margin-top: 4px; }
.pwa-hint:empty { display: none; }
@media (max-width: 760px) {
  .pwa { flex-wrap: wrap; }
  .pwa-text { flex: 1 1 calc(100% - 100px); }
  .pwa .btn.primary { flex: 1; justify-content: center; }
}

/* install guide */
.hint.lead { font-size: 14px; color: var(--fg-2); margin: 0 0 12px; }
.install-native { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.install-native[hidden] { display: none; }
#install-tabs { margin-bottom: 10px; }
.alt { display: flex; flex-wrap: wrap; gap: 6px; }
.alt:empty { display: none; }
.alt .btn { height: 28px; font-size: 12.5px; padding: 0 10px; }
.alt .btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.steps { list-style: none; counter-reset: step; margin: 12px 0 0; padding: 0; }
.steps li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); line-height: 1.45; animation: rise .22s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  counter-increment: step; content: counter(step); flex: none; width: 22px; height: 22px; border-radius: 50%; margin-top: 1px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; justify-content: center;
}
.steps .icon { flex: none; color: var(--fg-2); margin-top: 3px; }
.steps b { font-weight: 600; }

/* dialogs */
.modal {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--bg); color: var(--fg);
  width: min(500px, calc(100vw - 32px)); box-shadow: var(--shadow);
  max-height: calc(100dvh - 48px); overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; }
.modal-head { flex: none; }
.modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.modal-sm { width: min(380px, calc(100vw - 32px)); }
dialog.modal {
  opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity .18s ease, transform .24s var(--ease), overlay .24s allow-discrete, display .24s allow-discrete;
}
dialog.modal[open] { opacity: 1; transform: none; }
@starting-style { dialog.modal[open] { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog.modal::backdrop { transition: background-color .22s ease, overlay .22s allow-discrete, display .22s allow-discrete; }
dialog.modal:not([open])::backdrop { background: rgba(10, 12, 16, 0); }
@starting-style { dialog.modal[open]::backdrop { background: rgba(10, 12, 16, 0); } }
.results li { animation: rise .22s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.favlist li { animation: rise .22s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.modal::backdrop { background: rgba(10, 12, 16, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.modal-body { padding: 14px 16px 16px; }
.modal-body p { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); color: var(--accent-fg); }
.btn.danger { background: var(--k-exam); color: #fff; border-color: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--k-exam) 85%, black); color: #fff; }
.btn .icon, .btn.primary .icon { width: 15px; height: 15px; margin-right: 6px; }
.fav-current { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border: 1px dashed var(--line-2); border-radius: var(--r); }
.fav-current[hidden] { display: none; }
.fav-current .lbl { flex: 1; min-width: 0; }
.fav-current .lbl b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-current .lbl small { color: var(--fg-3); }
.favlist { list-style: none; margin: 0 0 10px; padding: 0; }
.favlist li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.favlist li:last-child { border-bottom: 0; }
.favlist .row {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 9px 8px; margin: 3px 0;
  background: none; border: 0; border-radius: 8px; text-align: left; color: inherit; transition: background-color .12s ease;
}
.favlist .row:hover { background: var(--surface-2); }
.favlist .star { color: var(--k-consult); display: inline-flex; }
.favlist .star .icon { fill: currentColor; stroke: none; }
.favlist .lbl { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.favlist .lbl b { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.favlist .lbl small { color: var(--fg-3); font-size: 12.5px; }
.favlist .on .lbl b { color: var(--accent); }
.favlist .act { background: none; border: 0; padding: 8px; color: var(--fg-3); display: inline-flex; border-radius: 8px; transition: background-color .12s ease, color .12s ease; }
.favlist .act:hover { color: var(--k-exam); background: var(--surface-2); }
.iconbtn.starred .icon { fill: var(--k-consult); stroke: var(--k-consult); }
.icon.pop { animation: pop .45s var(--ease); }
.results .act.on .icon, .favlist .star .icon { transition: fill .15s ease, color .15s ease; }
.sync { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.sync summary { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.sync summary::-webkit-details-marker { display: none; }
.sync summary .icon { color: var(--fg-3); }
.sync .disclosure { margin-left: auto; transition: transform .15s ease; }
.sync[open] .disclosure { transform: rotate(180deg); }
.sync[open] summary { margin-bottom: 12px; }
.coderow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 17px; font-weight: 600; letter-spacing: .12em; padding: 5px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.codeinput { flex: 1 1 160px; min-width: 0; padding: 0 12px; text-transform: uppercase; letter-spacing: .08em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.codeinput::placeholder { text-transform: none; letter-spacing: normal; font-family: var(--font); }
.emptystate .btn { margin-top: 14px; }
.emptystate .hello { display: block; width: 200px; height: auto; max-width: 70vw; margin: 0 auto 18px; border-radius: 14px; }
.emptystate p { margin: 0; font-size: 15px; color: var(--fg-2); }

/* grid view */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-card); }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; padding: 5px; }
.grid th:last-child, .grid td:last-child { border-right: 0; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid th { font-weight: 600; padding: 9px 5px; background: var(--surface-3); }
.grid th .muted { font-weight: 500; font-size: 12px; }
.grid th.today { color: var(--accent); }
.grid th.slot, .grid td.slot { width: 64px; text-align: center; color: var(--fg-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.grid td.slot b { display: block; color: var(--fg); font-size: 13px; }
.grid td.today { background: color-mix(in srgb, var(--today) 55%, transparent); }
.card { border-left: 3px solid var(--k); background: var(--surface-3); border: 1px solid var(--line); border-left-width: 3px; border-radius: 6px; padding: 6px 8px; margin-bottom: 5px; }
.card.now { box-shadow: 0 0 0 2px var(--accent-soft); border-color: var(--accent); }
.card .ct { font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }
.card .cm { color: var(--fg-2); line-height: 1.35; margin-top: 2px; }
.card .warn { display: flex; align-items: center; gap: 4px; color: var(--k-exam); font-weight: 600; }
.card .warn .icon { width: 13px; height: 13px; }
.card .badge { margin-top: 4px; display: inline-block; }

.foot { display: flex; gap: 16px; padding: 0 20px 32px; font-size: 12.5px; color: var(--fg-3); }
.foot a { color: inherit; border-bottom: 1px dotted var(--line-2); }
.foot a:hover { color: var(--accent); border-bottom-color: var(--accent); }

@media (min-width: 761px) and (max-width: 1050px) {
  .tools .textbtn > span { display: none; }
  .tools .textbtn { width: 32px; padding: 0; }
}

@media (max-width: 760px) {
  :root { --gutter: 20px; }
  body { font-size: 15px; }
  .wrap { padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
  .top { padding-top: env(safe-area-inset-top); }
  .bar { gap: 12px; padding-top: 12px; padding-bottom: 10px; }
  .who { flex: 1; min-height: 48px; gap: 6px; padding: 4px 0; margin: 0; }
  .who-label { font-size: 18px; }
  .who-kind { margin-top: 4px; line-height: 1.35; font-size: 12px; }
  .who > .icon { width: 14px; }
  .tools { flex: none; gap: 6px; }
  .btn { height: auto; min-height: 44px; padding: 10px 14px; line-height: 1.35; }
  .iconbtn { width: 44px; height: 44px; flex: none; border-radius: 10px; }
  .iconbtn .icon { width: 18px; height: 18px; }
  #search-open { padding: 0; }
  #search-open span { display: none; }
  #more-open { display: inline-flex; }
  .nav { padding-top: 0; padding-bottom: 12px; }
  .view-tabs { display: flex; width: 100%; }
  .segbtn { min-height: 44px; height: auto; justify-content: center; }
  .view-tabs .segbtn { flex: 1; }
  #view-grid { display: none; }
  #mobile-navigation { display: block; }
  .weeknav { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; gap: 10px; margin-top: 20px; }
  .range { grid-column: 1 / -1; grid-row: 1; margin: 0 0 2px; text-align: center; font-size: 15px; }
  .weeknav #this-week { justify-self: center; background: transparent; border-color: transparent; color: var(--accent); }
  .status { display: block; line-height: 1.5; margin-top: 16px; }
  .status:empty { display: none; }

  /* Secondary actions retain their labels and generous touch areas in the sheet. */
  #secondary-tools { flex-direction: column; align-items: stretch; gap: 8px; }
  #secondary-tools > .iconbtn { width: 100%; min-height: 48px; height: auto; padding: 12px 14px; justify-content: flex-start; gap: 12px; font-size: 15px; font-weight: 500; letter-spacing: 0; }
  #secondary-tools .mobile-label { display: inline; }
  #secondary-tools .theme-control { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 12px 14px; margin-top: 4px; border-top: 1px solid var(--line); }
  #theme .segbtn { min-width: 44px; }
  .lang-value { margin-left: auto; color: var(--fg-3); }

  main.wrap { padding-top: 24px; padding-bottom: 48px; }
  .day { margin-bottom: 32px; }
  .day h2 { font-size: 17px; margin-bottom: 14px; gap: 8px; }
  .day h2 .dow { font-size: 12px; }
  .day h2 .tag { margin-left: auto; }
  h2.section { margin: 36px 0 20px; font-size: 12px; }
  .panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .panel .lesson { background: var(--surface); }
  .panel > .empty { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  .nextptr { margin: 14px 0 0; align-items: flex-start; }
  .nextptr > .icon { margin-top: 3px; }
  .toggle { min-height: 44px; height: auto; padding: 10px 12px; margin-bottom: 24px; font-size: 14px; }
  .past-block { padding-left: 10px; }
  .past-block .lesson, .lesson.past { opacity: .75; }
  .lesson { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 18px 16px; margin-bottom: 12px; border-radius: 14px; }
  .lesson:hover { transform: none; box-shadow: var(--shadow-card); }
  .lesson.now:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
  .time { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
  .time-range { flex-direction: row; align-items: baseline; gap: 6px; white-space: nowrap; }
  .time-range > span::before { content: "–"; margin-right: 6px; color: var(--fg-3); }
  .time b { font-size: 16px; }
  .time small { margin-top: 0; font-size: 12px; }
  .time .rel { margin-left: auto; }
  .title { display: block; font-size: 16px; line-height: 1.45; }
  .subject { display: block; }
  .lesson-badges { display: flex; margin-top: 10px; }
  .lesson-badges:empty { display: none; }
  .badge { font-size: 10px; line-height: 1.5; }
  .meta { flex-direction: column; align-items: stretch; gap: 10px; margin-top: 16px; font-size: 14px; line-height: 1.5; }
  .meta > span, .meta > a { gap: 8px; }
  .meta > a { flex-wrap: nowrap; align-items: flex-start; overflow-wrap: anywhere; }
  .meta > a .icon { margin-top: 3px; }
  .place-details { flex: 1; gap: 4px 6px; }
  .place-details .building-sep { display: none; }
  .place-details .maplink { flex-basis: 100%; width: fit-content; border: 0; text-decoration: underline dotted var(--line-2); text-underline-offset: 4px; }
  .note { margin-top: 14px; gap: 8px; line-height: 1.5; }
  .progress { margin-top: 18px; }
  .gap { margin: 4px 0 16px; font-size: 12px; gap: 8px; }
  .gap .gaptext { flex: 0 1 auto; min-width: 0; gap: 4px 6px; }
  .gap .chg { flex-wrap: wrap; justify-content: center; overflow-wrap: anywhere; }
  .gap.building, .gap.room { padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
  .gap.building::before, .gap.building::after, .gap.room::before, .gap.room::after { display: none; }
  .gap .routelink { min-height: 44px; padding: 8px 12px; }
  .gap.inner { margin: 12px 0 0; }
  .foot { flex-wrap: wrap; gap: 8px 16px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }

  /* Sheets scroll within the viewport; search stays above the software keyboard. */
  .modal { width: 100%; max-width: 560px; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); margin: auto auto 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .modal-head { padding: 16px 20px 12px; gap: 12px; }
  .modal-head h2 { font-size: 18px; }
  .modal-body { padding: 20px 20px max(24px, env(safe-area-inset-bottom)); }
  .modal-sm { width: calc(100% - 32px); margin: auto; border: 1px solid var(--line); border-radius: 18px; }
  #search { margin: max(12px, env(safe-area-inset-top)) auto auto; width: calc(100% - 16px); max-height: calc(100dvh - 24px - env(safe-area-inset-top)); border: 1px solid var(--line); border-radius: 18px; }
  .search-head { padding: 12px; gap: 8px; }
  .field.big input, .codeinput { height: 48px; font-size: 16px; }
  .field.big .icon { top: 16px; }
  #search .modal-body { padding: 8px 12px 20px; }
  .results { max-height: none; overflow: visible; }
  .results .row { min-height: 64px; padding: 12px 8px; gap: 5px; }
  .results .row b, .results .row small, .favlist .lbl b, .fav-current .lbl b { white-space: normal; overflow-wrap: anywhere; }
  .results .act, .favlist .act { flex: none; width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; margin-right: 0; }
  .favlist .row { padding: 12px 4px; min-height: 64px; }
  .favlist .lbl { gap: 5px; }
  .fav-current { flex-direction: column; align-items: stretch; padding: 16px; gap: 14px; }
  .fav-current .btn { width: 100%; }
  #fav-add { width: 100%; margin-top: 8px; }
  .sync { margin-top: 24px; padding-top: 12px; }
  .hint { line-height: 1.55; }
  .coderow { gap: 10px; }
  .code { flex-basis: 100%; padding: 12px; text-align: center; }
  .coderow .btn { flex: 1 1 100%; }
  .codeinput { flex-basis: 100%; }
  .modal-actions > .btn { flex: 1; }
  #install-tabs { display: flex; width: 100%; }
  #install-tabs .segbtn { flex: 1; min-width: 0; padding: 8px 4px; font-size: 12px; }
  .alt { gap: 8px; }
  .alt .btn { height: auto; min-height: 44px; }
  .steps { margin-top: 20px; }
  .steps li { padding: 14px 0; }
  .pwa { margin-top: 20px; padding: 16px; gap: 12px; }
  .emptystate { padding: 40px 0; }
}

@media (max-width: 360px) {
  :root { --gutter: 16px; }
  .bar { gap: 8px; }
  .who-label { font-size: 16px; }
  .lesson { padding: 16px 14px; }
  .modal-head { padding-left: 16px; padding-right: 16px; }
  .modal-body { padding-left: 16px; padding-right: 16px; }
}

/* Brand, application releases and timetable freshness. */
.brand-logo { flex: 0 0 36px; border-radius: 10px; }
.freshness-row { color: var(--fg-2); font-size: 12px; padding-top: 10px; }
.freshness-row:has(#fetched:empty) { display: none; }
#fetched.is-stale { color: var(--k-consult); }
.app-update { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: var(--r); background: var(--surface); font-size: 13px; }
.app-update > span { flex: 1 1 240px; }
.app-update[hidden] { display: none; }
#app-version { font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .brand-logo { width: 30px; height: 30px; flex-basis: 30px; border-radius: 8px; } }
