:root {
  --ink: #1c1915;
  --muted: #6b645c;
  --line: #e4ddd4;
  --paper: #f6f1ea;
  --card: #fffdf9;
  --field: #fff;
  --accent: #0f6e56;
  --accent-ink: #e7f6f1;
  --warn: #8a3b12;
  --wash: #efe4d4;
  --shadow: 0 10px 30px rgba(40, 28, 16, 0.06);
  --note: #fff1ea;
  --dow: #8b93a7;
  --day: #f7f8fb;
  --day-line: #d5dbe8;
  --day-has: #e7f6ee;
  --day-has-line: #b7dfc8;
  --day-has-ink: #14663a;
  --blue: #2f6fed;
  --blue-fill: #2f6fed;
  --green: #1f8a4c;
  --on-green: #fff;
  --checked: #f3fbf6;
  --orange: #c45e00;
  --orange-bg: #fff6eb;
  --orange-line: #f0d3b0;
  --orange-edge: #e07a1a;
  --meta: #5c6578;
  --badge-done: #eceae6;
  color-scheme: light;
  font-family: "Segoe UI", "Noto Sans", "Liberation Sans", system-ui, sans-serif;
}
html[data-theme="dark"] {
  --ink: #f4efe8;
  --muted: #b7aea3;
  --line: #3c342c;
  --paper: #14110e;
  --card: #221e1a;
  --field: #2c2722;
  --accent: #3cbe9a;
  --accent-ink: #16352c;
  --warn: #f0a07a;
  --wash: #2a2218;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --note: #3a2418;
  --dow: #9aa3b5;
  --day: #2a2622;
  --day-line: #3d3832;
  --day-has: #1a3326;
  --day-has-line: #2f6b48;
  --day-has-ink: #b7ebc9;
  --blue: #8eb4ff;
  --blue-fill: #2f6fed;
  --green: #7dcea0;
  --on-green: #102117;
  --checked: #173026;
  --orange: #f0b27a;
  --orange-bg: #3a2818;
  --orange-line: #6b4a2a;
  --orange-edge: #e09a45;
  --meta: #b7aea3;
  --badge-done: #322c27;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 10% -10%, var(--wash) 0%, transparent 55%),
    var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
}
button, input { font: inherit; }
button { cursor: pointer; }
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 4px; font-weight: 650; letter-spacing: 0; font-size: 1.05rem; }
a.brand { color: inherit; text-decoration: none; }
.brand img { width: 33px; height: 33px; flex: 0 0 auto; }
.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 2px 4px;
  min-width: 0;
}
.who {
  color: var(--muted);
  margin-left: 8px;
  font-size: 0.92rem;
  font-weight: 450;
  flex: 0 1 auto;
  max-width: min(14rem, 42vw);
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  line-height: 1.25;
}
.who-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
  flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.who-user, .who-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who-user { color: var(--ink); font-weight: 650; }
