:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --row: #f5f5f7;
  --row-2: #fbfbfc;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --line: #ececef;
  --line-2: #e3e3e7;
  --blue: #0a84ff;
  --green: #34c759;
  --orange: #ff9f0a;
  --purple: #af52de;
  --red: #ff453a;
  --radius: 20px;
  --bar-item-h: 32px;
  --shadow: 0 1px 2px rgba(0,0,0,.035), 0 8px 24px rgba(0,0,0,.045);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: none; opacity: .82; }

.wrap { max-width: 1680px; margin: 0 auto; padding: 8px 24px 60px; }

/* ---------- Шапка ---------- */
.topbar { padding: 14px 24px 4px; }
.topbar-inner {
  max-width: 1680px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.nav {
  display: flex; gap: 3px; flex-wrap: wrap;
  background: #fff; border-radius: 14px; padding: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 5px 14px rgba(0,0,0,.045);
}
.nav a {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--bar-item-h); padding: 0 12px;
  border-radius: 10px; font-size: 13.5px; font-weight: 500;
  color: var(--text-2); border: 1px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.nav a svg { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.nav a:hover { background: #f5f5f7; color: var(--text); opacity: 1; }
.nav a.active { background: #f2f2f5; color: var(--text); border-color: #e6e6ea; }
.nav a.active svg { opacity: 1; }
@media (max-width: 720px) { .nav a span { display: none; } .nav a { padding: 0 10px; } }

.railbar {
  margin-left: auto; display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  background: #fff; border-radius: 14px; padding: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 5px 14px rgba(0,0,0,.045);
}
.stat {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--bar-item-h); padding: 0 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
a.stat:hover { background: #f5f5f7; color: var(--text); opacity: 1; text-decoration: none; }
.stat.static { cursor: default; }
.stat b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .dot { width: 6px; height: 6px; }
.stat-sub { color: var(--text-3); font-size: 12px; font-weight: 400; }

.rail-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; flex: none; }

.rail-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--bar-item-h); height: var(--bar-item-h); border-radius: 10px; color: var(--text-2);
}
.rail-arrow svg { width: 15px; height: 15px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail-arrow:hover { background: #f5f5f7; color: var(--text); opacity: 1; }

.rail-now {
  display: inline-flex; align-items: center; justify-content: center;
  height: var(--bar-item-h); padding: 0 13px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--text);
  white-space: nowrap; min-width: 92px;
}
.rail-now:hover { background: #f5f5f7; opacity: 1; }
.rail-now.on { background: var(--text); color: #fff; }
.rail-now.on:hover { background: var(--text); opacity: .9; }

@media (max-width: 900px) {
  .railbar { margin-left: 0; }
}

/* ---------- Сетка ---------- */
.grid { display: grid; gap: 16px; align-items: start; }
.grid.side { grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); }
.grid.half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.third { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1080px) {
  .grid.side, .grid.half, .grid.third { grid-template-columns: 1fr; }
}

.page-head { margin: 10px 4px 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-2); font-size: 14px; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  margin-bottom: 14px;
}
.grid .card { margin-bottom: 0; }
.card-head { display: flex; align-items: center; gap: 9px; margin: 0 0 11px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.card-head .link.small { font-size: 12.5px; }
.card-head .link { margin-left: auto; font-size: 14px; color: var(--blue); cursor: pointer; }
.card-head .count { color: var(--text-3); font-size: 14px; font-weight: 400; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.empty { color: var(--text-3); font-size: 14px; padding: 10px 2px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); font-weight: 600; margin: 4px 2px 8px; }

/* ---------- Строки ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--row); border-radius: 13px;
  padding: 10px 13px; margin-bottom: 7px;
  transition: background .15s ease;
}
.row.tight { padding: 8px 13px; margin-bottom: 6px; }
.row:hover { background: var(--row-hover, #efeff3); }
.row:last-child { margin-bottom: 0; }
.row .body { min-width: 0; flex: 1; }
.row .title { font-size: 14.5px; font-weight: 500; line-height: 1.3; }
.row .sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.row.done .title { text-decoration: none; color: var(--text-3); }
.row.done .title { color: var(--text-2); }
.row .side { color: var(--text-3); font-size: 13px; white-space: nowrap;
  font-variant-numeric: tabular-nums; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.blue { background: var(--blue); }
.dot.green { background: var(--green); }
.dot.orange { background: var(--orange); }
.dot.purple { background: var(--purple); }
.dot.red { background: var(--red); }
.status-note { font-size: 13px; color: var(--text-3); white-space: nowrap; }

/* ---------- iOS toggle ---------- */
.toggle { position: relative; display: inline-block; width: 48px; height: 29px; flex: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0; cursor: pointer;
  background: #e3e3e8; border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.03);
  transition: background .25s cubic-bezier(.33,1,.68,1);
}
.toggle .track::before {
  content: ""; position: absolute; height: 25px; width: 25px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,.18), 0 0 1px rgba(0,0,0,.2);
  transition: transform .25s cubic-bezier(.33,1,.68,1), width .18s ease;
}
.toggle input:checked + .track { background: var(--green); box-shadow: none; }
.toggle input:checked + .track::before { transform: translateX(19px); }
.toggle:active .track::before { width: 29px; }
.toggle input:checked + .track:active::before { transform: translateX(15px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.toggle input:disabled + .track { opacity: .5; cursor: default; }

/* ---------- Круглый чекбокс ---------- */
.check {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.5px solid #c9c9ce; background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.check.on { background: var(--text); border-color: var(--text); }
.check.on::after {
  content: ""; width: 6px; height: 10px; margin-top: -2px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ---------- Сегментированные пилюли ---------- */
.segmented { display: inline-flex; background: #ececf0; border-radius: 999px; padding: 3px; gap: 2px; }
.segmented a, .segmented button {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-2); padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.segmented .on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.segmented .n { color: var(--text-3); font-size: 12px; margin-left: 4px; font-variant-numeric: tabular-nums; }
.segmented .on .n { color: var(--text-2); }

/* отдельные пилюли равной ширины — как «утро / день / вечер» */
.segmented.tabs { background: transparent; padding: 0; gap: 6px; flex-wrap: wrap; }
.segmented.tabs a, .segmented.tabs button {
  background: #f0f0f3; color: var(--text-2); padding: 8px 16px; border-radius: 999px;
  font-size: 13.5px; transition: background .15s ease, color .15s ease;
}
.segmented.tabs a:hover, .segmented.tabs button:hover { background: #e8e8ed; color: var(--text); }
.segmented.tabs .on, .segmented.tabs .on:hover {
  background: var(--text); color: #fff; box-shadow: none;
}
.segmented.tabs .on .n { color: rgba(255,255,255,.65); }

/* ---------- Формы ---------- */
input[type=text], input[type=date], input[type=number], input[type=password], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--row); border: 1px solid transparent; border-radius: 14px;
  padding: 11px 14px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: #d9d9de; background: #fff; }
textarea { resize: vertical; min-height: 84px; }
input[type=file] { font-size: 13px; background: transparent; padding: 6px 0; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 500;
  background: var(--text); color: #fff; border: 0; border-radius: 999px;
  padding: 9px 18px; cursor: pointer;
}
.btn:hover { opacity: .88; }
.btn.ghost { background: var(--row); color: var(--text); }
.btn.link { background: transparent; color: var(--blue); padding: 4px 0; }
.btn.tiny { font-size: 13px; padding: 6px 12px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Таблица ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.paid td:not(.num) { color: var(--text-2); }

/* ---------- Заметки ---------- */
.note { background: var(--row); border-radius: 16px; padding: 14px 16px; margin-bottom: 9px; }
.note h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.note .text { white-space: pre-wrap; font-size: 14px; }
.note .meta { margin-top: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-3); }
.tag { display: inline-block; background: #fff; border: 1px solid var(--line-2);
  border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--text-2); }
.note[draggable=true] { cursor: grab; }
.note.dragging { opacity: .4; }
.dropzone { border: 1.5px dashed #d6d6db; border-radius: 16px; padding: 16px;
  text-align: center; color: var(--text-3); font-size: 13px; margin-top: 10px; }
.dropzone.over { border-color: var(--blue); color: var(--blue); background: #f0f7ff; }

/* ---------- Учёба ---------- */
.lesson { background: var(--row); border-radius: 16px; margin-bottom: 9px; overflow: hidden; }
.lesson > summary { list-style: none; cursor: pointer; padding: 13px 15px;
  display: flex; align-items: center; gap: 12px; }
.lesson > summary::-webkit-details-marker { display: none; }
.lesson[open] { background: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }
.lesson .time { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.lesson .name { font-weight: 500; }
.lesson .kind { color: var(--text-3); font-size: 13px; }
.lesson .has-note { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.lesson .panel { padding: 14px 15px 16px; border-top: 1px solid var(--line); }
.filelist { list-style: none; margin: 10px 0 0; padding: 0; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px;
  border-top: 1px solid var(--line); }
.filelist li:first-child { border-top: 0; }
.daychips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.daychip { border: 1px solid var(--line-2); background: #fff; border-radius: 10px;
  padding: 6px 11px; font-size: 13px; color: var(--text-2); cursor: pointer; font: inherit; font-size: 13px; }
.daychip.on { background: var(--text); color: #fff; border-color: var(--text); }
.daychip small { display: block; font-size: 11px; opacity: .7; }

.flash { background: #eef6ff; color: #05559b; border-radius: 14px;
  padding: 11px 15px; font-size: 14px; margin-bottom: 14px; }

.stack-sm > * + * { margin-top: 8px; }
.hstack { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* выбор даты пары */
.daychip { position: relative; display: inline-flex; flex-direction: column; text-align: center; }
.daychip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.daychip:has(input:checked) { background: var(--text); color: #fff; border-color: var(--text); }
.daychip:has(input:checked) small { opacity: .75; }
.lesson-history { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.lesson-history a { font-size: 13px; }
.hist-row { display: flex; align-items: center; gap: 10px; font-size: 13px;
  color: var(--text-2); padding: 5px 0; }

/* ---------- Дашборд: колонки и задачи ---------- */
.col-stack { display: grid; gap: 14px; align-content: start; }

.quick-add { display: flex; gap: 8px; margin-bottom: 11px; }
.quick-add input[type=text] {
  flex: 1; border-radius: 999px; padding: 11px 18px; background: var(--row);
}
.quick-add .btn { border-radius: 999px; padding: 11px 22px; }
.quick-add.reminder input[type=text] { background: #fff6e8; border-color: #ffe2b8; }

.task-list { max-height: 44vh; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; }
.task-list::-webkit-scrollbar { width: 6px; }
.task-list::-webkit-scrollbar-thumb { background: #d9d9de; border-radius: 3px; }
.task-list::-webkit-scrollbar-track { background: transparent; }

.row.task .task-actions {
  display: flex; align-items: center; gap: 4px;
  opacity: 0; transition: opacity .15s ease;
}
.row.task:hover .task-actions, .row.task:focus-within .task-actions { opacity: 1; }
.row.task .task-actions form { display: inline; }
.row.task .task-actions .btn.link { font-size: 12px; color: var(--text-3); padding: 2px 4px; }
.row.task .task-actions .btn.link:hover { color: var(--blue); }
.row.task.done .title { color: var(--text-3); text-decoration: line-through; text-decoration-color: #d0d0d5; }
@media (hover: none) { .row.task .task-actions { opacity: 1; } }

.check { transition: background .15s ease, border-color .15s ease, transform .1s ease; }
.check:active { transform: scale(.92); }
.row .check { width: 21px; height: 21px; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
  background: #ececf0; border-radius: 5px; padding: 1px 5px; }
.empty code { background: #fff; }

/* пары на главной: компактный раскрывающийся блок */
.card .lesson { background: var(--row); }
.card .lesson > summary { padding: 10px 13px; }
.card .lesson[open] > summary { border-bottom: 1px solid var(--line); }
.card .lesson .panel { padding: 12px 13px 14px; border-top: 0; }
.card .lesson .panel textarea { min-height: 68px; }
.card .lesson .panel .field { margin-bottom: 10px; }

/* верхняя панель прилипает */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--bg);
  padding: 10px 24px 8px; }
