/* ═══════════════════════════════════════════════════
   SPACE LAB — SESIONES EDUCATIVAS
   Design System: Minimalist Dark Document-First Editor
   Fuente de verdad: design-system/space-lab-sesiones/MASTER.md
   ═══════════════════════════════════════════════════ */

:root {
    /* ════════════════════════════════════════════
       SPACE LAB — GRAPHITE DESIGN SYSTEM TOKENS
       Jerarquía de 4 niveles por luminosidad.
       Cyan (#22BEEB) + Muted Violet (#8A7CF6 <5%)
       ════════════════════════════════════════════ */

    /* ── Nivel 0: Workspace Canvas */
    --color-background:   #080B0F;

    /* ── Nivel 1: Container Shell (Topbar & Sidebar) */
    --color-card:         #141A23;

    /* ── Nivel 2: Surfaces, Cards, Modales */
    --color-card-surface: #1E2834;

    /* ── Nivel 3: Inputs, Selects, Buttons Secundarios */
    --color-muted:        #1E2834;
    --color-elevated:     #2A3949;
    --color-popover:      #3A4E61;

    /* ── Tipografía & Textos (Zinc Neutro & Legible) */
    --color-foreground:         #F4F4F6;
    --color-muted-foreground:   #B2BBC8;
    --color-subtle-foreground:  #758192;
    --color-label:              #B2BBC8;

    /* ── Bordes (Sutiles y equilibrados) */
    --color-border-subtle: #26313D;
    --color-border:        #384758;
    --color-border-hover:  #5A7086;
    --color-border-focus:  #22BEEB;

    /* ── Accent Primario: Cyan Space Lab (~95%) ── */
    --color-primary:        #2CC8EE;
    --color-primary-hover:  #54D4F3;
    --color-primary-dim:    rgba(44, 200, 238, 0.10);
    --color-primary-ring:   rgba(44, 200, 238, 0.16);
    --color-accent:         #2CC8EE;
    --color-accent-hover:   #54D4F3;
    --color-ring:           #2CC8EE;

    /* ── Accent Secundario: Muted Violet (<5%) ── */
    --color-violet:        #F2B84B;
    --color-violet-dim:    rgba(242, 184, 75, 0.09);
    --color-violet-border: rgba(242, 184, 75, 0.25);

    /* ── Semánticos estrictos */
    --color-success:     #22c55e;
    --color-warning:     #f59e0b;
    --color-destructive: #ef4444;

    /* Acentos funcionales: identidad por tarea, no decoración genérica. */
    --color-step-cyan:    #2CC8EE;
    --color-step-blue:    #6CA8FF;
    --color-step-amber:   #F5B942;
    --color-step-green:   #38D99F;
    --color-step-coral:   #FF7B72;
    --surface-cyan:       #12303A;
    --surface-blue:       #182B46;
    --surface-amber:      #352A16;
    --surface-green:      #12342C;
    --surface-coral:      #392126;

    /* ── Sombras de profundidad real */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.40);
    --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.48);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.68);
    --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.03);
    --glow-cyan: 0 0 16px rgba(34, 190, 235, 0.28);

    /* ── Microanimaciones (curva de aceleración fina) */
    --ease-out: 150ms cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in:  100ms ease-in;

    /* ── Compatibilidad con scripts y componentes */
    --bg-deep:       var(--color-background);
    --bg-primary:    var(--color-card);
    --bg-secondary:  var(--color-card-surface);
    --bg-elevated:   var(--color-elevated);
    --bg-card:       var(--color-card);
    --bg-card-hover: var(--color-card-surface);
    --text-primary:   var(--color-foreground);
    --text-secondary: var(--color-muted-foreground);
    --text-muted:     var(--color-subtle-foreground);
    --text-accent:    var(--color-accent);
    --border:         var(--color-border);
    --border-hover:   var(--color-border-hover);
    --border-accent:  rgba(34, 190, 235, 0.22);

    /* ── Tipografía */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* ── Layout */
    --header-h: 64px;
    --rail-w: 68px;
    --rail-expanded-w: 188px;
    --sidebar-w: 372px;
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* ════════════════════════════════════════════
       OVERRIDES DE TOKENS LEGACY (style.css)
       ════════════════════════════════════════════ */
    --accent:        #22BEEB;
    --accent-dark:   #12AEDC;
    --accent-glow:   rgba(34, 190, 235, 0.18);
    --accent-2:      #8A7CF6;
    --accent-2-glow: rgba(138, 124, 246, 0.12);
    --bg-deep:      var(--color-background);
    --bg-primary:   var(--color-card);
    --bg-secondary: var(--color-card-surface);
    --bg-elevated:  var(--color-elevated);
    --bg-card:      var(--color-card);
    --bg-card-hover:var(--color-card-surface);
    --text-primary:   #F4F4F6;
    --text-secondary: var(--color-muted-foreground);
    --text-muted:     #8390A0;
    --glass-bg:     rgba(20, 26, 35, 0.96);
    --glass-border: rgba(144, 174, 201, 0.10);
    --glass-blur:   16px;

    /* Bordes legacy → neutral */
    --border:        #2E3A47;
    --border-hover:  #435365;
    --border-accent: rgba(25, 188, 235, 0.22);

    /* Estados legacy */
    --success-bg:  rgba(34, 197, 94, 0.10);
    --warning-bg:  rgba(245, 158, 11, 0.10);
    --danger-bg:   rgba(239, 68, 68, 0.10);

    /* Shadow glow → sin cyan bloom */
    --shadow-glow: 0 0 16px rgba(25, 188, 235, 0.12);
}

