/* Мини-приложение студкомитета. Палитра, шрифты и компоненты — как на сайте studkom-site (assets/style.css). */

/* ============ Палитра — взята из логотипа ============ */
:root {
  --bg: #232c6b;
  --bg-deep: #19205c;
  --surface: #2d3787;
  --surface-2: #38439a;
  --ink: #f4f2ff;
  --muted: #b4b8ec;
  --lav: #c7bffb;          /* лаванда букв AI */
  --lav-soft: rgba(199, 191, 251, 0.14);
  --violet: #6c4dd0;       /* корпус телевизора */
  --violet-deep: #4a32a8;
  --on-lav: #1c2360;       /* тёмный текст на лаванде */
  --line: rgba(199, 191, 251, 0.24);
  --mark: #ffe08a;
  --danger: #ffb3c1;       /* ошибки — мягкий розовый в тон палитре */
  --ok: #9ff0c8;
  --radius: 24px;
  --pop: 0 5px 0 rgba(12, 16, 60, 0.6);          /* «мультяшная» жёсткая тень */
  --pop-hover: 0 8px 0 rgba(12, 16, 60, 0.6);
  --font-head: "Unbounded", "Nunito", system-ui, sans-serif;
  /* безопасные зоны: вырез экрана и полноэкранный режим Telegram (переменные ставит telegram-web-app.js) */
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  --gutter: 16px;
  color-scheme: dark;
}

