/* ============ Семестр — дизайн-система ============ */
:root {
  color-scheme: light;
  --page: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f1f0ed;
  --surface-3: #e8e7e3;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --hair: #e4e3dd;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, .10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, .10);
  --series-2: #1baf7a;
  --seq-1: #e9f1fc; --seq-2: #b7d3f6; --seq-3: #6da7ec; --seq-4: #2a78d6; --seq-5: #184f95;
  --good: #0ca30c; --good-ink: #006300; --good-wash: rgba(12, 163, 12, .10);
  --warn: #fab219; --warn-ink: #8a5a00; --warn-wash: rgba(250, 178, 25, .14);
  --serious: #ec835a;
  --bad: #d03b3b; --bad-ink: #b02a2a; --bad-wash: rgba(208, 59, 59, .09);
  --shadow: 0 1px 0 rgba(11, 11, 11, .03), 0 8px 24px -12px rgba(11, 11, 11, .10);
  --shadow-lg: 0 24px 64px -16px rgba(11, 11, 11, .28);
  --r: 14px; --r-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --side: 248px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #161615; --surface-2: #1f1f1d; --surface-3: #2a2a28;
    --ink: #f5f5f3; --ink-2: #c3c2b7; --ink-3: #898781;
    --hair: #2a2a28; --axis: #383835; --ring: rgba(255, 255, 255, .09);
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, .16);
    --series-2: #199e70;
    --seq-1: #1a2433; --seq-2: #184f95; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
    --good-ink: #3ec43e; --good-wash: rgba(12, 163, 12, .16);
    --warn-ink: #fab219; --warn-wash: rgba(250, 178, 25, .14);
    --bad: #e05252; --bad-ink: #f07a7a; --bad-wash: rgba(224, 82, 82, .14);
    --shadow: 0 1px 0 rgba(0, 0, 0, .4); --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #161615; --surface-2: #1f1f1d; --surface-3: #2a2a28;
  --ink: #f5f5f3; --ink-2: #c3c2b7; --ink-3: #898781;
  --hair: #2a2a28; --axis: #383835; --ring: rgba(255, 255, 255, .09);
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, .16);
  --series-2: #199e70;
  --seq-1: #1a2433; --seq-2: #184f95; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #9ec5f4;
  --good-ink: #3ec43e; --good-wash: rgba(12, 163, 12, .16);
  --warn-ink: #fab219; --warn-wash: rgba(250, 178, 25, .14);
  --bad: #e05252; --bad-ink: #f07a7a; --bad-wash: rgba(224, 82, 82, .14);
  --shadow: 0 1px 0 rgba(0, 0, 0, .4); --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: var(--accent-wash); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.small { font-size: 12px; }
.xs { font-size: 11px; letter-spacing: .02em; }
.upper { text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Каркас ============ */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--hair); background: var(--page);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--page); display: grid; place-items: center; }
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--ink-3); font-size: 11px; margin-top: -2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2);
  font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; transition: background .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ring), var(--shadow); }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-item .count.bad { color: var(--bad-ink); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.kbd { font: 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--hair); background: var(--surface); color: var(--ink-3); }
.search-btn {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--hair);
  background: var(--surface); color: var(--ink-3); cursor: pointer; width: 100%;
}
.search-btn .kbd { margin-left: auto; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.me:hover { background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600; font-size: 12px;
  color: #fff; background: linear-gradient(135deg, #2a78d6, #4a3aa7);
}
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }

.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.head-actions { display: flex; gap: 8px; align-items: center; }

.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: calc(14px + env(safe-area-inset-top)) 14px calc(96px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 22px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--page) 86%, transparent);
    backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--hair);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none;
    color: var(--ink-3); font-size: 10.5px; font-weight: 500; cursor: pointer; position: relative;
  }
  .tab.active { color: var(--ink); }
  .tab .dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--page); }
}

