:root{
  --bg:#fff; --bg-soft:#f6f7f9; --side:#f9fafb; --line:#e6e8ec; --ink:#14161f; --ink-2:#5b6070; --ink-3:#8a8f9e;
  --dark:#171a2b; --accent:#4b1d8f; --accent-2:#7c5cff; --radius:16px;
  --font:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
}
@media (prefers-color-scheme:dark){
  :root{--bg:#0f111a;--bg-soft:#1a1d2a;--side:#12141e;--line:#262a3a;--ink:#f1f2f7;--ink-2:#a8adbe;--ink-3:#7a8094;--dark:#2a2e48;--accent:#b79bff;--accent-2:#9b82ff}
}
*{box-sizing:border-box;margin:0}
html,body{height:100%}
body{font-family:var(--font);color:var(--ink);background:var(--bg);-webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}
a{color:inherit;text-decoration:none}
:focus-visible{outline:2px solid var(--accent-2);outline-offset:2px}
svg.i{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none}

.app{display:grid;grid-template-columns:326px 1fr;height:100vh;transition:grid-template-columns .25s}
.app.collapsed{grid-template-columns:0 1fr}
.app.collapsed .sidebar{transform:translateX(-100%);visibility:hidden}

.sidebar{background:var(--side);border-right:1px solid var(--line);padding:22px 18px;display:flex;flex-direction:column;overflow-y:auto;transition:transform .25s}
.brand{display:flex;align-items:center;gap:10px;padding:0 6px 20px}
.brand-logo{width:32px;height:32px;object-fit:contain}
.brand-name{font-size:24px;font-weight:600;letter-spacing:-.02em;flex:1}
.icon-btn{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;color:var(--ink-2)}
.icon-btn:hover{background:var(--bg-soft)}
.btn-new{display:flex;align-items:center;gap:14px;background:var(--dark);color:#fff;border-radius:14px;padding:0 20px;height:48px;font-weight:600;font-size:16px;margin-bottom:18px}
.btn-new:hover{filter:brightness(1.15)}
.nav{display:flex;flex-direction:column;gap:2px}
.nav-item{display:flex;align-items:center;gap:16px;padding:0 14px;height:42px;border-radius:12px;font-size:16px;font-weight:500;color:var(--ink)}
.nav-item:hover{background:var(--bg-soft)}
.nav-item.active{background:#eceef3;font-weight:600}
@media (prefers-color-scheme:dark){.nav-item.active{background:#222639}}
.nav.small .nav-item{height:38px;font-size:15px;font-weight:400}
.push{margin-left:auto;width:16px!important;height:16px!important;color:var(--ink-3)}
.section-title{font-size:14px;font-weight:600;padding:22px 14px 8px}
.divider{border:0;border-top:1px solid var(--line);margin:14px 6px 0}
.recent{display:flex;flex-direction:column;gap:2px;min-height:60px}
.recent .item{display:flex;align-items:center;gap:14px;padding:0 14px;height:36px;border-radius:10px;font-size:15px;color:var(--ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:left;width:100%}
.recent .item:hover{background:var(--bg-soft)}
.empty{font-size:14px;color:var(--ink-3);padding:6px 14px;line-height:1.5}
.plan{margin-top:auto;border:1px solid var(--line);background:var(--bg);border-radius:16px;padding:14px;display:grid;gap:14px}
.plan-row{display:flex;gap:12px;align-items:flex-start}
.plan-icon{color:var(--accent-2);width:24px!important;height:24px!important}
.plan strong{display:block;font-size:15px}
.plan span{font-size:13px;color:var(--ink-3)}
.btn-pro{height:44px;border-radius:12px;color:#fff;font-weight:600;background:linear-gradient(135deg,#2a2d4d,#4b3a8f)}
.btn-pro:hover{filter:brightness(1.12)}

.main{display:flex;flex-direction:column;min-width:0;height:100vh}
.topbar{display:flex;align-items:center;justify-content:space-between;padding:18px 40px;min-height:76px}
.top-actions{display:flex;align-items:center;gap:14px;margin-left:auto}
.user{display:flex;align-items:center;gap:6px;color:var(--ink-2)}
.user svg{width:16px;height:16px}
.avatar{width:38px;height:38px;border-radius:50%;background:var(--dark);color:#fff;display:grid;place-items:center;font-weight:600}
.only-mobile{display:none}
.app.collapsed .only-mobile{display:grid}

.stage{flex:1;overflow-y:auto;display:flex;flex-direction:column;align-items:center;padding:0 40px 40px}
.hero{text-align:center;margin-top:5vh}
.hero h1{font-size:clamp(34px,4.4vw,52px);font-weight:700;letter-spacing:-.03em;display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap}
.accent{color:var(--accent)}
.hero-spark{width:40px!important;height:40px!important;color:var(--accent-2);stroke-width:1.4}
.tagline{margin-top:14px;font-size:18px;color:var(--ink-2)}

.composer-wrap{width:100%;max-width:1024px;margin-top:44px}
.composer{border:1px solid var(--line);border-radius:28px;padding:20px 18px 16px 26px;background:var(--bg);box-shadow:0 1px 2px rgba(20,22,31,.04);transition:border-color .15s,box-shadow .15s}
.composer:focus-within{border-color:var(--accent-2);box-shadow:0 0 0 4px rgba(124,92,255,.12)}
textarea{width:100%;border:0;outline:0;resize:none;font:inherit;font-size:18px;background:transparent;color:var(--ink);max-height:200px;line-height:1.5}
/* El foco se indica en el contenedor, no con un rectángulo dentro del texto. */
.composer textarea:focus,.composer textarea:focus-visible{outline:none;box-shadow:none;border:0}
textarea::placeholder{color:var(--ink-3)}
.composer-bar{display:flex;justify-content:space-between;align-items:center;margin-top:14px}
.tools{display:flex;gap:12px;align-items:center}
.round{width:48px;height:48px;border-radius:50%;border:1px solid var(--line);display:grid;place-items:center;color:var(--ink);background:var(--bg-soft)}
.round:hover{border-color:var(--ink-3)}
.mic{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;color:var(--ink-2)}
.send{width:50px;height:50px;border-radius:50%;background:var(--dark);color:#fff;display:grid;place-items:center}
.send:disabled{opacity:.35;cursor:not-allowed}

.cards{width:100%;max-width:1180px;margin-top:40px;display:grid;grid-template-columns:repeat(5,1fr);gap:16px}
.card{text-align:left;border:1px solid var(--line);border-radius:var(--radius);padding:22px 22px 24px;display:flex;flex-direction:column;gap:6px;background:var(--bg)}
.card:hover{border-color:var(--accent-2);background:var(--bg-soft)}
.card svg{width:28px;height:28px;margin-bottom:10px}
.card b{font-size:17px}
.card span{font-size:15px;color:var(--ink-3);line-height:1.45}

.thread{width:100%;max-width:820px;display:flex;flex-direction:column;gap:22px;padding:10px 0 24px}
.msg{display:flex;gap:14px;line-height:1.65;font-size:16px}
.msg.user{justify-content:flex-end}
.msg.user .bubble{background:var(--bg-soft);padding:12px 18px;border-radius:20px 20px 6px 20px;max-width:80%}
.msg.ai .badge{width:32px;height:32px;border-radius:50%;background:var(--dark);color:#fff;display:grid;place-items:center;flex:none}
.msg.ai .badge svg{width:16px;height:16px}
.msg.error .bubble{color:#b42318}
.bubble{white-space:pre-wrap;word-break:break-word}
.msg.ai .bubble a{color:var(--accent);text-decoration:underline;text-underline-offset:3px;overflow-wrap:anywhere}
.msg.ai .bubble a:hover{color:var(--accent-2)}
.typing{display:inline-flex;gap:5px;padding:10px 0}
.typing i{width:7px;height:7px;border-radius:50%;background:var(--ink-3);animation:b 1s infinite}
.typing i:nth-child(2){animation-delay:.15s}.typing i:nth-child(3){animation-delay:.3s}
@keyframes b{0%,60%,100%{opacity:.3}30%{opacity:1}}

.stage.chatting{justify-content:space-between}
.stage.chatting .hero,.stage.chatting .cards{display:none}
.stage.chatting .composer-wrap{margin-top:0;position:sticky;bottom:0;background:var(--bg);padding-bottom:6px}

.scrim{display:none}
@media (max-width:1180px){.cards{grid-template-columns:repeat(3,1fr)}}
@media (max-width:860px){
  .app{grid-template-columns:1fr}
  .sidebar{position:fixed;inset:0 auto 0 0;width:300px;z-index:20;transform:translateX(-100%);visibility:hidden}
  .app.open .sidebar{transform:none;visibility:visible}
  .app.open ~ .scrim{display:block;position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:10}
  .only-mobile{display:grid}
  .topbar{padding:12px 16px}.stage{padding:0 16px 24px}
  .cards{grid-template-columns:1fr 1fr}
  .tagline{font-size:16px}
}
@media (max-width:480px){.cards{grid-template-columns:1fr}.round{width:42px;height:42px}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
