/* ============ Токены ============ */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .08);
  --accent: #2f7cf6;
  --on-accent: #ffffff;
  --accent-soft: rgba(47, 124, 246, .12);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .12);
  --success: #18a058;
  --success-soft: rgba(24, 160, 88, .12);
  --warning: #e5a000;
  --warning-soft: rgba(229, 160, 0, .14);
  --brand: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-top: max(env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px));
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d14;
    --surface: #121722;
    --surface-2: #1a2130;
    --text: #e7ebf3;
    --muted: #8a94a8;
    --border: rgba(255, 255, 255, .07);
    --accent: #4c8dff;
    --accent-soft: rgba(76, 141, 255, .16);
    --danger: #ff6369;
    --danger-soft: rgba(255, 99, 105, .14);
    --success: #3dd68c;
    --success-soft: rgba(61, 214, 140, .13);
    --warning: #ffc53d;
    --warning-soft: rgba(255, 197, 61, .13);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  --bg: #0a0d14; --surface: #121722; --surface-2: #1a2130; --text: #e7ebf3; --muted: #8a94a8;
  --border: rgba(255, 255, 255, .07); --accent: #4c8dff; --accent-soft: rgba(76, 141, 255, .16);
  --danger: #ff6369; --danger-soft: rgba(255, 99, 105, .14); --success: #3dd68c; --success-soft: rgba(61, 214, 140, .13);
  --warning: #ffc53d; --warning-soft: rgba(255, 197, 61, .13); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
}
/* Внутри Telegram — цвета берутся из темы клиента (задаются из JS) */
:root.tg { --shadow: none; }

