/* =========================================================
   KEOTECH — STYLE.CSS 3.0
   Dark / Light · Responsive · Sin desenfoque (blur)
========================================================= */

:root {
    --bg: #070a12;
    --bg-2: #0a0f1b;
    --bg-3: #0e1422;

    --surface: #101827;
    --surface-2: #141e2e;
    --surface-3: #1a273c;

    --border: #24334c;
    --border-strong: #34476a;

    --text: #f5f7fb;
    --text-soft: #b8c2d4;
    --text-muted: #8391a8;

    --primary: #7667ff;
    --primary-2: #a196ff;
    --on-primary: #ffffff;

    --cyan: #43d9ff;
    --green: #42d392;
    --yellow: #f7c95d;
    --red: #ff6b83;
    --orange: #ff9d5c;
    --pink: #f26bd8;
    --blue: #4e9fff;

    --sidebar-width: 272px;
    --topbar-height: 68px;

    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-xl: 30px;

    --shadow-sm: 0 8px 24px rgba(0, 0, 0, .16);
    --shadow: 0 16px 45px rgba(0, 0, 0, .22);
    --shadow-lg: 0 25px 70px rgba(0, 0, 0, .35);

    --transition: 180ms ease;

    --font-main: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Space Grotesk", "Inter", sans-serif;
    --font-mono: Consolas, "SFMono-Regular", "Courier New", monospace;
}

html[data-theme="light"] {
    --bg: #f3f6fb;
    --bg-2: #eef2f8;
    --bg-3: #e8edf5;

    --surface: #ffffff;
    --surface-2: #f5f7fb;
    --surface-3: #e9eff8;

    --border: #d5deea;
    --border-strong: #bcc9db;

    --text: #121827;
    --text-soft: #3f4a5e;
    --text-muted: #5f6c80;

    --primary: #5b4de0;
    --primary-2: #4d3fd0;

    --cyan: #0a8fb3;
    --green: #16875a;
    --yellow: #9a6a00;
    --red: #c9304b;
    --orange: #c4621b;
    --pink: #b4359c;
    --blue: #1f6fd6;

    --shadow-sm: 0 8px 24px rgba(28, 42, 68, .08);
    --shadow: 0 16px 45px rgba(28, 42, 68, .10);
    --shadow-lg: 0 25px 70px rgba(28, 42, 68, .16);
}

/* =========================================================
   RESET
========================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 0%, rgba(118, 103, 255, .09), transparent 30%),
        radial-gradient(circle at 90% 20%, rgba(67, 217, 255, .06), transparent 28%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 15px;
    line-height: 1.55;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }
img { max-width: 100%; display: block; }
textarea { resize: vertical; }
h1, h2, h3, h4 { margin: 0; }

::selection { background: rgba(118, 103, 255, .35); color: var(--text); }

.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;
}

.skip-link {
    position: fixed; left: 12px; top: -60px; z-index: 1000;
    padding: 10px 14px; border-radius: 10px;
    background: var(--primary); color: var(--on-primary); font-weight: 700;
    transition: top var(--transition);
}
.skip-link:focus { top: 12px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =========================================================
   FONDO
========================================================= */

.ambient { position: fixed; pointer-events: none; z-index: -2; border-radius: 50%; opacity: .28; }
.ambient-one { width: 400px; height: 400px; top: -180px; left: 15%; background: rgba(118, 103, 255, .12); }
.ambient-two { width: 330px; height: 330px; right: -120px; top: 30%; background: rgba(67, 217, 255, .08); }
.ambient-three { width: 260px; height: 260px; left: 25%; bottom: -100px; background: rgba(66, 211, 146, .06); }

#particles { position: fixed; inset: 0; pointer-events: none; z-index: -3; overflow: hidden; }
.particle { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--text-muted); opacity: .25; animation: particleFloat 8s infinite ease-in-out; }

@keyframes particleFloat {
    0%, 100% { transform: translateY(0); opacity: .12; }
    50% { transform: translateY(-30px); opacity: .35; }
}

/* =========================================================
   APP
========================================================= */

.app-shell { min-height: 100vh; }

.main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    outline: none;
    transition: margin-left var(--transition);
}

.content { flex: 1; width: 100%; padding: 27px; max-width: 1700px; margin: 0 auto; }

/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width); z-index: 100;
    display: flex; flex-direction: column;
    padding: 18px 13px;
    background: linear-gradient(180deg, var(--surface), var(--bg-2));
    border-right: 1px solid var(--border);
    overflow-y: auto;
    transition: transform var(--transition);
}

.sidebar-overlay { display: none; }
.sidebar-top { flex: 1; }

.brand { display: flex; align-items: center; gap: 11px; padding: 5px 9px 20px; }

.brand-logo {
    width: 40px; height: 40px; display: grid; place-items: center; flex-shrink: 0;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    color: #fff; font-family: var(--font-display); font-size: 19px; font-weight: 700;
    box-shadow: 0 8px 25px rgba(118, 103, 255, .28);
}
.brand-logo.small { width: 34px; height: 34px; font-size: 16px; border-radius: 11px; }

.brand-text { min-width: 0; display: flex; flex-direction: column; }
.brand-text strong { font-family: var(--font-display); font-size: 17px; line-height: 1.1; }
.brand-text small { margin-top: 3px; color: var(--text-muted); font-size: 11px; white-space: nowrap; }

.new-chat-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px;
    padding: 11px 13px; border: 1px solid rgba(118, 103, 255, .4); border-radius: 12px;
    background: linear-gradient(135deg, rgba(118, 103, 255, .18), rgba(67, 217, 255, .07));
    color: var(--text); font-weight: 600; font-size: 13px;
    transition: transform var(--transition), border-color var(--transition), background var(--transition);
}
.new-chat-btn:hover { transform: translateY(-1px); border-color: var(--primary); }
.new-chat-btn i { color: var(--primary-2); }

.sidebar-section { margin-top: 23px; }

.sidebar-section-title {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 9px 8px; color: var(--text-muted);
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}

.sidebar-section-count {
    min-width: 22px; height: 22px; display: grid; place-items: center;
    border-radius: 7px; background: var(--surface-3); color: var(--text-soft); font-size: 11px;
}

.conversation-list { display: flex; flex-direction: column; gap: 3px; }

.conv-row { display: flex; align-items: center; gap: 2px; border-radius: 9px; }
.conv-row:hover { background: var(--surface-2); }
.conv-row.active { background: rgba(118, 103, 255, .14); }

.conversation-item {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
    padding: 8px 9px; border-radius: 9px; background: transparent;
    color: var(--text-soft); text-align: left;
}
.conv-row:hover .conversation-item, .conv-row.active .conversation-item { color: var(--text); }
.conversation-item i { color: var(--primary-2); font-size: 12px; }
.conversation-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.conv-delete {
    width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: 7px; color: var(--text-muted); font-size: 11px; opacity: 0;
}
.conv-row:hover .conv-delete, .conv-delete:focus-visible { opacity: 1; }
.conv-delete:hover { color: var(--red); background: rgba(255, 100, 124, .1); }

.main-nav { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
    width: 100%; display: flex; align-items: center; gap: 11px;
    padding: 10px; border: 1px solid transparent; border-radius: 10px;
    background: transparent; color: var(--text-soft); text-align: left;
    transition: color var(--transition), background var(--transition), border-color var(--transition), transform var(--transition);
}
.nav-item i { width: 18px; text-align: center; color: var(--text-muted); font-size: 14px; transition: color var(--transition); }
.nav-item span { font-size: 13px; font-weight: 600; }
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(2px); }
.nav-item:hover i { color: var(--primary-2); }
.nav-item.active {
    background: linear-gradient(90deg, rgba(118, 103, 255, .18), rgba(118, 103, 255, .05));
    border-color: rgba(118, 103, 255, .25); color: var(--text);
}
.nav-item.active i { color: var(--primary-2); }