/* ─── RESET Y BASE DE CONTENCIÓN 100VH ─── */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
    background-color: var(--color-background) !important;
    color: var(--color-foreground) !important;
    font-family: var(--font) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.ui-icon-sprite {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.space-background { display: none !important; }

/* Scrollbars minimalistas */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2A2A2E; border-radius: 6px; transition: background 140ms ease; }
::-webkit-scrollbar-thumb:hover { background: #3A3A40; }

/* Iconos vectoriales consistentes */
.ui-icon {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Skip link de accesibilidad */
.skip-link {
    position: fixed;
    z-index: 10000;
    top: 6px;
    left: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: #0B0B0C;
    font-weight: 600;
    font-size: 0.76rem;
    transform: translateY(-150%);
    transition: transform 140ms ease;
}
.skip-link:focus { transform: translateY(0); }

/* Enfoque visible */
*:focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: 1px;
}

/* ═══════════════════════════════════════════════════
   ESTRUCTURA PRINCIPAL (APP WRAPPER)
   ═══════════════════════════════════════════════════ */
.app-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-background);
}

/* ─── TOPBAR COMPACTA ─── */
.app-header {
    height: var(--header-h);
    min-height: var(--header-h);
    padding: 0 20px;
    background: #181F29;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.header-leading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 9px;
}

.header-context {
    min-width: 0;
    padding-left: 20px;
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.header-context-label {
    color: var(--color-subtle-foreground);
    font-size: 0.64rem;
    font-weight: 650;
    text-transform: uppercase;
}

.header-context-title {
    max-width: 260px;
    overflow: hidden;
    color: var(--color-foreground);
    font-size: 0.78rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-icon {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-xs);
    background: var(--color-card-surface);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-img { width: 16px; height: 16px; }

.brand-title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.1;
    /* Neutraliza gradiente cyan+purple de style.css */
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: var(--color-foreground) !important;
    background-clip: initial !important;
    color: var(--color-foreground) !important;
    letter-spacing: -0.01em;
}

.brand-subtitle {
    margin-top: 1px;
    color: var(--color-subtle-foreground);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Indicador de guardado */
.save-indicator {
    position: static;
    height: 30px;
    padding: 0 10px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--color-muted-foreground);
    font-size: 0.72rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transform: none;
}

.save-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
}

.save-indicator.unsaved .save-dot { background: var(--color-warning); }

