/* ════════════════════════════════════════════════════
   SOFiA · Sanatorio Aconcagua
   Paleta moderna: azul vibrante + blanco
   ════════════════════════════════════════════════════ */

:root {
    --primary:        #2563eb;
    --primary-strong: #1d4ed8;
    --primary-soft:   #dbeafe;
    --primary-mid:    #3b82f6;
    --primary-bright: #60a5fa;
    --accent:         #06b6d4;

    --ink:            #0f172a;
    --ink-soft:       #1e293b;
    --muted:          #64748b;
    --muted-soft:     #94a3b8;
    --line:           #e5e7eb;
    --line-soft:      #f1f5f9;

    --bg:             #e9eef5;
    --bg-soft:        #f1f4f9;
    --panel:          #ffffff;
    --panel-alt:      #f7f9fc;

    --user-bubble:    #dbeafe;
    --user-bubble-ink:#1e3a8a;
    --bot-bubble:     #f3f4f6;
    --bot-bubble-ink: #0f172a;

    --danger:         #ef4444;
    --danger-soft:    #fee2e2;
    --success:        #10b981;
    --success-soft:   #d1fae5;

    --shadow-sm:      0 1px 2px rgba(15,23,42,.05), 0 2px 6px rgba(15,23,42,.08);
    --shadow:         0 4px 8px rgba(15,23,42,.06), 0 14px 36px rgba(15,23,42,.10);
    --shadow-lg:      0 25px 50px rgba(15,23,42,.18);
    --shadow-blue:    0 8px 24px rgba(37,99,235,.25);

    --radius-sm:      10px;
    --radius:         16px;
    --radius-lg:      22px;
    --radius-xl:      28px;
}

body.dark {
    --primary:        #60a5fa;
    --primary-strong: #93c5fd;
    --primary-soft:   #1e293b;
    --primary-mid:    #3b82f6;
    --primary-bright: #93c5fd;
    --accent:         #22d3ee;

    --ink:            #f1f5f9;
    --ink-soft:       #cbd5e1;
    --muted:          #94a3b8;
    --muted-soft:     #64748b;
    --line:           #1e293b;
    --line-soft:      #0f172a;

    --bg:             #0b1220;
    --bg-soft:        #0f172a;
    --panel:          #111c30;
    --panel-alt:      #0f1a2c;

    --user-bubble:    #1e3a8a;
    --user-bubble-ink:#dbeafe;
    --bot-bubble:     #1e293b;
    --bot-bubble-ink: #f1f5f9;

    --danger:         #f87171;
    --danger-soft:    #2d1b1b;
    --success:        #34d399;
    --success-soft:   #0f2b20;

    --shadow:         0 4px 6px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.4);
    --shadow-blue:    0 8px 24px rgba(96,165,250,.25);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Manrope', system-ui, sans-serif;
    color: var(--ink);
    min-height: 100dvh;
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
    /* Fondo base "hospitalario": blanco con un degradado radial muy sutil que da
       sensación de luz cálida / limpia, sin saturar. */
    background:
        radial-gradient(ellipse 1200px 700px at 100% 0%, rgba(37, 99, 235, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 900px 600px at 0% 100%, rgba(6, 182, 212, 0.045) 0%, transparent 55%),
        var(--bg);
}

/* Capa de patrón médico: electrocardiograma horizontal apenas perceptible,
   evoca el sector salud sin caer en clichés gráficos. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 70'><path d='M0 35 H72 L78 24 L84 46 L90 8 L96 62 L102 35 H128 L134 30 L140 40 L146 35 H196 L202 24 L208 46 L214 8 L220 62 L226 35 H252 L258 30 L264 40 L270 35 H320' fill='none' stroke='%232563eb' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' opacity='0.32'/></svg>");
    background-repeat: repeat;
    background-size: 320px 70px;
    background-position: 0 0;
}

/* Acento sutil: orbe de luz superior derecha (efecto "luz de sol médica"). */
body::after {
    content: '';
    position: fixed;
    top: -180px;
    right: -180px;
    width: 460px;
    height: 460px;
    pointer-events: none;
    z-index: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,0.10) 0%, rgba(37,99,235,0.04) 40%, transparent 70%);
    filter: blur(20px);
}

body.dark {
    background:
        radial-gradient(ellipse 1200px 700px at 100% 0%, rgba(96, 165, 250, 0.10) 0%, transparent 60%),
        radial-gradient(ellipse 900px 600px at 0% 100%, rgba(34, 211, 238, 0.06) 0%, transparent 55%),
        var(--bg);
}

body.dark::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 70'><path d='M0 35 H72 L78 24 L84 46 L90 8 L96 62 L102 35 H128 L134 30 L140 40 L146 35 H196 L202 24 L208 46 L214 8 L220 62 L226 35 H252 L258 30 L264 40 L270 35 H320' fill='none' stroke='%2360a5fa' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round' opacity='0.28'/></svg>");
    opacity: 1;
}