.sidebar-bottom { padding-top: 14px; border-top: 1px solid var(--border); }

.sidebar-action {
    width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px;
    background: transparent; color: var(--text-muted); border-radius: 9px; font-size: 12px;
    transition: background var(--transition), color var(--transition);
}
.sidebar-action:hover { background: rgba(255, 100, 124, .1); color: var(--red); }

.backend-mini { margin-top: 10px; display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 10px; background: var(--surface-2); }
.backend-mini strong { display: block; font-size: 12px; }
.backend-mini small { color: var(--text-muted); font-size: 11px; }

.status-dot, .online-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--yellow); color: var(--yellow); box-shadow: 0 0 10px currentColor; }
.status-dot.online, .online-dot.online { background: var(--green); color: var(--green); }
.status-dot.offline, .online-dot.offline { background: var(--red); color: var(--red); }

/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    position: sticky; top: 0; z-index: 50; min-height: var(--topbar-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 27px; background: var(--bg); border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right { display: flex; align-items: center; }
.topbar-left { gap: 13px; }
.topbar-right { gap: 7px; }

.page-heading { display: flex; flex-direction: column; }
.page-kicker { color: var(--primary-2); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.topbar h1 { margin-top: 1px; font-family: var(--font-display); font-size: 21px; line-height: 1.1; }

.icon-btn {
    width: 38px; height: 38px; display: inline-grid; place-items: center;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text-soft);
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); transform: translateY(-1px); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 8px; font-size: 12px; }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }
.mobile-menu-btn { display: none; }
.language-button { width: auto; padding: 0 10px; display: inline-flex; gap: 6px; font-size: 12px; font-weight: 700; }

.global-search-button {
    min-width: 170px; display: flex; align-items: center; gap: 8px; padding: 9px 11px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
    color: var(--text-muted); font-size: 12px;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.global-search-button:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.global-search-button kbd { margin-left: auto; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--text-muted); font-size: 10px; font-family: var(--font-main); }

/* =========================================================
   PÁGINAS
========================================================= */

.page { display: none; animation: pageIn .25s ease both; }
.page.active { display: block; }

@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.page-intro { margin-bottom: 22px; }
.page-intro .section-kicker { display: block; }
.page-intro h2 { margin: 4px 0 6px; font-family: var(--font-display); font-size: clamp(26px, 3vw, 36px); line-height: 1.08; }
.page-intro p { max-width: 720px; margin: 0; color: var(--text-soft); font-size: 14px; }