/* ─── BOTONES Y ACCIONES ─── */
.btn {
    min-height: 34px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-elevated);
    box-shadow: var(--shadow-inset);
    color: var(--color-muted-foreground);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: background var(--ease-out), border-color var(--ease-out), color var(--ease-out), box-shadow var(--ease-out);
}

.btn:hover {
    background: var(--color-popover);
    border-color: var(--color-border-hover);
    color: var(--color-foreground);
    box-shadow: var(--shadow-sm);
}

.btn:active { transform: scale(0.98); }

.btn-icon {
    min-width: 34px;
    padding: 0 8px;
}

.btn-sm {
    min-height: 30px;
    height: 30px;
    padding: 0 9px;
    font-size: 0.72rem;
}

.btn-primary {
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    color: #08090C;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 0 0 0 rgba(34, 190, 235, 0), var(--shadow-xs);
    transition: background var(--ease-out), box-shadow var(--ease-out), border-color var(--ease-out);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: #08090C;
    box-shadow: var(--shadow-sm);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-muted-foreground);
}

.btn-ghost:hover {
    background: var(--color-card-surface);
    border-color: var(--color-border);
    color: var(--color-foreground);
}

/* PDF y Word usan el estilo neutro estándar */
.btn-pdf,
.btn-word {
    background: var(--color-card-surface);
    border-color: var(--color-border);
    color: var(--color-muted-foreground);
}
.btn-pdf:hover,
.btn-word:hover {
    background: var(--color-elevated);
    border-color: var(--color-border-hover);
    color: var(--color-foreground);
}

.btn-connected,
.btn-connected:hover {
    background: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.25) !important;
    color: #34d399 !important;
}

/* ═══════════════════════════════════════════════════
   WORKSPACE (APP-MAIN)
   ═══════════════════════════════════════════════════ */
.app-main {
    flex: 1;
    height: calc(100vh - var(--header-h));
    display: flex;
    overflow: hidden;
    background: var(--color-background);
}

#btn-close-sidebar {
    display: inline-flex !important;
}

#btn-menu-mobile {
    display: none !important;
}

.workflow-rail {
    position: fixed;
    inset: var(--header-h) auto 0 0;
    z-index: 1003;
    width: var(--rail-w);
    overflow: hidden;
    background: #10161E;
    border-right: 1px solid var(--color-border);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.26);
    transition: width 180ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 180ms ease;
}

.workflow-rail.expanded,
.workflow-rail:hover {
    width: var(--rail-expanded-w);
    box-shadow: 16px 0 38px rgba(0, 0, 0, 0.46);
}

body.sidebar-open .workflow-rail { width: var(--rail-w); }

.workflow-rail-brand {
    width: 100%;
    height: 66px;
    padding: 0 14px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    color: var(--color-foreground);
    background: #151E28;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    cursor: pointer;
}

.workflow-rail-brand > .ui-icon {
    width: 36px;
    height: 36px;
    padding: 9px;
    box-sizing: border-box;
    border-radius: var(--radius-sm);
    color: var(--color-muted-foreground);
    background: var(--color-card-surface);
    border: 1px solid var(--color-border);
}

.workflow-rail-brand span,
.workflow-rail .tab-copy {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity 120ms ease, transform 180ms ease, visibility 120ms;
}