/* ============ База ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 88% -6%, rgba(108, 77, 208, 0.5), transparent 62%),
    radial-gradient(760px 520px at -4% 18%, rgba(199, 191, 251, 0.1), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: var(--tg-viewport-stable-height, 100vh);
}
body.noscroll { overflow: hidden; }
/* зерно, как на логотипе */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
img { max-width: 100%; display: block; }
a { color: var(--lav); }
h1, h2 { font-family: var(--font-head); line-height: 1.15; margin: 0; letter-spacing: -0.02em; overflow-wrap: break-word; }
h3 { line-height: 1.25; margin: 0; font-weight: 800; overflow-wrap: anywhere; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.9em; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; border-radius: 8px; }
.ic { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* искры */
.spark { width: 1em; height: 1em; fill: currentColor; flex: none; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.76rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--lav);
}
.eyebrow .spark { color: #fff; width: 13px; height: 13px; }
@keyframes twinkle { 0%, 100% { transform: scale(0.65) rotate(0deg); opacity: 0.55; } 50% { transform: scale(1) rotate(18deg); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(2deg); } 50% { transform: translateY(-8px) rotate(-1deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
.twinkle { animation: twinkle 3.2s ease-in-out infinite; }

/* ============ Кнопки (как на сайте) ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: 999px; border: 2px solid var(--on-lav);
  background: var(--lav); color: var(--on-lav);
  font-family: inherit; font-size: 1rem; font-weight: 800; line-height: 1.2; text-align: center;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--on-lav);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--on-lav); background: #d8d2ff; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--on-lav); }
.btn-violet { background: var(--violet); color: #fff; border-color: var(--on-lav); }
.btn-violet:hover { background: #7a5ce0; }
.btn-sm { padding: 9px 16px; font-size: 0.9rem; box-shadow: 0 3px 0 var(--on-lav); }
.btn-ghost { background: transparent; color: var(--lav); border-color: var(--line); box-shadow: none; }
.btn-ghost:hover { background: var(--lav-soft); box-shadow: none; border-color: var(--lav); }
.btn-ghost:active { transform: translateY(1px); box-shadow: none; }
.btn-ghost.danger { color: var(--danger); border-color: rgba(255, 179, 193, 0.4); }
.btn-ghost.danger:hover { background: rgba(255, 179, 193, 0.1); border-color: var(--danger); }
.btn.is-disabled, .btn:disabled { background: rgba(255, 255, 255, 0.08); color: var(--muted); border-color: transparent; box-shadow: none; cursor: default; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 auto; }
.btn-row.center { justify-content: center; margin-top: 22px; }
.btn-row.center > .btn { flex: 0 1 auto; }
.link-btn {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--lav); font: inherit; font-weight: 800; font-size: 0.92rem;
  text-decoration: underline; text-underline-offset: 4px;
}
.icon-btn {
  width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--lav-soft); color: var(--ink); display: grid; place-items: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--lav); color: var(--on-lav); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger); color: var(--on-lav); }
.icon-btn .ic { width: 18px; height: 18px; }

/* ============ Шапка ============ */
.app-header {
  position: sticky; top: 0; z-index: 50;
  padding-top: var(--safe-top);
  background: rgba(25, 32, 92, 0.86);
  background: color-mix(in srgb, var(--bg-deep) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px); backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1.5px solid var(--line);
}
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px;
  width: min(760px, 100% - 2 * var(--gutter) - var(--safe-left) - var(--safe-right)); margin-inline: auto;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
/* знак РУДН слева от названия, отделён тонкой чертой */
.brand-logo { height: 36px; width: auto; flex: none; padding-right: 12px; border-right: 2px solid var(--line); box-sizing: content-box; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text b { font-family: var(--font-head); font-size: 0.84rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 0.74rem; font-weight: 700; }
.me { display: flex; align-items: center; gap: 8px; flex: none; }
.me-ava {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--lav); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
  font-family: var(--font-head); font-weight: 800; font-size: 0.78rem; text-decoration: none;
}
.me-dev { font-size: 0.68rem; font-weight: 800; color: var(--mark); border: 1.5px solid rgba(255, 224, 138, 0.5); border-radius: 999px; padding: 2px 8px; }

/* ============ Каркас экрана ============ */
.view {
  position: relative; z-index: 1;
  width: min(760px, 100% - 2 * var(--gutter) - var(--safe-left) - var(--safe-right)); margin-inline: auto;
  padding: 4px 0 calc(36px + var(--safe-bottom));
}
.view.has-bar { padding-bottom: 0; }
.view:focus { outline: none; }
.ph { padding: 20px 0 14px; }
.ph h1 { font-size: clamp(1.35rem, 6vw, 2rem); font-weight: 800; margin: 10px 0 8px; }
.ph .lead { color: var(--muted); font-weight: 600; max-width: 60ch; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px; padding: 6px 0;
  background: none; border: 0; cursor: pointer; color: var(--lav); font: inherit; font-weight: 800; font-size: 0.92rem;
}
.sec { margin-top: 24px; }
.sec-title { font-family: var(--font-head); font-size: 1rem; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -0.01em; }
.stack { display: grid; gap: 14px; }
.list { display: grid; gap: 12px; }
.hint { color: var(--muted); font-size: 0.88rem; font-weight: 600; margin-top: 10px; }
.hint.top { margin: 0 0 14px; }
.hint code, .note code, .card code { background: rgba(12, 16, 60, 0.5); color: var(--lav); padding: 1px 6px; border-radius: 6px; }
.mini-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.label { display: block; font-weight: 800; margin: 0 0 8px; }
.label.mt { margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ============ Карточки ============ */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--pop); min-width: 0;
}
a.card, button.card { text-decoration: none; color: inherit; display: block; font: inherit; text-align: left; width: 100%; cursor: pointer; transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s; }
a.card:hover, button.card:hover { transform: translateY(-3px); box-shadow: var(--pop-hover); border-color: var(--lav); }
a.card:active, button.card:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(12, 16, 60, 0.6); }
.card-ic {
  width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px; margin-bottom: 18px;
  background: var(--lav); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
}
.card-ic .ic { width: 26px; height: 26px; }
.card h3 { font-size: 1.08rem; }
.card p { font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h3 { font-size: 1.06rem; }
.card-title { font-family: var(--font-head); font-size: 1rem; font-weight: 700; margin-bottom: 4px; }

.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-weight: 800; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; background: var(--lav); color: var(--on-lav); white-space: nowrap; }
.badge-violet { background: var(--violet); color: #fff; }
.badge-muted { background: var(--surface-2); color: var(--lav); box-shadow: inset 0 0 0 1.5px var(--line); }
.badge-warn { background: var(--mark); color: var(--on-lav); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 3px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.02em; text-decoration: none;
  background: rgba(12, 16, 60, 0.45); color: var(--lav); border: 1.5px solid var(--line); overflow-wrap: anywhere;
}
a.chip, button.chip { cursor: pointer; font-family: inherit; }
a.chip:hover, button.chip:hover { background: var(--lav); color: var(--on-lav); border-color: var(--on-lav); }
.chip-static { color: var(--muted); }

/* ============ Главная ============ */
.hero-mini { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 22px 0 4px; }
.hero-mini h1 { font-size: clamp(1.45rem, 7vw, 2.3rem); font-weight: 800; margin: 10px 0 8px; }
.hero-mini .hl { color: var(--lav); }
.hero-mini .lead { color: var(--muted); font-weight: 600; }
.hero-art { position: relative; width: clamp(80px, 24vw, 140px); }
.hero-art img {
  width: 100%; height: auto; border-radius: 26px; border: 3px solid rgba(199, 191, 251, 0.4);
  box-shadow: 0 6px 0 rgba(12, 16, 60, 0.6), 0 20px 40px rgba(6, 8, 40, 0.45);
  animation: float 7s ease-in-out infinite;
}
.hero-art .spark { position: absolute; color: #fff; }
.hero-art .s1 { width: 24px; height: 24px; top: -10px; left: -12px; }
.hero-art .s2 { width: 16px; height: 16px; bottom: 6%; right: -10px; animation-delay: 0.9s; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 136px), 1fr)); gap: 14px; }
.tile { position: relative; padding: 16px; display: flex; flex-direction: column; }
.tile .card-ic { width: 46px; height: 46px; border-radius: 15px; margin-bottom: 12px; }
.tile .card-ic .ic { width: 23px; height: 23px; }
.tiles .tile:nth-child(2n) .card-ic { background: var(--violet); color: #fff; }
.tile h3 { font-size: 0.98rem; margin-bottom: 4px; }
.tile p { color: var(--muted); font-size: 0.84rem; line-height: 1.4; }
.tile-count {
  position: absolute; top: 12px; right: 12px; min-width: 30px; height: 30px; padding: 0 9px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--mark); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
  font-weight: 800; font-size: 0.86rem;
}

/* ============ Списки ============ */
.item { padding: 16px 18px; }
.item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; color: var(--muted); font-weight: 700; font-size: 0.86rem; }
.item h3 { font-size: 1.02rem; }
.item-meta { color: var(--muted); font-weight: 700; font-size: 0.88rem; margin-top: 6px; overflow-wrap: anywhere; }
.item-row { display: flex; gap: 14px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-line; font-weight: 600; }
.count-big {
  display: flex; flex-direction: column; align-items: center; flex: none; min-width: 66px; padding: 8px 10px;
  border-radius: 16px; background: var(--lav); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
}
.count-big b { font-family: var(--font-head); font-size: 1.3rem; line-height: 1.1; }
.count-big small { font-weight: 800; font-size: 0.7rem; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 16px; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.6rem; line-height: 1.15; }
.stat span { color: var(--muted); font-weight: 700; font-size: 0.86rem; }
.mini-list li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1.5px solid var(--line); font-weight: 700; min-width: 0; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > span { min-width: 0; overflow-wrap: anywhere; }
.mini-list time, .mini-list .n { color: var(--muted); flex: none; }
.mini-list a { color: inherit; text-decoration: none; display: flex; gap: 10px; width: 100%; justify-content: space-between; }
.bullets { list-style: disc; padding-left: 20px; display: grid; gap: 4px; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; margin-top: 8px; }

