/* ═══════════════════════════════════════════════════════════════
   TOKENS — redaccion.news (Google / Apple / Gemini style)
   ═══════════════════════════════════════════════════════════════ */
:root {
    --primary:        #5755F5;
    --primary-hover:  #4442E2;
    --primary-light:  rgba(87,85,245,0.09);
    --primary-xlight: rgba(87,85,245,0.04);
    --primary-grad:   linear-gradient(160deg, #6B69FF 0%, #4442E2 100%);

    --success: #00C48C;
    --danger:  #F44336;
    --warning: #FF9800;

    --f-sans: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --f-mono: 'SFMono-Regular', Consolas, monospace;
    --f-serif: 'Georgia', 'Times New Roman', serif;

    --ink-1: #1C1C1E;
    --ink-2: #3A3A3C;
    --ink-3: #6C6C70;
    --ink-4: #AEAEB2;

    --bg:       #F4F4F8;
    --surface:  #FFFFFF;
    --surface-2:#F9F9FC;

    --border:       rgba(0,0,0,0.08);
    --border-focus: rgba(87,85,245,0.45);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.05);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.04), 0 12px 32px rgba(0,0,0,0.08);
    --shadow-xl: 0 8px 16px rgba(0,0,0,0.05), 0 24px 48px rgba(0,0,0,0.10);

    --r-xs:   6px;
    --r-sm:   10px;
    --r-md:   14px;
    --r-lg:   18px;
    --r-xl:   24px;
    --r-pill: 100px;
}

/* ─── BASE ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--f-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--ink-1);
    margin: 0; padding: 0;
    min-height: 100vh;
}

.ag2-root { min-height: 100vh; display: flex; flex-direction: column; }

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */
.ag2-header {
    height: 56px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center;
}
.ag2-header-top {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; max-width: 1280px; margin: 0 auto;
    padding: 0 20px;
}
.ag2-header-actions { display: flex; align-items: center; gap: 8px; }

/* Brand */
.ag2-day-label {
    font-size: 1.05rem; font-weight: 700;
    color: var(--ink-1); letter-spacing: -0.3px;
    display: flex; align-items: center; gap: 10px;
    text-decoration: none;
}
.ag2-day-label small {
    display: none;
}
.brand-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary-grad);
    display: inline-block;
    flex-shrink: 0;
}

/* Header buttons */
.header-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(0,0,0,0.04);
    border: none;
    border-radius: var(--r-md);
    padding: 7px 12px;
    font-size: 0.8rem; font-weight: 500;
    font-family: var(--f-sans);
    color: var(--ink-2);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.header-btn:hover { background: rgba(0,0,0,0.08); color: var(--ink-1); }
.header-btn svg { flex-shrink: 0; opacity: 0.7; }

.header-btn-indicator {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--success);
    position: absolute; top: 5px; right: 5px;
    border: 1.5px solid var(--surface);
    display: none;
}
.header-btn-indicator.active { display: block; }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.main-layout {
    display: flex; flex-direction: column;
    gap: 16px; padding: 20px 16px;
    max-width: 1280px; margin: 0 auto; width: 100%;
    flex: 1;
}
@media (min-width: 768px) {
    .main-layout { flex-direction: row; align-items: flex-start; padding: 28px 24px; gap: 20px; }
    .sidebar { width: 360px; flex-shrink: 0; }
    .content { flex: 1; min-width: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   CARDS / PAPER
   ═══════════════════════════════════════════════════════════════ */
.ag2-paper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-md);
}
.ag2-paper::before { display: none; } /* remove old left stripe */