.workflow-rail.expanded .workflow-rail-brand span,
.workflow-rail:hover .workflow-rail-brand span,
.workflow-rail.expanded .tab-copy,
.workflow-rail:hover .tab-copy {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

body.sidebar-open .workflow-rail-brand span,
body.sidebar-open .workflow-rail .tab-copy {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateX(-6px) !important;
}

/* ─── SIDEBAR / INSPECTOR LATERAL ─── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    max-width: var(--sidebar-w);
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: var(--rail-w);
    z-index: 1002;
    height: auto;
    overflow: hidden;
    padding: 0;
    background: var(--color-card);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 0;
    transform: translateX(-100%);
    transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.open { transform: translateX(0); }

body.sidebar-open .sidebar {
    box-shadow: 100vw 0 0 100vw rgba(3, 6, 10, 0.68), var(--shadow-lg);
}

body.sidebar-open .chatbot-container { display: none !important; }

.sidebar-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1px;
    min-height: 76px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    box-sizing: border-box;
    justify-content: center;
}

.sidebar-workflow {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
}

.sidebar-eyebrow {
    color: var(--color-accent);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar-title {
    color: var(--color-foreground);
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Tabs de navegación */
.sidebar-tabs {
    grid-row: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 8px;
    background: transparent;
    border: 0;
    border-right: 0;
    border-radius: 0;
}

.sidebar-tab {
    --step-color: var(--color-primary);
    --step-tint: rgba(44, 200, 238, 0.12);
    position: relative;
    width: 100%;
    min-height: 56px;
    padding: 7px 9px;
    color: var(--color-subtle-foreground);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    transition: color var(--ease-out), background var(--ease-out);
}

.sidebar-tab:nth-child(2) { --step-color: var(--color-step-blue); --step-tint: var(--surface-blue); }
.sidebar-tab:nth-child(3) { --step-color: var(--color-step-amber); --step-tint: var(--surface-amber); }
.sidebar-tab:nth-child(4) { --step-color: var(--color-step-green); --step-tint: var(--surface-green); }
.sidebar-tab:nth-child(5) { --step-color: var(--color-step-coral); --step-tint: var(--surface-coral); }
.sidebar-tab:nth-child(6) { --step-color: var(--color-step-cyan); --step-tint: var(--surface-cyan); }

.sidebar-tab::before {
    content: '';
    position: absolute;
    inset: 8px auto 8px -8px;
    width: 3px;
    border-radius: 2px;
    background: transparent;
}

.sidebar-tab .tab-step {
    display: none;
}

.sidebar-tab .tab-icon {
    display: block;
    width: 18px;
    height: 18px;
    padding: 9px;
    box-sizing: content-box;
    color: var(--step-color);
    background: var(--step-tint);
    border: 1px solid color-mix(in srgb, var(--step-color) 34%, transparent);
    border-radius: var(--radius-sm);
}

.sidebar-tab .tab-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-tab .tab-text {
    color: var(--color-muted-foreground);
    font-size: 0.72rem;
    font-weight: 650;
    white-space: nowrap;
}

.sidebar-tab .tab-state {
    color: var(--color-subtle-foreground);
    font-size: 0.6rem;
    font-weight: 500;
}

.sidebar-tab:hover {
    color: var(--color-foreground);
    background: var(--step-tint);
}

.sidebar-tab.active {
    background: var(--step-tint) !important;
    border-color: color-mix(in srgb, var(--step-color) 58%, var(--color-border)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), var(--shadow-sm) !important;
    color: var(--color-foreground);
}

.sidebar-tab.active::before { background: var(--step-color); }
.sidebar-tab.active .tab-icon { box-shadow: 0 0 18px color-mix(in srgb, var(--step-color) 24%, transparent); }
.sidebar-tab.active .tab-text { color: var(--color-foreground); }
.sidebar-tab.active .tab-state { color: var(--step-color); }

.sidebar-tab.completed .tab-step {
    border-color: rgba(34, 197, 94, 0.38);
    color: var(--color-success);
}

.sidebar-tab.completed .tab-state { color: var(--color-success); }

.session-form {
    grid-column: 1;
    min-width: 0;
    min-height: 0;
    padding: 18px 20px 26px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    background: #171E27;
}

.inspector-heading {
    margin: -18px -20px 18px;
    padding: 18px 20px 16px;
    background: color-mix(in srgb, var(--step-accent, var(--color-primary)) 22%, var(--color-card-surface));
    border-left: 3px solid var(--step-accent, var(--color-primary));
    border-bottom: 1px solid var(--color-border);
}

.sidebar[data-active-tab="tab-ai"] { --step-accent: var(--color-step-cyan); }
.sidebar[data-active-tab="tab-general"] { --step-accent: var(--color-step-blue); }
.sidebar[data-active-tab="tab-propositos"] { --step-accent: var(--color-step-amber); }
.sidebar[data-active-tab="tab-design"] { --step-accent: var(--color-step-green); }
.sidebar[data-active-tab="tab-alumnos"] { --step-accent: var(--color-step-coral); }

.inspector-step {
    color: var(--step-accent, var(--color-accent));
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
}

.inspector-heading h3 {
    margin: 4px 0 5px;
    color: var(--color-foreground);
    font-size: 1rem;
    font-weight: 700;
}

.inspector-heading p {
    margin: 0;
    color: var(--color-muted-foreground);
    font-size: 0.72rem;
    line-height: 1.45;
}

/* Formulario */
.tab-pane {
    display: none;
    flex-direction: column;
    gap: 9px;
}

.tab-pane.active {
    display: flex;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.form-label {
    color: var(--color-label);
    font-size: 0.71rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.optional-label {
    margin-left: auto;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--color-card-surface);
    border: 1px solid var(--color-border);
    color: var(--color-subtle-foreground);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    min-height: 32px;
    height: 32px;
    padding: 5px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-elevated);
    color: var(--color-foreground);
    font-family: inherit;
    font-size: 0.78rem;
    box-sizing: border-box;
    transition: background var(--ease-out), border-color var(--ease-out), box-shadow var(--ease-out), color var(--ease-out);
}

.form-textarea {
    min-height: 64px;
    height: auto;
    line-height: 1.45;
    resize: vertical;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    background-color: var(--color-popover);
    border-color: var(--color-border-hover);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-border-focus);
    background-color: var(--color-popover);
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-subtle-foreground);
    font-weight: 400;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A6A6B4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 11px;
    padding-right: 26px;
    cursor: pointer;
}

