:root {
  --bg: #f4f3fb;
  --card: #ffffff;
  --ink: #1d1b2e;
  --muted: #7b7891;
  --accent: #6d4aff;
  --accent-2: #ff5fa2;
  --ok: #1faa73;
  --danger: #e0455e;
  --line: #ece9f6;
  --radius: 16px;
  --shadow: 0 6px 22px rgba(45, 30, 110, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--danger); font-weight: 600; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px); padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: var(--shadow);
}
.topbar .brand { color: #fff; font-weight: 800; font-size: 1.1rem; }
.topbar .who { font-size: .82rem; opacity: .95; }
.topbar .who a { color: #fff; text-decoration: underline; }

.container { max-width: 720px; margin: 0 auto; padding: 16px; }

/* Cards */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.card h3.list-sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 16px 0 8px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

/* Custody banner */
.custody { color: #fff; background: linear-gradient(120deg, var(--accent), #9a7bff); }
.custody.other { background: linear-gradient(120deg, #ff7eb3, var(--accent-2)); }
.custody-week { font-size: .8rem; opacity: .85; }
.custody-main { font-size: 1.5rem; font-weight: 800; margin: 4px 0 8px; }
.custody-main strong { text-decoration: underline; text-underline-offset: 3px; }
.custody-next { font-size: .9rem; opacity: .95; }

/* Lessons / exams */
ul { list-style: none; margin: 0; padding: 0; }
.lessons li { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px;
  align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lessons li:last-child { border-bottom: 0; }
.lessons .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.lessons .subj { font-weight: 600; }
.lessons .subj em { color: var(--accent-2); font-style: normal; font-weight: 700; }
.lessons .meta { color: var(--muted); font-size: .8rem; text-align: right; }
.lessons li.cancelled .subj { text-decoration: line-through; color: var(--muted); }
.lessons li.exam { background: #fff7d6; border-radius: 10px; padding: 8px; }

.exams li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.badge { background: var(--line); color: var(--ink); border-radius: 999px;
  padding: 2px 10px; font-size: .78rem; white-space: nowrap; }

/* Homework */
.homework li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.homework li:last-child { border-bottom: 0; }
.homework li.done .hw-body { opacity: .5; text-decoration: line-through; }
.hw-top { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.hw-text { font-size: .9rem; color: #444; }

/* Lists generic */
.watch li, .activities li, .todos li { display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line); }
.watch li:last-child, .activities li:last-child, .todos li:last-child { border-bottom: 0; }
.watch .title, .activities .title, .todos .title { flex: 1; }
.todos li.done .title, .watch li.seen .title { opacity: .55; }
.todos.compact li { padding: 6px 0; }
.by { color: var(--muted); font-style: normal; font-size: .8rem; }
.actions { display: flex; gap: 4px; }
.stars { display: flex; }
.star { background: none; border: 0; font-size: 1.2rem; color: #d8d5e8; cursor: pointer; padding: 0 1px; }
.star.on { color: #ffb400; }

/* Buttons */
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700;
  cursor: pointer; background: var(--line); color: var(--ink); font-size: .9rem; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); width: 100%; }
.btn.tiny { padding: 5px 9px; font-size: .8rem; border-radius: 8px; }
.btn.danger { color: var(--danger); background: #fde8eb; }
.check { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--accent); line-height: 1; }

/* Forms */
.add-form { display: flex; gap: 8px; margin-bottom: 8px; }
.add-form input { flex: 1; }
input, select { width: 100%; padding: 11px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 1rem; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.add-form select { width: auto; }

/* Login */
.login { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; width: 100%; max-width: 360px; text-align: center; }
.login-card h1 { margin: 0 0 4px; background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; text-align: left; }
.login-card label { font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.login-card .btn { margin-top: 6px; }
.sync form { margin-bottom: 8px; }

/* Bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 18px rgba(45, 30, 110, .06);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; color: var(--muted); flex: 1; }
.tabbar a span { font-size: 1.3rem; }
.tabbar a.active { color: var(--accent); font-weight: 700; }