.ag2-paper-title {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--ink-3); margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
    font-family: var(--f-mono);
}
.ag2-paper-cat {
    display: inline-block;
    font-size: 0.65rem; font-weight: 700; padding: 3px 10px;
    border-radius: var(--r-pill); font-family: var(--f-mono);
    text-transform: uppercase; letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════════════════════════ */
.input-box {
    width: 100%;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 14px;
    font-family: var(--f-sans);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
    color: var(--ink-1);
    -webkit-appearance: none;
}
.input-box:focus {
    background: var(--surface);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(87,85,245,0.10);
}
select.input-box { cursor: pointer; }

.ag2-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    padding: 13px 14px;
    font-family: var(--f-sans);
    font-size: 0.875rem;
    color: var(--ink-1);
    resize: none;
    line-height: 1.6;
    min-height: 140px;
    outline: none;
    transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.ag2-textarea:focus {
    background: var(--surface);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(87,85,245,0.10);
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.ag2-btn-save {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    background: var(--primary-grad);
    color: white;
    border: none;
    border-radius: var(--r-md);
    padding: 13px 22px;
    font-size: 0.9rem; font-weight: 600;
    font-family: var(--f-sans);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(87,85,245,0.28), 0 1px 2px rgba(0,0,0,0.08);
    letter-spacing: -0.1px;
}
.ag2-btn-save:hover { opacity: 0.92; box-shadow: 0 4px 16px rgba(87,85,245,0.35), 0 1px 2px rgba(0,0,0,0.08); }
.ag2-btn-save:active { transform: scale(0.97); }
.ag2-btn-save:disabled { background: var(--ink-4); box-shadow: none; cursor: not-allowed; opacity: 1; transform: none !important; }

.ag2-btn-cancel {
    background: rgba(0,0,0,0.05);
    color: var(--ink-2);
    border: none;
    border-radius: var(--r-md);
    padding: 11px 16px;
    font-size: 0.84rem; font-weight: 500;
    font-family: var(--f-sans);
    cursor: pointer;
    transition: background 0.14s, color 0.14s;
    white-space: nowrap;
}
.ag2-btn-cancel:hover { background: rgba(0,0,0,0.09); color: var(--ink-1); }

/* ═══════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════ */
.ag2-paste-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,0.38);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.22s;
}
.ag2-paste-overlay.open { opacity: 1; pointer-events: all; }

.ag2-paste-sheet {
    width: 100%; max-width: 680px;
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    display: flex; flex-direction: column;
    transform: translateY(24px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.34,1.46,0.64,1);
    border: 1px solid var(--border);
}
.ag2-paste-overlay.open .ag2-paste-sheet { transform: translateY(0) scale(1); }

/* ═══════════════════════════════════════════════════════════════
   SKELETON
   ═══════════════════════════════════════════════════════════════ */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position: 600px 0; }
}
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(87,85,245,0.04) 25%,
        rgba(87,85,245,0.09) 37%,
        rgba(87,85,245,0.04) 63%
    );
    background-size: 1200px 100%;
    animation: shimmer 1.6s ease infinite;
    border-radius: var(--r-sm);
}
.skeleton-line { height: 12px; border-radius: var(--r-xs); }

/* ═══════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed; top: 68px; right: 16px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9900; pointer-events: none; width: 300px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    font-family: var(--f-sans);
    color: var(--ink-1);
    animation: toastIn 0.32s cubic-bezier(0.34,1.46,0.64,1) both;
    pointer-events: auto;
    padding: 12px 14px;
    display: flex; flex-direction: column; gap: 3px;
}
.toast-error  { border-left: 3px solid var(--danger); }
.toast-success{ border-left: 3px solid var(--success); }
.toast-label {
    font-size: 0.7rem; font-weight: 700; font-family: var(--f-mono);
    text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-3);
}
.toast-text { font-size: 0.83rem; line-height: 1.4; color: var(--ink-1); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════════
   MICRÓFONO / AUDIO
   ═══════════════════════════════════════════════════════════════ */
