/* StasWeb Gold — AI-помощник и квиз. Подключается только на этих страницах. */

/* AI-помощник ------------------------------------------------------------- */
.ai-work { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: clamp(32px, 4vw, 56px); padding-bottom: clamp(56px, 8vw, 96px); }
.ai-side { position: sticky; top: calc(var(--header) + 24px); display: grid; gap: 24px; }
.ai-progress { padding: 22px; border: 1px solid var(--line-2); background: var(--card); }
.ai-progress__head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 13px; }
.ai-progress__head strong { font: 500 32px/1 var(--serif); color: var(--gold-2); }
.ai-progress__track { height: 2px; margin: 14px 0 12px; background: var(--line); }
.ai-progress__track i { display: block; width: 0; height: 100%; background: var(--grad); transition: width .6s var(--ease); }
.ai-progress p { color: var(--muted); font-size: 13px; }
.ai-steps { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; counter-reset: ai; }
.ai-steps li { display: flex; gap: 12px; padding: 10px 0; color: var(--faint); font-size: 14px; counter-increment: ai; transition: color .3s; }
.ai-steps li::before { content: counter(ai, decimal-leading-zero); color: inherit; font: italic 500 16px/1.3 var(--serif); }
.ai-steps li.is-done { color: var(--muted); }
.ai-steps li.is-active { color: var(--gold-2); }
.ai-side__note { color: var(--faint); font-size: 12px; }

.ai-chat { display: flex; flex-direction: column; height: min(720px, calc(100svh - var(--header) - 48px)); min-height: 480px; border: 1px solid var(--line-2); background: var(--bg-2); }
.ai-chat__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ai-chat__who { display: flex; align-items: center; gap: 12px; }
.ai-chat__who > img { width: 38px; height: auto; filter: drop-shadow(0 4px 12px rgb(201 164 92 / .3)); }
.ai-chat__who strong { display: block; font: 500 20px/1.1 var(--serif); }
.ai-chat__who small { color: var(--ok); font-size: 12px; }
.ai-chat__tools { display: flex; gap: 6px; }
.ai-chat__tools button, .ai-brief__head button { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: 12px; cursor: pointer; transition: border-color .25s, color .25s; }
.ai-chat__tools button:hover:not(:disabled), .ai-brief__head button:hover { border-color: var(--gold); color: var(--gold-2); }
.ai-chat__tools button:disabled { opacity: .4; cursor: default; }

.ai-chat__messages { flex: 1; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; padding: 20px 18px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.ai-msg { display: flex; max-width: 86%; animation: ai-in .35s var(--ease); }
.ai-msg--user { align-self: flex-end; }
.ai-msg__bubble { padding: 12px 16px; border: 1px solid var(--line); background: var(--bg); font-size: 15px; line-height: 1.6; white-space: pre-line; }
.ai-msg--user .ai-msg__bubble { border-color: transparent; background: rgb(201 164 92 / .14); color: var(--text); }
.ai-msg--error .ai-msg__bubble { border-color: rgb(224 138 125 / .4); color: var(--error); }
.ai-msg__bubble button { margin-top: 10px; padding: 6px 12px; border: 1px solid var(--line-2); background: none; color: var(--gold); font-size: 12px; cursor: pointer; }
.ai-msg--loading .ai-msg__bubble { display: flex; gap: 5px; padding: 16px; }
.ai-msg--loading i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); animation: ai-dot 1.2s infinite; }
.ai-msg--loading i:nth-child(2) { animation-delay: .15s; }
.ai-msg--loading i:nth-child(3) { animation-delay: .3s; }

.ai-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; }
.ai-quick:empty { display: none; }
.ai-quick button { padding: 8px 14px; border: 1px solid var(--line-2); background: none; color: var(--gold-2); font-size: 13px; text-align: left; cursor: pointer; transition: background .25s, border-color .25s; }
.ai-quick button:hover:not(:disabled) { border-color: var(--gold); background: rgb(201 164 92 / .1); }