.form-select option {
    background: var(--color-card);
    color: var(--color-foreground);
}

/* Insignia de Capacidades de Modelos de IA / Panel AI */
.model-capabilities-badge,
.ai-panel {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-top: 2px;
    border-radius: var(--radius-sm);
    background: var(--color-elevated);
    border: 1px solid rgba(34, 190, 235, 0.18);
    color: var(--color-muted-foreground);
    font-size: 0.7rem;
    line-height: 1.35;
}

.ai-model-card {
    margin-bottom: 8px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #222D3A;
    box-shadow: var(--shadow-md), var(--shadow-inset);
}

.ai-model-header {
    margin-bottom: 7px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.ai-model-header > div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ai-model-eyebrow {
    color: var(--color-accent);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
}

.ai-model-header strong { font-size: 0.8rem; }

.ai-model-status {
    color: var(--color-muted-foreground);
    font-size: 0.62rem;
    white-space: nowrap;
}

.ai-model-status > span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-radius: 50%;
    background: var(--color-success);
}

.model-capabilities-badge.badge-no-files {
    background: var(--color-card-surface);
    border-color: rgba(245, 158, 11, 0.20);
    color: var(--color-warning);
}

.model-capabilities-badge .badge-icon {
    font-size: 0.85rem;
    color: var(--color-accent);
    flex: 0 0 auto;
}

/* Dropzone de Archivo */
.source-file-dropzone {
    min-height: 68px;
    padding: 8px;
    background: var(--color-card-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-muted-foreground);
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    transition: background var(--ease-out), border-color var(--ease-out);
}

.source-file-dropzone:hover,
.source-file-dropzone.dragover {
    background: var(--color-elevated);
    border-color: var(--color-primary);
    color: var(--color-foreground);
}

.source-file-dropzone.disabled-dropzone {
    border-color: rgba(245, 158, 11, 0.20);
    background: transparent;
    cursor: not-allowed;
}

.source-file-dropzone .icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: var(--color-elevated);
    color: var(--color-accent);
}

.source-file-dropzone .text {
    font-size: 0.7rem;
    line-height: 1.3;
}