.mic-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--primary-xlight);
    border: 1.5px solid var(--primary-light);
    border-radius: var(--r-pill);
    padding: 4px 11px;
    font-size: 0.7rem; font-weight: 600;
    font-family: var(--f-mono);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
}
.mic-btn:hover { background: var(--primary-light); }
.mic-btn--recording {
    background: rgba(244,67,54,0.08);
    border-color: rgba(244,67,54,0.35);
    color: var(--danger);
    animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(244,67,54,0.15); }
    50%      { box-shadow: 0 0 0 5px rgba(244,67,54,0.04); }
}
.audio-status {
    display: flex; align-items: center; gap: 10px;
    background: rgba(244,67,54,0.05);
    border: 1px solid rgba(244,67,54,0.15);
    border-radius: var(--r-sm);
    padding: 8px 12px; margin-bottom: 10px;
    font-size: 0.78rem; color: var(--danger); font-weight: 500;
}
.audio-wave { display: flex; align-items: center; gap: 2px; height: 16px; }
.audio-wave span {
    display: block; width: 3px; background: var(--danger);
    border-radius: 3px; animation: wave 0.8s ease-in-out infinite;
}
.audio-wave span:nth-child(1) { height: 4px;  animation-delay: 0s; }
.audio-wave span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
.audio-wave span:nth-child(3) { height: 14px; animation-delay: 0.3s; }
.audio-wave span:nth-child(4) { height: 10px; animation-delay: 0.45s; }
.audio-wave span:nth-child(5) { height: 4px;  animation-delay: 0.6s; }
@keyframes wave {
    0%,100% { transform: scaleY(0.5); }
    50%      { transform: scaleY(1.4); }
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.ag2-empty {
    display: flex; flex-direction: column; align-items: center;
    gap: 10px; padding: 60px 24px; text-align: center; flex: 1;
    justify-content: center;
}
.ag2-empty p { font-size: 1rem; font-weight: 600; color: var(--ink-2); margin: 0; }
.ag2-empty span { font-size: 0.85rem; color: var(--ink-3); max-width: 280px; line-height: 1.5; }

/* ═══════════════════════════════════════════════════════════════
   KB BADGE
   ═══════════════════════════════════════════════════════════════ */
.kb-badge {
    font-family: var(--f-mono);
    font-size: 0.62rem; font-weight: 700;
    padding: 3px 9px; border-radius: var(--r-pill);
    background: rgba(0,196,140,0.10);
    color: var(--success);
    border: 1px solid rgba(0,196,140,0.22);
    text-transform: uppercase; letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════════════════════
   ARTICLE TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════ */
.article-typography {
    font-family: var(--f-sans);
    font-size: 0.97rem; line-height: 1.75;
    color: var(--ink-2);
}
.article-typography h1 {
    font-family: var(--f-sans);
    font-size: 1.5rem; font-weight: 700;
    color: var(--ink-1); margin-bottom: 18px;
    line-height: 1.3; letter-spacing: -0.3px;
}
.article-typography h2,
.article-typography h3 {
    font-family: var(--f-sans);
    font-weight: 700; color: var(--ink-1);
    margin: 1.5em 0 0.4em; line-height: 1.3;
}
.article-typography h2 { font-size: 1.08rem; }
.article-typography h3 { font-size: 0.97rem; }
.article-typography strong { font-weight: 700; color: var(--ink-1); }
.article-typography em { font-style: italic; }
.article-typography p { margin: 0 0 0.9em; }

/* ═══════════════════════════════════════════════════════════════
   PANEL: SEGUIR TRABAJANDO
   ═══════════════════════════════════════════════════════════════ */
#refinar-panel {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1.5px solid var(--border);
}
.refinar-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.refinar-label {
    font-size: 0.7rem; font-weight: 600;
    font-family: var(--f-mono); text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--ink-4);
}
.versiones-nav { display: flex; gap: 5px; flex-wrap: wrap; }
.version-chip {
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600; font-family: var(--f-sans);
    background: var(--surface-2); border: 1.5px solid var(--border);
    color: var(--ink-3); cursor: pointer; transition: all 0.12s;
}
.version-chip--active {
    background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}
.refinar-textarea {
    width: 100%; box-sizing: border-box;
    resize: none; font-size: 0.85rem;
    min-height: 62px; margin-bottom: 8px;
}
.refinar-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.refinar-btn {
    padding: 7px 13px; border-radius: var(--r-md);
    font-size: 0.78rem; font-weight: 600; font-family: var(--f-sans);
    background: var(--surface-2); border: 1.5px solid var(--border);
    color: var(--ink-2); cursor: pointer; transition: all 0.12s;
    display: inline-flex; align-items: center; gap: 5px;
}
.refinar-btn:hover:not(:disabled) { background: var(--surface-3, #EFEFF5); color: var(--ink-1); }
.refinar-btn:disabled { opacity: 0.5; cursor: default; }
.refinar-btn--main {
    background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}
.refinar-btn--main:hover:not(:disabled) { background: var(--primary); color: #fff; }
#opciones-panel {
    margin-top: 12px; padding: 12px 14px;
    background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
}
.opciones-label {
    font-size: 0.7rem; font-weight: 600; font-family: var(--f-mono);
    text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-4);
    margin-bottom: 8px;
}
.opcion-item {
    display: block; width: 100%; text-align: left;
    padding: 9px 12px; margin-bottom: 6px;
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--r-md); font-size: 0.85rem; line-height: 1.4;
    color: var(--ink-1); cursor: pointer; font-family: var(--f-sans);
    transition: all 0.12s;
}
.opcion-item:last-child { margin-bottom: 0; }
.opcion-item:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   PANEL CLAVES (modal)
   ═══════════════════════════════════════════════════════════════ */