.people { display: grid; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-width: 0;
  border-radius: 16px; background: rgba(12, 16, 60, 0.35); border: 2px solid var(--line);
}
.person .num {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--lav-soft); color: var(--lav); font-weight: 800; font-size: 0.82rem;
}
.pmeta { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.pmeta b { font-weight: 800; overflow-wrap: anywhere; }
.pmeta small { color: var(--muted); font-weight: 700; overflow-wrap: anywhere; }
.pmeta a { color: var(--lav); text-decoration: none; }
.ava {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--violet); color: #fff; border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
  font-family: var(--font-head); font-weight: 800; font-size: 0.82rem;
}
.person-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.author-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

/* ============ Сегменты и выбор ============ */
.seg { display: inline-flex; padding: 5px; border-radius: 999px; background: rgba(12, 16, 60, 0.4); border: 2px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 9px 16px; border-radius: 999px; font: inherit; font-size: 0.92rem; font-weight: 800;
  transition: background 0.15s, color 0.15s;
}
.seg button small { font-weight: 800; opacity: 0.7; margin-left: 5px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--lav); color: var(--on-lav); }
.seg-tabs { display: flex; width: 100%; margin: 18px 0 14px; }
.seg-tabs button { flex: 1; padding: 9px 10px; }

.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; max-width: 100%; padding: 7px 14px;
  border-radius: 999px; border: 2px solid var(--line); background: rgba(12, 16, 60, 0.45); color: var(--ink);
  font: inherit; font-size: 0.9rem; font-weight: 800; cursor: pointer; overflow-wrap: anywhere; text-align: left;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.pick:hover { border-color: var(--lav); }
