/* Главная (app.js, register('home')) и ИИ-помощник (assistant.js): чат по центру, под ним быстрые переходы.
   Токены — v5 (v5.css, объявлены на :root и для тёмной темы), сама главная в v5 не переведена.
   Два вида чата: .is-empty — пока разговора нет (заголовок, поле и подсказки по центру, как в ChatGPT);
   без него — заголовок строкой, лента сверху, поле под ней. */
/* .page ограничен 1280px и прижат влево (app.css) — на главной снимаем ограничение, иначе на широком
   мониторе «центр» чата левее центра экрана */
.page:has(> .home){max-width:none}
.home{
  position:relative; max-width:880px; margin:0 auto; font-family:var(--v5-font); color:var(--v5-ink);
  min-height:calc(100vh - var(--topbar-h) - 2 * var(--sp-6)); display:flex; flex-direction:column;
}
/* пустой чат — по центру экрана и по вертикали; с разговором — сверху */
.home > #asst-root{flex:1; display:flex; flex-direction:column; justify-content:center}
.home:has(.asst:not(.is-empty)) > #asst-root{justify-content:flex-start}

.asst{position:relative; width:100%; max-width:820px; margin:0 auto; font-family:var(--v5-font); color:var(--v5-ink)}
.asst.is-empty{position:static}   /* «История» — в правый верхний угол главной, а не над заголовком */
.asst-off{text-align:center; padding:12px 18px; font-size:14px; color:var(--v5-muted)}

/* ── шапка ── */
.asst-head{display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:14px}
.asst-kicker{font-family:var(--v5-mono); font-size:12px; text-transform:uppercase; letter-spacing:.14em; color:var(--v5-blue)}
[data-theme="dark"] .asst-kicker{color:var(--v5-blue-soft)}
.asst-title{font-size:20px; font-weight:600; letter-spacing:-.01em; line-height:1.15; margin:2px 0 0}
.asst-sub{display:none}
.asst-head-tools{display:flex; gap:6px; align-items:center}
.asst-hist{max-width:230px; height:34px; padding:0 10px; font-size:13px; border-radius:10px}

.is-empty .asst-head{flex-direction:column; justify-content:center; text-align:center; padding-top:44px; margin-bottom:26px}
.is-empty .asst-title{font-size:clamp(30px, 4.2vw, 44px); letter-spacing:-.025em; margin-top:10px}
.is-empty .asst-sub{display:block; max-width:560px; margin:12px auto 0; font-size:16px; line-height:1.55; color:var(--v5-muted)}
.is-empty .asst-head-tools{position:absolute; top:0; right:0}
.is-empty .asst-new{display:none}
.is-empty .asst-feed{display:none}

/* ── лента ── */
.asst-feed{
  max-height:max(300px, calc(100vh - 400px)); overflow-y:auto; padding:4px 2px 14px;
  display:flex; flex-direction:column; gap:12px; scroll-behavior:smooth;
}
.asst-msg{max-width:min(720px, 92%); padding:11px 15px; border-radius:20px; font-size:15px; line-height:1.55; overflow-wrap:anywhere}
.asst-user{align-self:flex-end; background:var(--v5-chip-on-bg); color:var(--v5-chip-on-fg); border-bottom-right-radius:6px}
.asst-bot{align-self:flex-start; background:var(--v5-surface); color:var(--v5-ink); border-bottom-left-radius:6px}
.asst-err{align-self:flex-start; background:var(--v5-bad-bg); color:var(--v5-bad)}
.asst-bot p{margin:0 0 8px} .asst-bot p:last-child{margin-bottom:0}
.asst-bot ul,.asst-bot ol{margin:0 0 8px; padding-left:20px} .asst-bot li{margin:2px 0}
.asst-bot .asst-h{font-weight:600}
.asst-bot a{color:var(--v5-blue); text-decoration:underline; text-underline-offset:2px}
[data-theme="dark"] .asst-bot a{color:var(--v5-blue-soft)}
.asst-bot code{font-family:var(--v5-mono); font-size:13px; background:var(--v5-tint); padding:1px 5px; border-radius:6px}
.asst-code{background:var(--v5-tint); border-radius:12px; padding:10px 12px; overflow-x:auto; margin:0 0 8px}
.asst-code code{background:none; padding:0}

.asst-status{align-self:flex-start; color:var(--v5-muted); font-size:13px; display:flex; align-items:center; gap:8px; padding:2px 4px}
.asst-dot{width:8px; height:8px; border-radius:50%; background:var(--v5-blue); animation:asst-pulse 1s ease-in-out infinite}
@keyframes asst-pulse{0%,100%{opacity:.25}50%{opacity:1}}
@media (prefers-reduced-motion:reduce){.asst-dot{animation:none}}