.claves-provider-tabs {
    display: flex; gap: 6px; margin-bottom: 20px;
}
.claves-tab {
    flex: 1; background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--r-md); padding: 8px 10px;
    font-size: 0.78rem; font-weight: 600;
    font-family: var(--f-sans); color: var(--ink-3);
    cursor: pointer; transition: all 0.14s;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    text-align: center;
}
.claves-tab.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.claves-tab-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--border); margin: 0 auto;
    transition: background 0.14s;
}
.claves-tab.has-key .claves-tab-dot { background: var(--success); }

.clave-row {
    margin-bottom: 12px; padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    transition: border-color 0.15s, background 0.15s;
}
.clave-row--active { border-color: rgba(87,85,245,0.3); background: var(--primary-xlight); }
.clave-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.clave-input { font-family: var(--f-mono) !important; font-size: 0.8rem !important; padding: 9px 12px !important; }
.clave-status { font-size: 0.7rem; font-family: var(--f-mono); color: var(--ink-4); }
.clave-status--ok { color: var(--success); font-weight: 700; }
.clave-link {
    display: inline-block; margin-top: 5px; font-size: 0.72rem;
    font-family: var(--f-mono); color: var(--primary);
    text-decoration: none; opacity: 0.7; transition: opacity 0.14s;
}
.clave-link:hover { opacity: 1; text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════
   AUTH MODAL
   ═══════════════════════════════════════════════════════════════ */
.auth-error {
    font-size: 0.8rem; color: var(--danger);
    background: rgba(244,67,54,0.06);
    border: 1px solid rgba(244,67,54,0.18);
    border-radius: var(--r-sm); padding: 9px 12px; margin-bottom: 12px;
}
.auth-tabs {
    display: flex; gap: 4px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 4px; margin-bottom: 20px;
}
.auth-tab {
    flex: 1; background: transparent; border: none;
    border-radius: var(--r-sm); padding: 8px 0;
    font-size: 0.82rem; font-weight: 600; font-family: var(--f-sans);
    color: var(--ink-3); cursor: pointer; transition: all 0.15s;
}
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ═══════════════════════════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.admin-layout {
    display: flex; flex-direction: column;
    gap: 20px; padding: 24px 16px;
    max-width: 1280px; margin: 0 auto;
}
@media (min-width: 768px) {
    .admin-layout { flex-direction: row; align-items: flex-start; padding: 28px 24px; }
    .admin-sidebar { width: 272px; flex-shrink: 0; }
    .admin-content { flex: 1; min-width: 0; }
}
.admin-section-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.admin-section-title {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; color: var(--ink-3); font-family: var(--f-mono);
}
.admin-btn-add {
    font-size: 0.72rem; font-weight: 600; font-family: var(--f-sans);
    background: var(--primary); color: white;
    border: none; border-radius: var(--r-pill);
    padding: 4px 13px; cursor: pointer; transition: background 0.14s;
}
.admin-btn-add:hover { background: var(--primary-hover); }

.admin-profile-list { display: flex; flex-direction: column; gap: 8px; }
.admin-profile-item {
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--r-lg); padding: 12px 14px;
    cursor: pointer; transition: all 0.14s;
}
.admin-profile-item:hover { border-color: rgba(87,85,245,0.25); }
.admin-profile-item.active { border-color: var(--primary); background: var(--primary-xlight); }
.admin-profile-name { font-weight: 600; font-size: 0.88rem; color: var(--ink-1); margin-bottom: 2px; }
.admin-profile-desc {
    font-size: 0.75rem; color: var(--ink-3); margin-bottom: 8px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-profile-actions { display: flex; gap: 6px; }
.admin-action-btn {
    font-size: 0.7rem; font-family: var(--f-sans); font-weight: 500;
    padding: 3px 10px; border-radius: var(--r-pill); cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
    transition: all 0.12s;
}
.admin-action-btn:hover { background: var(--surface-2); }
.admin-action-btn--danger { color: var(--danger); border-color: rgba(244,67,54,0.2); }
.admin-action-btn--danger:hover { background: rgba(244,67,54,0.06); border-color: var(--danger); }
.admin-empty-list { font-size: 0.8rem; color: var(--ink-3); padding: 12px; text-align: center; }
.admin-loading { font-size: 0.8rem; color: var(--ink-3); padding: 12px; }

/* KB Panel */
.kb-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
    padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.kb-perfil-nombre { font-size: 1.1rem; font-weight: 700; color: var(--ink-1); margin-bottom: 4px; }
.kb-stats { font-size: 0.78rem; color: var(--ink-3); font-family: var(--f-mono); }
.kb-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-sm-btn { padding: 6px 12px !important; font-size: 0.75rem !important; }

/* Tabla KB */
.kb-tabla { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.kb-tabla th {
    text-align: left; padding: 8px 10px;
    font-size: 0.63rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--ink-3); font-family: var(--f-mono);
    border-bottom: 1px solid var(--border);
}
.kb-tabla td {
    padding: 10px; border-bottom: 1px solid rgba(0,0,0,0.04);
    color: var(--ink-2); vertical-align: top;
}
.kb-tabla tr:hover td { background: var(--primary-xlight); }
.kb-preview-cell { max-width: 280px; color: var(--ink-3); font-size: 0.79rem; }
.kb-fuente-cell { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-tipo-badge {
    display: inline-block; font-size: 0.62rem; font-weight: 700;
    padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap;
    font-family: var(--f-mono); text-transform: uppercase;
}
.kb-tipo-articulo   { background: rgba(87,85,245,0.08);  color: var(--primary); }
.kb-tipo-libro      { background: rgba(245,158,11,0.12);  color: #92400e; }
.kb-tipo-video      { background: rgba(244,67,54,0.10);   color: #b91c1c; }
.kb-tipo-tv         { background: rgba(139,92,246,0.12);  color: #6d28d9; }
.kb-tipo-evento     { background: rgba(0,196,140,0.10);   color: #065f46; }
.kb-tipo-entrevista { background: rgba(59,130,246,0.10);  color: #1e40af; }
.kb-tipo-pdf        { background: rgba(255,152,0,0.12);   color: #a04000; }

/* Modal fields */
.admin-modal-title { font-size: 1.05rem; font-weight: 700; color: var(--ink-1); margin: 0 0 20px 0; }
.admin-field { margin-bottom: 14px; }
.admin-label {
    display: block; font-size: 0.72rem; font-weight: 600;
    color: var(--ink-2); margin-bottom: 5px; font-family: var(--f-mono);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.admin-row { display: flex; gap: 12px; }

/* Source URL subtle */
.source-url-wrap {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.source-url-label {
    font-size: 0.68rem; font-weight: 600; color: var(--ink-4);
    font-family: var(--f-mono); text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 6px; display: block;
}

/* ─── RESPONSIVE ────────────────────────────────────────────── */

/* Tablet+ */
@media (max-width: 767px) {
    .ag2-paper { padding: 14px 14px; }
    .main-layout { padding: 10px; gap: 10px; }

    /* Article typography */
    .article-typography { font-size: 1rem; line-height: 1.75; }
    .article-typography h1 { font-size: 1.25rem; }

    /* Admin table horizontally scrollable */
    #kb-tabla-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .kb-tabla { min-width: 560px; }

    /* KB header stacks */
    .kb-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .kb-actions { width: 100%; }

    /* Form rows stack */
    .admin-row { flex-direction: column; gap: 8px; }

    /* Touch targets */
    .ag2-btn-save, .ag2-btn-cancel { min-height: 44px; }
    .input-box { min-height: 44px; }
    select.input-box { min-height: 44px; }
}

/* Mobile bottom-sheet modals + compact header */
@media (max-width: 600px) {
    /* Modals → bottom sheet */
    .ag2-paste-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .ag2-paste-sheet {
        border-radius: var(--r-xl) var(--r-xl) 0 0 !important;
        max-width: 100% !important;
        max-height: 90dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateY(100%) scale(1) !important;
        padding-bottom: max(env(safe-area-inset-bottom), 20px);
    }
    .ag2-paste-overlay.open .ag2-paste-sheet {
        transform: translateY(0) scale(1) !important;
    }

    /* Toasts → bottom of screen, full width */
    .toast-container {
        top: auto;
        bottom: 12px;
        right: 10px;
        left: 10px;
        width: auto;
    }

    /* Header compact: hide provider label, shrink buttons */
    #api-provider-label { display: none; }
    .header-btn { padding: 6px 9px; gap: 4px; font-size: 0.76rem; }
    .ag2-header-top { padding: 0 12px; }
    .ag2-day-label { font-size: 0.95rem; }

    /* Sidebar textarea smaller */
    .ag2-textarea { min-height: 110px; }

    /* Auth / API modals inner padding */
    .ag2-paste-sheet > div { padding: 24px 20px !important; }

    /* Admin KB actions wrap on 2 lines */
    .kb-actions { flex-wrap: wrap; gap: 6px; }
    .admin-sm-btn { font-size: 0.72rem !important; padding: 5px 10px !important; }
}

/* Very small (≤ 360px) */
@media (max-width: 360px) {
    .header-btn svg { display: none; }
    .ag2-day-label { font-size: 0.88rem; }
}

/* ─── PROVIDER CARDS ─────────────────────────────────────────── */
.api-modal-sheet { max-width: 560px !important; padding: 24px !important; }
.api-modal-header {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
/* Bloque proveedor activo — destacado en la parte superior */
.active-provider-block {
    background: var(--primary-light);
    border: 1.5px solid rgba(87,85,245,0.18);
    border-radius: var(--r-md);
    padding: 12px 14px 10px;
    margin-bottom: 18px;
}
.active-provider-label {
    display: flex; align-items: center; gap: 5px;
    font-size: 0.68rem; font-weight: 700; color: var(--primary);
    font-family: var(--f-mono); text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 7px;
}
.active-provider-select {
    font-weight: 600; font-size: 0.88rem !important;
    border-color: rgba(87,85,245,0.3) !important;
    margin-bottom: 0 !important;
}
.active-provider-select:focus { border-color: var(--border-focus) !important; }
.active-provider-note {
    font-size: 0.71rem; color: var(--ink-3); margin: 7px 0 0; line-height: 1.4;
}
/* Separador antes de las tarjetas de claves */
.provider-section-label {
    font-size: 0.69rem; font-weight: 700; color: var(--ink-3);
    font-family: var(--f-mono); text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.provider-section-label span { font-weight: 400; text-transform: none; letter-spacing: 0; }
.provider-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 20px;
}
.provider-card {
    background: var(--surface-2); border: 1.5px solid var(--border);
    border-radius: var(--r-md); padding: 11px 11px 9px; transition: border-color 0.15s;
}
.provider-card:focus-within { border-color: var(--border-focus); }
.provider-card-top { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.provider-dot { width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0; }
.provider-info { flex: 1; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; min-width: 0; }
.provider-name { font-size: 0.8rem; font-weight: 700; color: var(--ink-1); white-space: nowrap; }
.provider-pill {
    font-size: 0.59rem; font-weight: 700; padding: 1px 5px;
    border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: 0.2px; white-space: nowrap;
}
.provider-pill--free  { background: rgba(0,196,140,0.12); color: #047857; }
.provider-pill--cheap { background: rgba(87,85,245,0.10); color: var(--primary); }
.provider-model { font-size: 0.68rem; color: var(--ink-3); margin-bottom: 7px; }
.provider-card .clave-input { font-size: 0.8rem; height: 34px; padding: 0 9px; margin-bottom: 5px; }
.provider-link {
    font-size: 0.69rem; font-weight: 600; color: var(--primary);
    text-decoration: none; display: inline-block;
}
.provider-link:hover { text-decoration: underline; }
.clave-status { font-size: 0.75rem; color: var(--ink-4); flex-shrink: 0; margin-left: auto; }
.clave-status--ok { color: var(--success) !important; }

@media (max-width: 520px) {
    .provider-grid { grid-template-columns: 1fr; }
    .api-modal-sheet { padding: 18px !important; }
}