.who-name { font-size: 0.85rem; }
button.text {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 8px 8px;
  min-height: 44px;
  font-size: 0.92rem;
  font-weight: 600;
}
.nav button.text:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  padding: 0;
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
html[data-theme="dark"] .theme-moon,
html:not([data-theme="dark"]) .theme-sun { display: none; }
button.warn { color: var(--warn); border-color: var(--orange-line); }
main {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left));
  flex: 1 1 auto;
}
.site-foot {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
  text-align: center;
}
.site-foot p { margin: 0; }
.site-foot a { color: var(--accent); }
.site-contact { display: flex; flex-wrap: wrap; gap: 6px 14px; }
body:has(.legal) main { display: flex; justify-content: center; }
.legal {
  max-width: 680px;
  width: 100%;
  margin-inline: auto;
  text-align: center;
}
.legal ul {
  display: inline-block;
  text-align: left;
  margin-inline: auto;
}
.legal h1 { font-size: 1.6rem; }
.legal h2 { font-size: 1.05rem; margin: 1.4rem 0 0.4rem; }
.legal p, .legal li { line-height: 1.5; color: var(--ink); }
.legal ul { padding-left: 1.2rem; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 4vw, 28px);
}
h1 { font-size: clamp(1.35rem, 5vw, 2rem); margin: 0 0 8px; font-weight: 650; }
p.lead { color: var(--muted); margin-top: 0; line-height: 1.45; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
input[type="email"], input[type="text"], input[type="url"], input[type="password"] {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 16px;
}
.signin {
  display: grid;
  width: 100%;
  gap: 20px;
}
.signin-side h2 { font-size: 1.25rem; margin: 0 0 4px; }
.signin .lead { margin-bottom: 8px; font-size: 0.92rem; }
.signin label { margin-bottom: 4px; }
.signin input[type="email"],
.signin input[type="text"],
.signin input[type="password"] {
  padding: 8px 12px;
  margin-bottom: 8px;
}
.signin .steps { margin: 8px 0; }
.signin .steps li { margin: 2px 0; }
.signin .row { margin-bottom: 8px; }
.signin .row > button { flex: 0 1 auto; }
body:has(.signin) main {
  max-width: min(1240px, calc(100vw - 32px));
  padding-top: 12px;
  padding-bottom: 12px;
}
.panel:has(.signin) { padding: 16px 22px; }
@media (min-width: 860px) {
  body:has(.signin) {
    height: 100dvh;
    overflow: hidden;
  }
  .signin {
    grid-template-columns: 1.2fr 0.8fr;
    gap: 0;
    align-items: start;
  }
  .signin-side + .signin-side {
    border-left: 1px solid var(--line);
    padding-left: 32px;
    margin-left: 32px;
  }
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > button { flex: 1 1 10rem; }
button.primary, button.secondary {
  border-radius: 999px;
  padding: 12px 18px;
  border: 1px solid transparent;
  min-height: 44px;
}
button.primary { background: var(--accent); color: white; }
button.secondary { background: transparent; border-color: var(--line); color: var(--ink); }
button:disabled { opacity: 0.55; cursor: default; }
a { color: var(--accent); }
.secure-note {
  margin: 0;
  padding: 12px 16px;
  background: var(--note);
  color: var(--warn);
}
details.extra { margin-top: 18px; }
details.extra summary { cursor: pointer; color: var(--accent); margin-bottom: 12px; }
.setup { margin-bottom: 16px; }
.setup h2 { font-size: 1.35rem; margin: 0 0 8px; }
.error {
  background: var(--note);
  color: var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 14px;
}
.steps { margin: 0 0 16px; padding-left: 18px; color: var(--ink); }
.steps li { margin: 6px 0; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar h1 {
  font-size: clamp(1.15rem, 4.2vw, 1.6rem);
  flex: 1 1 9rem;
  text-align: center;
  min-width: 0;
}
.scan-row { margin: 0 0 16px; }
.scan-row > button { flex: 1 1 100%; }
.cal-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.cal-tools > button { flex: 1 1 auto; }
.month-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px 16px;
  margin-bottom: 14px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.cal-head h1 { font-size: 1.15rem; margin: 0; font-family: inherit; }
.cal-nav { display: flex; gap: 8px; }
.cal-nav button { min-width: 44px; padding: 0 12px; border-radius: 12px; }
.month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.dow {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--dow);
  text-align: center;
  padding: 4px 0;
}
.day-btn {
  width: 100%;
  min-height: 2.75rem;
  margin: 0;
  padding: 8px 2px;
  border-radius: 6px;
  border: 1px solid var(--day-line);
  background: var(--day);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
}
.day-btn.has { background: var(--day-has); border-color: var(--day-has-line); color: var(--day-has-ink); }
.day-btn.selected { background: var(--blue-fill); border-color: var(--blue-fill); color: white; }
.day-btn.has.selected { background: var(--green); border-color: var(--green); color: var(--on-green); }
.day-btn.outside { color: var(--dow); background: transparent; }
dialog.stats-view {
  width: min(1100px, calc(100vw - 24px));
  height: min(92dvh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
dialog.stats-view .cal-head { flex: 0 0 auto; }
dialog.stats-view .lead { flex: 0 0 auto; }
dialog.stats-view #uni-picker {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
dialog.stats-view .uni-list {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  margin-bottom: 0;
}
a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 44px;
  background: var(--accent);
  color: white;
  text-decoration: none;
}
.uni-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  margin-bottom: 14px;
}
.uni-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 56px;
}
.uni-pick img { width: 72px; height: 36px; object-fit: contain; }
.uni-pick.selected { border-color: var(--accent); background: var(--accent-ink); }
.day-btn.today,
.day-btn.has.today,
.day-btn.selected.today,
.day-btn.has.selected.today,
.day-btn.outside.today { border: 2px solid var(--blue); }
.class-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--day-line);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.class-card .kind { color: var(--blue); font-weight: 700; margin-bottom: 2px; }
.class-card .title {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.class-card .meta, .class-card .when { color: var(--meta); font-size: 0.92rem; }
.class-card.checked {
  background: var(--checked);
  border-color: var(--day-has-line);
  border-left-color: var(--green);
}
.class-card.checked .kind { color: var(--green); }
.class-card.checked .status { color: var(--day-has-ink); }
.class-card.projected {
  background: var(--orange-bg);
  border-color: var(--orange-line);
  border-left-color: var(--orange-edge);
}
.class-card.projected .kind { color: var(--orange); }
.class-card.projected .status { color: var(--orange); }
.class-card.ready .status { color: var(--blue); }
.status {
  color: var(--meta);
  font-size: 0.82rem;
  text-align: center;
  min-width: 4.5rem;
  max-width: 6.5rem;
}
.pin {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 4px;
  color: var(--green);
}
.clock {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 4px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  position: relative;
}
.clock::before, .clock::after {
  content: "";
  position: absolute;
  background: var(--blue);
  left: 11px;
}
.clock::before { top: 5px; width: 2px; height: 8px; }
.clock::after { top: 12px; width: 7px; height: 2px; }
.tick {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 4px;
  color: var(--green);
}
.maybe {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 4px;
  color: var(--orange-edge);
}
.day { margin: 18px 0; }
.day h2 {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 650;
}
.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "when badge"
    "body body"
    "action action";
  gap: 8px 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 8px;
}
.when { grid-area: when; color: var(--accent); font-variant-numeric: tabular-nums; }
.card .body { grid-area: body; min-width: 0; }
.card .badge { grid-area: badge; justify-self: end; }
.card button.action { grid-area: action; width: 100%; }
.title { font-weight: 650; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 0.92rem; margin-top: 3px; overflow-wrap: anywhere; }
.badge {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--accent-ink);
  color: var(--accent);
}
.badge.done { background: var(--badge-done); color: var(--muted); }
dialog {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: min(460px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(92dvh, 760px);
  overflow: auto;
  margin: auto;
}
dialog::backdrop { background: rgba(28, 25, 21, 0.35); }
video.preview {
  display: block;
  width: 100%;
  max-height: 48dvh;
  background: #141210;
  border-radius: 12px;
  object-fit: cover;
  margin-bottom: 12px;
}
.choices { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.choices button { text-align: left; }
.empty { color: var(--muted); padding: 24px 0; }
@media (min-width: 800px) {
  .top { padding: 18px 28px; }
  main { padding: 28px 20px 64px; }
  .row > button, .scan-row > button { flex: 0 0 auto; }
  .card {
    grid-template-columns: 9.5rem minmax(0, 1fr) auto auto;
    grid-template-areas: "when body badge action";
    gap: 12px;
  }
  .card button.action { width: auto; }
}