body.dark::after {
    background: radial-gradient(circle, rgba(96,165,250,0.18) 0%, rgba(96,165,250,0.06) 40%, transparent 70%);
}

.hidden { display: none !important; }

/* ── Gate de DNI ── */
.dni-gate-fullpage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    min-height: 70vh;
    position: relative;
    z-index: 1;
}

.dni-gate-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2.2rem 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.dni-gate-icon {
    width: 88px; height: 88px;
    margin: 0 auto 1.2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    color: white;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow-blue);
    overflow: hidden;
}
.dni-gate-icon svg { width: 36px; height: 36px; }
.dni-gate-logo {
    width: 84px;
    height: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.dni-gate-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 0.5rem;
    letter-spacing: -0.01em;
}

.dni-gate-text {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.55;
    margin: 0 0 1.5rem;
}

.dni-form {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.dni-input {
    width: 100%;
    padding: 0.95rem 1rem;
    font-family: inherit;
    font-size: 1.15rem;
    text-align: center;
    letter-spacing: 0.06em;
    border: 2px solid #cbd5e1;
    border-radius: var(--radius);
    background: #f1f5fb;
    color: var(--ink);
    outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    box-shadow: inset 0 1px 2px rgba(15,23,42,.04);
}
.dni-input::placeholder { color: #94a3b8; font-size: 0.9rem; letter-spacing: 0; font-weight: 500; }
.dni-input:hover { border-color: #94a3b8; }
.dni-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37,99,235,.18), inset 0 1px 2px rgba(15,23,42,.04);
}
body.dark .dni-input {
    background: #050b16;
    border-color: #334155;
    color: #f1f5f9;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.5);
}
body.dark .dni-input::placeholder { color: #64748b; }
body.dark .dni-input:hover { border-color: #475569; }
body.dark .dni-input:focus {
    background: #0a1220;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(96,165,250,.22), inset 0 1px 3px rgba(0,0,0,.5);
}

.dni-submit {
    width: 100%;
    padding: 0.95rem 1rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform .12s, box-shadow .18s, opacity .15s;
    box-shadow: var(--shadow-blue);
}
.dni-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(37,99,235,.4);
}
.dni-submit:active:not(:disabled) { transform: translateY(0); }
.dni-submit:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.dni-gate-error {
    font-size: 0.88rem;
    color: var(--danger);
    background: var(--danger-soft);
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    margin: 1rem 0 0;
    text-align: left;
    border-left: 3px solid var(--danger);
}

/* ── Modal: paciente no registrado ── */
.dni-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: dni-fade-in .25s ease;
}
@keyframes dni-fade-in { from { opacity: 0; } to { opacity: 1; } }

.dni-modal {
    background: var(--panel);
    border-radius: var(--radius-xl);
    padding: 2.2rem 1.8rem 1.6rem;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: dni-zoom-in .28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes dni-zoom-in {
    from { opacity: 0; transform: scale(.92); }
    to   { opacity: 1; transform: scale(1); }
}

.dni-modal-icon {
    width: 64px; height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--danger-soft);
    color: var(--danger);
    display: grid;
    place-items: center;
}
.dni-modal-icon svg { width: 34px; height: 34px; }

.dni-modal-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 0.9rem;
    letter-spacing: -0.01em;
}

.dni-modal-text {
    font-size: 0.95rem;
    color: var(--ink-soft);
    line-height: 1.6;
    margin: 0 0 0.8rem;
}
.dni-modal-text strong { color: var(--primary); white-space: nowrap; font-size: 1.1rem; font-weight: 800; }

.dni-modal-text-small {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
    margin: 0 0 1.4rem;
}

.dni-modal-btn {
    min-width: 160px;
    padding: 0.8rem 1.6rem;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s, box-shadow .18s;
    box-shadow: var(--shadow-blue);
}
.dni-modal-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(37,99,235,.4); }

.app-gated { display: contents; }
.app-gated.hidden { display: none !important; }

/* ── App Shell ── */
.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 100dvh;
    position: relative;
    z-index: 1;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 0.9rem 1.4rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 0.95rem;
    flex: 1;
    min-width: 0;
}

.brand-mark {
    width: 56px; height: 56px;
    border-radius: var(--radius);
    background: white;
    border: 1.5px solid var(--line);
    display: grid;
    place-items: center;
    padding: 6px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-copy { min-width: 0; flex: 1; }

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.brand-copy h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}

.panel-step {
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
}

body.dark .panel-step { color: var(--primary); }

.brand-copy p {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0.18rem 0 0;
    font-weight: 500;
}

.brand-by {
    color: var(--primary);
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.icon-btn {
    width: 40px; height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 1rem;
    transition: all .15s;
}
.icon-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
}