.pick small { color: var(--muted); font-weight: 800; }
.pick .ic { width: 16px; height: 16px; }
.pick[aria-pressed="true"] { background: var(--lav); color: var(--on-lav); border-color: var(--on-lav); box-shadow: 0 3px 0 var(--on-lav); }
.pick[aria-pressed="true"] small { color: var(--on-lav); opacity: 0.7; }
.pick.all { font-family: var(--font-head); font-weight: 700; font-size: 0.8rem; }
.pick.sm { min-height: 34px; padding: 5px 12px; font-size: 0.84rem; }
.pick.dim:not([aria-pressed="true"]) { opacity: 0.6; }
.course { margin-top: 16px; padding-top: 14px; border-top: 1.5px solid var(--line); }
.course-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.course-head .mini-label { margin: 0; }

.choices { display: grid; gap: 14px; }
.choice { display: flex; gap: 16px; align-items: flex-start; padding: 18px; }
.choice.on { border-color: var(--lav); }
.choice .emo {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center; font-size: 1.55rem;
  border-radius: 16px; background: var(--lav); border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
}
.choice:nth-child(2) .emo { background: var(--violet); }
.choice h3 { font-size: 1.06rem; margin-bottom: 4px; }
.choice p { color: var(--muted); font-size: 0.9rem; }

.steps { display: flex; gap: 6px; margin-top: 14px; }
.steps span { flex: 1; height: 6px; border-radius: 999px; background: var(--lav-soft); }
.steps span.on { background: var(--lav); }

/* ============ Поля ввода (как поиск на сайте) ============ */
.field {
  display: block; width: 100%; min-width: 0;
  background: rgba(255, 255, 255, 0.08); border: 2.5px solid var(--line); border-radius: 18px; box-shadow: var(--pop);
  color: var(--ink); font: inherit; font-size: 1rem; font-weight: 700; padding: 13px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus { outline: none; border-color: var(--lav); box-shadow: var(--pop), 0 0 0 5px rgba(199, 191, 251, 0.2); }
.field::placeholder { color: var(--muted); opacity: 0.85; font-weight: 600; }
textarea.field { resize: vertical; min-height: 150px; line-height: 1.5; font-weight: 600; }
input[type="date"].field, input[type="time"].field { -webkit-appearance: none; appearance: none; min-height: 52px; }
input::-webkit-calendar-picker-indicator { filter: invert(0.85); cursor: pointer; }
.input-row { display: flex; flex-wrap: wrap; gap: 10px; }
.input-row .field { flex: 1 1 170px; width: auto; }
.input-row .btn { flex: 1 0 auto; }
.dt-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.dl-out { margin-top: 14px; font-weight: 800; color: var(--lav); }
.dl-out.bad { color: var(--danger); }
.ed-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 0.84rem; font-weight: 700; color: var(--muted); }
.ed-err { color: var(--danger); }
.counter { margin-left: auto; white-space: nowrap; }
.counter.over { color: var(--danger); }

