:root {
  color-scheme: dark;
  --background: #111813;
  --surface: #1a231c;
  --higher: #243128;
  --text: #f1f4eb;
  --muted: #aab9ab;
  --line: #354439;
  --accent: #caf478;
  --on-accent: #18230e;
  --hero: #233522;
  --hero-line: #4c6342;
  --hero-text: #f1fae6;
  --hero-muted: #b7caaa;
  --warning: #e6bc87;
  --focus: #caf478;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #f2f5ee;
  --surface: #fff;
  --higher: #e8eee4;
  --text: #17241a;
  --muted: #526558;
  --line: #d2ddd0;
  --warning: #845118;
  --focus: #367137;
}

:root[data-theme="indigo"] {
  --background: #141625;
  --surface: #1e2237;
  --higher: #292e48;
  --text: #f1f0ff;
  --muted: #b7bbd5;
  --line: #414762;
  --accent: #c3bcff;
  --on-accent: #221b54;
  --hero: #292647;
  --hero-line: #544c7c;
  --hero-text: #f7f3ff;
  --hero-muted: #cbc0eb;
  --focus: #c3bcff;
}

:root[data-theme="amber"] {
  --background: #211813;
  --surface: #2e221b;
  --higher: #3e2e25;
  --text: #fff4e8;
  --muted: #dac0aa;
  --line: #584333;
  --accent: #ffcd87;
  --on-accent: #352112;
  --hero: #3f2b1e;
  --hero-line: #69513a;
  --hero-text: #fff4e8;
  --hero-muted: #e6c8a7;
  --focus: #ffcd87;
}

:root[data-theme="paper"] {
  color-scheme: light;
  --background: #f2ece0;
  --surface: #fffbf4;
  --higher: #ebe2d3;
  --text: #30271e;
  --muted: #625549;
  --line: #d6c9b8;
  --accent: #754921;
  --on-accent: #fff7eb;
  --hero: #efe1cb;
  --hero-line: #d6c0a1;
  --hero-text: #38281b;
  --hero-muted: #695140;
  --warning: #8b4b15;
  --focus: #754921;
}

:root[data-theme="ocean"] {
  --background: #0b1921;
  --surface: #122730;
  --higher: #1d3540;
  --text: #eaf6f7;
  --muted: #aac2ca;
  --line: #34515d;
  --accent: #8ce1d6;
  --on-accent: #103232;
  --hero: #173640;
  --hero-line: #3c656c;
  --hero-text: #ebfbf9;
  --hero-muted: #accdd0;
  --focus: #8ce1d6;
}

:root[data-theme="plum"] {
  --background: #211723;
  --surface: #2c2030;
  --higher: #3d2c42;
  --text: #fff1fe;
  --muted: #d2b9cd;
  --line: #554055;
  --accent: #f0b7df;
  --on-accent: #3b2438;
  --hero: #40293f;
  --hero-line: #6a4b64;
  --hero-text: #fff4fe;
  --hero-muted: #ddc0d5;
  --focus: #f0b7df;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 280px;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.app {
  max-width: 620px;
  margin-inline: auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.list-heading, .settings-heading, .picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quiet, .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 650;
}
.primary { color: var(--on-accent); border-color: transparent; background: var(--accent); }
.quiet:active, .primary:active, .group-choice:active { transform: translateY(1px); }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 23px;
  border: 1px solid var(--hero-line);
  background: var(--hero);
  color: var(--hero-text);
}
.hero-main { min-width: 0; }
.hero-group, .hero-caption { margin: 0; color: var(--hero-muted); font-size: .9rem; }
.hero-group { font-weight: 650; overflow-wrap: anywhere; }
h1, h2, p { margin: 0; }
.hero h1 { margin: 5px 0 4px; font-size: clamp(1.65rem, 7vw, 2.7rem); letter-spacing: -.045em; line-height: 1.04; }
.hero-date { display: grid; gap: 5px; justify-items: end; color: var(--accent); font-size: clamp(2.35rem, 10vw, 3.4rem); line-height: .88; letter-spacing: -.075em; }
.hero-date b { font-weight: 750; }
.hero-date span { color: var(--hero-muted); font-size: .875rem; letter-spacing: 0; font-weight: 650; }