/* ============ Базовые элементы ============ */
.card {
  background: var(--surface); border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--ring), var(--shadow);
  padding: 18px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.card-head .sub { color: var(--ink-3); font-size: 12px; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 16px 18px 0; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
@media (max-width: 1100px) { .span-8, .span-7, .span-5, .span-4 { grid-column: span 12; } .span-3 { grid-column: span 6; } .span-6 { grid-column: span 12; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 9px;
  border: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--ring); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: var(--page); box-shadow: none; }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--page)); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; font-size: 12.5px; padding: 0 10px; border-radius: 8px; }
.btn.danger { color: var(--bad-ink); }
.btn .spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; }
.chip.good { background: var(--good-wash); color: var(--good-ink); }
.chip.warn { background: var(--warn-wash); color: var(--warn-ink); }
.chip.bad { background: var(--bad-wash); color: var(--bad-ink); }
.chip.accent { background: var(--accent-wash); color: var(--accent-ink); }
.chip.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--hair); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0; background: none; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 500; white-space: nowrap;
  font-size: 13px;
}
.seg button .n { color: var(--ink-3); margin-left: 4px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0,0,0,.06); }

.input, .select {
  height: 34px; padding: 0 11px; border-radius: 9px; border: 0; background: var(--surface); box-shadow: inset 0 0 0 1px var(--ring);
  min-width: 0; outline: none;
}
.input:focus, .select:focus, textarea.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 500; }

.switch { position: relative; width: 36px; height: 22px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }

.toggle-chip { display: inline-flex; }
.toggle-chip input { display: none; }
.toggle-chip span {
  padding: 5px 11px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--hair); cursor: pointer; font-size: 12.5px; color: var(--ink-2); user-select: none;
}
.toggle-chip input:checked + span { background: var(--ink); color: var(--page); box-shadow: none; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s var(--ease); }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-3); }
.empty svg { margin: 0 auto 10px; width: 28px; height: 28px; opacity: .6; }
.divider { height: 1px; background: var(--hair); margin: 14px 0; }

/* ============ Статистические плитки ============ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { position: relative; overflow: hidden; }
.kpi .label { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.kpi .label svg { width: 14px; height: 14px; color: var(--ink-3); }
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; margin-top: 10px; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 3px; }
.kpi .foot { margin-top: 6px; font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; min-height: 18px; }
.kpi .spark { position: absolute; right: 14px; top: 16px; opacity: .9; }
.kpi.alert .value { color: var(--bad-ink); }

/* ============ Приветствие ============ */
.hello { display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; align-items: end; margin-bottom: 20px; }
.hello h1 { margin: 0; font-size: 28px; letter-spacing: -.025em; font-weight: 650; line-height: 1.15; }
.hello .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.sem-bar { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.sem-track { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); }
.sem-track > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: var(--ink); }
.sem-track > b { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--axis); border-radius: 2px; }
@media (max-width: 900px) { .hello { grid-template-columns: 1fr; } .hello h1 { font-size: 23px; } }