.ai-composer { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 18px 14px; border-top: 1px solid var(--line); }
.ai-composer textarea { min-height: 48px; max-height: 140px; padding: 12px 14px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; resize: none; }
.ai-composer textarea:focus { outline: none; border-color: var(--gold); }
.ai-composer button { display: grid; place-items: center; width: 48px; height: 48px; border: 0; background: var(--grad); color: var(--bg); cursor: pointer; align-self: end; }
.ai-composer button svg { width: 20px; height: 20px; fill: currentColor; }
.ai-composer button:disabled { opacity: .5; cursor: wait; }
.ai-composer small { grid-column: 1 / -1; display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; }

.ai-result { padding-block: clamp(56px, 8vw, 96px); border-top: 1px solid var(--line); }
.ai-brief { border: 1px solid var(--line); background: var(--bg-2); padding: clamp(20px, 3vw, 32px); }
.ai-brief__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.ai-brief__head strong { font: 500 26px/1.1 var(--serif); color: var(--gold-2); }
.ai-brief .g-dl div { grid-template-columns: 170px 1fr; }
.ai-brief dd { font-size: 14.5px; }

@keyframes ai-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Встраивание в панель: только чат во всю высоту */
.is-embed .ai-work { grid-template-columns: 1fr; width: 100%; margin-top: 0; padding: 0; }
.is-embed .ai-side { display: none; }
.is-embed .ai-chat { height: 100svh; min-height: 0; border: 0; }
.is-embed .ai-result { width: auto; padding: 32px 16px; }
.is-embed .ai-result .g-contact__in { grid-template-columns: 1fr; }

/* Квиз -------------------------------------------------------------------- */
.q { padding: clamp(24px, 4vw, 48px); border: 1px solid var(--line-2); background: var(--bg); box-shadow: 0 40px 100px -40px rgb(0 0 0 / .8); scroll-margin-top: calc(var(--header) + 24px); }
.q__progress { display: grid; gap: 10px; margin-bottom: 32px; color: var(--muted); font-size: 13px; }
.q__track { height: 2px; background: var(--line); }
.q__track i { display: block; width: 20%; height: 100%; background: var(--grad); transition: width .5s var(--ease); }
.q__form { display: grid; gap: 24px; }
.q__step { display: grid; gap: 18px; min-width: 0; margin: 0; padding: 0; border: 0; }
.q__step legend { float: left; width: 100%; margin-bottom: 4px; padding: 0; outline: none; }
.q__step legend + * { clear: both; }
.q__options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.q__options label { cursor: pointer; }
.q__options input { position: absolute; opacity: 0; pointer-events: none; }
.q__options span { display: grid; gap: 4px; height: 100%; padding: 18px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; transition: border-color .25s, background .25s; }
.q__options b { color: var(--text); font: 500 22px/1.1 var(--serif); }
.q__options label:hover span { border-color: var(--line-2); }
.q__options input:checked + span { border-color: var(--gold); background: rgb(201 164 92 / .08); }
.q__options input:checked + span b { color: var(--gold-2); }
.q__options input:focus-visible + span { outline: 1px solid var(--gold); outline-offset: 3px; }
.q__hint { color: var(--muted); font-size: 14px; }
.q__hint strong { color: var(--gold-2); }
.q__nav { display: flex; justify-content: space-between; gap: 12px; }
.q__nav .g-btn:disabled { visibility: hidden; }

@media (max-width: 900px) {
  .ai-work { grid-template-columns: 1fr; }
  .ai-side { position: static; }
  .ai-steps, .ai-side__note { display: none; }
  .ai-chat { height: calc(100svh - var(--header) - 24px); }
  .ai-brief .g-dl div { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .ai-msg { max-width: 94%; }
  .ai-chat__tools button:first-child { display: none; }
  .ai-composer small span:first-child { display: none; }
  .q__nav .g-btn { flex: 1; }
}