.icon-btn-logout svg { width: 17px; height: 17px; }
.icon-btn-logout:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger);
}

.call-timer {
    font-size: 0.95rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    padding: 0.4rem 0.8rem;
    background: var(--primary-soft);
    border-radius: 999px;
    letter-spacing: 0.04em;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.connection-status.connected { background: var(--success-soft); color: #047857; border-color: rgba(16,185,129,.3); }
.connection-status.connected .status-dot { background: var(--success); animation: pulse-dot 2s infinite; }
body.dark .connection-status.connected { color: var(--success); }

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.45); }
    50%      { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* ── Selector de modo (tabs) ── */
.mode-selector {
    display: flex;
    gap: 0.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.mode-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.85rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s ease;
    letter-spacing: 0.01em;
}
.mode-tab:hover:not(.active) {
    background: var(--bg-soft);
    color: var(--ink);
}
.mode-tab.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    color: white;
    box-shadow: var(--shadow-blue);
}
.mode-tab svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Hero status bar ── */
.hero-status-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.1rem 1.4rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.hero-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.hero-stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.hero-stat strong {
    font-size: 1rem;
    color: var(--ink);
    font-weight: 700;
}

/* ── Workspace ── */
.workspace-grid {
    flex: 1;
    display: grid;
    gap: 1rem;
    min-height: 0;
}

.workspace-grid.voice-layout {
    grid-template-columns: 380px 1fr;
}

.workspace-grid.chat-layout {
    grid-template-columns: 1fr;
}

@media (max-width: 900px) {
    .workspace-grid.voice-layout { grid-template-columns: 1fr; }
}

/* ── Panel cards ── */
.panel-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.panel-heading {
    padding: 0.95rem 1.3rem;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: space-between;
}

.panel-heading .connection-status {
    margin-left: auto;
}

.panel-heading h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.01em;
    margin: 0;
}

.panel-body {
    flex: 1;
    padding: 1.3rem;
    min-height: 0;
    overflow-y: auto;
}

.control-panel-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    overflow: visible;
}

.transcript-panel-body { padding: 1rem; }

/* ── Orb voz ── */
.orb-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
    width: 100%;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0;
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.orb-ring-1 { width: 150px; height: 150px; }
.orb-ring-2 { width: 200px; height: 200px; }
.orb-ring-3 { width: 250px; height: 250px; }

.orb-stage.listening .orb-ring { border-color: var(--danger); }
.orb-stage.listening .orb-ring-1 { animation: orb-pulse 1.6s 0.0s ease-out infinite; }
.orb-stage.listening .orb-ring-2 { animation: orb-pulse 1.6s 0.3s ease-out infinite; }
.orb-stage.listening .orb-ring-3 { animation: orb-pulse 1.6s 0.6s ease-out infinite; }

.orb-stage.speaking .orb-ring { border-color: var(--primary-bright); }
.orb-stage.speaking .orb-ring-1 { animation: orb-pulse 1.0s 0.0s ease-out infinite; }
.orb-stage.speaking .orb-ring-2 { animation: orb-pulse 1.0s 0.2s ease-out infinite; }
.orb-stage.speaking .orb-ring-3 { animation: orb-pulse 1.0s 0.4s ease-out infinite; }

@keyframes orb-pulse {
    0%   { opacity: .65; transform: translate(-50%,-50%) scale(1); }
    100% { opacity: 0;   transform: translate(-50%,-50%) scale(1.25); }
}

.orb {
    position: relative;
    z-index: 2;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, var(--primary-bright) 0%, var(--primary) 50%, var(--primary-strong) 100%);
    box-shadow:
        0 12px 36px rgba(37,99,235,.45),
        0 0 0 8px rgba(37,99,235,.06),
        inset 0 -4px 12px rgba(0,0,0,.15),
        inset 0 4px 12px rgba(255,255,255,.25);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform .2s ease, box-shadow .2s ease;
    overflow: hidden;
}

.orb:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow:
        0 16px 48px rgba(37,99,235,.55),
        0 0 0 12px rgba(37,99,235,.08),
        inset 0 -4px 12px rgba(0,0,0,.15),
        inset 0 4px 12px rgba(255,255,255,.25);
}
.orb:disabled { opacity: .55; cursor: not-allowed; }

.orb-stage.idle .orb { animation: orb-breathe 3.5s ease-in-out infinite; }

@keyframes orb-breathe {
    0%, 100% { box-shadow: 0 12px 36px rgba(37,99,235,.4), 0 0 0 8px rgba(37,99,235,.06), inset 0 -4px 12px rgba(0,0,0,.15), inset 0 4px 12px rgba(255,255,255,.25); }
    50%      { box-shadow: 0 18px 48px rgba(37,99,235,.55), 0 0 0 14px rgba(37,99,235,.10), inset 0 -4px 12px rgba(0,0,0,.15), inset 0 4px 12px rgba(255,255,255,.25); }
}