.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-block: 15px 20px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.tab, .week-nav, .week-day {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 680;
}
.tab[aria-pressed="true"], .week-day[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.week {
  padding: 9px;
  margin-bottom: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.week-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.week-nav { width: 42px; font-size: 1.37rem; }
.week-days { display: grid; gap: 2px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.week-day { padding: 4px 0; display: grid; align-content: center; gap: 4px; font-size: .875rem; }
.week-day b { color: var(--text); font-size: 1rem; }
.week-day[aria-pressed="true"] b { color: var(--on-accent); }

h2 { font-size: 1.2rem; letter-spacing: -.02em; font-weight: 750; }
.list-heading { margin-bottom: 11px; }
.day-content { display: grid; gap: 9px; }
.day-content.entering { animation: show-day 180ms ease-out both; }
@keyframes show-day {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .day-content.entering { animation: none; }
}
.lesson, .empty {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.lesson.active { border-color: var(--focus); }
.lesson-time { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 8px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.lesson-time b { color: var(--text); font-weight: 700; }
.lesson h3 { margin: 6px 0; font-size: 1.0625rem; line-height: 1.25; overflow-wrap: anywhere; }
.lesson-detail { color: var(--muted); font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.lesson-option + .lesson-option { margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.lesson-subgroup { display: block; margin-top: 7px; color: var(--muted); font-size: .875rem; font-weight: 680; }
.lesson-option + .lesson-option .lesson-subgroup { margin-top: 0; }
.compact-cards .lesson {
  border-radius: 12px;
  border-inline-start-width: 3px;
  padding: 10px 12px;
}
.compact-cards .lesson-time { align-items: center; font-size: .8125rem; }
.compact-cards .lesson-time b {
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--higher);
}
.compact-cards .lesson-now { color: var(--focus); font-weight: 680; }
.compact-cards .lesson h3 { margin: 5px 0 3px; }
.compact-cards .lesson-detail { line-height: 1.4; }
.compact-cards .lesson-option + .lesson-option { margin-top: 8px; padding-top: 8px; }
.empty { padding: 24px 15px; text-align: center; color: var(--muted); line-height: 1.45; }
.provenance { margin: 15px 3px 0; line-height: 1.45; font-size: .825rem; color: var(--muted); }
.provenance.stale { color: var(--warning); }

.picker, .launch { padding: 16px 0 7px; }
.picker-heading { align-items: flex-start; margin-bottom: 18px; }
.picker h1, .launch h1 { font-size: clamp(1.7rem, 7vw, 2.25rem); line-height: 1.12; letter-spacing: -.045em; }
.picker-heading p, .launch p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.4;
}
.launch .primary { margin-top: 16px; }
.search-form {
  position: relative;
  padding-block: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.search-form:focus-within { border-color: var(--focus); }
.search-icon {
  position: absolute;
  top: 19px;
  left: 15px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}
.search-icon::after {
  position: absolute;
  content: "";
  width: 7px;
  height: 2px;
  border-radius: 1px;
  background: var(--muted);
  transform: rotate(45deg);
  top: 10px;
  left: 9px;
}
input[type="search"] {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  padding: 7px 13px 7px 42px;
  background: transparent;
  color: var(--text);
}
input[type="search"]:focus-visible { outline-offset: -3px; }
.search-status { margin: 12px 2px; color: var(--muted); line-height: 1.4; font-size: .875rem; }
.search-status:empty { margin: 0; }
.groups { display: grid; gap: 6px; margin-top: 8px; }
.group-choice {
  display: grid;
  width: 100%;
  gap: 4px;
  min-height: 50px;
  padding: 9px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}
.group-choice span { font-size: .875rem; color: var(--muted); }
.group-choice b { overflow-wrap: anywhere; }

dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  margin-block: auto max(12px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgb(8 16 9 / 65%); }
.settings-inner { padding: 16px; }
.settings-heading { margin-bottom: 14px; }
.settings-group { width: 100%; justify-content: flex-start; }
.settings-inner label { display: grid; gap: 6px; margin-top: 12px; }
.settings-inner :is(.digest-toggle, .card-layout-toggle) { display: flex; align-items: center; gap: 8px; padding-block: 5px; }
:is(.digest-toggle, .card-layout-toggle) input { inline-size: 18px; block-size: 18px; accent-color: var(--accent); flex-shrink: 0; }
.card-layout-toggle { min-height: 40px; }
.appearance { min-width: 0; margin: 18px 0 0; padding: 0; border: 0; }
.appearance legend { padding: 0; color: var(--muted); font-size: .875rem; font-weight: 650; }
.appearance > label:first-of-type, .appearance > label[hidden] + label { margin-top: 6px; }
.picker-preferences { margin-top: 12px; }
.settings-inner input[type="time"] {
  min-height: 44px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--higher);
  color: var(--text);
}
.feed-day { display: grid; gap: 9px; padding-block: 5px 12px; scroll-margin-top: 14px; }
.feed-day > h3 { margin: 6px 0 1px; font-size: 1rem; text-transform: capitalize; }
.class-gap {
  margin: 0;
  padding: 2px 12px;
  color: var(--muted);
  font-size: .875rem;
}
select {
  min-height: 45px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 7px 10px;
  background: var(--higher);
  color: var(--text);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 350px) {
  .app { padding-inline: 12px; }
  .hero { padding: 12px; }
  .picker-heading { flex-wrap: wrap; }
}
