:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e3e5ec;
  --accent: #4f46e5;
  --accent-soft: #ecebfd;
  --today: #0f9d58;
  --now: #f59e0b;
  --radius: 14px;
}
html[data-theme="dark"] {
  --bg: #101218;
  --card: #191c25;
  --text: #e8eaf0;
  --muted: #9aa1b1;
  --line: #272b37;
  --accent: #8b85ff;
  --accent-soft: #23233a;
  --today: #34d399;
  --now: #fbbf24;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: 3.5rem;
  -webkit-text-size-adjust: 100%;
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: .75rem 1rem .6rem;
  padding-top: max(.75rem, env(safe-area-inset-top));
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
h1 { font-size: 1.05rem; margin: 0; font-weight: 650; }
.icon-btn {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  width: 2.2rem; height: 2.2rem; border-radius: 50%; font-size: 1rem;
  cursor: pointer; flex: none;
}
.controls { display: flex; gap: .75rem; margin-top: .6rem; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: .25rem; flex: 1 1 8rem; min-width: 8rem; }
.field-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
select {
  font: inherit; padding: .5rem .6rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}
.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button {
  flex: 1; padding: .5rem .4rem; font: inherit; font-size: .85rem;
  border: 0; background: var(--bg); color: var(--muted); cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.hint { margin: .5rem 0 0; font-size: .78rem; color: var(--muted); }

main { padding: .85rem 1rem 0; max-width: 44rem; margin: 0 auto; }
.loading, .empty-all { color: var(--muted); text-align: center; padding: 2rem 0; }

.day { margin-bottom: 1.1rem; }
.day-head {
  display: flex; align-items: baseline; gap: .5rem;
  font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 0 0 .45rem .15rem;
}
.day.is-today .day-head { color: var(--today); }
.badge-today {
  font-size: .62rem; letter-spacing: .03em; padding: .12rem .4rem;
  border-radius: 999px; background: var(--today); color: #fff; font-weight: 700;
}
.day-empty { font-size: .85rem; color: var(--muted); padding: .1rem .15rem .4rem; }

.lesson {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .65rem .8rem; margin-bottom: .45rem;
}
.lesson.is-now { border-color: var(--now); box-shadow: 0 0 0 2px color-mix(in srgb, var(--now) 25%, transparent); }
.time {
  flex: none; width: 4.1rem; font-variant-numeric: tabular-nums;
  font-size: .78rem; font-weight: 600; color: var(--accent); padding-top: .1rem;
}
.body { min-width: 0; flex: 1; }
.subject { font-weight: 600; overflow-wrap: anywhere; }
.meta { font-size: .82rem; color: var(--muted); margin-top: .15rem; overflow-wrap: anywhere; }
.tags { margin-top: .3rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.tag {
  font-size: .66rem; padding: .1rem .4rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.tag.now { background: var(--now); color: #241c00; }

.footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem 1rem; padding-bottom: max(.5rem, env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
  font-size: .72rem; color: var(--muted);
}
.offline-badge { color: var(--now); font-weight: 600; }
@media (min-width: 40rem) { .time { width: 5rem; font-size: .82rem; } }