/* ============ Задания ============ */
.task-list { display: flex; flex-direction: column; }
.week-head {
  display: flex; align-items: baseline; gap: 10px; padding: 18px 4px 8px; position: sticky; top: 0; z-index: 2;
  background: linear-gradient(var(--page) 70%, transparent);
}
.week-head b { font-size: 13px; font-weight: 600; }
.week-head span { color: var(--ink-3); font-size: 12px; }
.week-head .bar { margin-left: auto; width: 90px; }
.task {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px;
  background: var(--surface); cursor: pointer; transition: background .12s; position: relative;
}
.task-group { border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--ring), var(--shadow); overflow: hidden; background: var(--surface); }
.task + .task { box-shadow: inset 0 1px 0 var(--hair); }
.task:hover { background: var(--surface-2); }
.task .t-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .t-meta { display: flex; gap: 8px; align-items: center; color: var(--ink-3); font-size: 12px; margin-top: 1px; min-width: 0; }
.task .t-meta .ellipsis { min-width: 0; }
.task .t-when { text-align: right; font-size: 12.5px; white-space: nowrap; }
.task .t-when b { display: block; font-weight: 550; font-variant-numeric: tabular-nums; }
.task .t-when span { color: var(--ink-3); font-size: 12px; }
.task.is-done .t-title { color: var(--ink-3); }
.task .t-when .bad { color: var(--bad-ink); }
.task .t-when .warn { color: var(--warn-ink); }
.status-ico { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.status-ico svg { width: 12px; height: 12px; }
.status-ico.todo { box-shadow: inset 0 0 0 1.5px var(--axis); }
.status-ico.soon { box-shadow: inset 0 0 0 1.5px var(--warn); color: var(--warn); }
.status-ico.upcoming { box-shadow: inset 0 0 0 1.5px dashed var(--axis); background: repeating-conic-gradient(var(--surface-3) 0 25%, transparent 0 50%) 50% / 6px 6px; }
.status-ico.done { background: var(--good); color: #fff; }
.status-ico.graded { background: var(--accent); color: #fff; }
.status-ico.overdue { background: var(--bad); color: #fff; }
.status-ico.missed { background: var(--surface-3); color: var(--ink-3); }
.type-ico { width: 14px; height: 14px; color: var(--ink-3); flex: none; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.toolbar .grow { flex: 1; min-width: 160px; }
@media (max-width: 900px) { .toolbar .select, .toolbar .input { flex: 1 1 140px; } }

/* ============ Ближайшее (таймлайн) ============ */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-day { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 8px 0; }
.tl-day + .tl-day { border-top: 1px solid var(--hair); }
.tl-date b { display: block; font-size: 20px; font-weight: 650; letter-spacing: -.02em; line-height: 1; }
.tl-date span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.tl-date.today b { color: var(--accent); }
.tl-items { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tl-item { display: grid; grid-template-columns: 50px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 9px; cursor: pointer; }
.tl-item:hover { background: var(--surface-2); }
.tl-item .time { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); }
.tl-item .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item .course { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.countdown { font-variant-numeric: tabular-nums; font-weight: 650; letter-spacing: -.02em; }
.next-up { display: flex; flex-direction: column; gap: 10px; }
.next-up .big { font-size: 34px; line-height: 1; }

/* ============ Инсайты ============ */
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.insight .ico { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-2); }
.insight .ico svg { width: 15px; height: 15px; }
.insight b { font-weight: 600; }
.insight p { margin: 1px 0 0; color: var(--ink-2); font-size: 13px; line-height: 1.45; }

/* ============ Успеваемость ============ */
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .subjects { grid-template-columns: 1fr; } }
.subject .s-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.subject h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.subject .score { text-align: right; white-space: nowrap; }
.subject .score b { font-size: 28px; font-weight: 650; letter-spacing: -.03em; line-height: 1; }
.subject .score span { color: var(--ink-3); margin-left: 2px; }
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); margin: 18px 0 22px; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: var(--accent); min-width: 6px; transition: width .7s var(--ease); }
.meter > em { position: absolute; top: -4px; width: 2px; height: 16px; margin-left: -1px; background: var(--surface); box-shadow: 0 0 0 1px var(--axis); border-radius: 2px; font-style: normal; }
.meter > em small { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.cat-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.cat-row { font-size: 12px; }
.cat-row .top { display: flex; justify-content: space-between; color: var(--ink-2); gap: 6px; }
.cat-row .top b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.cat-row .progress { height: 3px; margin-top: 4px; }
.items-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items-table td { padding: 6px 0; border-top: 1px solid var(--hair); vertical-align: middle; }
.items-table td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.items-table td:first-child { padding-right: 8px; }
details.more summary { cursor: pointer; list-style: none; color: var(--ink-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary svg { width: 14px; height: 14px; transition: transform .2s; }
details.more[open] summary svg { transform: rotate(90deg); }

/* ============ Календарь ============ */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .cal-wrap { grid-template-columns: 1fr; } }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--hair); border-radius: var(--r); overflow: hidden; box-shadow: inset 0 0 0 1px var(--ring); }
.cal .dow { background: var(--surface); padding: 8px 10px; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.cal .day { background: var(--surface); min-height: 104px; padding: 7px 7px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; transition: background .12s; }
.cal .day:hover { background: var(--surface-2); }
.cal .day.out { background: color-mix(in srgb, var(--surface) 55%, var(--page)); }
.cal .day.out .d { color: var(--ink-3); opacity: .6; }
.cal .day.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.cal .d { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal .today .d { background: var(--accent); color: #fff; }
.cal .ev { font-size: 11px; line-height: 1.3; padding: 2px 5px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.cal .ev i { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--axis); }
.cal .ev.bad i { background: var(--bad); } .cal .ev.done i { background: var(--good); } .cal .ev.quiz i { background: var(--accent); }
.cal .ev.done { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--axis); }
.cal .more { font-size: 11px; color: var(--ink-3); padding-left: 5px; }
@media (max-width: 700px) {
  .cal .day { min-height: 52px; padding: 4px; align-items: center; }
  .cal .ev { display: none; }
  .cal .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
  .cal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--axis); }
  .cal .dots i.bad { background: var(--bad); } .cal .dots i.quiz { background: var(--accent); } .cal .dots i.done { background: var(--good); }
  .cal .more { display: none; }
}
@media (min-width: 701px) { .cal .dots { display: none; } }

/* ============ Графики ============ */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--hair); stroke-width: 1; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { transition: opacity .15s; }
.chart .dim .bar { opacity: .45; }
.chart .dim .bar.hl { opacity: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) 64px; gap: 12px; align-items: center; font-size: 12.5px; }
.hbar .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { position: relative; height: 10px; border-radius: 3px; background: var(--surface-2); }
.hbar .track > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 0 3px 3px 0; min-width: 2px; }
.hbar .track > em { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 550; }
@media (max-width: 520px) { .hbar { grid-template-columns: minmax(0, 96px) minmax(0, 1fr) 52px; } }
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring-wrap .ring-num { font-size: 26px; font-weight: 650; letter-spacing: -.03em; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 16px); grid-auto-columns: 16px; justify-content: start; gap: 4px; overflow-x: auto; padding: 2px 2px 4px; }
.heat i { width: 16px; height: 16px; border-radius: 4px; background: var(--surface-2); display: block; }
.heat i.l1 { background: var(--seq-2); } .heat i.l2 { background: var(--seq-3); } .heat i.l3 { background: var(--seq-4); } .heat i.l4 { background: var(--seq-5); }
.heat i.now { box-shadow: 0 0 0 1.5px var(--ink); }
.heat i.pad { background: transparent; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-3); }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--page); padding: 7px 10px; border-radius: 8px;
  font-size: 12px; line-height: 1.4; max-width: 260px; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 10px));
  opacity: 0; transition: opacity .12s;
}
.tooltip.on { opacity: 1; }
.tooltip b { font-weight: 600; }

