/* Планер курса. Цвет кодирует смысл: синий — повторение, зелёный — новое, жёлтый — изменения, красный — отставание. */
:root {
  --paper: #F6F7FB;
  --surface: #FFFFFF;
  --ink: #1F2340;
  --ink-2: #5A5F80;
  --line: #E3E5F0;
  --review: #5B6CFF;
  --review-soft: #E8EBFF;
  --study: #1FA37A;
  --study-soft: #DDF4EC;
  --change: #F2B233;
  --change-soft: #FFF4D9;
  --late: #E5484D;
  --late-soft: #FDE7E8;
  --display: "Unbounded", "Manrope", system-ui, sans-serif;
  --text: "Manrope", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #14162A;
  --surface: #1D2038;
  --ink: #ECEEFA;
  --ink-2: #A3A8C8;
  --line: #2C3050;
  --review: #8592FF;
  --review-soft: #262B55;
  --study: #3CC497;
  --study-soft: #1B3A35;
  --change: #F5C04F;
  --change-soft: #3A3220;
  --late: #FF6B70;
  --late-soft: #3E2229;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 16px/1.45 var(--text);
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin-inline: auto;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--review); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 0 10px; }
h1 { font: 700 24px/1.15 var(--display); letter-spacing: -0.01em; margin: 0; }
h2 { font: 600 17px/1.3 var(--display); margin: 0; }
.sub { color: var(--ink-2); margin: 4px 0 0; font-size: 14px; }
.badge { flex: none; font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--change-soft); color: var(--ink); }

.tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; padding: 8px 0; background: var(--paper); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: 15px; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }

.empty { color: var(--ink-2); text-align: center; padding: 40px 0; }
.error { color: var(--late); font-weight: 700; }

/* ---- кольцо дня: главная деталь ---- */
.day { display: grid; grid-template-columns: 172px 1fr; gap: 18px; align-items: center; padding: 14px 0 6px; }
.ring { position: relative; width: 172px; height: 172px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-num { font: 700 30px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ring-num.running { font-size: 20px; color: var(--study); }
.ring-cap { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.day-side { display: grid; gap: 10px; }
.day-side p { margin: 0; font-size: 14px; color: var(--ink-2); }
.day-side strong { color: var(--ink); }

.btn { border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 800; font-size: 15px; cursor: pointer; text-align: center; }
.btn.primary { background: var(--study); color: #fff; }
.btn.stop { background: var(--late); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink-2); padding-inline: 6px; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .5; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- плашки ---- */
.note { border-left: 5px solid var(--change); background: var(--change-soft); border-radius: 4px 14px 14px 4px; padding: 12px 14px; margin: 14px 0; }
.note h2 { font-size: 15px; margin-bottom: 6px; }
.note ul { margin: 0; padding-left: 18px; }
.note li + li { margin-top: 4px; }
.note li.good::marker { color: var(--study); }
.note.rest { border-color: var(--review); background: var(--review-soft); }

/* ---- блоки задач ---- */
.block { margin: 22px 0 0; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.block-head h2::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 8px; background: var(--accent); vertical-align: 1px; }
.block-head .sum { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.block .why { font-size: 13px; color: var(--ink-2); margin: 4px 0 10px; }
.block.review { --accent: var(--review); --soft: var(--review-soft); }
.block.study { --accent: var(--study); --soft: var(--study-soft); }

.task { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; background: var(--surface); border-left: 4px solid var(--accent); border-radius: 4px 14px 14px 4px; padding: 12px 12px 12px 10px; margin-top: 8px; }
.check { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--accent); background: none; display: grid; place-items: center; cursor: pointer; padding: 0; }
.check svg { width: 16px; height: 16px; opacity: 0; }
.task.done .check { background: var(--accent); }
.task.done .check svg { opacity: 1; }
.task.done .t-title { color: var(--ink-2); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.task.just { animation: settle .6s ease-out; }
@keyframes settle { 0% { transform: scale(.97); background: var(--soft); } 100% { transform: none; } }
.t-title { font-weight: 700; line-height: 1.3; }
.t-meta { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.t-meta b { color: var(--ink); font-weight: 700; }
.part { display: inline-block; font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--soft); color: var(--accent); margin-left: 4px; }
.dots { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--review); }
.bar { height: 6px; border-radius: 99px; background: var(--line); margin-top: 7px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent, var(--study)); border-radius: 99px; }

/* ---- как идёт курс ---- */
.course { margin: 26px 0 0; padding: 16px; border-radius: 18px; background: var(--surface); border-top: 5px solid var(--tone); }
.course.ok { --tone: var(--study); }
.course.warn { --tone: var(--change); }
.course.late { --tone: var(--late); }
.course .verdict { font: 600 18px/1.3 var(--display); color: var(--tone); margin: 0 0 8px; }
.course p { margin: 6px 0 0; font-size: 15px; }
.course .bar { height: 10px; margin-top: 12px; }
.course .bar > span { background: var(--ink); }
.course .legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-top: 5px; }
.course.pulse { animation: pulse 1.2s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--change); } 100% { box-shadow: 0 0 0 14px transparent; } }
.skip-link { display: block; margin: 18px auto 0; }

