/* Лия · «Гроссбух». Prefix .lya-
   Two columns: a quiet sidebar (who she is, what to ask, limit, privacy) and a full-height chat panel. */

.lya-sec { --lya-top: 112px; padding: clamp(20px, 3vw, 36px) 0 clamp(40px, 5vw, 72px); }
.lya { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }

/* Sidebar ------------------------------------------------------------------ */
.lya-side { position: sticky; top: calc(var(--lya-top) + 24px); display: grid; gap: 20px; padding-top: 6px; }
.lya-id { display: flex; align-items: center; gap: 14px; }
.lya-av { --_s: 52px; font-size: 21px; }
.lya-title { line-height: 1.15; }
.lya-aka { display: inline; font-family: var(--font); font-size: 0.48em; font-weight: 500; letter-spacing: 0; color: var(--ink-3); vertical-align: 0.08em; white-space: normal; }
.lya-role { margin-top: 6px; color: var(--ink-3); font-size: 14.5px; }
.lya-about { color: var(--ink-2); font-size: 15.5px; line-height: 1.6; text-wrap: pretty; }

.lya-pay {
  display: grid; gap: 10px; padding: 16px 0 4px;
  border-top: var(--bw) solid var(--line); border-bottom: var(--bw) solid var(--line);
}
.lya-pay-price { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-h); font-size: clamp(28px, 3vw, 34px); line-height: 1.1; letter-spacing: var(--track-h); }
.lya-pay-price span { font-family: var(--font); font-size: 14.5px; color: var(--ink-3); font-weight: 400; }
.lya-pay-desc { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }
.lya-pay-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--ink-2); }
.lya-pay-list li { padding-left: 14px; position: relative; }
.lya-pay-list li::before { content: ""; position: absolute; left: 0; top: .55em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.lya-pay-cta, .lya-pay-legal { margin: 0; }
.lya-pay-legal { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.lya-more { border-top: var(--bw) solid var(--line); }
.lya-more-sum { display: none; }
.lya-more-body { display: grid; gap: 24px; padding-top: 20px; }

.lya-asks { display: grid; margin-top: 10px; border-top: var(--bw) solid var(--line); }
.lya-asks button {
  display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 8px; align-items: baseline; width: 100%; min-height: 40px;
  padding: 10px 2px; border-bottom: var(--bw) solid var(--line); text-align: left; font-size: 14.5px; line-height: 1.4; color: var(--ink);
  transition: color var(--t-fast), padding var(--t-med) var(--ease-out), background-color var(--t-fast);
}
.lya-asks button:hover { color: var(--accent-text); padding-left: 8px; }
.lya-asks button:active { background: var(--surface-2); }
.lya-topic { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

.lya-limit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.lya-left { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lya-left.is-flash { animation: flash 1.2s var(--ease-out); }
.lya-meter { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin-top: 10px; min-height: 6px; }
.lya-meter i { height: 6px; background: var(--accent); font-style: normal; transform-origin: center; transition: background-color .45s var(--ease-out); }
.lya-meter i.is-used { background: var(--line-2); }
.lya-meter i.is-bump { animation: lya-bump .5s var(--ease-out); }
.lya-meter.is-unlimited i { opacity: .55; }
@keyframes lya-bump { 0% { transform: scaleY(1); } 40% { transform: scaleY(2.2); } 100% { transform: none; } }
.lya-note { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.lya-note a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.lya-privacy { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--warn-soft); font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.lya-privacy .i { flex: none; margin-top: 1px; color: var(--warn); }
.lya-privacy b { color: var(--ink); font-weight: var(--w-strong); }

/* Chat panel --------------------------------------------------------------- */
.lya-panel {
  position: relative; display: flex; flex-direction: column;
  height: calc(100svh - var(--lya-top) - 56px); min-height: 540px; max-height: 980px;
  border: var(--bw) solid var(--line-2); background: var(--raised); overflow: hidden;
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.lya-panel.is-drop { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.lya-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; border-bottom: var(--bw) solid var(--line); }
.lya-head-t { display: grid; gap: 2px; flex: 1; min-width: 0; }
.lya-head-t b { font-weight: var(--w-h-sm); }
.lya-head-t .caption { display: inline-flex; align-items: center; gap: 7px; }
.lya-head-t .dot { width: 6px; height: 6px; transition: background-color .3s; }
.lya-reset .i { transition: transform .5s var(--ease-out); }
.lya-reset:hover .i { transform: rotate(-120deg); }

.lya-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lya-log { padding: 24px clamp(16px, 3vw, 32px); transition: opacity .18s var(--ease-out); overscroll-behavior: contain; }
.lya-log.is-fading { opacity: 0; }
.lya-log .msg { max-width: min(700px, 88%); }
.lya-log .msg-me .bubble { white-space: pre-wrap; }
.lya-att { display: inline-flex; align-items: center; gap: 6px; align-self: flex-end; max-width: 100%; font-size: 12.5px; color: var(--ink-3); }
.lya-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lya-att .i { width: 14px; height: 14px; flex: none; }
.lya-wait { display: flex; align-items: center; gap: 12px; }
.lya-wait .caption { animation: fade-in .3s .2s both; }

/* Error / retry bubble */
.lya-err .bubble { background: var(--surface-2); border-color: var(--line-2); }
.lya-err-t { display: flex; gap: 10px; align-items: flex-start; }
.lya-err-t .i { flex: none; margin-top: 3px; width: 18px; height: 18px; color: var(--warn); }
.lya-err-a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Markdown answers */
.lya-md { overflow-wrap: anywhere; }
.lya-md > :first-child { margin-top: 0; }
.lya-md p + *, .lya-md ul + *, .lya-md ol + *, .lya-md table + *, .lya-md pre + *, .lya-md blockquote + * { margin-top: 10px; }
.lya-md ul { padding-left: 18px; list-style: disc; }
.lya-md ol { padding-left: 20px; list-style: decimal; }
.lya-md li + li { margin-top: 4px; }
.lya-md li > ul, .lya-md li > ol { margin-top: 4px; }
.lya-md h1, .lya-md h2, .lya-md h3, .lya-md h4 { margin-top: 16px; margin-bottom: 6px; font-family: var(--font-ui); font-size: 15px; font-weight: var(--w-strong); color: var(--ink); }
.lya-md strong, .lya-md b { font-weight: var(--w-strong); color: var(--ink); }
.lya-md a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.lya-md code { font-family: var(--font-mono); font-size: .9em; padding: 1px 4px; background: var(--surface-2); }
.lya-md pre { padding: 10px 12px; background: var(--surface-2); white-space: pre-wrap; overflow-x: auto; }
.lya-md pre code { padding: 0; background: none; }
.lya-md blockquote { padding-left: 12px; border-left: 2px solid var(--line-2); color: var(--ink-2); }
.lya-md hr { border: 0; border-top: var(--bw) solid var(--line); margin: 14px 0; }
.lya-md .lya-tbl { overflow-x: auto; }
.lya-md table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lya-md th, .lya-md td { padding: 6px 8px; border: var(--bw) solid var(--line); text-align: left; vertical-align: top; }
.lya-md th { background: var(--surface-2); font-weight: var(--w-strong); }

/* Composer area */
.lya-foot { display: grid; gap: 10px; padding: 12px 16px 14px; border-top: var(--bw) solid var(--line); }
.lya-suggest { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.lya-suggest::-webkit-scrollbar { display: none; }
.lya-suggest .chip { flex: none; height: 36px; }
.lya-suggest.is-gone { display: none; }

.lya-banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; background: var(--warn-soft); font-size: 14px; line-height: 1.5; color: var(--ink-2); animation: rise .35s var(--ease-out) both; }
.lya-banner .i { flex: none; margin-top: 2px; width: 18px; height: 18px; color: var(--warn); }
.lya-banner a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.lya-hint { display: flex; gap: 8px; align-items: center; font-size: 13.5px; line-height: 1.4; color: var(--ink-2); animation: rise .3s var(--ease-out) both; }
.lya-hint .i { flex: none; width: 16px; height: 16px; color: var(--warn); }

.lya-file { display: inline-flex; align-items: center; gap: 8px; justify-self: start; max-width: 100%; height: 36px; padding: 0 2px 0 10px; border: var(--bw) solid var(--line-2); background: var(--surface); font-size: 13.5px; color: var(--ink); animation: rise .3s var(--ease-out) both; }
.lya-file > .i { flex: none; color: var(--accent-text); width: 16px; height: 16px; }
.lya-file-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lya-file-s { flex: none; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }
.lya-file .icon-btn { width: 32px; height: 32px; flex: none; }
.lya-file .icon-btn .i { width: 16px; height: 16px; }

.lya-composer { position: relative; align-items: center; padding: 6px 6px 6px 4px; }
.lya-composer textarea { padding: 8px 6px; font-family: var(--font-ui); color: var(--ink); }
.lya-composer textarea::placeholder { color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lya-composer .icon-btn { width: 40px; height: 40px; flex: none; cursor: pointer; }
.lya-composer .btn-send { position: relative; width: 40px; height: 40px; }
.lya-composer .btn-send .i { width: 18px; height: 18px; transition: opacity var(--t-fast); }
.lya-composer .btn-send.is-loading { opacity: 1; }
.lya-composer .btn-send.is-loading .i { opacity: 0; }
.lya-composer .btn-send.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.lya-attach.has-file { color: var(--accent-text); }
.lya-attach input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Microphone: idle → recording (red, square «stop», live level) → busy (spinner) */
.lya-mic { position: relative; }
.lya-mic .lya-stop { display: none; width: 12px; height: 12px; background: currentColor; }
.lya-mic.is-rec, .lya-mic.is-rec:hover { background: var(--neg); color: #fff; }
.lya-mic.is-rec .i { display: none; }
.lya-mic.is-rec .lya-stop { display: block; }
.lya-mic.is-rec::before { content: ""; position: absolute; inset: -3px; border: 2px solid var(--neg); opacity: .45; transform: scale(var(--lvl, 1)); transition: transform .08s linear; pointer-events: none; }
.lya-mic.is-busy { pointer-events: none; color: var(--ink-3); }
.lya-mic.is-busy .i { opacity: 0; }
.lya-mic.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.lya-rec { position: absolute; left: 46px; right: 96px; top: 50%; transform: translateY(-50%); display: none; align-items: center; gap: 12px; height: 36px; padding: 0 6px; background: var(--raised); font-size: 14.5px; color: var(--ink); pointer-events: none; }
.lya-composer.is-rec .lya-rec, .lya-composer.is-busy .lya-rec { display: flex; animation: fade-in .2s both; }
.lya-rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--neg); flex: none; animation: pulse 1.2s infinite; }
.lya-rec-t { white-space: nowrap; }
.lya-rec-time { font-family: var(--font-mono); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lya-level { display: flex; align-items: center; gap: 3px; height: 24px; flex: 1; min-width: 0; overflow: hidden; }
.lya-level i { flex: none; width: 3px; height: 3px; background: var(--neg); opacity: .8; transition: height .08s linear; }
.lya-composer.is-busy .lya-rec-dot { animation: none; background: var(--ink-3); }
.lya-composer.is-busy .lya-level, .lya-composer.is-busy .lya-rec-time { display: none; }

.lya-disc { font-size: 12.5px; color: var(--ink-3); }

/* Daily limit reached */
.lya-chat.is-limited .lya-composer, .lya-chat.is-limited .lya-suggest, .lya-chat.is-limited .lya-file { display: none !important; }
.lya-limit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; background: var(--accent-soft); animation: rise .4s var(--ease-out) both; }
.lya-limit > .i { flex: none; color: var(--accent-text); }
.lya-limit-t { display: grid; gap: 2px; flex: 1 1 260px; min-width: 0; font-size: 14.5px; line-height: 1.45; color: var(--ink-2); }
.lya-limit-t b { font-weight: var(--w-strong); color: var(--ink); }
.lya-limit-a { display: flex; gap: 6px; flex-wrap: wrap; }
.lya-limit.is-shake { animation: lya-shake .42s var(--ease-out); }
@keyframes lya-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

@media (max-width: 900px) {
  .lya { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .lya-side { position: static; gap: 14px; padding-top: 0; }
  .lya-id .lya-av { --_s: 44px; font-size: 18px; }
  .lya-about { font-size: 15px; }
  .lya-more { border-bottom: var(--bw) solid var(--line); }
  .lya-more-sum { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; list-style: none; font-size: 14.5px; font-weight: 500; color: var(--ink); }
  .lya-more-sum::-webkit-details-marker { display: none; }
  .lya-more-sum .lya-left { margin-left: auto; color: var(--ink-3); font-weight: 400; }
  .lya-plus { position: relative; width: 14px; height: 14px; flex: none; }
  .lya-plus::before, .lya-plus::after { content: ""; position: absolute; left: 0; top: 6.2px; width: 14px; height: 1.6px; background: currentColor; transition: transform .35s var(--ease-out); }
  .lya-plus::after { transform: rotate(90deg); }
  .lya-more[open] .lya-plus::after { transform: rotate(0deg); }
  .lya-more::details-content { block-size: 0; overflow: clip; transition: block-size .4s var(--ease-out), content-visibility .4s allow-discrete; }
  .lya-more[open]::details-content { block-size: auto; }
  .lya-more-body { padding: 4px 0 20px; }
  .lya-panel { height: calc(100svh - var(--lya-top) - 16px); min-height: 460px; scroll-margin-top: calc(var(--lya-top) + 8px); }
}
@media (max-width: 760px) {
  .lya-sec { padding-top: 16px; padding-bottom: 28px; }
  .lya-panel { margin-inline: calc(var(--gutter) * -1); border-inline: 0; }
  .lya-log { padding: 18px 14px; gap: 14px; }
  .lya-log .msg { max-width: 94%; }
  .lya-foot { padding: 10px 10px 12px; gap: 8px; }
  .lya-head { padding: 10px 8px 10px 14px; }
  .lya-reset span { display: none; }
  .lya-reset { width: 40px; height: 40px; padding: 0; }
  .lya-asks button { padding: 12px 2px; }
  .lya-rec { right: 90px; gap: 10px; }
  .lya-composer.is-rec .lya-rec-t { display: none; }
  .lya-disc { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .lya-mic.is-rec::before { transform: none; }
}