/* ── карточка изменения ── */
.asst-act-wrap{align-self:stretch; max-width:720px}
.asst-act{border:1px solid var(--v5-tint-3); background:var(--v5-tint); border-radius:20px; padding:14px 16px}
.asst-act-kicker{font-family:var(--v5-mono); font-size:11px; text-transform:uppercase; letter-spacing:.12em; color:var(--v5-muted)}
.asst-act-title{font-weight:600; font-size:16px; margin:4px 0 10px}
.asst-chg{display:grid; grid-template-columns:minmax(120px, 200px) 1fr; gap:10px; padding:8px 0; border-top:1px solid var(--v5-line)}
.asst-chg-label{color:var(--v5-muted); font-size:13px}
.asst-chg-vals{display:flex; flex-wrap:wrap; align-items:baseline; gap:6px; font-size:14px; min-width:0}
.asst-before{color:var(--v5-faint); text-decoration:line-through; text-decoration-color:var(--v5-line-2); min-width:0}
.asst-arrow{color:var(--v5-faint)}
.asst-after{font-weight:500; min-width:0}
.asst-none{color:var(--v5-faint)}
.asst-chg details summary{cursor:pointer}
.asst-long{white-space:pre-wrap; max-height:260px; overflow:auto; margin-top:6px; font-size:13px}
.asst-act-btns{display:flex; gap:8px; margin-top:12px}
.asst-act-st{margin-top:10px; font-size:14px; color:var(--v5-muted)}
.asst-act-st.ok{color:var(--v5-ok)} .asst-act-st.bad{color:var(--v5-bad)}

/* ── поле ввода ── */
.asst-form{
  display:flex; gap:8px; align-items:flex-end; background:var(--v5-card);
  border:1px solid var(--v5-line-2); border-radius:22px; padding:8px 8px 8px 18px;
  transition:border-color .15s, box-shadow .15s;
}
.is-empty .asst-form{box-shadow:var(--v5-shadow-float); padding:12px 12px 12px 20px; border-radius:26px}
.asst-form:focus-within{border-color:var(--v5-blue)}
.asst-input{flex:1; border:0; outline:0; background:transparent; color:var(--v5-ink); font:inherit; font-size:15.5px; line-height:1.45; resize:none; padding:9px 0; max-height:200px}
.is-empty .asst-input{font-size:17px; min-height:52px}
.asst-input::placeholder{color:var(--v5-faint)}
.asst-send{width:44px; height:44px; border-radius:14px; padding:0; font-size:19px; flex:none}

/* ── подсказки и подпись ── */
.asst-chips{display:flex; flex-wrap:wrap; justify-content:center; gap:8px; margin:16px 0 0}
.asst-chips[hidden]{display:none}
.asst-chip{
  border:1px solid var(--v5-line-2); background:var(--v5-card); color:var(--v5-ink); border-radius:999px;
  padding:8px 14px; font:inherit; font-size:13.5px; cursor:pointer; transition:background .15s, border-color .15s;
}
.asst-chip:hover{background:var(--v5-tint); border-color:var(--v5-tint-3)}
.asst-foot{color:var(--v5-faint); font-size:12px; margin-top:12px; text-align:center}
.asst-bal-row{margin-top:8px}
.asst-bal{display:inline-block; padding:4px 10px; border-radius:999px; background:var(--v5-surface); color:var(--v5-muted); font-size:12px}
.asst-bal.is-low{background:rgba(224,142,0,.12); color:var(--v5-amber)}
.asst-bal.is-out{background:var(--v5-bad-bg); color:var(--v5-bad)}
.asst-input:disabled{cursor:not-allowed}

/* ── быстрые переходы под чатом ── */
.home-links{display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:12px; width:100%; max-width:820px; margin:40px auto 0}
.home-link{
  display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:18px;
  background:var(--v5-card); border:1px solid var(--v5-line); color:var(--v5-ink); text-decoration:none;
  transition:background .15s, border-color .15s, transform .15s;
}
.home-link:hover{background:var(--v5-tint); border-color:var(--v5-tint-3); transform:translateY(-1px)}
.home-link-ico{
  flex:none; width:38px; height:38px; border-radius:12px; display:grid; place-items:center;
  background:var(--v5-tint); color:var(--v5-blue);
}
[data-theme="dark"] .home-link-ico{color:var(--v5-blue-soft)}
.home-link:hover .home-link-ico{background:var(--v5-card)}
.home-link-ico svg{width:19px; height:19px}
.home-link-txt{display:flex; flex-direction:column; min-width:0}
.home-link-txt b{font-weight:600; font-size:15px}
.home-link-txt small{color:var(--v5-muted); font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

/* ── «Настройки» → ИИ-помощник ── */
.asst-set{margin-top:var(--sp-4)}
.asst-set .asst-switch{display:flex; align-items:center; gap:10px; font-size:15px; margin:4px 0 6px; cursor:pointer}
.asst-balance{margin:14px 0 4px}
.asst-balance-top{display:flex; justify-content:space-between; align-items:baseline; gap:12px; font-size:14px}
.asst-balance-top b{font-size:18px; font-weight:600}
.asst-balance-top .muted{font-size:13px; font-weight:400}
.asst-meter{height:8px; border-radius:999px; background:var(--v5-surface); margin-top:8px; overflow:hidden}
.asst-meter span{display:block; height:100%; border-radius:inherit; background:var(--v5-blue)}
.asst-usage{display:flex; gap:28px; margin:14px 0 8px}
.asst-usage-n{font-size:22px; font-weight:600}
.asst-small{font-size:12.5px}

@media (max-width:900px){ .home-links{grid-template-columns:repeat(2, minmax(0, 1fr))} }
@media (max-width:640px){
  .is-empty .asst-head{padding-top:44px}
  .is-empty .asst-head-tools{position:static; order:-1; align-self:flex-end}
  .asst-chg{grid-template-columns:1fr; gap:2px}
  .asst-msg{max-width:100%}
  .asst-hist{max-width:150px}
  .home-links{grid-template-columns:1fr}
}