/* ============ Профиль ============ */
.profile-head { display: flex; align-items: center; gap: 18px; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 600px) {
  .kpis.three { grid-template-columns: 1fr; gap: 10px; }
  .row { flex-wrap: wrap; }
  .row .grow { flex-basis: calc(100% - 40px); }
  .profile-head { align-items: flex-start; }
  .avatar.lg { width: 56px; height: 56px; font-size: 19px; }
}
.profile-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-width: 0; }
.row + .row { border-top: 1px solid var(--hair); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; }
.row .desc { font-size: 12.5px; color: var(--ink-3); }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); flex: none; }
.state-dot.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-wash); }
.state-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-wash); }
.state-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-wash); }
.code-line { display: flex; gap: 8px; align-items: center; }
.code-line code { flex: 1; min-width: 0; font: 12px var(--mono); padding: 8px 10px; background: var(--surface-2); border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ Оверлеи ============ */
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 10, .32); z-index: 60; opacity: 0; transition: opacity .2s; }
.scrim.on { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); z-index: 61; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .28s var(--ease); display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 12px; }
.drawer-head h2 { margin: 0; font-size: 18px; letter-spacing: -.015em; line-height: 1.3; flex: 1; }
.drawer-body { padding: 4px 20px 24px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--hair); display: flex; gap: 8px; }
@media (max-width: 700px) {
  .drawer { top: auto; left: 0; width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; transform: translateY(100%); }
}
.facts { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; font-size: 13px; margin: 8px 0 16px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }

