    :root {
      --accent: #3b82f6;
      --accent2: #10b981;
      --danger: #ef4444;
      --bg: #09111f;
      --surface: #0f1e33;
      --surface2: #162540;
      --border: #1e3a5f;
      --text: #e2e8f0;
      --muted: #64748b;
    }

    * { box-sizing: border-box; }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: 'Syne', sans-serif;
      min-height: 100vh;
    }

    code, pre, .mono { font-family: 'Space Mono', monospace; }

    .glass {
      background: rgba(15, 30, 51, 0.85);
      -webkit-backdrop-filter: blur(16px);
      backdrop-filter: blur(16px);
      border: 1px solid var(--border);
    }

    /* ── Auth overlay ───────────────────────────────────────────── */
    #auth-overlay {
      position: fixed; inset: 0; z-index: 9999;
      background: var(--bg);
      display: flex; align-items: center; justify-content: center;
      padding: 1rem;
    }
    #auth-overlay.hidden { display: none; }

    .auth-card {
      width: 100%; max-width: 420px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 1.5rem;
      padding: 2.5rem 2rem;
      box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    }

    .auth-tab-btn {
      flex: 1; padding: .6rem; border-radius: .6rem;
      font-size: .8rem; font-weight: 700; letter-spacing: .05em;
      text-transform: uppercase; transition: all .2s;
      background: transparent; color: var(--muted); border: none; cursor: pointer;
    }
    .auth-tab-btn.active {
      background: var(--accent); color: #fff;
    }

    .auth-error {
      background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
      color: #fca5a5; border-radius: .75rem;
      padding: .75rem 1rem; font-size: .8rem; display: none;
    }
    .auth-error.show { display: block; }

    .auth-success {
      background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3);
      color: #6ee7b7; border-radius: .75rem;
      padding: .75rem 1rem; font-size: .8rem; display: none;
    }
    .auth-success.show { display: block; }

    /* ── User chip en el header ─────────────────────────────────── */
    #user-chip {
      display: flex; align-items: center; gap: .6rem;
      background: var(--surface2); border: 1px solid var(--border);
      border-radius: 999px; padding: .35rem .35rem .35rem .85rem;
      font-size: .75rem; cursor: default;
    }
    #user-chip.hidden { display: none; }
    #user-chip .avatar {
      width: 28px; height: 28px; border-radius: 50%;
      background: linear-gradient(135deg, var(--accent), var(--accent2));
      display: flex; align-items: center; justify-content: center;
      font-size: .7rem; font-weight: 800; color: #fff; flex-shrink: 0;
    }
    #btn-logout {
      background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.25);
      color: #fca5a5; border-radius: 999px;
      padding: .25rem .7rem; font-size: .7rem; font-weight: 700;
      cursor: pointer; transition: background .2s;
    }
    #btn-logout:hover { background: rgba(239,68,68,.3); }

    /* Grid de fondo */
    .bg-grid {
      background-image:
        linear-gradient(rgba(59,130,246,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59,130,246,0.04) 1px, transparent 1px);
      background-size: 40px 40px;
    }

    /* Scrollbar */
    ::-webkit-scrollbar { width: 4px; }
    ::-webkit-scrollbar-track { background: var(--bg); }
    ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--accent); }

    /* Tabs */
    .tab-btn { transition: all .2s; position: relative; }
    .tab-btn.active { color: var(--accent); }
    .tab-btn.active::after {
      content: '';
      position: absolute;
      bottom: -2px; left: 0; right: 0;
      height: 2px;
      background: var(--accent);
      border-radius: 2px;
    }

    /* Cards de pregunta en editor */
    .q-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      transition: border-color .2s;
    }
    .q-card:hover { border-color: rgba(59,130,246,0.4); }

    /* Toggle */
    .toggle-track {
      width: 48px; height: 26px;
      background: var(--surface2);
      border-radius: 13px;
      position: relative;
      transition: background .2s;
      cursor: pointer;
      border: 1px solid var(--border);
    }
    .toggle-track.on { background: var(--accent); }
    .toggle-thumb {
      position: absolute;
      top: 3px; left: 3px;
      width: 18px; height: 18px;
      background: white;
      border-radius: 50%;
      transition: transform .2s;
      pointer-events: none;
    }
    .toggle-track.on .toggle-thumb { transform: translateX(22px); }

    /* Bloque badges */
    .badge-b1 { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
    .badge-b2 { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
    .badge-b3 { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
    .badge-b4 { background: rgba(168,85,247,0.15); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }

    /* Input / select estilo base */
    .field {
      background: var(--surface2);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 10px 14px;
      color: var(--text);
      outline: none;
      transition: border-color .2s;
      width: 100%;
      font-family: 'Syne', sans-serif;
    }
    .field:focus { border-color: var(--accent); }
    textarea.field { resize: vertical; }

    /* Respuesta opción */
    .opt-btn {
      width: 100%; text-align: left;
      padding: 14px 18px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      transition: all .15s;
      cursor: pointer;
      font-family: 'Syne', sans-serif;
    }
    .opt-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(59,130,246,0.08); }
    .opt-btn.correct { border-color: #10b981 !important; background: rgba(16,185,129,0.12) !important; }
    .opt-btn.wrong { border-color: #ef4444 !important; background: rgba(239,68,68,0.10) !important; }
    .opt-btn:disabled { cursor: default; }

    /* Progress bar */
    .progress-bar {
      height: 3px;
      background: var(--surface2);
      border-radius: 2px;
      overflow: hidden;
    }
    .progress-fill {
      height: 100%;
      background: linear-gradient(90deg, var(--accent), var(--accent2));
      transition: width .4s ease;
      border-radius: 2px;
    }

    /* Animaciones */
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes scaleIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
    .anim-fade { animation: fadeIn .3s ease forwards; }
    .anim-scale { animation: scaleIn .25s ease forwards; }

    /* LED */
    .led { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
    .led-off { background: #334155; }
    .led-ok { background: #10b981; box-shadow: 0 0 6px #10b981; }
    .led-err { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
    .led-wait { background: #f59e0b; animation: pulse 1s infinite; }
    @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

    /* Sidebar */
    .sidebar-item {
      padding: 8px 12px;
      border-radius: 8px;
      cursor: pointer;
      transition: all .15s;
      font-size: 12px;
      color: var(--muted);
      border: 1px solid transparent;
    }
    .sidebar-item:hover { background: var(--surface2); color: var(--text); }
    .sidebar-item.active { background: rgba(59,130,246,0.12); color: var(--accent); border-color: rgba(59,130,246,0.3); }

    /* Skeleton sidebar */
    @keyframes shimmer {
      0%   { background-position: -200% 0; }
      100% { background-position:  200% 0; }
    }
    .skeleton-card {
      background: linear-gradient(90deg, var(--surface) 0%, var(--surface2) 50%, var(--surface) 100%);
      background-size: 200% 100%;
      animation: shimmer 1.4s ease-in-out infinite;
      border-radius: 8px;
      border: 1px solid var(--border);
    }

    /* Modal */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.7);
      display: flex; align-items: center; justify-content: center;
      z-index: 100;
      padding: 16px;
    }
    .modal-box {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 28px;
      max-width: 560px; width: 100%;
      max-height: 90vh;
      overflow-y: auto;
    }

    /* Spinner */
    .spinner {
      width: 20px; height: 20px;
      border: 2px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin .6s linear infinite;
      display: inline-block;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* Btn primario */
    .btn-primary {
      background: var(--accent);
      color: white;
      border: none;
      border-radius: 10px;
      padding: 12px 20px;
      font-family: 'Syne', sans-serif;
      font-weight: 700;
      cursor: pointer;
      transition: opacity .15s, transform .1s;
      font-size: 14px;
    }
    .btn-primary:hover { opacity: .88; }
    .btn-primary:active { transform: scale(.97); }

    .btn-secondary {
      background: var(--surface2);
      color: var(--text);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 12px 20px;
      font-family: 'Syne', sans-serif;
      font-weight: 600;
      cursor: pointer;
      transition: all .15s;
      font-size: 14px;
    }
    .btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
    .btn-secondary.compact {
      padding: 6px 10px;
      font-size: 11px;
      border-radius: 6px;
    }

    .btn-danger {
      background: rgba(239,68,68,0.1);
      color: #ef4444;
      border: 1px solid rgba(239,68,68,0.3);
      border-radius: 10px;
      padding: 8px 14px;
      font-family: 'Syne', sans-serif;
      font-weight: 600;
      cursor: pointer;
      transition: all .15s;
      font-size: 12px;
    }
    .btn-danger:hover { background: rgba(239,68,68,0.2); }

    .faq-summary {
      display: flex;
      width: 100%;
      min-width: 0;
      min-height: 30px;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      cursor: pointer;
      user-select: none;
      padding: 4px 0;
    }

    .faq-summary::-webkit-details-marker {
      display: none;
    }

    .faq-summary::marker {
      display: none;
    }

    .faq-summary-text {
      min-width: 0;
      flex: 1 1 auto;
      overflow: hidden;
    }

    .faq-summary-title {
      display: block;
      margin: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      line-height: 24px;
      font-size: 1rem;
      font-weight: 700;
      padding: 0;
    }

    /* Select option fix */
    option { background: var(--surface); }

    /* Responsive tweaks for mobile: mejor comportamiento de paneles y botones */
    @media (max-width: 640px) {
        /* Refuerzo: panel de alcance 100% responsive, máxima compatibilidad */
        #alcance-panel, .alcance-panel, .alcance-wrap, [id*="alcance"], [class*="alcance"] {
          display: flex !important;
          flex-wrap: wrap !important;
          gap: 8px !important;
          overflow-x: auto !important;
          padding: 8px 4px !important;
          max-width: 100vw !important;
          min-width: 0 !important;
          box-sizing: border-box;
          align-items: stretch !important;
        }
        #alcance-panel button, .alcance-panel button, .alcance-wrap button, [id*="alcance"] button, [class*="alcance"] button {
          min-width: 90px !important;
          max-width: 100vw !important;
          font-size: 13px !important;
          padding: 7px 10px !important;
          border-radius: 8px !important;
          white-space: nowrap !important;
          flex: 1 1 90px !important;
        }
        /* Panel de alcance: que los botones hagan wrap y scroll-x si es necesario */
        #alcance-panel, .alcance-panel, .alcance-wrap {
          display: flex !important;
          flex-wrap: wrap !important;
          gap: 8px !important;
          overflow-x: auto !important;
          padding: 8px 4px !important;
          max-width: 100vw !important;
          box-sizing: border-box;
        }
        #alcance-panel button, .alcance-panel button, .alcance-wrap button {
          min-width: 90px;
          font-size: 13px !important;
          padding: 7px 10px !important;
          border-radius: 8px !important;
          white-space: nowrap;
        }
      /* Transformar el supuesto-panel en un bottom-sheet más natural en móvil */
      aside#supuesto-panel {
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 72vh !important;
        border-radius: 12px 12px 0 0 !important;
        padding-bottom: calc(env(safe-area-inset-bottom) + 12px) !important;
        margin: 0 auto !important;
        box-shadow: 0 -12px 30px rgba(0,0,0,0.55);
      }

      /* Asegurar que cuando el panel está oculto no queda rastro visible */
      aside#supuesto-panel.hidden {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
      }

      /* Evitar que las pestañas desborden o se muestren cuando no corresponde */
      .tab-btn { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
      .panel-resizable .tab-btn { max-width: 100%; }

      /* Favoritos: botones más compactos en móvil para asemejarse al tamaño de escritorio */
      #favoritos-setup-panel .btn-secondary,
      #favoritos-setup-panel .btn-primary,
      .favoritos-panel .btn-secondary {
        padding: 6px 10px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
        line-height: 1 !important;
      }

      /* Ajustes generales de botones para mejorar densidad en pantallas pequeñas */
      .btn-primary { padding: 10px 14px !important; font-size: 13px !important; }
      .btn-secondary { padding: 8px 12px !important; font-size: 13px !important; }

      /* Evitar que la sidebar ocupada se superponga con el contenido principal */
      .w-full.lg\:w-56 { width: 100% !important; }
    }