.orb-stage.processing .orb::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: white;
    animation: spin .9s linear infinite;
}

.orb-logo {
    width: 78px;
    height: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.orb-stop-icon {
    position: absolute;
    width: 36px; height: 36px;
    color: white;
}

.orb-caption {
    font-size: 0.95rem;
    color: var(--muted);
    text-align: center;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* ── Tool activity ── */
.tool-activity {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.95rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 0.82rem;
    font-weight: 700;
}
body.dark .tool-activity { color: var(--primary); }

.tool-spinner {
    width: 12px; height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Waveform ── */
.waveform-box {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.live-label {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.waveform-canvas {
    display: block;
    width: 100%;
    height: 50px;
    border-radius: 8px;
}

/* ── Transcript ── */
.transcript-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 0.4rem;
    scroll-behavior: smooth;
}

.transcript-area::-webkit-scrollbar { width: 6px; }
.transcript-area::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.transcript-area::-webkit-scrollbar-thumb:hover { background: var(--muted-soft); }

.transcript-placeholder {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    padding: 3rem 1rem;
    line-height: 1.6;
}

/* ── Mensajes (chat bubbles) ── */
.message {
    margin-bottom: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.92rem;
    line-height: 1.55;
    max-width: 78%;
    word-break: break-word;
    position: relative;
}

.message.user {
    background: var(--user-bubble);
    color: var(--user-bubble-ink);
    margin-left: auto;
    border-bottom-right-radius: 6px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}

.message.assistant {
    background: var(--bot-bubble);
    color: var(--bot-bubble-ink);
    border: 1px solid var(--line);
    margin-right: auto;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(15,23,42,.03);
}

body.dark .message.assistant { background: var(--panel-alt); }

.message .label {
    font-size: 0.64rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
    color: var(--muted);
}

.message.user .label { color: var(--primary-strong); }
body.dark .message.user .label { color: var(--primary-bright); }

/* ── Typing indicator ── */
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Chat input ── */
.chat-input-bar {
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    padding: 0.85rem 1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.chat-input {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    line-height: 1.5;
    outline: none;
    overflow-y: hidden;
    transition: border-color .15s, box-shadow .15s, background .15s;
    min-height: 48px;
    max-height: 120px;
}
.chat-input::placeholder { color: var(--muted-soft); }
.chat-input:focus {
    border-color: var(--primary);
    background: var(--bg);
    box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}
body.dark .chat-input { background: var(--panel-alt); }
body.dark .chat-input:focus { background: var(--panel); }

.send-btn {
    width: 48px; height: 48px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-mid) 100%);
    color: white;
    cursor: pointer;
    transition: transform .12s, box-shadow .15s, opacity .15s;
    box-shadow: var(--shadow-blue);
}
.send-btn:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 12px 28px rgba(37,99,235,.45);
}
.send-btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; transform: none; }
.send-btn svg { width: 22px; height: 22px; }

/* ── Footer ── */
.app-footer {
    padding: 1rem 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: color .15s, text-decoration-color .15s;
}

.app-footer a:hover {
    color: var(--primary-strong);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .app-shell { padding: 1rem 0.85rem 1.5rem; gap: 1rem; }
    .topbar { padding: 0.75rem 1rem; }
    .brand-mark { width: 48px; height: 48px; }
    .brand-copy h1 { font-size: 1.2rem; }
    .hero-status-bar { grid-template-columns: 1fr 1fr; }
    .hero-stat:nth-child(3) { grid-column: 1 / -1; }
    .panel-body { padding: 1rem; }
    .orb { width: 110px; height: 110px; }
    .orb-logo { width: 64px; }
    .orb-ring-1 { width: 130px; height: 130px; }
    .orb-ring-2 { width: 175px; height: 175px; }
    .orb-ring-3 { width: 220px; height: 220px; }
    .message { max-width: 90%; font-size: 0.9rem; }
    .dni-gate-card { padding: 2rem 1.5rem 1.5rem; }
    body::after { width: 320px; height: 320px; top: -140px; right: -140px; }
}

@media (max-width: 480px) {
    .topbar-actions .connection-status { display: none; }
    .mode-tab span { display: none; }
    .hero-status-bar { grid-template-columns: 1fr; }
    .hero-stat:nth-child(3) { grid-column: 1; }
}

/* ── Aviso de alcance del canal (post-DNI) ── */
.scope-notice {
    position: relative;
    margin: 0 0 16px;
    padding: 12px 34px 12px 14px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-bright);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-soft);
}
.scope-notice-text { margin: 0; }
.scope-notice-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 19px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 5px;
}
.scope-notice-close:hover { color: var(--ink); }