/* редактор с панелью форматирования */
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tool {
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: rgba(12, 16, 60, 0.4); color: var(--ink);
  font: inherit; font-weight: 800; font-size: 0.98rem; line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tool:hover { border-color: var(--lav); }
.tool:active { background: var(--lav); color: var(--on-lav); }
.tool-i { font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.tool-u { text-decoration: underline; }
.tool-s { text-decoration: line-through; }
.tool-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.78rem; }
.linkrow { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.linkrow .field { flex: 1 1 180px; width: auto; box-shadow: none; padding: 10px 14px; }
.ed-prev { margin-top: 14px; padding: 14px; border-radius: 16px; background: rgba(12, 16, 60, 0.35); border: 2px dashed var(--line); }
.rich.is-empty::before { content: "Здесь появится предпросмотр"; color: var(--muted); }

/* текст с форматированием Telegram */
.rich { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.rich b { font-weight: 800; }
.rich a { color: var(--lav); }
.rich code { background: rgba(12, 16, 60, 0.5); padding: 1px 6px; border-radius: 6px; }
.rich blockquote { margin: 6px 0; padding: 4px 10px 4px 12px; border-left: 3px solid var(--lav); background: var(--lav-soft); border-radius: 0 10px 10px 0; }
.rich tg-spoiler { background: rgba(199, 191, 251, 0.45); color: transparent; border-radius: 5px; cursor: pointer; transition: background 0.2s, color 0.2s; }
.rich tg-spoiler:not(.open) * { color: transparent !important; }
.rich tg-spoiler.open { background: rgba(199, 191, 251, 0.12); color: inherit; }

/* ============ Файлы ============ */
.flist { display: grid; gap: 8px; margin-bottom: 12px; }
.fitem {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px;
  border-radius: 16px; background: rgba(12, 16, 60, 0.35); border: 2px solid var(--line);
}
.fitem.ro { grid-template-columns: 44px minmax(0, 1fr); }
.fthumb { width: 44px; height: 44px; border-radius: 12px; overflow: hidden; display: grid; place-items: center; background: var(--lav); color: var(--on-lav); }
.fthumb img { width: 100%; height: 100%; object-fit: cover; }
.fmeta { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.fmeta b { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmeta small { color: var(--muted); font-weight: 700; }

.atts { display: grid; gap: 12px; }
.att { padding: 12px; border-radius: 18px; background: rgba(12, 16, 60, 0.35); border: 2px solid var(--line); min-width: 0; }
.att-img {
  display: grid; place-items: center; width: 100%; min-height: 170px; padding: 0; border: 0; border-radius: 12px; overflow: hidden;
  background: rgba(255, 255, 255, 0.06); color: var(--muted); font: inherit; font-weight: 700; cursor: zoom-in;
}
.att-img img { width: 100%; max-height: 380px; object-fit: contain; }
.att-img.att-noimg { min-height: 0; padding: 14px; cursor: pointer; }
.att-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.att-ic {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px;
  background: var(--lav); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 3px 0 var(--on-lav);
}
.att-cap { margin-top: 10px; font-size: 0.94rem; }
.att-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.att-btns .btn { flex: 1 1 auto; }

/* ============ Предпросмотр как в Telegram ============ */
.tg-chat {
  display: grid; gap: 6px; padding: 16px 12px; border-radius: 22px; border: 2px solid var(--line); box-shadow: var(--pop);
  background: radial-gradient(420px 260px at 100% 0, rgba(108, 77, 208, 0.35), transparent 70%), #151b4f;
}
.tg-msg { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.tg-ava { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 2px solid var(--line); background: var(--lav); object-fit: cover; }
.tg-ava.ghost { visibility: hidden; }
.tg-col { min-width: 0; max-width: calc(100% - 42px); display: grid; gap: 4px; }
.tg-bubble { background: var(--surface); border-radius: 18px 18px 18px 6px; padding: 8px 12px 6px; min-width: 140px; overflow: hidden; box-shadow: 0 2px 0 rgba(12, 16, 60, 0.5); }
.tg-name { color: var(--lav); font-weight: 800; font-size: 0.86rem; margin-bottom: 4px; }
.tg-media { margin: 0 -12px 8px; }
.tg-media img, .tg-media video { width: 100%; max-height: 300px; object-fit: cover; display: block; background: #0d1240; }
.tg-text { font-size: 0.97rem; line-height: 1.45; }
.tg-time { float: right; margin: 6px 0 -2px 12px; font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.tg-doc { display: flex; gap: 10px; align-items: center; padding: 4px 0 8px; min-width: 0; }
.tg-doc-ic { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--violet); color: #fff; display: grid; place-items: center; }
.tg-kb span { display: block; text-align: center; padding: 9px 12px; border-radius: 12px; background: rgba(45, 55, 135, 0.85); font-weight: 800; font-size: 0.92rem; }

/* ============ Ключ-значение, прогресс, уведомления ============ */
.kv { display: grid; gap: 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.kv dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.prog { height: 12px; border-radius: 999px; background: rgba(12, 16, 60, 0.5); border: 2px solid var(--line); overflow: hidden; margin-top: 10px; }
.prog > span { display: block; height: 100%; min-width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--violet), var(--lav)); transition: width 0.3s ease; }
.prog.lg { height: 18px; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.prog-head span { color: var(--muted); font-weight: 800; }
.prog-head span b { color: var(--ink); font-family: var(--font-head); font-size: 1.2rem; }

.note {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 18px; min-width: 0;
  background: var(--lav-soft); border: 2px solid var(--line); font-weight: 700; overflow-wrap: anywhere;
}
.note > .ic { margin-top: 2px; color: var(--lav); }
.note.warn { background: rgba(255, 224, 138, 0.1); border-color: rgba(255, 224, 138, 0.4); }
.note.warn > .ic { color: var(--mark); }
.note.ok { background: rgba(159, 240, 200, 0.1); border-color: rgba(159, 240, 200, 0.35); }
.note.ok > .ic { color: var(--ok); }
.note.err { background: rgba(255, 179, 193, 0.1); border-color: rgba(255, 179, 193, 0.4); }
.banner { background: linear-gradient(135deg, rgba(108, 77, 208, 0.55), rgba(255, 255, 255, 0.04)); }
.banner h3 { font-family: var(--font-head); font-size: 1.02rem; font-weight: 700; margin-bottom: 6px; }
.banner p { color: var(--ink); opacity: 0.9; margin-bottom: 14px; }
.row-switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row-switch small { font-weight: 600; }
.switch {
  position: relative; width: 54px; height: 32px; flex: none; padding: 0; cursor: pointer;
  border-radius: 999px; border: 2px solid var(--line); background: rgba(12, 16, 60, 0.5); transition: background 0.18s, border-color 0.18s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted); transition: transform 0.18s, background 0.18s;
}
.switch[aria-checked="true"] { background: var(--violet); border-color: var(--on-lav); }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: #fff; }

.legend { display: grid; gap: 4px; margin-top: 10px; color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.mem-list { display: grid; gap: 10px; margin: 6px 0 16px; }
.mem-list:last-child { margin-bottom: 0; }
.mem-list li { display: grid; gap: 6px; }
.mem-people { display: flex; flex-wrap: wrap; gap: 6px; }
.groups { display: grid; margin-top: 6px; }
.grp { padding: 10px 0; border-top: 1.5px solid var(--line); min-width: 0; }
.grp:first-child { border-top: 0; }
.grp-name { display: block; font-weight: 800; }
.chat { margin-top: 6px; }
.chat-title { display: block; font-weight: 700; overflow-wrap: anywhere; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.asg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.asg-head a, .asg-head b { font-weight: 800; text-decoration: none; }
.asg .atts { margin-top: 12px; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 10px; }

/* ============ Нижняя панель действий ============ */
.actionbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 24px calc(-1 * var(--gutter)) 0;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  background: rgba(25, 32, 92, 0.9);
  background: color-mix(in srgb, var(--bg-deep) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px); backdrop-filter: saturate(1.3) blur(14px);
  border-top: 1.5px solid var(--line);
}
.actionbar .btn { flex: 1 1 auto; }
.ab-info { flex: 1 1 auto; color: var(--muted); font-weight: 700; font-size: 0.92rem; }
.ab-info b { color: var(--ink); }

/* ============ Пустые состояния, итог, скелеты ============ */
.empty-state { text-align: center; padding: 40px 20px; background: rgba(12, 16, 60, 0.3); border: 2.5px dashed var(--line); border-radius: var(--radius); }
.empty-state > .ic { width: 46px; height: 46px; color: var(--lav); margin: 0 auto 14px; display: block; }
.empty-state h3 { font-size: 1.15rem; margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin: 0 auto 20px; max-width: 46ch; font-weight: 600; }
.empty-state p:last-child { margin-bottom: 0; }

.done { text-align: center; padding: 30px 20px; margin-top: 18px; }
.done-ic {
  position: relative; width: 76px; height: 76px; margin: 0 auto 18px; display: grid; place-items: center;
  border-radius: 24px; background: var(--lav); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 4px 0 var(--on-lav);
}
.done-ic .ic { width: 38px; height: 38px; }
.done-ic .spark { position: absolute; color: #fff; }
.done-ic .d1 { width: 22px; height: 22px; top: -10px; right: -12px; }
.done-ic .d2 { width: 14px; height: 14px; bottom: -4px; left: -12px; animation-delay: 0.8s; }
.done h1 { font-size: clamp(1.25rem, 5.5vw, 1.8rem); font-weight: 800; }
.done .lead { color: var(--muted); font-weight: 600; margin-top: 10px; }

.sk {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.13) 37%, rgba(255, 255, 255, 0.05) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 14px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line { height: 14px; margin: 10px 0; }
.sk-line.w40 { width: 40%; }
.sk-line.w70 { width: 70%; }
.sk-title { height: 30px; width: 65%; margin: 12px 0; border-radius: 10px; }
.sk-card { height: 104px; border-radius: var(--radius); }
.sk-tile { height: 150px; border-radius: var(--radius); }

/* ============ Тосты, загрузка, просмотр файлов ============ */
.toasts {
  position: fixed; left: 0; right: 0; top: calc(72px + var(--safe-top)); z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: min(460px, 100%); padding: 12px 18px; border-radius: 18px; cursor: pointer;
  background: var(--lav); color: var(--on-lav); border: 2px solid var(--on-lav); box-shadow: 0 4px 0 var(--on-lav);
  font-weight: 800; font-size: 0.95rem; line-height: 1.35; white-space: pre-line; overflow-wrap: anywhere;
  animation: toast-in 0.2s ease; transition: opacity 0.25s, transform 0.25s;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

.busy { position: fixed; inset: 0; z-index: 280; display: grid; place-items: center; padding: 24px; background: rgba(12, 16, 60, 0.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.busy-card { width: min(320px, 100%); text-align: center; padding: 26px 22px; }
.busy-card .spark { width: 44px; height: 44px; color: var(--lav); margin: 0 auto 14px; display: block; animation: spin 1.4s linear infinite; }
.busy-text { font-weight: 800; }

.viewer {
  position: fixed; inset: 0; z-index: 260; display: flex; flex-direction: column;
  background: rgba(8, 10, 40, 0.96);
  padding: calc(10px + var(--safe-top)) 12px calc(14px + var(--safe-bottom));
}
.viewer-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.viewer-name { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; border-radius: 14px; }
.viewer-body audio { width: min(420px, 100%); }
.viewer-text { width: 100%; max-height: 100%; margin: 0; padding: 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.06); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9rem; }

/* ============ Адаптив ============ */
@media (min-width: 640px) {
  .card { padding: 22px; }
  .item { padding: 18px 22px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .tile { padding: 20px; }
  .ph { padding-top: 28px; }
}
@media (max-width: 359px) {
  :root { --gutter: 12px; }
  .brand-logo { height: 30px; padding-right: 10px; }
  .brand-text b { font-size: 0.78rem; }
  .card { padding: 16px; }
  .btn { padding: 12px 16px; }
  .seg-tabs button { font-size: 0.86rem; padding: 9px 6px; }
}

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