/* Asistente IA */
.as-app .app-scroll { overflow: hidden; display: flex; flex-direction: column; }
.as-app .page { padding: 0; max-width: none; height: 100%; min-height: 0; display: flex; }

.as { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: 272px minmax(0, 1fr); background: var(--panel); }

/* Lista de conversaciones */
.as-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel-2); padding: 14px 10px 10px; gap: 10px; }
.as-new { width: 100%; justify-content: center; gap: 6px; }
.as-quota { padding: 0 6px; font-size: 12px; color: var(--muted); }
.as-quota i { display: block; height: 4px; margin-top: 6px; border-radius: 4px; background: var(--line); position: relative; overflow: hidden; }
.as-quota i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--accent); border-radius: 4px; }
.as-quota.is-low i::after { background: var(--brand); }
.as-threads { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.as-threads h3 { margin: 12px 8px 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.as-threads h3:first-child { margin-top: 2px; }
.as-thread { position: relative; display: flex; align-items: center; border-radius: var(--r-ctl); }
.as-thread a { flex: 1; min-width: 0; padding: 8px 32px 8px 10px; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: var(--r-ctl); }
.as-thread:hover a { background: var(--hover); color: var(--ink); }
.as-thread.is-on a { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.as-del { position: absolute; right: 4px; width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--faint); cursor: pointer; opacity: 0; }
.as-thread:hover .as-del, .as-thread.is-on .as-del, .as-del:focus-visible { opacity: 1; }
.as-del:hover { color: var(--brand); background: var(--hover); }
.as-none { padding: 6px 10px; font-size: 12.5px; color: var(--faint); }
.as-clear { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--faint); font-size: 12.5px; padding: 6px; cursor: pointer; border-radius: 6px; }
.as-clear:hover { color: var(--brand); background: var(--hover); }
.as-confirm { margin: 4px 2px 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-item); background: var(--panel); box-shadow: var(--shadow-pop); font-size: 13px; }
.as-confirm div { display: flex; gap: 6px; margin-top: 8px; }
.as-danger { background: var(--brand); border-color: var(--brand); color: #fff; }
.as-danger:hover { filter: brightness(1.06); }

/* Zona principal */
.as-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.as-mtop { display: none; }
.as-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 24px 24px 8px; scroll-behavior: smooth; }
.as-log, .as-welcome { max-width: 860px; margin: 0 auto; }

.as-welcome { text-align: center; padding: 6vh 8px 20px; }
.as-welcome[hidden] { display: none; }
.as-welcome-ico, .as-login-ico { flex: none; display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); }
.as-welcome h1 { font-size: 26px; font-weight: 700; font-stretch: 108%; margin: 14px 0 8px; }
.as-welcome p { color: var(--muted); max-width: 56ch; margin: 0 auto; }
.as-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 26px; text-align: left; }
.as-example { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-item); background: var(--panel); color: var(--ink-2); font-size: 14px; line-height: 1.4; cursor: pointer; text-align: left; }
.as-example:hover { border-color: var(--line-2); background: var(--hover); color: var(--ink); }

.as-msg { margin: 0 0 18px; display: flex; }
.as-user { justify-content: flex-end; }
.as-bubble { max-width: min(640px, 85%); padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--navy); color: var(--on-navy); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.as-answer { flex: 1; min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; background: var(--panel); }
.as-stats { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.as-text { font-size: 15px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.as-text p + p, .as-text p + ul, .as-text ul + p { margin-top: 10px; }
.as-text ul { padding-left: 20px; display: grid; gap: 6px; margin: 8px 0; }
.as-text li { list-style: disc; }
.as-cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 0 0 2px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; line-height: 1; vertical-align: 2px; text-decoration: none; font-variant-numeric: tabular-nums; }
.as-cite:hover { background: var(--accent); color: #fff; }

.as-sources { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.as-sources h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 8px; }
.as-sources ol { display: grid; gap: 2px; list-style: none; padding: 0; margin: 0; }
.as-src { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 7px 6px; border-radius: var(--r-ctl); scroll-margin: 80px; }
.as-src:hover { background: var(--hover); }
.as-src.is-flash { animation: as-flash 1.6s ease-out; }
@keyframes as-flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }
.as-src-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.as-src-title { display: block; color: var(--ink); font-weight: 600; font-size: 14px; line-height: 1.4; }
.as-src-title:hover { color: var(--accent); text-decoration: underline; }
.as-src-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.as-src-meta b { color: var(--ink-2); font-weight: 600; }
.as-src-meta .flag { border-radius: 2px; margin-right: -4px; }
.as-src-meta a { color: var(--accent); font-weight: 600; }
.as-more { margin-top: 6px; }
.as-more summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); padding: 6px; border-radius: var(--r-ctl); width: max-content; }
.as-more summary:hover { background: var(--hover); }
.as-tools { display: flex; justify-content: flex-end; margin-top: 8px; }
.as-copy { border: 0; background: none; color: var(--faint); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.as-copy:hover { color: var(--ink); background: var(--hover); }
.as-error { color: var(--brand); border-color: var(--breaking-soft, var(--line)); }
.as-loading { color: var(--faint); text-align: center; padding: 30px; }

.as-pending .as-answer { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; flex: 0 1 auto; }
.as-dots { display: inline-flex; gap: 4px; }
.as-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: as-dot 1.2s infinite ease-in-out; }
.as-dots i:nth-child(2) { animation-delay: .15s; }
.as-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes as-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Caja de pregunta */
.as-composer { flex: none; padding: 10px 24px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.as-input { max-width: 860px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); }
.as-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.as-input textarea { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: none; color: var(--ink); font: inherit; font-size: 15px; line-height: 1.45; padding: 7px 0; max-height: 180px; }
.as-input textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-send { flex: none; gap: 6px; border-radius: 10px; }
.as-disclaimer, .as-off { max-width: 860px; margin: 8px auto 0; font-size: 12px; color: var(--faint); text-align: center; }
.as-off { color: var(--brand); margin: 0 auto 8px; font-weight: 600; }

/* Sin cuenta */
.as-login { display: flex; gap: 18px; align-items: flex-start; padding: 22px 24px; max-width: 760px; }
.as-login h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.as-login p { color: var(--muted); }
.as-login-free { margin: 8px 0 14px; font-size: 13px; }
.as-scrim { display: none; }

@media (max-width: 900px) {
    .as { grid-template-columns: 1fr; }
    .as-side { position: absolute; z-index: 25; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-pop); }
    .as.side-open .as-side { transform: none; }
    .as.side-open .as-scrim { display: block; position: absolute; inset: 0; z-index: 24; background: rgba(10, 16, 28, .35); }
    .as-mtop { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
    .as-scroll { padding: 16px 12px 8px; }
    .as-composer { padding: 8px 10px 10px; }
    .as-examples { grid-template-columns: 1fr; }
    .as-welcome { padding-top: 3vh; }
    .as-del { opacity: 1; }
}
@media (max-width: 760px) {
    .as-app .page { padding: 0 0 calc(62px + env(safe-area-inset-bottom)); }
    .as-send span { display: none; }
    .as-disclaimer { font-size: 11px; }
    .as-answer { padding: 12px; }
    .as-login { flex-direction: column; padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { .as-dots i, .as-src.is-flash { animation: none; } .as-side { transition: none; } }
