/* ============ Токены ============ */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --text: var(--tg-theme-text-color, #14151a);
  --hint: var(--tg-theme-hint-color, #8b8f9a);
  --link: var(--tg-theme-link-color, #6d5efc);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --sep: color-mix(in srgb, var(--hint) 18%, transparent);
  --soft: color-mix(in srgb, var(--hint) 10%, transparent);

  --a1: #8b5cf6; --a2: #6366f1; --a3: #3b82f6;
  --accent: #6d5efc;
  --grad: linear-gradient(135deg, var(--a1) 0%, var(--a2) 50%, var(--a3) 100%);
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);

  --P: #22c55e; --L: #f59e0b; --A: #ef4444; --E: #3b82f6; --N: #94a3b8;
  --r: 18px; --r-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
  --spring: cubic-bezier(.2, .9, .25, 1.15);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
html.dark { --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); overscroll-behavior-y: none;
  font: 15px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 16px; height: 16px; } svg.i.lg { width: 24px; height: 24px; }

#app { padding: 0 14px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--hint); } .small { font-size: 13px; } .tiny { font-size: 11.5px; }
.center { text-align: center; } .grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ============ Появление ============ */
.rise { animation: rise .5s var(--ease) both; animation-delay: calc(var(--d, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.fade { animation: fade .35s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
.pop { animation: pop .45s var(--spring) both; }
@keyframes pop { from { opacity: 0; transform: scale(.6); } }
.view-slide-l { animation: slideL .32s var(--ease) both; }
.view-slide-r { animation: slideR .32s var(--ease) both; }
@keyframes slideL { from { opacity: 0; transform: translateX(24px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(-24px); } }

/* ============ Шапка ============ */
.hero { position: relative; margin: 0 -14px 6px; padding: 18px 18px 22px; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: -60px -40px auto; height: 220px; background: var(--grad);
  opacity: .16; filter: blur(40px); border-radius: 50%; animation: drift 12s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translateX(30px) translateY(10px) scale(1.1); } }
.hero .row { position: relative; }
.avatar { width: 48px; height: 48px; border-radius: 15px; background: var(--grad); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 19px; box-shadow: 0 8px 20px color-mix(in srgb, var(--a2) 35%, transparent); flex: none; }
.hero h1 { margin: 0; font-size: 21px; letter-spacing: -.01em; line-height: 1.15; }
.hero .sub { font-size: 13px; color: var(--hint); margin-top: 2px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--card); color: var(--text); display: grid;
  place-items: center; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s var(--ease); }
.icon-btn:active { transform: scale(.92); }
.page-title { display: flex; align-items: center; gap: 10px; padding: 18px 4px 12px; }
.page-title h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--link); background: none; border: 0; padding: 14px 0 0; cursor: pointer; font-size: 14px; }

/* ============ Карточки ============ */
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); position: relative; }
.card.tap { cursor: pointer; transition: transform .18s var(--ease); }
.card.tap:active { transform: scale(.98); }
.list { background: var(--card); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; transition: background .15s; }
.item + .item::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--sep); }
.item.tap { cursor: pointer; } .item.tap:active { background: var(--soft); }
.item .chev { color: var(--hint); opacity: .6; }
.section { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--hint); margin: 20px 6px 8px; display: flex; align-items: center; justify-content: space-between; }
.section a { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--link); text-decoration: none; cursor: pointer; }
.empty { text-align: center; padding: 34px 20px; color: var(--hint); }
.empty .big-ic { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .big-ic svg { width: 30px; height: 30px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ============ Кнопки и поля ============ */
.btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0;
  border-radius: 14px; padding: 13px 16px; background: var(--grad); color: #fff; font-weight: 650; cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--a2) 30%, transparent); transition: transform .15s var(--ease), opacity .2s, box-shadow .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.plain { background: var(--soft); color: var(--text); box-shadow: none; }
.btn.danger { background: color-mix(in srgb, var(--A) 12%, transparent); color: var(--A); box-shadow: none; }
.btn.sm { padding: 8px 12px; font-size: 13.5px; border-radius: 11px; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ripple { position: absolute; border-radius: 50%; background: currentColor; opacity: .25; transform: scale(0); animation: ripple .55s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
.btns { display: flex; gap: 8px; margin-top: 14px; } .btns > * { flex: 1; }
label.f { display: block; font-size: 12.5px; color: var(--hint); margin: 12px 4px 6px; font-weight: 600; }
input, select, textarea { width: 100%; background: var(--bg2); border: 1.5px solid transparent; border-radius: 13px; padding: 12px 14px;
  outline: none; transition: border-color .2s, background .2s; appearance: none; -webkit-appearance: none; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238b8f9a' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
.sheet-body input, .sheet-body select, .sheet-body textarea { background-color: var(--soft); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background-color: var(--card); }
textarea { min-height: 120px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--sep); transition: background .25s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .3s var(--spring); }
.switch input:checked + i { background: var(--P); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ============ Чипы и бейджи ============ */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--card); padding: 8px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow); transition: all .25s var(--ease); color: var(--text); }
.chip.on { background: var(--grad); color: #fff; }
.chip:active { transform: scale(.95); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.P { background: color-mix(in srgb, var(--P) 15%, transparent); color: var(--P); }
.badge.L { background: color-mix(in srgb, var(--L) 17%, transparent); color: var(--L); }
.badge.A { background: color-mix(in srgb, var(--A) 14%, transparent); color: var(--A); }
.badge.E { background: color-mix(in srgb, var(--E) 15%, transparent); color: var(--E); }
.badge.N { background: color-mix(in srgb, var(--N) 18%, transparent); color: var(--N); }
.badge.kind { background: var(--soft); color: var(--hint); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.pulse { position: relative; }
.pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { to { transform: scale(2.8); opacity: 0; } }

/* ============ Живая сводка ============ */
.live { overflow: hidden; padding: 16px; }
.live::before { content: ""; position: absolute; width: 220px; height: 220px; right: -70px; top: -90px; border-radius: 50%;
  background: var(--grad); opacity: .12; filter: blur(10px); }
.live .phase { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.live h2 { margin: 8px 0 2px; font-size: 19px; letter-spacing: -.01em; }
.live .meta { font-size: 13px; color: var(--hint); }
.ring-wrap { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring .seg { transition: stroke-dasharray 1s var(--ease), stroke-dashoffset 1s var(--ease); stroke-linecap: butt; }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .lbl b { font-size: 26px; line-height: 1; letter-spacing: -.02em; }
.ring .lbl span { font-size: 11px; color: var(--hint); margin-top: 3px; }
.legend { display: grid; gap: 7px; flex: 1; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.answer-btns { display: grid; gap: 8px; margin-top: 14px; }
.answer { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 15px; border: 1.5px solid var(--sep); background: var(--bg2);
  cursor: pointer; font-weight: 650; transition: all .25s var(--ease); text-align: left; width: 100%; }
.answer .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.answer:active { transform: scale(.98); }
.answer.on { border-color: currentColor; background: color-mix(in srgb, currentColor 9%, var(--card)); }
.answer.P { color: var(--P); } .answer.L { color: var(--L); } .answer.A { color: var(--A); }
.answer span { color: var(--text); }
.answer.on::after { content: "✓"; margin-left: auto; font-weight: 900; animation: pop .4s var(--spring); }

/* ============ Таймлайн дня ============ */
.timeline { position: relative; padding-left: 6px; }
.tl { display: flex; gap: 14px; position: relative; padding-bottom: 10px; }
.tl .rail { width: 12px; display: flex; flex-direction: column; align-items: center; flex: none; padding-top: 18px; }
.tl .rail .dot { width: 12px; height: 12px; border: 2.5px solid var(--sep); background: var(--card); }
.tl .rail::after { content: ""; flex: 1; width: 2px; background: var(--sep); margin-top: 4px; border-radius: 2px; }
.tl:last-child .rail::after { display: none; }
.tl.past .rail .dot { background: var(--sep); border-color: var(--sep); }
.tl.now .rail .dot { background: var(--accent); border-color: var(--accent); }
.tl .card { flex: 1; margin-bottom: 0; }
.tl.past .card { opacity: .72; }
.time { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; }
.time small { font-weight: 500; color: var(--hint); }
.progress { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--P); transform-origin: left; animation: grow 1s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.note { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--L) 12%, transparent); font-size: 13px; }

/* ============ Быстрые действия ============ */
.qgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa { background: var(--card); border-radius: var(--r); padding: 14px; cursor: pointer; box-shadow: var(--shadow); transition: transform .18s var(--ease); border: 0; text-align: left; }
.qa:active { transform: scale(.96); }
.qa .tile { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 10px; }
.qa b { display: block; font-size: 15px; } .qa span { font-size: 12.5px; color: var(--hint); }
.tile.c1 { background: color-mix(in srgb, #8b5cf6 15%, transparent); color: #8b5cf6; }
.tile.c2 { background: color-mix(in srgb, #22c55e 15%, transparent); color: #16a34a; }
.tile.c3 { background: color-mix(in srgb, #f59e0b 17%, transparent); color: #d97706; }
.tile.c4 { background: color-mix(in srgb, #ef4444 14%, transparent); color: #ef4444; }
.tile.c5 { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #3b82f6; }
.tile.c6 { background: color-mix(in srgb, #ec4899 14%, transparent); color: #ec4899; }

/* ============ Онбординг ============ */
.steps .step { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.steps .step + .step { border-top: 1px solid var(--sep); }
.steps .mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none;
  border: 2px solid var(--sep); color: var(--hint); }
.steps .done .mark { background: var(--P); border-color: var(--P); color: #fff; animation: pop .5s var(--spring) both; }
.steps .done b { text-decoration: line-through; opacity: .6; }

/* ============ Календарь ============ */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-size: 17px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: 11px; color: var(--hint); font-weight: 700; padding: 4px 0; }
.cal .d { aspect-ratio: 1; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-weight: 600; font-size: 14px; cursor: pointer; position: relative; transition: transform .15s var(--ease), background .2s; border: 0; background: none; }
.cal .d:active { transform: scale(.9); }
.cal .d.off { color: var(--hint); opacity: .45; cursor: default; }
.cal .d.has { background: var(--soft); }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .d.holiday { background: color-mix(in srgb, var(--E) 12%, transparent); color: var(--E); }
.cal .d.session { background: color-mix(in srgb, var(--L) 14%, transparent); color: var(--L); }
.cal .d .marks { display: flex; gap: 2px; height: 5px; }
.cal .d .marks i { width: 5px; height: 5px; border-radius: 50%; background: var(--P); }
.cal .d .marks i.todo { background: none; box-shadow: inset 0 0 0 1.5px var(--A); }

/* ============ Таблица журнала ============ */
.jgrid { overflow-x: auto; border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); margin-bottom: 12px; }
.jgrid table { border-collapse: separate; border-spacing: 0; width: 100%; }
.jgrid th, .jgrid td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--sep); }
.jgrid tr:last-child td { border-bottom: 0; }
.jgrid th { font-size: 11.5px; font-weight: 700; vertical-align: bottom; min-width: 64px; }
.jgrid th small { display: block; color: var(--hint); font-weight: 500; }
.jgrid .name { text-align: left; position: sticky; left: 0; background: var(--card); z-index: 1; padding-left: 14px; min-width: 130px; max-width: 160px;
  font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell { width: 36px; height: 36px; border-radius: 11px; border: 1.5px dashed var(--sep); background: none; display: inline-grid; place-items: center;
  font-weight: 800; font-size: 13px; cursor: pointer; transition: transform .2s var(--spring), background .2s; color: #fff; position: relative; }
.cell:active { transform: scale(.85); }
.cell.P { background: var(--P); border: 0; } .cell.L { background: var(--L); border: 0; } .cell.A { background: var(--A); border: 0; }
.cell.E { background: var(--E); border: 0; } .cell.N { background: var(--N); border: 0; }
.cell .clip { position: absolute; right: -4px; top: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--card); color: var(--E); font-size: 9px; display: grid; place-items: center; box-shadow: var(--shadow); }
.cell.changed { animation: pop .35s var(--spring); }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--hint); margin: 0 4px 12px; }
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.status-pick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 12px; }
.status-pick button { border: 0; border-radius: 13px; padding: 12px 4px; color: #fff; font-weight: 700; font-size: 12px; cursor: pointer; display: grid; gap: 4px; justify-items: center; transition: transform .15s; }
.status-pick button:active { transform: scale(.92); }
.status-pick .P { background: var(--P); } .status-pick .L { background: var(--L); } .status-pick .A { background: var(--A); }
.status-pick .E { background: var(--E); } .status-pick .N { background: var(--N); }

/* ============ Ученики / статистика ============ */
.ava { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; flex: none; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 28px; letter-spacing: -.02em; line-height: 1.1; }
.kpi span { font-size: 12.5px; color: var(--hint); }
.spark { width: 100%; height: 70px; display: block; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: draw 1.4s var(--ease) forwards; }
.spark path.area { fill: url(#sparkfill); opacity: 0; animation: fade .8s .5s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.pct { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
.code { font-size: 64px; font-weight: 900; letter-spacing: 14px; text-align: center; font-variant-numeric: tabular-nums; margin: 6px 0 4px;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.code-input { text-align: center; font-size: 26px; letter-spacing: 10px; font-weight: 800; }
.pinned { box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.file-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; font-size: 10px; font-weight: 800; }

/* ============ Нижняя навигация ============ */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); width: min(calc(100% - 20px), 620px);
  display: flex; background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-radius: 22px; padding: 6px; z-index: 5; box-shadow: 0 10px 30px rgba(15, 23, 42, .14), 0 0 0 1px var(--sep); }
.tabs .ind { position: absolute; top: 6px; bottom: 6px; left: 6px; border-radius: 16px; background: var(--accent-soft); transition: transform .45s var(--spring), width .45s var(--spring); }
.tabs button { position: relative; flex: 1; background: none; border: 0; color: var(--hint); font-size: 10.5px; font-weight: 650; padding: 6px 0 4px;
  cursor: pointer; display: grid; justify-items: center; gap: 2px; transition: color .25s; }
.tabs button svg { transition: transform .35s var(--spring); }
.tabs button.on { color: var(--accent); }
.tabs button.on svg { transform: translateY(-1px) scale(1.1); }
.fab { position: fixed; right: max(18px, calc(50% - 300px)); bottom: calc(96px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 24px color-mix(in srgb, var(--a2) 45%, transparent);
  cursor: pointer; z-index: 4; animation: pop .5s var(--spring) both; transition: transform .2s var(--ease); }
.fab:active { transform: scale(.9); }

/* ============ Шторка ============ */
.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet .backdrop { position: absolute; inset: 0; background: rgba(8, 10, 20, .45); backdrop-filter: blur(2px); animation: fade .3s both; }
.sheet-body { position: relative; background: var(--card); width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom)); animation: sheetUp .5s var(--spring) both; touch-action: pan-y; }
.sheet.closing .backdrop { animation: fade .25s reverse both; }
.sheet.closing .sheet-body { animation: sheetDown .28s var(--ease) both; }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(105%); } }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--sep); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 2px; font-size: 19px; letter-spacing: -.01em; }

/* ============ Тост, скелетон, конфетти ============ */
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 30;
  background: rgba(20, 22, 30, .92); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; max-width: 88%;
  display: flex; align-items: center; gap: 8px; transition: all .35s var(--spring); pointer-events: none; backdrop-filter: blur(10px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.sk { background: linear-gradient(90deg, var(--soft) 25%, color-mix(in srgb, var(--hint) 20%, transparent) 50%, var(--soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ============ Сегменты ============ */
.seg { display: flex; background: var(--soft); border-radius: 14px; padding: 4px; margin-bottom: 12px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 11px; font-weight: 650; font-size: 13.5px; color: var(--hint);
  cursor: pointer; transition: all .3s var(--spring); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 2px 8px rgba(15, 23, 42, .1); }
.seg .now-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--P); box-shadow: 0 0 0 3px color-mix(in srgb, var(--P) 25%, transparent); }

/* ============ Оценки ============ */
.gchip { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 9px; font-weight: 800; font-size: 13px; color: #fff; flex: none; }
.gchip.lg { min-width: 36px; height: 36px; border-radius: 11px; font-size: 15px; }
.g5 { background: var(--P); } .g4 { background: var(--E); } .g3 { background: var(--L); } .g2 { background: var(--A); }
.gz { background: color-mix(in srgb, var(--a1) 75%, #fff); } .g- { background: var(--soft); color: var(--hint); }
.gcell { width: 32px; height: 32px; border-radius: 10px; border: 0; font-weight: 800; font-size: 12.5px; color: #fff; cursor: pointer; transition: transform .2s var(--spring); }
.gcell.g- { background: none; box-shadow: inset 0 0 0 1.5px var(--sep); }
.gcell:active { transform: scale(.85); }
.gcell.changed { animation: pop .35s var(--spring); }
.mini-grades { display: flex; gap: 2px; margin: 5px 0 3px; flex-wrap: wrap; }
.mini-grades i { width: 9px; height: 9px; border-radius: 3px; }
.mini-grades i.g- { background: var(--soft); }
.avg-pill { min-width: 50px; padding: 6px 8px; border-radius: 11px; color: #fff; font-weight: 800; font-size: 14px; text-align: center; font-variant-numeric: tabular-nums; flex: none; }
.grade-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 14px; }
.grade-pick button { border: 0; height: 54px; border-radius: 15px; color: #fff; font-weight: 900; font-size: 18px; cursor: pointer; transition: transform .15s; }
.grade-pick button.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px currentColor; color: #fff; }
.grade-pick button:active { transform: scale(.9); }
.dist { display: flex; height: 26px; border-radius: 9px; overflow: hidden; margin-top: 12px; gap: 2px; }
.dist i { display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; font-style: normal; white-space: nowrap; overflow: hidden; animation: grow .9s var(--ease) both; transform-origin: left; }
.vtext { writing-mode: vertical-rl; transform: rotate(180deg); max-height: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; margin: 0 auto; }

/* ============ Вход вне Telegram ============ */
.login { min-height: 92vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 6px; }
.login h1 { font-size: 27px; letter-spacing: -.02em; margin: 18px 0 6px; }
.login > p { max-width: 330px; margin: 0 auto 26px; }
.login .card { width: 100%; }
.login-art { position: relative; }
.login-art::before { content: ""; position: absolute; inset: -40px; background: var(--grad); filter: blur(46px); opacity: .35; border-radius: 50%; z-index: -1; animation: drift 9s ease-in-out infinite alternate; }
.tg-btn { background: linear-gradient(135deg, #2aabee, #229ed9); box-shadow: 0 8px 22px rgba(34, 158, 217, .35); padding: 15px 18px; font-size: 16px; }
.tg-logo { width: 22px; height: 22px; border-radius: 50%; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23229ED9' d='M17.6 7.3 15.8 16c-.1.6-.5.8-1 .5l-2.8-2-1.3 1.3c-.2.2-.3.3-.6.3l.2-2.9 5.2-4.7c.2-.2 0-.3-.3-.1L8.8 12.4 6 11.5c-.6-.2-.6-.6.1-.9l10.8-4.2c.5-.2.9.1.7.9z'/%3E%3C/svg%3E") center/16px no-repeat; flex: none; }
.spin-lg { width: 42px; height: 42px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--soft); border-top-color: var(--accent); animation: spin .9s linear infinite; }
html.standalone body { padding-top: env(safe-area-inset-top); }

/* перелистывание страниц */
body { overflow-x: clip; }
.page-ghost { position: fixed; margin: 0; box-sizing: border-box; pointer-events: none; z-index: 3; will-change: transform, opacity; }
.page-ghost, .page-ghost * { animation: none !important; transition: none !important; }
#app { transform-origin: 50% 40vh; }
.page-ghost { transform-origin: 50% 40vh; }

/* согласие */
.consent { text-align: left; padding: 6px 16px; }
.consent-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; font-size: 14.5px; line-height: 1.45; cursor: pointer; }
.consent-row + .consent-row { border-top: 1px solid var(--sep); }
.consent-row input { appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 1px 0 0; border-radius: 7px;
  border: 2px solid var(--hint); display: grid; place-items: center; transition: background .2s, border-color .2s; cursor: pointer; }
.consent-row input:checked { background: var(--accent); border-color: var(--accent); }
.consent-row input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.consent-row a { color: var(--link, var(--accent)); }
.btn:disabled { opacity: .45; pointer-events: none; }