.source-file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 9px;
    background: var(--color-card-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-foreground);
    font-size: 0.74rem;
}

.btn-remove-file {
    background: transparent;
    border: none;
    color: var(--color-destructive);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 1px 3px;
}

.source-file-guidance {
    margin-top: 8px;
    padding: 9px;
    background: var(--color-card-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.source-file-guidance .form-label {
    display: block;
    margin-bottom: 5px;
    color: var(--color-foreground);
    font-size: 0.74rem;
    font-weight: 650;
}

.source-file-guidance .form-textarea {
    width: 100%;
    min-height: 62px;
    resize: vertical;
    font-size: 0.72rem;
    line-height: 1.35;
}

.source-file-guidance-help {
    margin: 5px 0 0;
    color: var(--color-muted-foreground);
    font-size: 0.66rem;
    line-height: 1.35;
}

.pb-trigger-btn {
    min-height: 30px;
    width: 100%;
    background: var(--color-card-surface);
    border: 1px solid var(--color-border);
    color: var(--color-muted-foreground);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.76rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: background var(--ease-out), border-color var(--ease-out), color var(--ease-out);
}

.pb-trigger-btn:hover {
    background: var(--color-elevated);
    border-color: var(--color-border-hover);
    color: var(--color-foreground);
}

/* Botón principal Generar */
#btn-generate {
    width: 100%;
    min-height: 40px;
    height: 40px;
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    color: #08090C;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 0 rgba(34, 190, 235, 0), var(--shadow-xs);
    transition: background var(--ease-out), box-shadow var(--ease-out), border-color var(--ease-out);
}

#btn-generate:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: #08090C;
    box-shadow: var(--shadow-sm);
}

.sidebar-primary-action {
    grid-column: 1;
    padding: 12px 16px 14px;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.38);
}

.sidebar-primary-hint {
    display: block;
    margin-bottom: 6px;
    color: var(--color-subtle-foreground);
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
}

.form-section-divider {
    height: 1px;
    margin: 20px 0 14px;
    background: var(--color-border);
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}

.form-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

/* ═══════════════════════════════════════════════════
   PREVIEW WORKSPACE (Lienzo Central 16:9)
   ═══════════════════════════════════════════════════ */
.preview-area {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--color-background);
    margin-left: var(--rail-w);
}

/* Ribbon Toolbar Flotante */
.preview-toolbar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    max-width: 840px;
    margin-bottom: 14px;
    padding: 5px 10px;
    gap: 5px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.toolbar-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.toolbar-sublabel {
    color: var(--color-subtle-foreground);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--color-border);
    margin: 0 3px;
}

.toolbar-btn {
    min-height: 24px !important;
    height: 24px;
    padding: 0 6px !important;
    background: var(--color-card-surface) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-muted-foreground) !important;
    font-size: 0.72rem !important;
}

.toolbar-btn:hover {
    background: var(--color-muted) !important;
    border-color: var(--color-border-hover) !important;
    color: var(--color-foreground) !important;
}

.toolbar-select {
    min-height: 24px !important;
    height: 24px;
    padding: 0 4px !important;
    background: var(--color-card-surface) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-foreground) !important;
    font-size: 0.72rem !important;
}

.toolbar-color {
    width: 24px;
    height: 24px;
    padding: 1px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--color-primary-subtle);
    border: 1px solid rgba(39, 182, 230, 0.2);
    color: var(--color-accent);
    font-size: 0.68rem;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════
   HOJA A4 (Fiel reproducción imprimible MINEDU)
   ═══════════════════════════════════════════════════ */
.session-sheet {
    background: #ffffff;
    color: #000000;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    border-radius: 2px;
    margin: 0 auto;
    transition: transform 120ms ease;
    transform-origin: top center;
}

/* ═══════════════════════════════════════════════════
   EMPTY STATE / ONBOARDING (Discreto y Enfocado)
   ═══════════════════════════════════════════════════ */