/* ---- неделя ---- */
.weeknav { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 4px; }
.weeknav button { border: 1.5px solid var(--line); background: var(--surface); width: 40px; height: 40px; border-radius: 12px; font-size: 20px; cursor: pointer; }
.weeknav h2 { font-size: 16px; }
.legend-line { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); margin: 6px 0 4px; flex-wrap: wrap; }
.legend-line span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); }
.dayrow { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.dayrow .wd { font: 600 15px/1.2 var(--display); }
.dayrow .dt { font-size: 13px; color: var(--ink-2); }
.dayrow.today .wd { color: var(--study); }
.dayrow.today { background: linear-gradient(90deg, var(--study-soft), transparent 70%); border-radius: 12px; padding-left: 8px; margin-left: -8px; }
.dayfact { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.dayfact .bar { flex: 1; margin: 0; --accent: var(--ink-2); }
.dayfact.none { color: var(--late); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 10px; background: var(--soft); color: var(--ink); border-left: 3px solid var(--accent); line-height: 1.3; }
.chip.review { --accent: var(--review); --soft: var(--review-soft); }
.chip.study { --accent: var(--study); --soft: var(--study-soft); }
.chip.done { opacity: .75; text-decoration: line-through; }
.dayplan-sum { font-size: 13px; color: var(--ink-2); }

/* ---- весь план ---- */
.lead { font-size: 15px; margin: 12px 0; }
details.sec { background: var(--surface); border-radius: 16px; margin-top: 10px; overflow: hidden; }
details.sec summary { list-style: none; padding: 14px 16px; cursor: pointer; display: grid; gap: 4px; }
details.sec summary::-webkit-details-marker { display: none; }
.sec-title { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; }
.sec-count { font-variant-numeric: tabular-nums; color: var(--ink-2); flex: none; }
.sec-dates { font-size: 13px; color: var(--ink-2); }
.shift { display: inline-block; font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--change-soft); color: var(--ink); margin-left: 4px; }
.shift.ahead { background: var(--study-soft); }
.lesson { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--line); width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer; }
.lesson .st { font-weight: 800; }
.lesson.done .st { color: var(--study); }
.lesson.current { background: var(--study-soft); }
.lesson .l-title { font-weight: 700; line-height: 1.3; }
.lesson .l-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* ---- дневник ---- */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.fact { background: var(--surface); border-radius: 16px; padding: 14px; }
.fact b { display: block; font: 700 22px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.fact span { font-size: 13px; color: var(--ink-2); }
.log { padding: 12px 0; border-bottom: 1px solid var(--line); }
.log .l-head { display: flex; justify-content: space-between; font-weight: 700; }
.log .l-item { font-size: 13px; color: var(--ink-2); }
.log p { margin: 4px 0 0; font-size: 14px; }

/* ---- окно ввода и уведомление ---- */
dialog { border: 0; border-radius: 20px; padding: 20px; width: min(92vw, 420px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 12, 30, .45); }
dialog label { display: block; font-size: 14px; font-weight: 700; margin-top: 14px; }
dialog input, dialog textarea { width: 100%; margin-top: 6px; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); font: 600 16px/1.4 var(--text); }
dialog textarea { min-height: 80px; resize: vertical; }
.hm { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.quick button { border: 1.5px solid var(--line); background: var(--paper); border-radius: 10px; padding: 6px 10px; font-weight: 700; cursor: pointer; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 140%); background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 14px; font-weight: 700; font-size: 14px; max-width: 92vw; transition: transform .25s ease, opacity .25s ease; z-index: 20; opacity: 0; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 380px) {
  .day { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .row-btns { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
