:root{--header:#020617;--header-text:#fff;--conversation:#eef1f6;--bot-bubble:#fff;--user-bubble:#ede9fe;--bot-text:#0f172a;--user-text:#0f172a;--accent:#7c3aed}
*{box-sizing:border-box}
body{margin:0;background:#dfe4ed;color:#0f172a;font-family:'Segoe UI',sans-serif;font-size:14px}
button,select,textarea,input{font:inherit}
button{cursor:pointer}
button:disabled{opacity:.5;cursor:not-allowed}
button:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible{outline:2px solid #8b5cf6;outline-offset:3px}
[hidden]{display:none!important}
.chat-app{width:100%;max-width:900px;margin:0 auto;display:flex;flex-direction:column;height:100vh;height:100dvh;background:#fff;box-shadow:0 10px 50px #0f172a14;overflow:hidden}
.chat-header{background:var(--header);color:var(--header-text);padding:18px 24px;padding-top:max(18px,env(safe-area-inset-top));display:flex;gap:16px;align-items:center;justify-content:space-between;flex-shrink:0}
.brand{display:flex;align-items:center;gap:18px;min-width:0}
.brand img{width:128px;height:38px;object-fit:contain;flex-shrink:0}
.brand h1{font-size:15px;line-height:1.35;font-weight:600;margin:0;overflow-wrap:anywhere}
.brand span{display:block;font-size:11px;margin-top:4px;opacity:.75}
.header-actions{display:flex;gap:8px;flex-shrink:0}
.header-actions button{background:transparent;color:inherit;border:1px solid currentColor;border-radius:9px;height:36px;min-width:36px;font-size:16px;opacity:.8}
.header-actions #install{font-size:11px;padding:0 10px}
.header-actions button:hover{opacity:1}
.project-bar{padding:10px 24px;display:flex;align-items:center;gap:10px;border-bottom:1px solid #e2e8f0;background:#fff;font-size:11px;color:#64748b}
.project-bar select{color:#334155;font-weight:600;font-size:12px;background:none;border:0;max-width:65%;padding:4px}
#chat{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;background:var(--conversation);padding:28px 32px;display:flex;flex-direction:column;gap:14px}
.msg{max-width:82%;padding:13px 17px;border-radius:16px;line-height:1.6;overflow-wrap:anywhere;white-space:pre-wrap;box-shadow:0 1px 2px #0f172a05;flex-shrink:0}
.msg.bot{background:var(--bot-bubble);color:var(--bot-text);align-self:flex-start;border-bottom-left-radius:4px}
.msg.user{background:var(--user-bubble);color:var(--user-text);align-self:flex-end;border-bottom-right-radius:4px}
.message-meta{display:flex;justify-content:space-between;gap:24px;font-size:9px;letter-spacing:.03em;opacity:.65;margin-top:8px;white-space:normal}
.msg a{color:inherit;text-decoration:underline;text-underline-offset:3px;word-break:break-word}
.msg.has-card{background:transparent;padding:0;box-shadow:none;max-width:420px;width:100%;white-space:normal;color:#0f172a}
.file-card{display:flex;align-items:flex-start;flex-direction:column;gap:10px;margin-top:8px;padding:12px;border:1px solid #cbd5e1;background:#ffffffa0;color:#0f172a;border-radius:10px;font-size:12px;white-space:normal;min-width:0}
.file-card audio,.file-card video{width:100%;max-width:340px;min-width:0}
.file-card video{max-height:220px;background:#020617;border-radius:8px}
.file-card a{font-weight:600}
.file-card img{max-height:150px;max-width:100%;border-radius:8px}
.notice,.chat-error{padding:10px 24px;font-size:12px;flex-shrink:0}
.notice{color:#475569;background:#f8fafc;border-bottom:1px solid #e2e8f0}
.chat-error{background:#fff1f2;color:#9f1239;border-bottom:1px solid #fecdd3}
#typing{padding:10px 24px;font-size:11px;color:#64748b;background:var(--conversation)}
#typing span{display:inline-block;width:4px;height:4px;border-radius:50%;background:#8b5cf6;margin-right:3px;animation:pulse 1.2s infinite}
#typing span:nth-child(2){animation-delay:.2s}#typing span:nth-child(3){animation-delay:.4s}
@keyframes pulse{50%{opacity:.3;transform:translateY(-2px)}}
#composer{display:flex;align-items:flex-end;gap:12px;padding:16px 20px 8px;background:#fff;border-top:1px solid #e2e8f0}
#message{flex:1;min-width:0;resize:none;max-height:140px;border:1px solid #e2e8f0;border-radius:14px;background:#f8fafc;padding:12px 15px;font-size:14px;line-height:1.5;color:#0f172a}
#composer button{height:46px;width:46px;flex-shrink:0;border-radius:12px;border:0;display:flex;align-items:center;justify-content:center}
#composer svg{width:22px;height:22px}
.attach-button{background:#f1f5f9;color:#64748b}
.send-button{background:var(--accent);color:white}
#dictate[aria-pressed=true]{background:#fee2e2;color:#b91c1c;box-shadow:0 0 0 2px #fecaca}
#dictation-status{font-size:11px;padding:6px 20px;color:#9f1239;background:#fff1f2}
footer{background:#fff;color:#64748b;text-align:center;font-size:10px;padding:6px 16px max(12px,env(safe-area-inset-bottom))}
#attachment-preview{display:flex;align-items:center;gap:14px;background:#f8fafc;padding:12px 24px;border-top:1px solid #e2e8f0}
#attachment-preview{flex-wrap:wrap}
#attachment-audio{width:100%;height:36px;order:3}
#attachment-video{max-width:120px;max-height:80px;border-radius:8px;background:#020617}
#attachment-map{font-size:12px;color:#6d28d9}
#attachment-image{width:64px;height:64px;border-radius:8px;object-fit:cover}
.file-info{min-width:0;flex:1}
.file-info strong{display:block;font-size:12px;overflow-wrap:anywhere}
.file-info span{display:block;font-size:11px;color:#64748b;margin-top:3px}
#remove-attachment{border:0;background:#e2e8f0;border-radius:50%;height:30px;width:30px;font-size:20px;color:#475569}
#upload-progress{padding:10px 24px;font-size:11px;color:#64748b}
progress{width:100%;height:4px;accent-color:#7c3aed;display:block;margin-bottom:5px}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
dialog{border:1px solid #e2e8f0;border-radius:16px;padding:24px;width:360px;max-width:calc(100vw - 32px);color:#0f172a;box-shadow:0 20px 80px #02061740}
dialog::backdrop{background:#02061780;backdrop-filter:blur(3px)}
dialog h2{font-size:18px;margin:0 0 8px}
dialog p{font-size:13px;color:#64748b;line-height:1.6;margin:0 0 20px}
dialog button{padding:11px 14px;border:1px solid #e2e8f0;border-radius:8px;background:#f8fafc;color:#334155}
#attachment-menu button{display:block;width:100%;margin-top:10px;text-align:left}
#attachment-menu button small{display:block;color:#64748b;font-size:11px;font-weight:400;margin-top:3px}
#attachment-menu button:hover{border-color:#a78bfa;background:#f5f3ff}
.dialog-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:20px}
dialog .primary{background:#7c3aed;border-color:#7c3aed;color:white}
#location-form{display:grid;gap:8px;margin-top:16px;font-size:12px}
#location-form input{padding:10px;min-width:0;width:100%;border:1px solid #cbd5e1;border-radius:8px;background:white;color:#0f172a}
.coordinates{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:6px}
.coordinates label{display:grid;gap:6px}
#location-error{margin-top:12px;border-radius:8px;padding:10px}
#camera-dialog{width:460px;padding:20px}
.camera-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}
.camera-heading h2{margin:0}
#close-camera{border:0;background:#f1f5f9;font-size:22px;width:36px;height:36px;padding:0;border-radius:50%}
#camera-dialog>p{margin-top:8px;margin-bottom:16px}
.camera-view{position:relative;background:#020617;border-radius:12px;overflow:hidden;aspect-ratio:4/3;display:flex;align-items:center;justify-content:center}
#camera-video{width:100%;height:100%;object-fit:contain}
#camera-video[data-facing=user]{transform:scaleX(-1)}
#camera-status{position:absolute;bottom:12px;left:12px;color:#fff;background:#020617b3;border-radius:20px;padding:6px 12px;font-size:11px}
.camera-actions{display:flex;gap:10px;margin-top:16px}
.camera-actions button{flex:1;min-height:44px}
#camera-error{margin-top:12px;border-radius:8px;padding:10px}
#retry-camera,#native-camera{margin-top:10px;width:100%}
#reset-dialog form{display:flex;gap:8px;justify-content:flex-end}
#reset-dialog button[value=confirm]{background:#7c3aed;color:white;border-color:#7c3aed}
.chat-app.dragging #chat{box-shadow:inset 0 0 0 3px #8b5cf6}
/* Los templates enriquecidos conservan sus formularios, medios y botones. */
.card{border:1px solid #e2e8f0;border-radius:16px;background:#fff;color:#0f172a;overflow:hidden;box-shadow:0 4px 16px #0f172a08;width:100%;margin:4px 0}
.msg.has-card .card{background:var(--bot-bubble);color:var(--bot-text)}
.card-header{padding:14px 16px;background:#0f172a;color:#fff;display:flex;justify-content:space-between;align-items:center;gap:8px;font-weight:700;font-size:13px}
.card-header-badge{background:#ffffff30;border-radius:20px;font-size:10px;padding:3px 8px}
.card-body{padding:16px;font-size:13px;line-height:1.6;color:inherit}
.card-body p{margin:0 0 10px}.card-body p:last-child{margin-bottom:0}
.detail-row{display:flex;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid #f1f5f9;font-size:12px}
.detail-row span{color:#64748b}.detail-row b{text-align:right}
.highlight-box{border-left:3px solid #7c3aed;background:#f5f3ff;padding:10px;border-radius:6px;font-size:12px;margin-top:12px}
.card-options{display:flex;flex-direction:column;gap:8px;padding:14px 16px;background:#f8fafc;border-top:1px solid #e2e8f0}
.btn-option,.card button{border:1px solid #cbd5e1;border-radius:8px;background:#fff;color:#334155;padding:10px 12px;font-size:12px;font-weight:600;cursor:pointer;text-decoration:none;text-align:center}
.btn-option:hover,.card button:hover{background:#f5f3ff;border-color:#a78bfa}
.btn-option.primary{background:#7c3aed;color:#fff;border-color:#7c3aed}
.card-footer{padding:12px 16px;font-size:11px;background:#f8fafc;color:#64748b}
.card-form,.form-group{display:flex;flex-direction:column;gap:8px}.form-group{margin-bottom:12px}
.form-label{font-size:11px;color:#475569;font-weight:600}
.form-input,.form-select,.form-textarea,.card input:not([type=checkbox]):not([type=radio]),.card select,.card textarea{width:100%;padding:10px;border:1px solid #cbd5e1;border-radius:8px;font:inherit;color:#0f172a;background:#fff}
.media-card img,.media-card video,.card img{max-width:100%;height:auto}.media-card audio{width:100%}
.location-card iframe{border:0;max-width:100%}
@media(min-width:940px){body{padding:24px}.chat-app{height:calc(100dvh - 48px);border-radius:20px}}
@media(max-width:600px){
 .chat-header{padding:14px 16px;padding-top:max(14px,env(safe-area-inset-top));gap:10px}
 .brand{gap:10px}.brand img{width:92px;height:30px}.brand h1{font-size:12px}
 .header-actions{gap:5px}.header-actions button{height:32px;min-width:32px}
 .project-bar{padding:8px 16px}
 #chat{padding:20px 16px}.msg{max-width:92%;padding:11px 14px;font-size:13px}
 #composer{padding:12px 12px 6px;gap:8px}#composer button{width:40px;height:44px}
 #message{font-size:16px;padding:10px 12px}
 .notice,.chat-error{padding:10px 16px}
}
@media(display-mode:standalone){body{padding:0}.chat-app{height:100dvh;border-radius:0;max-width:100%}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;scroll-behavior:auto!important}}