.empty-state {
    width: calc(100% + 48px);
    max-width: none;
    margin: auto -24px;
    padding: 48px 56px;
    border-block: 1px solid var(--color-border);
    border-radius: 0;
    background: var(--color-card);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255,255,255,0.025);
    text-align: left;
    display: grid;
    grid-template-columns: minmax(320px, 470px) minmax(360px, 520px);
    justify-content: center;
    align-items: center;
    gap: 72px;
}

.empty-state-copy {
    padding: 28px 32px;
    background: var(--surface-cyan);
    border: 1px solid rgba(44, 200, 238, 0.38);
    border-left: 4px solid var(--color-accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md), var(--shadow-inset);
}

.empty-brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-bottom: 12px;
    border: 1px solid rgba(44, 200, 238, 0.44);
    border-radius: var(--radius-xs);
    background: #214453;
}

.empty-brand-mark img { width: 20px; height: 20px; }

.empty-eyebrow {
    color: var(--color-accent);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
}

.mobile-only { display: none !important; }

.empty-title {
    margin-bottom: 6px;
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: var(--color-foreground) !important;
    background-clip: initial !important;
    color: var(--color-foreground) !important;
    max-width: 15ch;
    font-size: 2.15rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.empty-text {
    max-width: 50ch;
    margin-bottom: 18px;
    color: #D0D9E3;
    font-size: 0.9rem;
    line-height: 1.55;
}

.empty-primary-action { min-height: 38px; }

.empty-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.step-item {
    --step-card-color: var(--color-step-amber);
    --step-card-surface: var(--surface-amber);
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 14px 16px;
    background: var(--step-card-surface);
    border: 1px solid color-mix(in srgb, var(--step-card-color) 38%, var(--color-border));
    border-left: 3px solid var(--step-card-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm), var(--shadow-inset);
    transition: border-color var(--ease-out), background var(--ease-out), box-shadow var(--ease-out);
}

.step-item:nth-child(2) { --step-card-color: var(--color-step-blue); --step-card-surface: var(--surface-blue); }
.step-item:nth-child(3) { --step-card-color: var(--color-step-green); --step-card-surface: var(--surface-green); }
.step-item:nth-child(4) { --step-card-color: var(--color-step-coral); --step-card-surface: var(--surface-coral); }

.step-item:hover {
    border-color: var(--step-card-color);
    background: color-mix(in srgb, var(--step-card-color) 18%, var(--step-card-surface));
    box-shadow: var(--shadow-md);
}

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    background: color-mix(in srgb, var(--step-card-color) 22%, #101318);
    border: 1px solid var(--step-card-color);
    color: var(--step-card-color);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 1px;
}

.step-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.step-title {
    color: var(--color-foreground);
    font-size: 0.78rem;
    font-weight: 600;
    display: block;
}

.step-desc {
    color: var(--color-muted-foreground);
    font-size: 0.7rem;
    line-height: 1.35;
    display: block;
}

/* ═══════════════════════════════════════════════════
   MODALES, DIÁLOGOS Y OVERLAYS
   ═══════════════════════════════════════════════════ */
.confirm-overlay,
.pdf-guide-overlay,
.load-modal,
.auth-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.confirm-card,
.pdf-guide-card,
.load-card,
.load-modal-content,
.auth-card {
    background: var(--color-card);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
}

.toast {
    background: var(--color-card);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
}

.confirm-icon .ui-icon,
.pdf-guide-icon .ui-icon {
    width: 30px;
    height: 30px;
}

.load-modal-header h3,
.popover-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════
   CHATBOT FLOTANTE (GPT-5.6 Luna Copilot)
   ═══════════════════════════════════════════════════ */
.chatbot-bubble {
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    color: #08090C;
    border: 1px solid var(--color-primary);
    box-shadow: var(--glow-cyan), var(--shadow-md);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--ease-out), background-color var(--ease-out), box-shadow var(--ease-out);
}

.chatbot-bubble .ui-icon { width: 17px; height: 17px; }