.palette {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%) scale(.98); width: min(620px, calc(100% - 24px)); z-index: 70;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--ring); opacity: 0; transition: opacity .15s, transform .15s var(--ease);
  display: flex; flex-direction: column; max-height: 70vh; overflow: hidden;
}
.palette.on { opacity: 1; transform: translateX(-50%); }
.palette input { border: 0; outline: none; background: none; padding: 16px 18px; font-size: 16px; border-bottom: 1px solid var(--hair); }
.palette .results { overflow-y: auto; padding: 6px; }
.palette .group { padding: 8px 12px 4px; }
.palette .item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.palette .item svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.palette .item .ellipsis { flex: 1; min-width: 0; }
.palette .item.on { background: var(--surface-2); }
.palette .item small { color: var(--ink-3); white-space: nowrap; }

.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.98); width: min(460px, calc(100% - 24px)); z-index: 70;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 20px; opacity: 0; transition: opacity .15s, transform .15s var(--ease);
}
.modal.on { opacity: 1; transform: translate(-50%, -50%); }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal form { display: flex; flex-direction: column; gap: 12px; }

.toast-host { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
@media (max-width: 900px) { .toast-host { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast { background: var(--ink); color: var(--page); padding: 9px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============ Вход ============ */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); text-align: center; }
.login-card .brand-mark { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 16px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.login-card p { color: var(--ink-3); margin: 0 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card .field { text-align: left; }
.login-card > .btn { width: 100%; }
.auth-tabs { display: flex; width: 100%; margin: 0 0 16px; }
.auth-tabs button { flex: 1; }
.auth-err { color: var(--bad-ink); margin: 12px 0 0; font-size: 13px; }
.auth-hint { margin: 12px 0 0; }
.auth-note { margin: -4px 0 2px; text-align: left; line-height: 1.45; }
.auth-back { margin-top: 14px; }
.auth-spinner { display: grid; place-items: center; padding: 18px 0; color: var(--ink-3); }
.auth-spinner svg { width: 26px; height: 26px; animation: spin .9s linear infinite; }

.fade-in { animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- вкладка «Предметы» ---------- */
.subject-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.subject-card {
  display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer;
  border: 0; font: inherit; color: inherit; transition: transform .12s var(--ease), box-shadow .12s var(--ease);
}
.subject-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.09); }
.subject-card:disabled { opacity: .55; cursor: default; }
.subject-head { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.subject-title { font-weight: 600; line-height: 1.3; }
.subject-score { font-size: 22px; font-weight: 640; letter-spacing: -.02em; white-space: nowrap; }
.subject-score small { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.subject-bar { position: relative; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.subject-bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; }
.subject-bar b { position: absolute; top: -2px; width: 2px; height: 10px; background: var(--ink-3); opacity: .45; }
.subject-foot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.subject-foot svg { margin-left: auto; color: var(--ink-3); flex: none; }

.cat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.cat-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 5px; }
.cat-bar { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.cat-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.items { display: flex; flex-direction: column; }
.item { border-top: 1px solid var(--hair); }
.item:first-child { border-top: 0; }
.item.is-done .item-name { color: var(--ink-3); }
.item-head {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 0;
  background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.item-head:hover .item-name { color: var(--accent-ink); }
.item-name { font-weight: 550; line-height: 1.3; }
.item-meta { display: flex; gap: 5px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.item-meta .good { color: var(--good-ink); }
.item-chev { color: var(--ink-3); transition: transform .18s var(--ease); flex: none; }
.item-chev.on { transform: rotate(90deg); }
.item-body { padding: 2px 0 16px 28px; animation: fade .25s var(--ease); }
.item-facts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.item-facts .upper { display: block; margin-bottom: 2px; }
.item-facts b { font-weight: 550; font-size: 13.5px; }
.item-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.mats { display: flex; flex-direction: column; gap: 2px; }
.mat {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px;
  color: inherit; text-decoration: none; min-width: 0;
}
.mat:hover { background: var(--surface-2); }
.mat svg { color: var(--ink-3); flex: none; }
.mat .small { margin-left: auto; flex: none; }

@media (max-width: 600px) {
  .item-body { padding-left: 0; }
  .subject-grid { grid-template-columns: 1fr; }
}