/* ============ База ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ============ Заставка ============ */
.splash { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 22px; }
.splash-logo, .logo { width: 64px; height: 64px; border-radius: 18px; background: url(/static/logo.svg) center/cover; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Экран входа ============ */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.login-card { width: 100%; max-width: 400px; text-align: center; }
.login-card .logo { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 22px; box-shadow: 0 12px 40px rgba(99, 102, 241, .35); }
.login-card h1 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 8px; font-weight: 800; }
.login-card .lead { color: var(--muted); margin: 0 0 28px; font-size: 16px; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); text-align: left; }
.feature { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.feature + .feature { border-top: 1px solid var(--border); }
.feature .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.feature b { display: block; font-weight: 600; font-size: 14px; }
.feature span { color: var(--muted); font-size: 13px; }
.login-hint { font-size: 13px; color: var(--muted); text-align: center; margin: 14px 0 0; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; margin-top: 14px; }

/* ============ Кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  background: var(--surface-2); color: var(--text); transition: transform .12s, filter .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-tg { background: #2aabee; color: #fff; }
.btn-tg:hover { filter: brightness(1.06); }
.btn-block { width: 100%; height: 50px; font-size: 16px; border-radius: 14px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-success { background: var(--success-soft); color: var(--success); }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============ Каркас приложения ============ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex: none; position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.brand .logo { width: 36px; height: 36px; border-radius: 11px; }
.brand b { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--muted); font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .badge-count { margin-left: auto; }
.side-user { color: var(--text); margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface-2); }
.side-user .meta { min-width: 0; flex: 1; }
.side-user .meta b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .meta span { font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; }
.stats > *, .stack > *, .options > * { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.015em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { max-width: 1040px; margin: 0 auto; padding: 8px 16px calc(100px + var(--safe-bottom)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: none;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--border);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 500; position: relative; }
.tabbar a.active { color: var(--accent); }
.tabbar svg.i { width: 24px; height: 24px; }
.tabbar .dot { position: absolute; top: 3px; left: calc(50% + 8px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .tabbar { display: flex; }
  body.nested .tabbar { display: none; }
  body.nested .content { padding-bottom: calc(110px + var(--safe-bottom)); }
}
@media (min-width: 900px) {
  .topbar { padding: 22px max(32px, calc((100% - 1040px) / 2 + 32px)) 14px; }
  .topbar h1 { font-size: 26px; }
  .content { padding: 6px 32px 60px; }
  .only-mobile { display: none !important; }
}
:root.tg .topbar .tg-hide { display: none; }

/* ============ Карточки, сетки ============ */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 4px 10px; }
.section-title h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.section-title a { font-size: 14px; font-weight: 500; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
:root.tg .card { border-color: transparent; }
.card-pad { padding: 18px; }
.stack > * + * { margin-top: 10px; }

.hello { margin: 6px 4px 18px; }
.hello h2 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.hello p { margin: 4px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.stat { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.stat .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; }
.stat .val { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tone-accent { background: var(--accent-soft); color: var(--accent); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }

.grid-2 { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.grid-2 > * { min-width: 0; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; } }

/* График недели */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.chart .bar-wrap { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; }
.chart .bar { width: 100%; border-radius: 8px 8px 4px 4px; background: var(--accent-soft); position: relative; overflow: hidden; min-height: 4px; transition: height .5s cubic-bezier(.2, .8, .2, 1); }
.chart .bar .v { position: absolute; left: 0; right: 0; bottom: 0; background: var(--danger); border-radius: 0 0 4px 4px; }
.chart .bar.today { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.chart .d { font-size: 12px; color: var(--muted); }
.chart .d.today { color: var(--text); font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Списки / строки */
.list { overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; position: relative; color: var(--text); }
a.row:hover, button.row:hover { background: var(--surface-2); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; height: 1px; background: var(--border); }
.row.plain + .row.plain::before { left: 16px; }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: var(--muted); opacity: .6; }
.row .ico-box { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
button.row { width: 100%; text-align: left; }

.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; object-fit: cover; }
.avatar.lg { width: 84px; height: 84px; font-size: 32px; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.off { background: var(--muted); box-shadow: 0 0 0 3px var(--surface-2); }

/* Бейджи */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge svg.i { width: 14px; height: 14px; }
.badge-count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--danger); color: #fff; }

/* Запись журнала */
.log { padding: 15px 16px; }
.log + .log { border-top: 1px solid var(--border); }
.log-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-head .when { margin-left: auto; font-size: 12px; color: var(--muted); }
.log-meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.log-meta b { color: var(--text); font-weight: 600; }
.log-text {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2);
  font-size: 14px; white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer;
}
.log-text.open { -webkit-line-clamp: unset; display: block; }
.log-reason { margin-top: 8px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; }
.log-reason svg.i { width: 16px; height: 16px; margin-top: 1px; color: var(--accent); }
.log-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.log-foot .grow { flex: 1; }
.log-foot .btns { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 420px) { .log-foot .grow { display: none; } .log-foot .btns { width: 100%; } .log-foot .btns .btn { flex: 1; } }
.conf { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conf .meter { width: 44px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.conf .meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.log.compact .log-text { -webkit-line-clamp: 2; }

/* Сегменты / фильтры */
.segments { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 13px; }
.segments button { flex: 1; height: 34px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; padding: 0 10px; }
.segments button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .segments { flex: 1; min-width: 260px; }
.select {
  height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 0 34px 0 12px;
  appearance: none; -webkit-appearance: none; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}

/* Формы */
.field { padding: 16px; }
.field + .field { border-top: 1px solid var(--border); }
.field > label, .field-label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.input, .textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px;
  padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; min-height: 380px; }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 6px; }

.switch-row { display: flex; align-items: center; gap: 12px; }
.switch-row .body { flex: 1; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: transform .22s cubic-bezier(.3, .7, .4, 1.2); }
.switch input:checked + span { background: var(--success); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(20px); }

.options { display: grid; gap: 8px; }
@media (min-width: 600px) { .options { grid-template-columns: 1fr 1fr; } }
.option {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px; border-radius: 14px; text-align: left;
  border: 1.5px solid var(--border); background: var(--surface); transition: border-color .15s, background .15s;
}
.option .ico-box { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.option b { display: block; font-size: 14px; }
.option span { font-size: 12.5px; color: var(--muted); }
.option.on { border-color: var(--accent); background: var(--accent-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px 0 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; font-weight: 500; }
.chip button { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.chip button:hover { background: var(--danger-soft); color: var(--danger); }
.chip button svg.i { width: 14px; height: 14px; }
.chip-pick { height: 32px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.chip-pick.on { background: var(--accent); color: var(--on-accent); }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row .input { flex: 1; }

/* Панель сохранения */
.savebar {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translate(-50%, 140%); z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px; border-radius: 16px;
  background: var(--text); color: var(--bg); box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility .3s; width: max-content; max-width: calc(100% - 32px); visibility: hidden;
}
.savebar.show { transform: translate(-50%, 0); visibility: visible; }
.savebar span { font-size: 14px; font-weight: 500; }
.savebar .btn { height: 38px; }
@media (min-width: 900px) { .savebar { left: calc(50% + 130px); } }

/* Пустые состояния */
.empty { text-align: center; padding: 38px 20px; }
.empty .ico { width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .ico svg.i { width: 28px; height: 28px; }
.empty h3 { margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0 auto 18px; color: var(--muted); max-width: 340px; }

.hero {
  position: relative; overflow: hidden; padding: 22px; border-radius: var(--radius); color: #fff; background: var(--brand);
}
.hero h3 { margin: 0 0 6px; font-size: 19px; }
.hero p { margin: 0 0 16px; opacity: .9; font-size: 14px; max-width: 420px; }
.hero .btn { background: #fff; color: #3b4bd8; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .12); }

/* Профиль */
.profile { text-align: center; padding: 26px 18px 22px; }
.profile .avatar { margin: 0 auto 12px; }
.profile h2 { margin: 0; font-size: 22px; font-weight: 750; }
.profile p { margin: 4px 0 10px; color: var(--muted); }

/* Расписание */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 34px 18px; border: 2px dashed var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop .ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.day h3 { margin: 0; padding: 14px 16px 6px; font-size: 16px; }
.lesson { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 10px 16px; }
.lesson + .lesson { border-top: 1px solid var(--border); }
.lesson .t { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson .s { font-weight: 600; }
.lesson .m { font-size: 13px; color: var(--muted); }

/* Тост */
.toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-top)); transform: translate(-50%, -160%); z-index: 100;
  padding: 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 500; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility .3s; max-width: calc(100% - 32px);
  visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.err { background: var(--danger); color: #fff; }

/* Скелетоны */
.skel { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.fade-in { animation: fi .28s ease both; }
body.silent .fade-in { animation: none; }
@keyframes fi { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Шапка группы */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.group-head { padding: 18px; }
.gh-top { display: flex; gap: 16px; align-items: center; }
.gh-top .avatar.lg { width: 72px; height: 72px; font-size: 26px; }
.gh-main { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.gh-main h2 { margin: 0; font-size: 21px; font-weight: 750; letter-spacing: -.01em; overflow-wrap: anywhere; }
.gh-main a, .gh-main .muted { font-size: 14px; }
.id-pill { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.id-pill:hover { color: var(--text); }
.id-pill svg.i { width: 14px; height: 14px; }
.gh-desc { margin: 14px 0 0; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 16px; border-radius: 14px; overflow: hidden; background: var(--border); border: 1px solid var(--border); }
@media (min-width: 640px) { .info-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.info-grid > div { background: var(--surface); padding: 11px 13px; min-width: 0; }
.info-grid span { display: block; font-size: 12px; color: var(--muted); }
.info-grid b { display: block; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-grid small { color: var(--muted); font-weight: 500; }
.gh-rights { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }

/* Вложения в журнале */
.log-media { position: relative; margin-top: 10px; max-width: 280px; border-radius: 14px; overflow: hidden; background: var(--surface-2); cursor: default; }
.log-media img, .log-media video { display: block; width: 100%; max-height: 300px; object-fit: contain; }
.log-media.nsfw { cursor: pointer; }
.log-media.nsfw img, .log-media.nsfw video { filter: blur(28px) saturate(.6); transform: scale(1.1); }
.log-media .reveal { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 10px;
  color: #fff; font-size: 13px; font-weight: 600; background: rgba(0, 0, 0, .3); }
.log-media:not(.nsfw) .reveal { display: none; }

/* Доверенные каналы и база знаний */
.trust-list, .ex-list { margin: 4px -16px 0; }
.trust-list .row, .ex-list .row { padding: 10px 16px; }
.ex-list .row { align-items: flex-start; }
.ex-list .sub { white-space: normal; }

/* Поддержка */
.ticket-head { display: flex; align-items: flex-start; gap: 12px; }
.ticket-head .body { flex: 1; min-width: 0; }
.ticket-head .title { font-weight: 650; font-size: 16px; }
.ticket-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.chat-thread { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.bubble { max-width: 85%; align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px;
  padding: 9px 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.bubble .who { font-size: 12px; font-weight: 600; opacity: .7; margin-bottom: 2px; }
.bubble .at { font-size: 11px; opacity: .6; margin-top: 4px; text-align: right; }
.list .row .badge { flex-shrink: 0; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }

/* Лимит ИИ */
.usage { padding: 14px 16px; margin-bottom: 14px; }
.usage-top { display: flex; align-items: center; gap: 12px; }
.usage-top .body { flex: 1; min-width: 0; }
.usage-top .title { font-weight: 650; font-size: 15px; }
.usage-top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.usage-num { text-align: right; white-space: nowrap; }
.usage-num b { font-size: 18px; display: block; }
.usage-num span { color: var(--muted); font-size: 12px; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.meter i { display: block; height: 100%; border-radius: inherit; transition: width .4s ease; }
.meter .m-accent { background: var(--accent); } .meter .m-warning { background: var(--warning); } .meter .m-danger { background: var(--danger); }
.lim-row .meter { margin-top: 8px; height: 6px; }
.lim-row .add-row { margin-top: 10px; }
.lim-row .add-row .btn { flex-shrink: 0; }
.bot-reach { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 14px; }
.bot-reach .body { flex: 1; min-width: 0; }
.bot-reach .title { font-weight: 650; font-size: 15px; }
.bot-reach .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
