:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e6e8f0;
  --brand: #2f5bea;
  --brand-soft: #e8eeff;
  --test: #e5484d;
  --test-soft: #ffeceb;
  --quiz: #d97706;
  --quiz-soft: #fff4e0;
  --notice: #0e9384;
  --notice-soft: #e2f6f3;
  --assign: #2f5bea;
  --assign-soft: #e8eeff;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b; --card: #1a1f2a; --ink: #eef0f6; --muted: #9aa3b5; --line: #2a3140;
    --brand-soft: #22305a; --test-soft: #3b1f22; --quiz-soft: #3a2c14; --notice-soft: #12322f; --assign-soft: #22305a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", "Rubik", "Heebo", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: baseline; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.top h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; color: var(--brand); }

main { max-width: 640px; margin: 0 auto; padding: 4px 14px 24px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--test); margin: 6px 0 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); }
.card.empty { text-align: center; padding: 28px 18px; }
.card.empty h2 { margin: 0 0 6px; }
.card.soft { background: transparent; border: 1px dashed var(--line); box-shadow: none; }
.card.soft p { margin: 6px 0 12px; color: var(--muted); }

.banner { background: var(--brand-soft); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.banner p { margin: 4px 0 10px; }
.banner p:last-child { margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:active { transform: scale(0.98); }
.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 6px; }
.link.danger { color: var(--test); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 2px; scrollbar-width: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--brand)); display: inline-block; flex: none; }
.dot.big { width: 14px; height: 14px; }

.group { margin: 22px 4px 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.item {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: 14px; padding: 14px 14px 14px 12px; margin: 8px 0;
  border-inline-start: 5px solid var(--c);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); cursor: pointer;
}
.item .body { flex: 1; min-width: 0; }
.item .row1 { display: flex; align-items: center; gap: 8px; }
.item .row1 b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.item .details { margin: 6px 0 0; font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item.k-test, .item.k-quiz { box-shadow: 0 1px 2px rgb(0 0 0 / 0.04), inset 0 0 0 1px color-mix(in srgb, var(--test) 25%, transparent); }
.item.done { opacity: 0.55; }
.item.done .row1 b { text-decoration: line-through; }
.item.cancelled { opacity: 0.5; }
.item.cancelled .row1 b { text-decoration: line-through; }

.check {
  flex: none; width: 28px; height: 28px; margin-top: 2px; border-radius: 9px;
  border: 2px solid var(--line); background: transparent; color: #fff; font-weight: 700; cursor: pointer;
}
.check[aria-pressed="true"] { background: var(--c); border-color: var(--c); }

.badge { flex: none; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.test { background: var(--test-soft); color: var(--test); }
.badge.quiz { background: var(--quiz-soft); color: var(--quiz); }
.badge.notice { background: var(--notice-soft); color: var(--notice); }
.badge.assignment { background: var(--assign-soft); color: var(--assign); }

.kid .kidhead { display: flex; align-items: center; gap: 10px; }
.kid h2 { margin: 0; font-size: 19px; flex: 1; }
.classes { list-style: none; padding: 0; margin: 10px 0; }
.classes li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pick { display: grid; gap: 8px; }

.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
select, input {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input { width: 100%; margin-top: 8px; }

.tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; font: inherit; font-size: 12px; color: var(--muted); padding: 6px; cursor: pointer;
}
.tab span { font-size: 20px; filter: grayscale(1); opacity: 0.7; }
.tab.on { color: var(--brand); font-weight: 600; }
.tab.on span { filter: none; opacity: 1; }

.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet .backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.35); }
.sheet .panel {
  position: absolute; inset-inline: 0; bottom: 0; max-height: 85vh; overflow: auto;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
  animation: up 0.18s ease-out;
}
.sheet h2 { margin: 8px 0 4px; }
.quote { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin-top: 12px; white-space: pre-wrap; }
.quote p { margin: 4px 0 0; }
.linkbox { background: var(--bg); border-radius: 10px; padding: 12px; direction: ltr; word-break: break-all; font-size: 14px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 420px; margin: 0 auto; text-align: center;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px;
}
[hidden] { display: none !important; }
