:root {
  --bg: #f3f5fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-ink: #3730a3;
  --teal: #0f766e;
  --teal-soft: #ecfdf5;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --info: #0369a1;
  --info-bg: #f0f9ff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -16px rgba(15, 23, 42, .25);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 750; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 12px; }
small, .small { font-size: 12.5px; color: var(--muted); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: #0b1220; color: #e2e8f0; padding: 14px; border-radius: 12px; overflow-x: auto; }

.topbar {
  background: #0f172a;
  color: #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid #1e293b;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; color: #f8fafc; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, #818cf8, #22d3ee);
  display: grid; place-items: center;
  font-weight: 800; color: #0f172a; font-size: 14px;
}
.brand-title { font-weight: 750; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: #94a3b8; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: #cbd5e1;
  padding: 7px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
}
.nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav a.active { background: #f8fafc; color: #0f172a; }
.nav .count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 99px;
  background: #334155;
  color: #e2e8f0;
  font-size: 11px;
  text-align: center;
}
.nav a.active .count { background: #e0e7ff; color: #3730a3; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions .who { color: #94a3b8; font-size: 12px; }
.top-actions form { margin: 0; }
.top-actions button.linklike {
  background: none; border: 0; color: #cbd5e1; cursor: pointer;
  font: inherit; font-size: 12.5px; padding: 4px;
}
.top-actions button.linklike:hover { color: #fff; }

.page { max-width: 1280px; margin: 0 auto; padding: 26px 22px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .lede { color: var(--muted); margin-top: 5px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.section { margin-top: 26px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.stat { padding: 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat .value { font-size: 30px; font-weight: 780; letter-spacing: -.03em; margin-top: 3px; }
.stat .hint { color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.stat.accent { background: linear-gradient(135deg, #eef2ff, #ffffff); border-color: #c7d2fe; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 650; line-height: 1.5;
  background: #f1f5f9; color: #475569; border: 1px solid transparent;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }
.badge.muted { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: #c7d2fe; }
.badge.teal { background: var(--teal-soft); color: var(--teal); border-color: #99f6e4; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink);
  font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.dark { background: #0f172a; border-color: #0f172a; color: #fff; }
.btn.dark:hover { background: #1e293b; }
.btn.danger { background: #fff; color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 11px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel); font-size: 13.5px;
}
.flash.success { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }
.flash.error { background: var(--bad-bg); border-color: #fecaca; color: #991b1b; }
.flash.info { background: var(--info-bg); border-color: #bae6fd; color: #075985; }

.notice {
  padding: 14px 16px; border-radius: 12px; border: 1px solid #fde68a;
  background: var(--warn-bg); color: #78350f; font-size: 13.5px;
}
.notice.info { background: var(--info-bg); border-color: #bae6fd; color: #075985; }
.notice.bad { background: var(--bad-bg); border-color: #fecaca; color: #991b1b; }
.notice.ok { background: var(--ok-bg); border-color: #a7f3d0; color: #065f46; }
.notice strong { font-weight: 700; }
.notice p:last-child { margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--panel-soft); }
tr:last-child td { border-bottom: 0; }
td .meta, .meta { color: var(--muted); font-size: 12.5px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table-wrap table { min-width: 640px; }

.list { display: flex; flex-direction: column; gap: 0; }
.list-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-title { font-weight: 650; font-size: 14.5px; }
.list-text { color: #334155; font-size: 13.5px; margin-top: 4px; }
.list-meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }

.quote {
  border-left: 3px solid var(--accent);
  background: #fafaff;
  padding: 11px 14px;
  border-radius: 0 10px 10px 0;
  font-size: 13.5px;
  color: #1e293b;
}
.quote .who { color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.generated {
  background: var(--panel-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  color: #334155;
}
.tag-label {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}

form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 650; color: #334155; }
.field .help { font-size: 11.5px; color: var(--muted-2); }
input[type="text"], input[type="url"], input[type="number"], input[type="date"], input[type="time"],
input[type="password"], input[type="search"], input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: #334155; }
.check input { margin-top: 3px; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  padding: 7px 12px; border-radius: 99px; background: #fff;
  border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.tabs a.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.tabs a:hover { text-decoration: none; border-color: var(--line-strong); }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; font-size: 12.5px; color: var(--muted);
}
.pagination .current { background: #0f172a; color: #fff; border-color: #0f172a; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .icon { font-size: 28px; margin-bottom: 8px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

.progress { height: 7px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #22d3ee); }
.progress.warn > span { background: linear-gradient(90deg, #f59e0b, #ef4444); }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.limit-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-soft); }
.limit-card h4 { font-size: 13.5px; margin-bottom: 5px; }
.limit-card p { font-size: 12.5px; color: var(--muted); margin: 0; }
.limit-card details { margin-top: 8px; }
.limit-card summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.limit-card ul { margin: 8px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.limit-card li { margin-bottom: 5px; }

.source-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.source-card .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.source-card .name { font-weight: 700; font-size: 14.5px; }
.source-card .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.source-card .numbers { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.source-card .numbers strong { color: var(--ink); font-size: 14px; display: block; }

.calendar { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-head { background: var(--panel-soft); padding: 9px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); text-align: center; }
.calendar-day { min-height: 118px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.out { background: #fafbfc; color: var(--muted-2); }
.calendar-day.today { background: #eef2ff; }
.calendar-day .num { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.calendar-day.today .num { color: var(--accent-ink); }
.calendar-entry { display: block; padding: 5px 6px; border-radius: 7px; background: var(--panel-soft); border: 1px solid var(--line); font-size: 11px; margin-bottom: 5px; color: var(--ink); line-height: 1.35; }
.calendar-entry:hover { text-decoration: none; border-color: var(--accent); }
.calendar-entry .st { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }

.idea-card { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.idea-card h3 { font-size: 15.5px; }
.idea-card h3 a { color: var(--ink); }
.idea-card .excerpt { color: var(--muted); font-size: 13px; }
.idea-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: auto; }

.priority { display: flex; align-items: center; gap: 8px; }
.priority-num { font-size: 24px; font-weight: 780; letter-spacing: -.03em; }
.priority-num.high { color: var(--ok); }
.priority-num.mid { color: var(--warn); }
.priority-num.low { color: var(--muted); }

.evidence { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: #fff; }
.evidence + .evidence { margin-top: 10px; }
.evidence .head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 7px; }
.evidence .quote { background: transparent; padding: 0 0 0 12px; }

.hero {
  background: radial-gradient(1200px 300px at 10% -50%, #312e81 0%, transparent 60%),
              radial-gradient(800px 240px at 100% 0%, #0f766e 0%, transparent 55%), #0f172a;
  color: #f8fafc; border-radius: 20px; padding: 26px; margin-bottom: 20px;
}
.hero h1 { font-size: 30px; }
.hero .lede { color: #cbd5e1; max-width: 760px; margin-top: 8px; }
.hero .hero-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.hero .chip { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); color: #e2e8f0; border-radius: 99px; padding: 4px 10px; font-size: 12px; }
.hero .btn { margin-top: 0; }

details summary { cursor: pointer; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.note-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.note-list li { margin-bottom: 6px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-word; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.footer { border-top: 1px solid var(--line); margin-top: 30px; padding: 18px 22px; color: var(--muted-2); font-size: 12px; }
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 400px at 50% -10%, #312e81, transparent 60%), #0f172a; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 28px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.6); }
.login-card h1 { font-size: 23px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* Публичная страница политики конфиденциальности (открывается без входа). */
.legal-body { background: radial-gradient(1100px 480px at 50% -20%, #e0e7ff, transparent 65%), var(--bg); }
.legal-top { max-width: 900px; margin: 0 auto; padding: 22px 22px 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.legal-top .brand { color: var(--ink); }
.legal-top .brand-sub { color: var(--muted); }
.legal-back { font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.legal-wrap { max-width: 900px; margin: 0 auto; padding: 10px 22px 34px; }
.legal-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 38px 44px 30px; box-shadow: var(--shadow); }
.legal-kicker { text-transform: uppercase; letter-spacing: .09em; font-size: 11px; font-weight: 750; color: var(--accent); margin-bottom: 8px; }
.legal-card h1 { font-size: 32px; margin-bottom: 8px; }
.legal-meta { color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 22px; }
.legal-lead { font-size: 15.5px; color: #1f2937; }
.legal-card h2 { font-size: 19px; margin: 30px 0 10px; }
.legal-card p, .legal-card li { font-size: 14.5px; line-height: 1.7; color: #1f2937; }
.legal-card ul { margin: 0 0 14px; padding-left: 22px; }
.legal-card li { margin-bottom: 7px; }
.legal-card a { text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.legal-note { background: var(--panel-soft); border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; padding: 12px 16px; margin: 16px 0; }
.legal-steps { margin: 0 0 14px; padding-left: 22px; }
.legal-steps li { margin-bottom: 10px; }
.legal-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 6px 0 18px; }
.legal-form .field { flex: 1 1 260px; }
.legal-form .field > span { font-size: 12.5px; font-weight: 650; color: #334155; }
.legal-form input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.legal-status { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin: 6px 0 22px; }
.legal-status .legal-kicker { margin-bottom: 10px; }
.legal-status .kv { font-size: 13px; margin-bottom: 10px; }
.legal-status .small { margin: 0; }
.legal-footer { max-width: 900px; margin: 0 auto; padding: 0 22px 36px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted-2); font-size: 12px; }
.legal-footer a { color: var(--muted); }
@media (max-width: 640px) {
  .legal-card { padding: 26px 20px 22px; border-radius: 16px; }
  .legal-card h1 { font-size: 26px; }
  .legal-top { padding: 16px 16px 6px; }
  .legal-wrap { padding: 8px 12px 26px; }
  .legal-footer { padding: 0 16px 28px; }
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .limits { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }
  .nav a { padding: 6px 9px; font-size: 12.5px; }
  .page { padding: 18px 14px 50px; }
  h1 { font-size: 23px; }
  .calendar-day { min-height: 88px; padding: 6px; }
  .calendar-entry { font-size: 10px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 24px; }
  .card { padding: 15px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 24px; }
  .kv { grid-template-columns: 1fr; gap: 3px; }
  .kv dt { margin-top: 6px; }
  .calendar-grid { min-width: 620px; }
  .calendar { overflow-x: auto; }
  .page-head { gap: 10px; }
}

/* --- AI-ассистент --------------------------------------------------------- */

.inline-form { display: inline; }

.assistant-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.assistant-status .value.small-value { font-size: 17px; line-height: 1.35; word-break: break-word; }

.assistant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.assistant-ability {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}
.assistant-ability h3 { margin: 0 0 6px; font-size: 15px; }
.assistant-ability p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }

.assistant-examples { margin: 0 0 16px 18px; padding: 0; line-height: 1.8; }
.assistant-examples li { margin-bottom: 4px; }

.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.chat-empty {
  padding: 20px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--panel);
}
.chat-empty h3 { margin: 0 0 6px; }
.chat-empty ul { margin: 10px 0 0 18px; line-height: 1.8; color: var(--muted); }

.chat-row { display: flex; gap: 10px; align-items: flex-start; }
.chat-row.user { flex-direction: row-reverse; }
.chat-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
}
.chat-row.assistant .chat-avatar { background: var(--accent-soft); color: var(--accent-ink); }
.chat-row.user .chat-avatar { background: #0f172a; color: #fff; }
.chat-row.user .chat-bubble { background: #0f172a; color: #f8fafc; border-color: #0f172a; }
.chat-main { min-width: 0; max-width: 82%; }
.chat-row.user .chat-bubble { max-width: 72%; }
.chat-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  font-size: 14px;
}
.chat-meta { margin-top: 5px; color: var(--muted-2); font-size: 11.5px; }

.chat-tools, .chat-tool {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  padding: 8px 10px;
}
.chat-tools summary, .chat-tool summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
.chat-tools pre, .chat-tool pre {
  margin: 8px 0 0;
  padding: 10px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 340px;
}
.chat-tool-line { margin-top: 8px; }
.chat-tool-line code { font-size: 12px; }

.chat-event {
  align-self: center;
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

/* Markdown-ответы ассистента: разметка модели в читаемый HTML */
.chat-bubble.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 16px 0 8px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.md h1 { font-size: 19px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15.5px; }
.md h4, .md h5, .md h6 { font-size: 14.5px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 24px; }
.md ul .md-list, .md ol .md-list { margin: 4px 0 2px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0 0 4px; }
.md li::marker { color: var(--muted-2); }
.md strong { font-weight: 700; }
.md del { color: var(--muted); }
.md code {
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.md pre.md-code {
  position: relative;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #0b1220;
  color: #e2e8f0;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}
.md pre.md-code code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
}
.md .md-code-lang {
  display: block;
  margin-bottom: 6px;
  color: #94a3b8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.md blockquote.md-quote {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
}
.md blockquote.md-quote > :last-child { margin-bottom: 0; }
.md hr.md-hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md a { text-decoration: underline; }
.md .md-table-wrap {
  margin: 0 0 12px;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.md table.md-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 13px;
}
.md table.md-table th,
.md table.md-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}
.md table.md-table thead th { background: var(--panel-soft); font-weight: 700; }
.md table.md-table tbody tr:last-child td { border-bottom: 0; }
.md table.md-table .md-al-r { text-align: right; }
.md table.md-table .md-al-c { text-align: center; }

.chat-actions { display: flex; flex-direction: column; gap: 12px; }
.chat-action {
  padding: 14px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 12px;
}
.chat-action-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.chat-action p { margin: 0 0 6px; }
.chat-action details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.chat-action pre {
  margin: 8px 0 0;
  padding: 10px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 11.5px;
  max-height: 280px;
}

.chat-busy {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #bae6fd;
  background: var(--info-bg);
  color: #075985;
  font-size: 13px;
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid #7dd3fc;
  border-top-color: transparent;
  animation: chat-spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes chat-spin { to { transform: rotate(360deg); } }

.chat-composer label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.chat-composer textarea { width: 100%; resize: vertical; }
.chat-composer textarea:disabled { background: #f1f5f9; color: #94a3b8; }

@media (max-width: 980px) {
  .assistant-status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assistant-grid { grid-template-columns: minmax(0, 1fr); }
  .chat-main { max-width: 100%; }
  .chat-row.user .chat-bubble { max-width: 86%; }
}