.chatbot-bubble:hover {
    transform: scale(1.06);
    background: var(--color-primary-hover);
    box-shadow: 0 0 20px rgba(34, 190, 235, 0.40), var(--shadow-lg);
}

.chatbot-window {
    background: var(--color-card-surface);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
}

.chatbot-header {
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border-subtle);
    padding: 9px 12px;
}

.chatbot-title {
    color: var(--color-foreground);
    font-size: 0.84rem;
    font-weight: 600;
}

.chatbot-subtitle {
    color: var(--color-accent);
    font-size: 0.66rem;
    font-weight: 600;
}

.chatbot-dot {
    background: var(--color-success);
    box-shadow: 0 0 6px var(--color-success);
}

.chatbot-messages {
    background: var(--color-background);
    padding: 10px;
}

.chat-message.bot .message-bubble {
    background: var(--color-elevated);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    border-radius: 6px 6px 6px 2px;
    font-size: 0.8rem;
}

.chat-message.user .message-bubble {
    background: var(--color-primary);
    color: #08090C;
    border-radius: 6px 6px 2px 6px;
    font-size: 0.8rem;
}

.chatbot-input-container {
    background: var(--color-card);
    border-top: 1px solid var(--color-border-subtle);
    padding: 7px 10px;
}

.chatbot-input-container input {
    background: var(--color-card-surface);
    color: var(--color-foreground);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    transition: background var(--ease-out), border-color var(--ease-out), box-shadow var(--ease-out);
}

.chatbot-input-container input:focus {
    border-color: var(--color-border-focus);
    background: var(--color-elevated);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
    outline: none;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVIDAD & ADAPTABILIDAD
   ═══════════════════════════════════════════════════ */
@media (max-width: 1280px) {
    .header-actions #btn-toggle-edit .btn-label,
    .header-actions #btn-preview .btn-label,
    .header-actions #btn-download-engine .btn-label { display: none; }
    .header-actions #btn-toggle-edit,
    .header-actions #btn-preview,
    .header-actions #btn-download-engine { min-width: 34px; padding-inline: 8px; }
}

@media (max-width: 1100px) {
    .mobile-only { display: inline-flex !important; }
    .app-header { padding: 0 12px; }
    .header-context,
    .save-indicator { display: none; }
    .auth-header-container .auth-label { display: none; }
    .header-actions .btn-label { display: none; }
    .header-actions #btn-toggle-edit,
    .header-actions #btn-preview,
    .header-actions #btn-download-engine { display: none; }
    .header-actions .btn { width: 34px; min-width: 34px; padding: 0; }

    .sidebar {
        position: fixed;
        top: var(--header-h);
        bottom: 0;
        left: var(--rail-w);
        z-index: 1001;
        width: min(var(--sidebar-w), calc(100vw - var(--rail-w)));
        max-width: calc(100vw - var(--rail-w));
        min-width: 0;
        height: auto;
        transform: translateX(-100%);
        transition: transform 180ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar {
        box-shadow: 100vw 0 0 100vw rgba(0, 0, 0, 0.64), var(--shadow-lg);
    }

}

@media (max-width: 820px) {
    .empty-state {
        max-width: none;
        padding: 36px 28px;
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .empty-title { max-width: 18ch; }
}

@media (max-width: 560px) {
    :root { --rail-w: 58px; --rail-expanded-w: 174px; }
    .brand-subtitle { display: none; }
    .empty-state { padding: 20px 16px; gap: 18px; }
    .empty-state-copy { padding: 20px; }
    .step-item { padding: 12px; }
    .empty-title { font-size: 1.55rem; }
    .workflow-rail-brand { padding-inline: 9px; grid-template-columns: 40px minmax(0, 1fr); }
    .sidebar-workflow { grid-template-columns: minmax(0, 1fr); }
    .sidebar-tab { grid-template-columns: 40px minmax(0, 1fr); padding-inline: 1px 8px; gap: 8px; }
    .session-form { padding-inline: 14px; }
    .inspector-heading { margin-inline: -14px; padding-inline: 14px; }
    .sidebar-primary-action { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