.section-kicker { color: var(--primary-2); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.section-heading { margin: 30px 0 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.section-heading.compact { margin-top: 26px; }
.section-heading h2, .section-heading h3 { margin: 3px 0 0; font-family: var(--font-display); }
.section-heading h2 { font-size: 24px; }
.section-heading h3 { font-size: 19px; }
.section-heading p { max-width: 440px; margin: 0; color: var(--text-muted); font-size: 13px; text-align: right; }

/* =========================================================
   PANELES
========================================================= */

.panel, .card {
    background: linear-gradient(145deg, var(--surface), var(--surface-2));
    border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.panel { padding: 18px; }
.card { padding: 18px; }

.panel-title { display: flex; align-items: center; gap: 8px; margin-bottom: 15px; font-size: 14px; font-weight: 700; }
.panel-title i { color: var(--primary-2); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar h3 { font-family: var(--font-display); font-size: 18px; }

/* =========================================================
   HERO
========================================================= */

.hero-card {
    min-height: 390px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
    align-items: center; padding: 43px; overflow: hidden; position: relative;
    border: 1px solid rgba(118, 103, 255, .2); border-radius: var(--radius-xl);
    background: radial-gradient(circle at 75% 50%, rgba(118, 103, 255, .13), transparent 34%), linear-gradient(135deg, var(--surface), var(--surface-2));
    box-shadow: var(--shadow);
}

.hero-copy { position: relative; z-index: 2; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
    border: 1px solid var(--border); border-radius: 100px; background: var(--surface-2);
    color: var(--text-muted); font-size: 11px; font-weight: 800; letter-spacing: .08em;
}
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

.hero-card h2 { max-width: 730px; margin: 18px 0 13px; font-family: var(--font-display); font-size: clamp(38px, 5vw, 66px); line-height: 1; letter-spacing: -.04em; }
.hero-card h2 span { color: var(--primary-2); }
.hero-copy > p { max-width: 600px; margin: 0; color: var(--text-soft); font-size: 15px; line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-trust { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; color: var(--text-muted); font-size: 12px; }
.hero-trust span { display: inline-flex; align-items: center; gap: 6px; }
.hero-trust i { color: var(--green); }

.hero-visual { min-height: 330px; position: relative; display: grid; place-items: center; }

.hero-core {
    width: 255px; height: 255px; display: grid; place-items: center; border-radius: 50%;
    background: radial-gradient(circle, rgba(118, 103, 255, .19), rgba(118, 103, 255, .04) 60%, transparent 70%);
    border: 1px solid rgba(118, 103, 255, .18); box-shadow: 0 0 70px rgba(118, 103, 255, .08);
}

.hero-orbit { position: absolute; border-radius: 50%; border: 1px dashed rgba(118, 103, 255, .25); animation: orbitSpin 15s linear infinite; }
.orbit-one { width: 235px; height: 235px; }
.orbit-two { width: 315px; height: 315px; border-color: rgba(67, 217, 255, .15); animation-duration: 21s; animation-direction: reverse; }

@keyframes orbitSpin { to { transform: rotate(360deg); } }

.hero-bubble {
    position: absolute; display: flex; align-items: center; gap: 5px; padding: 7px 11px;
    border: 1px solid var(--border); border-radius: 100px; background: var(--surface);
    color: var(--text-soft); box-shadow: var(--shadow-sm); font-size: 12px; font-weight: 700;
    animation: bubbleFloat 4s infinite ease-in-out;
}
.hero-bubble i { color: var(--primary-2); }
.bubble-one { top: 18%; right: 10%; }
.bubble-two { left: 3%; top: 50%; animation-delay: .8s; }
.bubble-three { right: 6%; bottom: 14%; animation-delay: 1.4s; }

@keyframes bubbleFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ROBOT */

.robot { position: relative; width: 125px; animation: robotFloat 4s ease-in-out infinite; }
@keyframes robotFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.robot-antenna { position: absolute; width: 3px; height: 22px; left: 50%; top: -20px; transform: translateX(-50%); background: var(--primary-2); border-radius: 5px; }
.robot-antenna::after { content: ""; position: absolute; width: 8px; height: 8px; top: -5px; left: 50%; transform: translateX(-50%); border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }

.robot-head { position: relative; width: 100px; height: 82px; margin: 0 auto; border: 2px solid var(--primary-2); border-radius: 25px; background: linear-gradient(145deg, #182039, #0d1425); box-shadow: 0 15px 30px rgba(0, 0, 0, .25); }
.robot-ear { position: absolute; width: 11px; height: 26px; top: 28px; border: 1px solid var(--primary); border-radius: 7px; background: var(--surface-3); }
.robot-ear.left { left: -8px; }
.robot-ear.right { right: -8px; }
.robot-face { position: absolute; inset: 14px; display: flex; align-items: center; justify-content: center; gap: 22px; border-radius: 15px; background: #080d18; }
.robot-eye { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 13px var(--cyan); }
.robot-mouth { position: absolute; width: 19px; height: 5px; left: 50%; bottom: 12px; transform: translateX(-50%); border-bottom: 2px solid var(--primary-2); border-radius: 50%; }
.robot-body { width: 77px; height: 62px; margin: 8px auto 0; display: grid; place-items: center; border: 2px solid var(--primary); border-radius: 20px 20px 27px 27px; background: linear-gradient(145deg, #182039, #0d1425); }
.robot-screen { width: 37px; height: 24px; display: grid; place-items: center; border: 1px solid rgba(67, 217, 255, .5); border-radius: 7px; color: #43d9ff; font-size: 10px; font-weight: 800; }

/* =========================================================
   BOTONES
========================================================= */

.btn {
    min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 15px; border: 1px solid transparent; border-radius: 10px;
    font-size: 13px; font-weight: 700; line-height: 1.2;
    transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }

.btn-primary { background: linear-gradient(135deg, var(--primary), #6555e9); color: var(--on-primary); box-shadow: 0 9px 25px rgba(118, 103, 255, .2); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 30px rgba(118, 103, 255, .32); }
.btn-secondary { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: rgba(255, 100, 124, .1); border-color: rgba(255, 100, 124, .3); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 100, 124, .18); }
.btn-success { background: rgba(66, 211, 146, .12); border-color: rgba(66, 211, 146, .35); color: var(--green); }
.btn-success:hover:not(:disabled) { background: rgba(66, 211, 146, .2); }
.small-btn { min-height: 33px; padding: 6px 11px; font-size: 12px; }
.full-button { width: 100%; }

.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading::after {
    content: ""; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn { display: inline; padding: 0; background: none; color: var(--primary-2); text-decoration: underline; font-weight: 600; }
.link-btn:hover { color: var(--text); }

/* =========================================================
   STATS Y FEATURES
========================================================= */

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }

.stat-card { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: transform var(--transition), border-color var(--transition); }
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.stat-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: rgba(118, 103, 255, .12); color: var(--primary-2); }
.stat-card strong { display: block; font-family: var(--font-display); font-size: 21px; }
.stat-card span { display: block; color: var(--text-muted); font-size: 12px; }

.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.feature-card {
    min-height: 185px; padding: 20px; display: flex; flex-direction: column; align-items: flex-start;
    border: 1px solid var(--border); border-radius: 16px;
    background: linear-gradient(145deg, var(--surface), var(--surface-2));
    color: var(--text); text-align: left; box-shadow: var(--shadow-sm);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.feature-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.feature-card > strong { margin-top: 13px; font-family: var(--font-display); font-size: 16px; }
.feature-card p { margin: 6px 0; color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.feature-link { margin-top: auto; display: inline-flex; gap: 6px; color: var(--primary-2); font-size: 12px; font-weight: 700; }
.feature-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: rgba(118, 103, 255, .12); color: var(--primary-2); }
.feature-icon.cyan { color: var(--cyan); background: rgba(67, 217, 255, .1); }
.feature-icon.green { color: var(--green); background: rgba(66, 211, 146, .1); }
.feature-icon.blue { color: var(--blue); background: rgba(78, 159, 255, .1); }
.feature-icon.orange { color: var(--orange); background: rgba(255, 157, 92, .1); }
.feature-icon.pink { color: var(--pink); background: rgba(242, 107, 216, .1); }

/* =========================================================
   KEO
========================================================= */

.keo-workspace {
    display: grid; grid-template-columns: 240px minmax(0, 1fr);
    height: calc(100vh - 150px); min-height: 520px; overflow: hidden;
    border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
}

.keo-side-panel { padding: 15px; border-right: 1px solid var(--border); overflow-y: auto; }
.keo-side-panel .panel-header { display: flex; justify-content: space-between; align-items: center; }
.panel-header h3 { margin: 2px 0 0; font-family: var(--font-display); font-size: 16px; }

.keo-conversations { margin-top: 15px; display: flex; flex-direction: column; gap: 4px; }

.keo-conversation {
    display: block; width: 100%; padding: 9px 10px; border-radius: 9px;
    color: var(--text-soft); text-align: left; font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.keo-conversation:hover, .keo-conversation.active { background: var(--surface-2); color: var(--text); }
.keo-conversation.active { box-shadow: inset 2px 0 0 var(--primary); }

.memory-box { margin-top: 20px; display: flex; gap: 10px; padding: 12px; border: 1px solid rgba(118, 103, 255, .2); border-radius: 12px; background: rgba(118, 103, 255, .07); }
.memory-icon { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; background: rgba(118, 103, 255, .15); color: var(--primary-2); font-size: 12px; }
.memory-box strong { display: block; font-size: 12px; }
.memory-box p { margin: 3px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }

.keo-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }

.keo-header { min-height: 63px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--border); }
.keo-header-actions { display: flex; gap: 4px; }
.keo-title { display: flex; align-items: center; gap: 10px; }
.keo-title strong { display: block; font-family: var(--font-display); }
.keo-title > div > span { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; }

.keo-mini-avatar, .typing-avatar {
    width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--cyan)); color: #fff;
    font-family: var(--font-display); font-weight: 700; font-size: 13px;
}

.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; }

.chat-messages .empty-state { min-height: 100%; }

.message { display: flex; margin-bottom: 18px; }
.message.user { justify-content: flex-end; }
.message.ai { justify-content: flex-start; }

.message-stack { max-width: min(78%, 780px); display: flex; flex-direction: column; min-width: 0; }
.message.user .message-stack { align-items: flex-end; }

.message-body { padding: 12px 15px; border-radius: 14px; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.message.user .message-body { background: linear-gradient(135deg, var(--primary), #5f51df); color: #fff; border-bottom-right-radius: 4px; }
.message.ai .message-body { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text-soft); }
.message.error .message-body { border-color: rgba(255, 107, 131, .5); color: var(--text); }

.message-meta { margin-top: 5px; display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 11px; }
.message-actions { display: flex; gap: 2px; }
.msg-action { padding: 3px 7px; border-radius: 6px; color: var(--text-muted); font-size: 11px; display: inline-flex; gap: 5px; align-items: center; }
.msg-action:hover { background: var(--surface-3); color: var(--text); }

.message-badge { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 8px; padding: 2px 8px; border-radius: 6px; background: rgba(247, 201, 93, .14); color: var(--yellow); font-size: 11px; font-weight: 700; }

.message-body p, .rich p { margin: 0 0 .7em; }
.message-body p:last-child, .rich p:last-child { margin-bottom: 0; }
.message-body h3, .message-body h4, .rich h3, .rich h4 { margin: 1em 0 .4em; color: var(--text); font-family: var(--font-display); font-size: 15px; }
.message-body ul, .message-body ol, .rich ul, .rich ol { margin: .4em 0 .8em; padding-left: 22px; }
.message-body li, .rich li { margin: 3px 0; }
.message-body blockquote, .rich blockquote { margin: .6em 0; padding: 4px 12px; border-left: 3px solid var(--primary); color: var(--text-muted); }
.message-body a, .rich a { color: var(--cyan); }
.message.user .message-body a { color: #fff; }

.code-block { position: relative; margin: 10px 0 0; }
.code-block pre { overflow-x: auto; margin: 0; padding: 12px; padding-top: 34px; border-radius: 9px; background: #060912; border: 1px solid var(--border); color: #dfe8f8; font-size: 13px; line-height: 1.5; }
.code-block code { font-family: var(--font-mono); }
.code-lang { position: absolute; left: 12px; top: 8px; color: #7d8aa3; font-size: 11px; font-family: var(--font-mono); }
.code-copy { position: absolute; right: 8px; top: 6px; padding: 3px 8px; border-radius: 6px; background: #141e2e; color: #b8c2d4; font-size: 11px; border: 1px solid #24334c; }
.code-copy:hover { color: #fff; }

.message-body :not(pre) > code, .rich :not(pre) > code { padding: 2px 6px; border-radius: 5px; background: var(--surface-3); color: var(--cyan); font-family: var(--font-mono); font-size: 13px; }

.typing-indicator { display: flex; align-items: center; gap: 8px; padding: 0 22px 10px; color: var(--text-muted); font-size: 13px; }
.typing-avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }

.keo-robot-stage { position: absolute; right: 20px; top: 75px; pointer-events: none; opacity: .07; transform: scale(.7); }

.composer { margin: 6px 15px 4px; min-height: 56px; display: flex; align-items: flex-end; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.composer:focus-within { border-color: var(--primary); }
.composer-tools { display: flex; align-items: center; gap: 2px; }
.composer-tool { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: transparent; color: var(--text-muted); transition: background var(--transition), color var(--transition); }
.composer-tool:hover, .composer-tool.active { background: var(--surface-3); color: var(--text); }
.composer-tool.active { color: var(--red); }
.composer textarea { flex: 1; min-height: 34px; max-height: 140px; padding: 7px 4px; border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--text); resize: none; font-size: 14px; }
.composer textarea:focus { box-shadow: none; }
.composer textarea::placeholder { color: var(--text-muted); }

.send-button { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; transition: transform var(--transition), background var(--transition); }
.send-button:hover:not(:disabled) { background: var(--primary-2); transform: translateY(-1px); }

.composer-hint { margin: 0; padding: 4px 18px 10px; color: var(--text-muted); font-size: 11px; }

.attachment-preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 15px; }
.attachment-preview:not(:empty) { padding-bottom: 6px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-soft); font-size: 12px; }
.attachment-chip button { color: var(--text-muted); }
.attachment-chip button:hover { color: var(--red); }

/* =========================================================
   FORMULARIOS
========================================================= */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > span, .inline-field > span, .study-controls label > span { color: var(--text-soft); font-size: 12px; font-weight: 700; }

input, textarea, select {
    width: 100%; padding: 10px 11px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-2); color: var(--text); outline: none;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(118, 103, 255, .15); }
textarea { line-height: 1.6; }
select { cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input[type="checkbox"] { width: auto; accent-color: var(--primary); }
input[type="color"] { padding: 3px; cursor: pointer; }
input[type="file"] { padding: 8px; }

.full-field { margin-top: 12px; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field select { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* =========================================================
   ESTUDIO
========================================================= */

.study-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; align-items: start; }
.study-subjects { align-self: start; position: sticky; top: calc(var(--topbar-height) + 14px); }
.subject-list { display: flex; flex-direction: column; gap: 4px; }

.subject-button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text-soft); text-align: left; font-size: 13px; transition: background var(--transition), color var(--transition), border-color var(--transition); }
.subject-button:hover { background: var(--surface-2); color: var(--text); }
.subject-button.active { background: rgba(118, 103, 255, .13); border-color: rgba(118, 103, 255, .25); color: var(--text); font-weight: 600; }
.subject-button i { width: 16px; color: var(--primary-2); }

.study-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.study-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.study-controls label { display: flex; flex-direction: column; gap: 6px; }

.result-panel { min-height: 320px; }
.study-result, .summary-result { min-height: 240px; font-size: 14px; line-height: 1.75; color: var(--text-soft); overflow-wrap: anywhere; }
.study-result h2, .study-result h3, .summary-result h3 { font-family: var(--font-display); color: var(--text); }
.result-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.ai-generated-tag { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; padding: 4px 10px; border-radius: 7px; background: rgba(118, 103, 255, .12); color: var(--primary-2); font-size: 12px; font-weight: 700; }

.ai-notice-line { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.ai-notice-line i { margin-top: 2px; color: var(--cyan); }

/* SUBIDA DE ARCHIVOS */

.dropzone {
    padding: 38px 20px; display: flex; flex-direction: column; align-items: center;
    border: 1px dashed var(--border-strong); border-radius: 17px;
    background: linear-gradient(145deg, var(--surface), var(--surface-2)); text-align: center;
    cursor: pointer; transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.dropzone.compact { padding: 22px 16px; }
.dropzone:hover, .dropzone.drag-over { border-color: var(--primary); background: rgba(118, 103, 255, .07); }
.dropzone-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 11px; border-radius: 14px; background: rgba(118, 103, 255, .12); color: var(--primary-2); font-size: 19px; }
.dropzone h3 { font-family: var(--font-display); font-size: 16px; }
.dropzone p { max-width: 520px; margin: 5px 0 15px; color: var(--text-muted); font-size: 13px; }

.file-card-wrap { margin-top: 12px; }
.file-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.file-card.is-error { border-color: rgba(255, 107, 131, .55); }
.file-card.is-ready { border-color: rgba(66, 211, 146, .5); }
.file-card-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: rgba(67, 217, 255, .1); color: var(--cyan); }
.file-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-card small { display: block; color: var(--text-muted); font-size: 12px; }
.file-status { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; font-weight: 700; }
.file-status.ready { color: var(--green); }
.file-status.error { color: var(--red); }
.file-status.working { color: var(--yellow); }
.file-card-actions { display: flex; gap: 5px; }

/* PASOS DEL RESUMEN */

.step-flow { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; }
.step-flow li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 100px; color: var(--text-muted); font-size: 12px; }
.step-flow li.active { border-color: var(--yellow); color: var(--yellow); }
.step-flow li.done { border-color: rgba(66, 211, 146, .5); color: var(--green); }
.step-flow li.failed { border-color: rgba(255, 107, 131, .6); color: var(--red); }

/* =========================================================
   VACÍO / CARGA
========================================================= */

.empty-state { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); padding: 10px; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 15px; background: rgba(118, 103, 255, .1); color: var(--primary-2); font-size: 19px; }
.empty-state h3 { margin: 0 0 5px; color: var(--text); font-family: var(--font-display); font-size: 16px; }
.empty-state p { max-width: 380px; margin: 0; font-size: 13px; }
.empty-state .btn { margin-top: 12px; }

.loading { display: inline-flex; align-items: center; gap: 8px; color: var(--text-soft); }
.loading-dots { display: flex; gap: 4px; }
.loading-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: loadingDot 1s infinite; }
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes loadingDot { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

/* =========================================================
   RESUMEN
========================================================= */

.summary-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.large-textarea { min-height: 220px; }
.summary-panel { min-height: 470px; }

/* =========================================================
   INVESTIGADOR
========================================================= */

.research-search { display: flex; gap: 9px; }
.search-input-wrap { flex: 1; position: relative; }
.search-input-wrap > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }
.search-input-wrap input { padding-left: 34px; }

.source-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; border: 0; }
.check-option { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-soft); font-size: 13px; cursor: pointer; }
.check-option:has(input:checked) { border-color: var(--primary); color: var(--text); background: rgba(118, 103, 255, .08); }

.research-status { margin-top: 14px; }
.research-results { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.research-card { padding: 16px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.research-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.research-card h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 15px; overflow-wrap: anywhere; }
.research-card p { margin: 0; color: var(--text-soft); font-size: 13px; line-height: 1.65; }
.research-meta { margin-top: 10px; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.research-card a.source-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--primary-2); text-decoration: none; font-size: 13px; font-weight: 700; }
.research-card a.source-link:hover { text-decoration: underline; }

.origin-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.origin-tag.external { background: rgba(66, 211, 146, .13); color: var(--green); }
.origin-tag.local { background: rgba(78, 159, 255, .13); color: var(--blue); }
.origin-tag.link { background: rgba(247, 201, 93, .13); color: var(--yellow); }

/* =========================================================
   TARJETAS
========================================================= */

.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.flashcard { min-height: 170px; perspective: 900px; cursor: pointer; position: relative; }
.flashcard:focus-visible { outline-offset: 4px; }
.flashcard-inner { width: 100%; height: 100%; min-height: 170px; position: relative; transition: transform .5s ease; transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face { position: absolute; inset: 0; padding: 17px; overflow: auto; border: 1px solid var(--border); border-radius: 15px; background: linear-gradient(145deg, var(--surface), var(--surface-2)); backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: var(--shadow-sm); }
.flashcard-back { transform: rotateY(180deg); background: linear-gradient(145deg, rgba(118, 103, 255, .14), var(--surface)); }
.flashcard-label { color: var(--primary-2); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.flashcard-text { margin-top: 10px; color: var(--text-soft); font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.flashcard-status { position: absolute; right: 12px; top: 12px; z-index: 2; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-muted); }
.flashcard-status.known { background: rgba(66, 211, 146, .15); color: var(--green); }
.flashcard-status.review { background: rgba(255, 107, 131, .15); color: var(--red); }
.flashcard-delete { position: absolute; right: 10px; bottom: 10px; z-index: 3; width: 28px; height: 28px; border-radius: 8px; color: var(--text-muted); background: var(--surface-3); opacity: 0; }
.flashcard:hover .flashcard-delete, .flashcard-delete:focus-visible { opacity: 1; }
.flashcard-delete:hover { color: var(--red); }

.study-viewer { display: flex; flex-direction: column; gap: 16px; }
.viewer-progress { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; font-size: 13px; font-weight: 700; }
.progress-bar { height: 8px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, var(--primary), var(--green)); transition: width .3s ease; }
.viewer-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.viewer-card-wrap .flashcard { max-width: 640px; margin: 0 auto; }
.viewer-card-wrap .flashcard, .viewer-card-wrap .flashcard-inner { min-height: 240px; }
.viewer-card-wrap .flashcard-text { font-size: 17px; }
.viewer-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* =========================================================
   DOCUMENTOS
========================================================= */

.documents-toolbar, .commands-toolbar { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr) 190px 170px; gap: 9px; padding: 11px; }
.commands-toolbar { grid-template-columns: minmax(0, 1fr) 190px 170px; }
.documents-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.document-card { padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: transform var(--transition), border-color var(--transition); }
.document-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.document-icon { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 11px; border-radius: 10px; background: rgba(67, 217, 255, .1); color: var(--cyan); }
.document-card h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); font-size: 14px; }
.document-card p { margin: 5px 0; color: var(--text-muted); font-size: 12px; }
.document-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* =========================================================
   LABORATORIO
========================================================= */

.sim-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 15px; border: 1px solid rgba(247, 201, 93, .4); border-radius: 12px; background: rgba(247, 201, 93, .08); flex-wrap: wrap; }
.sim-banner > i { color: var(--yellow); font-size: 20px; }
.sim-banner > div { flex: 1; min-width: 220px; }
.sim-banner strong { display: block; font-size: 14px; }
.sim-banner span { color: var(--text-soft); font-size: 13px; }

.lab-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.lab-explorer { min-height: 560px; }

.lab-toolbar { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.lab-search { position: relative; margin-bottom: 10px; }
.lab-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.lab-search input { padding-left: 32px; }

.lab-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 10px; padding: 7px 9px; border-radius: 9px; background: var(--bg-2); font-family: var(--font-mono); font-size: 12px; }
.lab-breadcrumb button { padding: 2px 6px; border-radius: 5px; color: var(--cyan); }
.lab-breadcrumb button:hover { background: var(--surface-3); }
.lab-breadcrumb span { color: var(--text-muted); }

.lab-list { display: flex; flex-direction: column; gap: 3px; max-height: 420px; overflow-y: auto; }
.lab-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; color: var(--text-soft); text-align: left; font-size: 13px; }
.lab-item:hover { background: var(--surface-2); color: var(--text); }
.lab-item.selected { background: rgba(118, 103, 255, .14); border-color: rgba(118, 103, 255, .4); color: var(--text); }
.lab-item i { color: var(--text-muted); text-align: center; }
.lab-item.directory i { color: var(--yellow); }
.lab-item .lab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); }
.lab-item small { color: var(--text-muted); font-size: 11px; }
.lab-hint { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; }

