:root {
  --bg: #0d0d14;
  --card: #16161f;
  --card-2: #1d1d29;
  --line: #262636;
  --text: #ececf3;
  --muted: #8a8aa0;
  --accent: #7c6cf6;
  --accent-soft: rgba(124, 108, 246, .16);
  --green: #3ecf8e; --green-soft: rgba(62, 207, 142, .15);
  --amber: #f5b544; --amber-soft: rgba(245, 181, 68, .15);
  --blue: #5aa9ff; --blue-soft: rgba(90, 169, 255, .15);
  --red: #f26d6d; --red-soft: rgba(242, 109, 109, .15);
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: dark;
}
:root.light {
  --bg: #f3f3f8; --card: #ffffff; --card-2: #f6f6fb; --line: #e6e6ef;
  --text: #15151d; --muted: #6d6d82; --accent-soft: rgba(124, 108, 246, .12);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app { max-width: 560px; margin: 0 auto; padding: 16px; }
.splash { display: grid; place-items: center; height: 70vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

h1 { font-size: 26px; margin: 4px 0 2px; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 4px 10px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; }
.page-head { margin-bottom: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.tight { padding: 4px 0; }
.card.glow { background: radial-gradient(120% 140% at 100% 0%, rgba(124,108,246,.28), transparent 55%), var(--card); border-color: rgba(124,108,246,.35); }
.card-title { font-weight: 600; margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack > * + * { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card-2); border-radius: 12px;
  padding: 11px 16px; font-weight: 500; cursor: pointer; width: 100%;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }

/* список «как в настройках iOS» */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; cursor: pointer; width: 100%; background: none; border: 0; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item .ic { color: var(--muted); }
.item .val { color: var(--muted); font-size: 14px; }
.item .chev { color: var(--muted); opacity: .6; width: 16px; height: 16px; }
.item.static { cursor: default; }

.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #8b7bff, #5b4bd6); flex: none; }
.avatar.lg { width: 48px; height: 48px; border-radius: 14px; font-size: 20px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.red { background: var(--red-soft); color: var(--red); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); display: inline-block; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* шаги онбординга */
.step { display: flex; gap: 12px; padding: 12px 0; }
.step + .step { border-top: 1px solid var(--line); }
.step-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--accent-soft); color: var(--accent); flex: none; }
.step.done .step-n { background: var(--green-soft); color: var(--green); }
.step.done .step-t { text-decoration: line-through; color: var(--muted); }
.progress { height: 6px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

/* плитки быстрых действий */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 10px; min-height: 112px; }
.tile.wide { grid-column: span 2; min-height: 0; }
.tile .ti { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.tile b { font-size: 15px; }
.tile span { font-size: 12.5px; color: var(--muted); }
.c-violet { background: var(--accent-soft); color: var(--accent); }
.c-green { background: var(--green-soft); color: var(--green); }
.c-amber { background: var(--amber-soft); color: var(--amber); }
.c-blue { background: var(--blue-soft); color: var(--blue); }
.c-red { background: var(--red-soft); color: var(--red); }

/* пары */
.lesson { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; }
.lesson + .lesson { border-top: 1px solid var(--line); }
.lesson .time { width: 48px; flex: none; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); line-height: 1.35; }
.lesson .time b { color: var(--text); font-size: 15px; display: block; }
.lesson.now { background: var(--accent-soft); }
.lesson.done { opacity: .55; }
.lesson .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.seg { display: flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 9px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }

.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.datebar .btn { width: 44px; padding: 10px 0; }
.datebar .d { flex: 1; text-align: center; }
.datebar .d b { display: block; }

/* журнал */
.mark { min-width: 108px; justify-content: center; cursor: pointer; border: 0; padding: 6px 10px; font-size: 12.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

/* таблица прогулов */
.bar { height: 6px; border-radius: 6px; background: var(--card-2); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; }

/* формы */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin: 0 0 6px 2px; }
input.in, select.in, textarea.in {
  width: 100%; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; outline: none; -webkit-appearance: none; appearance: none;
}
textarea.in { min-height: 96px; resize: vertical; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* нижняя навигация */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar[hidden] { display: none; }
#tabbar .in { display: flex; width: 100%; max-width: 560px; }
#tabbar button { flex: 1; height: var(--tabbar-h); background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--muted); cursor: pointer; }
#tabbar button.on { color: var(--accent); }

/* шторка */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; animation: fade .18s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.2,.8,.2,1);
  max-width: 560px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 19px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.fab { position: fixed; right: max(16px, calc(50vw - 264px)); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(124,108,246,.45); z-index: 15; cursor: pointer; }
.fab svg.i { width: 26px; height: 26px; }

#toast { position: fixed; left: 50%; top: 16px; transform: translate(-50%, -150%); background: var(--card-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 60; transition: transform .25s; max-width: 90vw; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
#toast.show { transform: translate(-50%, 0); }
#toast.err { border-color: var(--red); color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 14px; }
.hero { text-align: center; padding: 32px 8px 8px; }
.hero .logo { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 16px; display: grid; place-items: center; background: linear-gradient(135deg, #8b7bff, #5b4bd6); color: #fff; }
.hero .logo svg.i { width: 36px; height: 36px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); background: none; border: 0; padding: 0; margin-bottom: 8px; cursor: pointer; font-size: 15px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 22px; letter-spacing: .18em; font-weight: 700; }
pre.note { white-space: pre-wrap; margin: 6px 0 0; font: inherit; }

/* типы занятий: лекции — розовые, практики — оранжевые, лабы — синие */
:root { --pink: #f472b6; --pink-soft: rgba(244, 114, 182, .16); --orange: #fb923c; --orange-soft: rgba(251, 146, 60, .16); }
.badge.pink { background: var(--pink-soft); color: var(--pink); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.lesson.k-lec { box-shadow: inset 4px 0 0 var(--pink); }
.lesson.k-prac { box-shadow: inset 4px 0 0 var(--orange); }
.lesson.k-lab { box-shadow: inset 4px 0 0 var(--blue); }
.kind-chip { margin-right: 6px; vertical-align: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* домашка */
.hw-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.hw-item + .hw-item { border-top: 1px solid var(--line); }
.hw-item.full:not(.mine) { opacity: .55; cursor: default; }
.hw-box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; margin-top: 1px; color: #fff; font-size: 14px; font-weight: 700; }
.hw-item.mine .hw-box { background: var(--accent); border-color: var(--accent); }
.hw-item.full:not(.mine) .hw-box { background: var(--card-2); }
.taker { display: inline-flex; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--card-2); margin: 4px 4px 0 0; border: 0; color: inherit; }
.taker.me { background: var(--accent-soft); color: var(--accent); }

/* контакты */
.contact-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.contact-btns a, .contact-btns button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); font-size: 13.5px; color: var(--text); cursor: pointer; }

/* переключатель дней недели */
.days { display: grid; gap: 6px; margin-bottom: 4px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 5px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: var(--text); }
.day .wd { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.day b { font-size: 17px; line-height: 1.2; }
.day .cnt { font-size: 9px; letter-spacing: 1px; color: var(--accent); height: 10px; line-height: 10px; }
.day.today { border-color: var(--accent); }
.day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.day.on .wd, .day.on .cnt { color: rgba(255, 255, 255, .85); }

/* отменённая / перенесённая в другой день пара */
.lesson.off { opacity: .6; }
.lesson.off > .grow > div:first-child, .lesson.off .time { text-decoration: line-through; }

/* аватары */
.avatar.emoji { font-size: 22px; }
.avatar.xl { width: 84px; height: 84px; border-radius: 26px; font-size: 34px; }
.avatar.xl.emoji { font-size: 46px; }
.profile-card { text-align: center; display: flex; flex-direction: column; align-items: center; }
.avatar-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; }
.avatar-btn .edit { position: absolute; right: -6px; bottom: -6px; width: 28px; height: 28px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border: 1px solid var(--line); background: var(--card-2); border-radius: 10px; font-size: 22px; cursor: pointer; padding: 0; }
.color-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.color-row button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }

/* выбор темы */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-align: left; }
.theme-opt .dotc { width: 18px; height: 18px; border-radius: 50%; background: var(--c); margin-bottom: 4px; }
.theme-opt b { font-size: 13px; }
.theme-opt.on { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; }

/* праздники и дни рождения */
.card.fun { display: flex; align-items: center; gap: 12px; border-color: var(--c); background: linear-gradient(120deg, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%), var(--card); }
.card.fun .fun-emoji { font-size: 34px; line-height: 1; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
#fx span { position: absolute; top: -40px; opacity: .75; animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
:root.spooky:not(.light) { --bg: #0b0806; --card: #17110c; --card-2: #201810; --line: #33241a; }