.terminal-panel { min-height: 560px; padding: 0; overflow: hidden; background: #060912; border-color: #1b2940; }
.terminal-header { min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 7px 11px; border-bottom: 1px solid #1b2940; background: #0b111d; }
.terminal-title { display: flex; align-items: center; gap: 6px; color: #9aa8bf; font-family: var(--font-mono); font-size: 12px; }
.terminal-tag { margin-left: 6px; padding: 1px 7px; border-radius: 5px; background: rgba(247, 201, 93, .15); color: #f7c95d; font-size: 10px; font-weight: 700; }
.terminal-dot { width: 9px; height: 9px; border-radius: 50%; }
.terminal-dot.red { background: #ff5f57; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #28c840; }
.terminal-output { height: 440px; padding: 14px; overflow-y: auto; color: #d0dbec; font-family: var(--font-mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal-line { margin-bottom: 4px; }
.terminal-line.command { color: #8ce7ff; }
.terminal-line.success { color: #7ce5b1; }
.terminal-line.error { color: #ff8ea1; }
.terminal-line.info { color: #f7c95d; }
.terminal-helper { display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-top: 1px solid #1b2940; }
.terminal-helper > span { color: #6ee7ff; font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.terminal-helper input { flex: 1; padding: 6px 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: #e5eefc; font-family: var(--font-mono); font-size: 13px; }
.terminal-helper input:focus { box-shadow: none; }
.terminal-helper input::placeholder { color: #55647c; }

/* =========================================================
   COMANDOS
========================================================= */

.command-category-grid { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; }
.command-category { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-soft); font-size: 13px; }
.command-category.active, .command-category:hover { border-color: var(--primary); color: var(--primary-2); }
.command-category.active { background: rgba(118, 103, 255, .1); font-weight: 700; }

.commands-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.command-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); transition: border-color var(--transition); min-width: 0; }
.command-card:hover { border-color: var(--border-strong); }
.command-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.command-card-head strong { font-family: var(--font-display); font-size: 15px; }
.command-card p { margin: 0; color: var(--text-soft); font-size: 13px; line-height: 1.6; }
.command-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.command-badge { padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-soft); font-size: 11px; font-weight: 700; }
.command-badge.easy { color: var(--green); }
.command-badge.medium { color: var(--yellow); }
.command-badge.hard { color: var(--red); }
.command-label { color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-bottom: -4px; }
.command-code { display: block; padding: 8px 10px; border-radius: 8px; background: #060912; color: #8ce7ff; font-family: var(--font-mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.command-code.output { color: #b9c6db; }
.command-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }

/* =========================================================
   CV
========================================================= */

.cv-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 8px; flex-wrap: wrap; }
.cv-toolbar > div:first-child { display: flex; flex-direction: column; }
.cv-toolbar strong { font-family: var(--font-display); font-size: 15px; }
.cv-toolbar span { color: var(--text-muted); font-size: 12px; }
.toolbar-right { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

.cv-layout { display: grid; grid-template-columns: 350px minmax(0, 1fr); gap: 14px; align-items: start; }
.cv-form { max-height: calc(100vh - 190px); overflow-y: auto; }

.cv-photo-editor { display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.cv-photo-preview { width: 68px; height: 68px; flex-shrink: 0; display: grid; place-items: center; overflow: hidden; border-radius: 13px; background: var(--surface-3); color: var(--text-muted); }
.cv-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.cv-photo-editor strong { display: block; font-size: 13px; }
.cv-photo-editor p { margin: 2px 0 7px; color: var(--text-muted); font-size: 12px; }

.color-input-wrap { display: flex; align-items: center; gap: 9px; }
.color-input-wrap input { width: 44px; height: 36px; }
.color-input-wrap span { color: var(--text-soft); font-family: var(--font-mono); font-size: 12px; }

.cv-preview-wrap { min-width: 0; padding: 20px; border-radius: 17px; overflow: hidden; background: repeating-linear-gradient(45deg, var(--bg-2), var(--bg-2) 10px, var(--bg-3) 10px, var(--bg-3) 20px); }
.cv-scaler { transform-origin: top left; width: 794px; }

.cv-paper {
    --cv-color: #6d5dfc; --cv-bg: #ffffff;
    width: 794px; min-height: 1123px; padding: 50px;
    background: var(--cv-bg); color: #1b2330;
    box-shadow: 0 20px 70px rgba(0, 0, 0, .25);
    font-family: Inter, Arial, sans-serif;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

.cv-paper-header { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 25px; align-items: center; padding-bottom: 24px; border-bottom: 3px solid var(--cv-color); }
.cv-paper-photo { width: 100px; height: 100px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #eef1f6; color: #8b96a8; }
.cv-paper-photo img { width: 100%; height: 100%; object-fit: cover; }
.cv-paper-header h1 { margin: 0; color: #101827; font-size: 32px; line-height: 1.15; }
.cv-paper-header h2 { margin: 5px 0 12px; color: var(--cv-color); font-size: 15px; font-weight: 600; }
.cv-contact { display: flex; flex-wrap: wrap; gap: 4px 14px; color: #566175; font-size: 11px; }

.cv-paper-body { padding-top: 24px; }
.cv-paper-body section { margin-bottom: 22px; }
.cv-paper-body h3 { margin: 0 0 7px; color: var(--cv-color); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.cv-paper-body p { margin: 0; color: #3f4958; font-size: 12px; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; }
.cv-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.cv-skill { padding: 4px 9px; border-radius: 6px; background: color-mix(in srgb, var(--cv-color) 14%, white); color: var(--cv-color); font-size: 11px; font-weight: 700; }

.cv-paper .is-placeholder { color: #9aa4b5; font-style: italic; }
.cv-paper .is-empty { display: none; }

/* Distribución: barra lateral */
.cv-paper.layout-sidebar .cv-paper-body { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 26px; }
.cv-paper.layout-sidebar .cv-col-side { order: 2; padding: 18px; border-radius: 10px; background: color-mix(in srgb, var(--cv-color) 8%, white); align-self: start; }

/* Distribución: cabecera de color */
.cv-paper.layout-band { padding: 0; }
.cv-paper.layout-band .cv-paper-header { padding: 40px 50px; border-bottom: 0; background: var(--cv-color); }
.cv-paper.layout-band .cv-paper-header h1, .cv-paper.layout-band .cv-paper-header h2, .cv-paper.layout-band .cv-contact { color: #fff; }
.cv-paper.layout-band .cv-paper-body { padding: 26px 50px 50px; }

/* =========================================================
   IMÁGENES
========================================================= */

.image-generator-layout { display: grid; grid-template-columns: minmax(310px, .7fr) minmax(0, 1.3fr); gap: 14px; align-items: start; }
.image-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.image-panel { min-height: 540px; display: flex; flex-direction: column; }
.image-result { flex: 1; min-height: 440px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.generated-image { width: 100%; max-height: 700px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); }
.image-panel .result-actions { margin: 14px 0 0; padding: 14px 0 0; border-bottom: 0; border-top: 1px solid var(--border); }

/* =========================================================
   AYUDA
========================================================= */

.help-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.help-card { padding: 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); }
.help-card > i { color: var(--primary-2); font-size: 20px; }
.help-card h3 { margin: 12px 0 5px; font-family: var(--font-display); font-size: 16px; }
.help-card p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.65; }

/* =========================================================
   AJUSTES Y LEGAL
========================================================= */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.setting-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.setting-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(118, 103, 255, .1); color: var(--primary-2); }
.setting-card strong { display: block; font-size: 14px; }
.setting-card p { margin: 3px 0 0; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 4px 9px; border-radius: 7px; background: var(--surface-3); color: var(--text-soft); font-size: 12px; font-weight: 700; }

.legal-links-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.legal-link-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) 16px; gap: 11px; align-items: center; padding: 15px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--text); text-align: left; transition: transform var(--transition), border-color var(--transition); }
.legal-link-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.legal-link-card > i:first-child { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: rgba(118, 103, 255, .1); color: var(--primary-2); }
.legal-link-card strong { display: block; font-size: 14px; }
.legal-link-card span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; }
.legal-link-card > i:last-child { color: var(--text-muted); }

/* =========================================================
   FOOTER
========================================================= */

.site-footer {
    display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 18px 40px;
    margin-top: 20px; padding: 26px 27px; border-top: 1px solid var(--border);
    background: var(--bg-2);
}
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand strong { font-family: var(--font-display); }
.footer-brand p { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; grid-row: span 2; }
.footer-links > strong { width: 100%; color: var(--text-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.footer-links button { padding: 4px 0; color: var(--text-soft); font-size: 13px; }
.footer-links button:hover { color: var(--primary-2); text-decoration: underline; }
.footer-note { margin: 0; color: var(--text-muted); font-size: 12px; max-width: 560px; }
.footer-copy { margin: 0; color: var(--text-muted); font-size: 12px; }

/* =========================================================
   MODALES
========================================================= */

.modal { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(2, 5, 11, .78); cursor: pointer; }
.modal-window { position: relative; width: min(700px, 100%); max-height: min(780px, 92vh); overflow-y: auto; padding: 22px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); animation: modalIn .18s ease both; }
html[data-theme="light"] .modal-overlay { background: rgba(20, 28, 45, .55); }

@keyframes modalIn { from { opacity: 0; transform: translateY(7px) scale(.99); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.modal-header h2 { margin: 3px 0 0; font-family: var(--font-display); font-size: 21px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions:empty { display: none; }
.small-print { margin: 12px 0 0; font-size: 12px; }
.search-modal { width: min(620px, 100%); }

.modal-search { position: relative; }
.modal-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.modal-search input { padding-left: 38px; font-size: 14px; }

.global-search-results { margin-top: 12px; display: flex; flex-direction: column; gap: 5px; max-height: 50vh; overflow-y: auto; }
.search-result-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px; border-radius: 10px; background: var(--surface-2); color: var(--text); text-align: left; transition: background var(--transition); }
.search-result-item:hover, .search-result-item:focus-visible { background: var(--surface-3); }
.search-result-item i { color: var(--primary-2); width: 18px; text-align: center; }
.search-result-item strong { display: block; font-size: 14px; }
.search-result-item span { display: block; color: var(--text-muted); font-size: 12px; }

.legal-modal { width: min(820px, 100%); }
.legal-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.legal-tab { padding: 8px 13px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.legal-tab.active { border-color: var(--primary); color: var(--text); background: rgba(118, 103, 255, .12); }

.legal-content { color: var(--text-soft); font-size: 14px; line-height: 1.75; }
.legal-content h3 { margin: 22px 0 7px; color: var(--text); font-family: var(--font-display); font-size: 16px; }
.legal-content h3:first-child { margin-top: 0; }
.legal-content p { margin: 0 0 10px; }
.legal-content ul { padding-left: 20px; margin: 0 0 10px; }
.legal-content li { margin-bottom: 5px; }
.legal-updated { margin-bottom: 14px; color: var(--text-muted); font-size: 12px; }
.legal-todo { padding: 1px 6px; border-radius: 5px; background: rgba(247, 201, 93, .18); color: var(--yellow); font-weight: 700; font-size: 12px; }
.legal-table-wrap { overflow-x: auto; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; }
.legal-table-wrap table { min-width: 620px; }

.cookie-categories { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.cookie-cat { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.cookie-cat strong { display: block; margin-bottom: 3px; font-size: 14px; }
.cookie-cat p { margin: 0; color: var(--text-muted); font-size: 12.5px; line-height: 1.55; }

.switch { display: inline-flex; align-items: center; gap: 9px; flex-shrink: 0; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-ui { width: 42px; height: 24px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background var(--transition); }
.switch-ui::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); transition: transform var(--transition), background var(--transition); }
.switch input:checked + .switch-ui { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); background: #fff; }
.switch input:disabled + .switch-ui { opacity: .7; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--cyan); outline-offset: 2px; }
.switch-text { min-width: 92px; color: var(--text-soft); font-size: 12px; font-weight: 600; }

.check-line { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px; cursor: pointer; }
.check-line input { margin-top: 3px; }

.prop-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.prop-list dt { color: var(--text-muted); }
.prop-list dd { margin: 0; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 13px; }

/* =========================================================
   COOKIE BANNER
========================================================= */

.cookie-banner {
    position: fixed; left: 20px; right: 20px; bottom: 20px; z-index: 700;
    display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center;
    max-width: 1100px; margin: 0 auto; padding: 16px;
    border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface);
    box-shadow: var(--shadow-lg); animation: cookieIn .25s ease both;
}
.cookie-banner.hidden { display: none; }
@keyframes cookieIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.cookie-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(247, 201, 93, .12); color: var(--yellow); font-size: 18px; }
.cookie-copy strong { display: block; font-family: var(--font-display); font-size: 14px; }
.cookie-copy p { margin: 3px 0 0; color: var(--text-muted); font-size: 12.5px; line-height: 1.55; }
.cookie-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

/* =========================================================
   TOASTS
========================================================= */

.toast-container { position: fixed; right: 18px; bottom: 18px; z-index: 800; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { min-width: 250px; max-width: 400px; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); pointer-events: auto; animation: toastIn .2s ease both, toastOut .25s ease 4s forwards; }
.toast-icon { width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center; border-radius: 7px; background: rgba(118, 103, 255, .12); color: var(--primary-2); font-size: 11px; }
.toast strong { display: block; font-size: 13px; }
.toast span { display: block; margin-top: 2px; color: var(--text-soft); font-size: 12.5px; }
.toast.success .toast-icon { color: var(--green); background: rgba(66, 211, 146, .12); }
.toast.error .toast-icon { color: var(--red); background: rgba(255, 107, 131, .12); }
.toast.warning .toast-icon { color: var(--yellow); background: rgba(247, 201, 93, .12); }

@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* =========================================================
   TABLAS
========================================================= */

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--text-soft); font-size: 12px; }
td { color: var(--text-soft); font-size: 13px; }
tr:last-child td { border-bottom: 0; }

/* =========================================================
   UTILIDADES
========================================================= */

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 16px; }

/* =========================================================
   FOCO
========================================================= */

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--cyan); outline-offset: 2px;
}
.composer textarea:focus-visible, .terminal-helper input:focus-visible { outline: 0; }

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1200px) {
    :root { --sidebar-width: 240px; }
    .lab-layout, .summary-layout { grid-template-columns: 1fr; }
    .commands-grid, .documents-grid, .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .content { padding: 22px; }
    .hero-card { grid-template-columns: 1fr; padding: 35px; }
    .hero-visual { min-height: 280px; }
    .feature-grid, .stats-grid, .help-grid, .legal-links-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .keo-workspace { grid-template-columns: 210px minmax(0, 1fr); }
    .study-layout { grid-template-columns: 190px minmax(0, 1fr); }
    .cv-layout { grid-template-columns: 1fr; }
    .cv-form { max-height: none; }
    .image-generator-layout { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
    :root { --sidebar-width: 0px; }

    .sidebar { width: min(300px, 88vw); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(2, 5, 11, .6); }
    .sidebar-overlay.show { display: block; }

    .main { width: 100%; margin-left: 0; }
    .mobile-menu-btn { display: inline-grid; }
    .topbar { padding: 10px 15px; }
    .global-search-button { min-width: 0; }
    .global-search-button span, .global-search-button kbd { display: none; }
    .content { padding: 16px; }

    .hero-card { padding: 27px 21px; border-radius: 21px; }
    .hero-card h2 { font-size: 42px; }
    .hero-visual { min-height: 250px; }
    .hero-core { width: 230px; height: 230px; }
    .hero-orbit { width: 210px; height: 210px; }
    .orbit-two { display: none; }

    .feature-grid, .stats-grid, .help-grid, .settings-grid, .legal-links-grid, .study-layout, .two-column, .image-options { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .study-subjects { position: static; }
    .subject-list { flex-direction: row; flex-wrap: wrap; }
    .subject-button { width: auto; }
    .study-controls { grid-template-columns: 1fr; }

    .keo-workspace { grid-template-columns: 1fr; height: auto; min-height: 0; }
    .keo-side-panel { max-height: 210px; border-right: 0; border-bottom: 1px solid var(--border); }
    .chat-messages { height: 55vh; flex: none; padding: 15px; }
    .message-stack { max-width: 90%; }

    .research-search { flex-direction: column; }
    .research-results, .cards-grid, .documents-grid, .commands-grid { grid-template-columns: 1fr; }
    .documents-toolbar, .commands-toolbar { grid-template-columns: 1fr; }

    .setting-card { grid-template-columns: 44px minmax(0, 1fr); }
    .setting-card > .btn { grid-column: 2; justify-self: start; }

    .viewer-stage { grid-template-columns: 1fr; }
    .viewer-stage > .icon-btn { display: none; }
    .viewer-progress { grid-template-columns: 1fr; gap: 6px; }

    .cv-preview-wrap { padding: 8px; }

    .site-footer { grid-template-columns: 1fr; padding: 22px 16px; }
    .footer-links { grid-row: auto; }

    .cookie-banner { grid-template-columns: 44px 1fr; left: 10px; right: 10px; bottom: 10px; max-height: 80vh; overflow-y: auto; }
    .cookie-actions { grid-column: 1 / -1; justify-content: stretch; }
    .cookie-actions .btn { flex: 1; }
    .cookie-cat { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .content { padding: 11px; }
    .topbar { min-height: 60px; }
    .topbar h1 { font-size: 17px; }
    .language-button span { display: none; }
    .hero-card { padding: 23px 17px; }
    .hero-card h2 { font-size: 34px; }
    .hero-copy > p { font-size: 14px; }
    .hero-actions { flex-direction: column; }
    .hero-actions button { width: 100%; }
    .hero-core { width: 205px; height: 205px; }
    .hero-orbit { width: 175px; height: 175px; }
    .panel, .card { padding: 15px; }
    .toolbar, .cv-toolbar { align-items: flex-start; flex-direction: column; }
    .toolbar-right { width: 100%; }
    .toolbar-right .btn { flex: 1; }
    .message-stack { max-width: 94%; }
    .composer-tools { display: none; }
    .toast { min-width: 0; width: calc(100vw - 30px); }
    .form-grid { grid-template-columns: 1fr; }
    .file-card { grid-template-columns: 38px minmax(0, 1fr); }
    .file-card-actions { grid-column: 1 / -1; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   MOVIMIENTO REDUCIDO
========================================================= */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* =========================================================
   IMPRESIÓN (CV → PDF)
========================================================= */

@page { size: A4; margin: 0; }

@media print {
    html, body { background: #fff !important; }

    .sidebar, .sidebar-overlay, .topbar, .site-footer, .cookie-banner, .toast-container, .modal,
    #particles, .ambient, .skip-link, .cv-toolbar, .page-intro, .cv-form, .ai-notice-line { display: none !important; }

    .main { margin: 0 !important; display: block; }
    .content { padding: 0 !important; max-width: none; }

    .page { display: none !important; }
    #page-cv { display: block !important; animation: none; }

    .cv-layout { display: block; }
    .cv-preview-wrap { padding: 0; background: none; overflow: visible; }
    .cv-scaler { transform: none !important; width: auto !important; height: auto !important; }

    #cvPaper {
        width: 210mm; min-height: 297mm; margin: 0; box-shadow: none;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }

    #cvPaper .is-placeholder { display: none; }
}

/* =========================================================
   CUENTA · CARGA · ACCESO (Firebase Authentication)
========================================================= */

body.auth-pending .app-shell,
body.auth-pending .sidebar-overlay { display: none !important; }

/* ---------- Pantalla de carga ---------- */
.app-loader {
    position: fixed; inset: 0; z-index: 450; display: grid; place-items: center;
    padding: 20px; background: var(--bg);
}
.loader-card { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.loader-card .brand-logo { width: 56px; height: 56px; border-radius: 18px; font-size: 25px; }
.loader-spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--primary);
    animation: keoSpin .8s linear infinite;
}
.loader-text { margin: 0; color: var(--text-soft); font-size: 14px; }
.loader-error {
    width: 100%; padding: 15px; text-align: left;
    border: 1px solid rgba(255, 107, 131, .38); border-radius: var(--radius-sm);
    background: rgba(255, 107, 131, .07);
}
.loader-error p { margin: 0 0 13px; color: var(--text-soft); font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.loader-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@keyframes keoSpin { to { transform: rotate(360deg); } }
@keyframes keoPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Pantalla de acceso ---------- */
.auth-screen {
    position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column;
    overflow-y: auto; padding: 0 clamp(16px, 4vw, 48px);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 6px; }
.auth-top .brand { padding: 0; }
.auth-top-actions { display: flex; gap: 7px; }

.auth-body {
    flex: 1; width: 100%; max-width: 1080px; margin: 0 auto;
    display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, 440px);
    gap: clamp(28px, 6vw, 72px); align-items: center; padding: 18px 0 30px;
}

.auth-intro h1 {
    margin: 0 0 14px; font-family: var(--font-display);
    font-size: clamp(30px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -.02em;
}
.auth-intro > p { margin: 0 0 28px; max-width: 520px; color: var(--text-soft); font-size: 16px; line-height: 1.7; }

.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.auth-points li { display: flex; align-items: flex-start; gap: 14px; }
.auth-points li > i {
    width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: 12px; background: rgba(118, 103, 255, .12); color: var(--primary-2);
}
.auth-points strong { display: block; font-size: 14px; }
.auth-points span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 13px; line-height: 1.55; }

.auth-card { padding: 26px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }

.auth-tabs {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 18px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2);
}
.auth-tab {
    padding: 9px 10px; border-radius: 9px; background: transparent; color: var(--text-muted);
    font-size: 13px; font-weight: 700; transition: background var(--transition), color var(--transition);
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

.auth-form { display: flex; flex-direction: column; }
.auth-form .field { margin-bottom: 14px; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }
.password-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; display: grid; place-items: center;
    border-radius: 8px; background: transparent; color: var(--text-muted);
}
.password-toggle:hover { background: var(--surface-3); color: var(--text); }

.field-hint { color: var(--text-muted); font-size: 12px; }
.model-note { display: flex; align-items: center; gap: 7px; margin: 2px 0 0; }
.model-note i { color: var(--primary-2); }

.auth-forgot { align-self: flex-start; margin: -2px 0 16px; font-size: 13px; }
.auth-note { margin: 0 0 14px; color: var(--text-soft); font-size: 13px; line-height: 1.65; }

.check-row { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0 16px; color: var(--text-soft); font-size: 13px; line-height: 1.6; cursor: pointer; }
.check-row input { margin-top: 4px; flex-shrink: 0; }

.auth-message { margin-top: 14px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; line-height: 1.6; color: var(--text); }
.auth-message.error { border-color: rgba(255, 107, 131, .42); background: rgba(255, 107, 131, .08); }
.auth-message.success { border-color: rgba(66, 211, 146, .42); background: rgba(66, 211, 146, .08); }
.auth-message.info { border-color: rgba(67, 217, 255, .35); background: rgba(67, 217, 255, .07); }

.btn-google { background: #ffffff; color: #1f2937; border-color: #dadce0; gap: 10px; }
.btn-google:hover:not(:disabled) { background: #f5f6f8; border-color: #c4c7cc; }

.auth-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0 18px; color: var(--text-muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.auth-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; padding: 14px 0 22px; }
.auth-footer button { padding: 4px 0; background: none; color: var(--text-muted); font-size: 12px; }
.auth-footer button:hover { color: var(--text); text-decoration: underline; }

/* ---------- Avatar (Google, foto propia o inicial) ---------- */
.avatar {
    width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; overflow: hidden;
    border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--cyan));
    color: #fff; font-family: var(--font-display); font-size: 14px; font-weight: 700;
    text-transform: uppercase; user-select: none;
}
.avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-lg { width: 76px; height: 76px; font-size: 28px; }

.topbar-avatar {
    padding: 0; line-height: 0; border: 2px solid var(--border); border-radius: 50%;
    background: transparent; transition: border-color var(--transition), transform var(--transition);
}
.topbar-avatar:hover { border-color: var(--primary); transform: translateY(-1px); }
.topbar-avatar .avatar { width: 34px; height: 34px; font-size: 13px; }

/* ---------- Tarjeta de cuenta (sidebar) ---------- */
.account-card {
    display: flex; align-items: center; gap: 10px; padding: 9px;
    border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.account-info { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.account-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 11px; }

.sync-line { display: flex; align-items: center; gap: 8px; margin: 9px 0 6px; padding: 0 5px; color: var(--text-muted); font-size: 11.5px; }
.sync-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: var(--green); }
.sync-dot.busy { background: var(--yellow); animation: keoPulse 1.2s ease-in-out infinite; }
.sync-dot.bad { background: var(--red); }

/* ---------- Ajustes: perfil ---------- */
.section-heading.first { margin-top: 4px; }

.profile-card { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 12px; }
.profile-main { min-width: 0; flex: 1 1 230px; display: flex; flex-direction: column; gap: 3px; }
.profile-main strong { font-family: var(--font-display); font-size: 18px; overflow-wrap: anywhere; }
.profile-main > span { color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.profile-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profile-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
    background: rgba(118, 103, 255, .13); color: var(--primary-2); font-size: 11.5px; font-weight: 700;
}
.profile-chip.subtle { background: var(--surface-3); color: var(--text-muted); font-weight: 600; }
.profile-chip:empty { display: none; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.setting-icon.danger { background: rgba(255, 107, 131, .12); color: var(--red); }

/* ---------- Corrector / taller de texto ---------- */
.text-tool { margin-bottom: 16px; }
.tool-intro { margin: -4px 0 14px; color: var(--text-muted); font-size: 13px; line-height: 1.65; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-result {
    margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-2); color: var(--text-soft); font-size: 14px; line-height: 1.75; overflow-wrap: anywhere;
}
.tool-result h3, .tool-result h4 { font-family: var(--font-display); color: var(--text); }

/* ---------- Generador visual (FLUX.2 Pro) ---------- */
.image-figure { width: 100%; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.image-meta { margin: 0; color: var(--text-muted); font-size: 12px; text-align: center; }

/* ---------- Responsive de las pantallas nuevas ---------- */
@media (max-width: 860px) {
    .auth-body { grid-template-columns: 1fr; gap: 22px; padding-top: 8px; }
    .auth-card { order: -1; padding: 20px; }
    .auth-intro > p { margin-bottom: 0; font-size: 15px; }
    .auth-points { display: none; }
    .profile-card { gap: 14px; }
    .profile-actions { width: 100%; }
    .profile-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
    .auth-card { padding: 16px; border-radius: var(--radius-md); }
    .avatar-lg { width: 64px; height: 64px; font-size: 24px; }
}