/* ── AI Pulse Mini App ───────────────────────────────────────────────────────
   Loads AFTER stylingStore.css so dark-theme overrides win.
   Page-level styles only — inner .pulse-card / .pulse-grid base styles live
   in stylingStore.css and are shared with the embedded store tab.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Page shell ──────────────────────────────────────────────────────────── */
.pulse-page {
    background: rgb(13 0 35);
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Helvetica Neue', Arial, sans-serif;
    margin-bottom: -96px;
}

/* ── Header — mirrors .if-header layout exactly ──────────────────────────── */
.pulse-page-header {
    background: linear-gradient(140deg, #0d0820 0%, #120c2e 55%, #0d1a2e 100%);
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
    position: relative;
    margin: -60px 0 -90px 0;
}

.pulse-page-header::before {
    content: '';
    position: absolute;
    top: -80px;
    right: -120px;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.10) 0%, transparent 65%);
    pointer-events: none;
}

/* Fix back-to-store button — prevent full-width stretch */
.pulse-page-header .back-to-store-btn {
    display: inline-flex !important;
    width: auto;
    align-self: flex-start;
}

.pulse-page-header__body {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.pulse-page-header__badge {
    display: inline-flex;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 999px;
    padding: 3px 10px;
    margin-bottom: 10px;
}

.pulse-page-header__title {
    font-size: 2rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.pulse-page-header__subtitle {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.50);
    max-width: 520px;
    line-height: 1.6;
    margin: 0;
}

/* ── Header chips ────────────────────────────────────────────────────────── */
.pulse-page-header__chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.pulse-page-chip {
    font-size: 0.78rem;
    font-weight: 600;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 5px 14px;
    white-space: nowrap;
}

.pulse-page-chip--sources {
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.12);
    border-color: rgba(124, 58, 237, 0.25);
}

.pulse-page-chip--updated {
    color: #475569;
    background: transparent;
    border-color: transparent;
    font-size: 0.72rem;
    font-weight: 400;
}

.pulse-page-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 999px;
    padding: 5px 14px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    white-space: nowrap;
}

.pulse-page-refresh:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.22);
    transform: translateY(-1px);
}

.pulse-page-refresh:disabled { opacity: 0.55; cursor: not-allowed; }

@keyframes pulse-page-spin { to { transform: rotate(360deg); } }
.pulse-page-refresh--spinning svg {
    animation: pulse-page-spin 0.8s linear infinite;
}

/* ── Body ────────────────────────────────────────────────────────────────── */
.pulse-page-body {
    padding-top: 60px;
    padding-bottom: 32px;
}

/* ── Source pills — dark theme overrides ─────────────────────────────────── */
.pulse-page .pulse-sources {
    margin-bottom: 24px;
}

.pulse-page .pulse-source-pill {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

.pulse-page .pulse-source-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
}

.pulse-page .pulse-source-pill--active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

.pulse-page .pulse-source-pill--active:hover {
    background: #6d28d9;
    border-color: #6d28d9;
}

/* ── Cards — dark theme overrides ───────────────────────────────────────── */
.pulse-page .pulse-card {
    background: #0d1829;
    border-color: rgba(255, 255, 255, 0.07);
    color: #e2e8f0;
}

.pulse-page .pulse-card:hover {
    border-color: rgba(124, 58, 237, 0.4);
    background: #101f36;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    color: #e2e8f0;
    text-decoration: none;
}

.pulse-page .pulse-card__thumb { background: #0a1220; }

.pulse-page .pulse-card__body { background: transparent; }

.pulse-page .pulse-card__title {
    color: #e2e8f0;
}

.pulse-page .pulse-card__snippet {
    color: #64748b;
}

.pulse-page .pulse-card__time {
    color: #475569;
}

.pulse-page .pulse-card__read-link {
    color: #7c3aed;
}

.pulse-page .pulse-card:hover .pulse-card__read-link {
    color: #a78bfa;
}

.pulse-page .pulse-card__footer {
    border-top-color: rgba(255, 255, 255, 0.06);
}

/* Skeleton on dark bg */
.pulse-page .pulse-card--skeleton {
    background: #0d1829;
    border-color: rgba(255, 255, 255, 0.05);
}

.pulse-page .pulse-skeleton-source,
.pulse-page .pulse-skeleton-title,
.pulse-page .pulse-skeleton-desc,
.pulse-page .pulse-skeleton-footer {
    background: rgba(255, 255, 255, 0.06);
}

/* Error state */
.pulse-page .pulse-error {
    color: #94a3b8;
}

.pulse-page .pulse-error__msg { color: #64748b; }

.pulse-page .pulse-error__retry {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
    color: #a78bfa;
}

/* Empty state */
.pulse-page-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 80px 0;
    color: #475569;
    font-size: 0.9rem;
    text-align: center;
}

.pulse-page-empty button {
    font-size: 0.82rem;
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 999px;
    padding: 6px 16px;
    cursor: pointer;
}

/* ── Paginator ───────────────────────────────────────────────────────────── */
.pulse-page .mini-paginator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 0 8px;
}

.pulse-page .mini-paginator button {
    background: rgba(124, 58, 237, 0.10);
    border: 1px solid rgba(124, 58, 237, 0.25);
    color: #a78bfa;
    border-radius: 999px;
    padding: 7px 20px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    white-space: nowrap;
}

.pulse-page .mini-paginator button:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.22);
    transform: translateY(-1px);
}

.pulse-page .mini-paginator button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pulse-page .mini-paginator__info {
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(190, 190, 190, 0.8);
    min-width: 60px;
    text-align: center;
}

/* Credit */
.pulse-page .pulse-credit {
    color: #97b2de;
    font-size: 0.72rem;
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ── Pulse light mode ────────────────────────────────────────────────────── */
html[data-theme="light"] .pulse-page { background: #f5f0ff; }
html[data-theme="light"] .pulse-page .pulse-page-header {
    background: linear-gradient(140deg, #ede9fe 0%, #ddd6fe 55%, #ede9fe 100%);
    border-bottom-color: rgba(124, 58, 237, 0.30);
}
html[data-theme="light"] .pulse-page .pulse-page-header__badge {
    color: #6d28d9;
    background: rgba(124, 58, 237, 0.12);
    border-color: rgba(124, 58, 237, 0.30);
}
html[data-theme="light"] .pulse-page .pulse-page-header__title { color: #3b0764; }
html[data-theme="light"] .pulse-page .pulse-page-header__subtitle { color: rgba(59, 7, 100, 0.65); }
html[data-theme="light"] .pulse-page .pulse-page-chip { color: #6d28d9; border-color: rgba(124, 58, 237, 0.30); background: rgba(124, 58, 237, 0.08); }
html[data-theme="light"] .pulse-page .pulse-page-refresh { color: #6d28d9; border-color: rgba(124, 58, 237, 0.30); background: rgba(124, 58, 237, 0.08); }
html[data-theme="light"] .pulse-page .pulse-page-body { color: #3b0764; }
html[data-theme="light"] .pulse-page .pulse-source-pill { background: #fff; color: #6d28d9; border-color: rgba(124,58,237,0.28); }
html[data-theme="light"] .pulse-page .pulse-source-pill:hover { background: #f5f0ff; color: #5b21b6; border-color: rgba(124,58,237,0.50); }
html[data-theme="light"] .pulse-page .pulse-source-pill--active { background: #7c3aed; border-color: #7c3aed; color: #fff; }
html[data-theme="light"] .pulse-page .pulse-source-pill--active:hover { background: #6d28d9; border-color: #6d28d9; }
html[data-theme="light"] .pulse-page .pulse-article-card { background: #fff; border-color: rgba(124, 58, 237, 0.15); }
html[data-theme="light"] .pulse-page .pulse-article-card:hover { border-color: rgba(124, 58, 237, 0.35); box-shadow: 0 4px 20px rgba(124, 58, 237, 0.12); }
html[data-theme="light"] .pulse-page .pulse-article__title { color: #3b0764; }
html[data-theme="light"] .pulse-page .pulse-article__excerpt { color: #64748b; }
html[data-theme="light"] .pulse-page .pulse-article__meta { color: #94a3b8; }
html[data-theme="light"] .pulse-page .pulse-page-empty { color: #6d28d9; }

html[data-theme="light"] .pulse-page .pulse-card {
    background: #ffffff;
    border-color: rgba(124, 58, 237, 0.12);
    color: #1e1b4b;
}
html[data-theme="light"] .pulse-page .pulse-card:hover {
    border-color: rgba(124, 58, 237, 0.35);
    background: #fafaf9;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.10);
}
html[data-theme="light"] .pulse-page .pulse-card__thumb { background: #f3f0ff; }
html[data-theme="light"] .pulse-page .pulse-card__title { color: #1e1b4b; }
html[data-theme="light"] .pulse-page .pulse-card__snippet { color: #4b5563; }
html[data-theme="light"] .pulse-page .pulse-card__time { color: #9ca3af; }
html[data-theme="light"] .pulse-page .pulse-card__read-link { color: #7c3aed; }
html[data-theme="light"] .pulse-page .pulse-card__footer { border-top-color: rgba(124, 58, 237, 0.10); }
html[data-theme="light"] .pulse-page .pulse-card--skeleton {
    background: #f3f0ff;
    border-color: rgba(124, 58, 237, 0.08);
}
html[data-theme="light"] .pulse-page .pulse-skeleton-source,
html[data-theme="light"] .pulse-page .pulse-skeleton-title,
html[data-theme="light"] .pulse-page .pulse-skeleton-desc,
html[data-theme="light"] .pulse-page .pulse-skeleton-footer {
    background: rgba(124, 58, 237, 0.08);
}
html[data-theme="light"] .pulse-page .pulse-credit {
    color: #6d28d9;
    border-top-color: rgba(124, 58, 237, 0.12);
}

/* ═══════════════════════════════════════════════════════════════════
   How It Works — button + modal
   ═══════════════════════════════════════════════════════════════════ */

.pulse-hiw-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.50);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.pulse-hiw-btn:hover {
    background: rgba(124, 58, 237, 0.14);
    color: #a78bfa;
    border-color: rgba(124, 58, 237, 0.35);
}

.pulse-hiw-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 0, 14, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: pulse-backdrop-in 0.18s ease;
}
@keyframes pulse-backdrop-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pulse-hiw-modal {
    position: relative;
    background: #0d0020;
    border: 1px solid rgba(124, 58, 237, 0.22);
    border-radius: 20px;
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 36px 36px 32px;
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.70), 0 0 0 1px rgba(124, 58, 237, 0.08);
    animation: pulse-modal-in 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 58, 237, 0.20) transparent;
}
.pulse-hiw-modal::-webkit-scrollbar       { width: 5px; }
.pulse-hiw-modal::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.20); border-radius: 99px; }
@keyframes pulse-modal-in {
    from { opacity: 0; transform: scale(0.94) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pulse-hiw-modal__close {
    position: absolute;
    top: 16px; right: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    width: 32px; height: 32px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pulse-hiw-modal__close:hover { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.30); }

.pulse-hiw-modal__header { margin-bottom: 28px; padding-right: 40px; }
.pulse-hiw-modal__eyebrow {
    font-size: 0.70rem; font-weight: 700; letter-spacing: 0.10em;
    text-transform: uppercase; color: #a78bfa; margin: 0 0 8px;
}
.pulse-hiw-modal__title {
    font-size: 1.50rem; font-weight: 800; color: #ffffff;
    margin: 0 0 10px; letter-spacing: -0.02em;
}
.pulse-hiw-modal__subtitle {
    font-size: 0.88rem; color: rgba(255,255,255,0.50); margin: 0; line-height: 1.6;
}

.pulse-hiw-section {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 24px 0;
}
.pulse-hiw-section:first-of-type { border-top: none; }
.pulse-hiw-section__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pulse-hiw-section__icon {
    font-size: 1.15rem; width: 34px; height: 34px;
    background: rgba(124,58,237,0.10); border-radius: 8px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pulse-hiw-section__title { font-size: 0.98rem; font-weight: 700; color: #fff; margin: 0; }
.pulse-hiw-section__body { font-size: 0.85rem; color: rgba(255,255,255,0.55); line-height: 1.7; margin: 0 0 10px; }
.pulse-hiw-section__body:last-child { margin-bottom: 0; }
.pulse-hiw-section__body strong { color: rgba(255,255,255,0.85); font-weight: 600; }
.pulse-hiw-section__body em     { color: #c4b5fd; font-style: normal; }

/* Sources grid */
.pulse-hiw-sources {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.pulse-hiw-source {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-left: 3px solid var(--sc, #7c3aed);
    border-radius: 10px;
    padding: 12px 14px;
}
.pulse-hiw-source__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.pulse-hiw-source__name { font-size: 0.80rem; font-weight: 700; color: var(--sc, #a78bfa); }
.pulse-hiw-source__tag {
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.pulse-hiw-source__tag--dedicated { background: rgba(124,58,237,0.15); color: #a78bfa; }
.pulse-hiw-source__tag--filtered  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.pulse-hiw-source__desc { font-size: 0.76rem; color: rgba(255,255,255,0.42); line-height: 1.55; margin: 0; }

/* Passes */
.pulse-hiw-passes { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pulse-hiw-pass {
    display: flex; align-items: flex-start; gap: 14px;
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px; padding: 14px;
}
.pulse-hiw-pass__num {
    min-width: 28px; height: 28px;
    background: rgba(124,58,237,0.15); border: 1px solid rgba(124,58,237,0.30);
    border-radius: 50%; color: #a78bfa; font-size: 0.72rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pulse-hiw-pass__content { flex: 1; min-width: 0; }
.pulse-hiw-pass__title { font-size: 0.83rem; font-weight: 700; color: rgba(255,255,255,0.80); margin: 0 0 4px; }
.pulse-hiw-pass__desc  { font-size: 0.78rem; color: rgba(255,255,255,0.45); line-height: 1.6; margin: 0; }

/* Costs table */
.pulse-hiw-table { width: 100%; border-collapse: collapse; font-size: 0.80rem; margin-top: 12px; }
.pulse-hiw-table th {
    text-align: left; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em;
    text-transform: uppercase; color: rgba(255,255,255,0.30);
    border-bottom: 1px solid rgba(255,255,255,0.08); padding: 0 12px 8px 0;
}
.pulse-hiw-table td {
    padding: 10px 12px 10px 0; color: rgba(255,255,255,0.55);
    border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: top;
}
.pulse-hiw-table tr:last-child td { border-bottom: none; }
.pulse-hiw-table__cost { color: #4ade80; font-weight: 700; }

/* ── Light mode ───────────────────────────────────────────────────── */
html[data-theme="light"] .pulse-page .pulse-hiw-btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.12); color: #6d28d9; }
html[data-theme="light"] .pulse-page .pulse-hiw-btn:hover { background: rgba(124,58,237,0.10); color: #5b21b6; border-color: rgba(124,58,237,0.35); }
html[data-theme="light"] .pulse-page .pulse-hiw-modal { background: #fff; border-color: rgba(124,58,237,0.25); box-shadow: 0 32px 100px rgba(0,0,0,0.12); }
html[data-theme="light"] .pulse-page .pulse-hiw-modal__close { background: rgba(0,0,0,0.04); border-color: #e7e5e4; color: #78716c; }
html[data-theme="light"] .pulse-page .pulse-hiw-modal__eyebrow { color: #6d28d9; }
html[data-theme="light"] .pulse-page .pulse-hiw-modal__title { color: #3b0764; }
html[data-theme="light"] .pulse-page .pulse-hiw-modal__subtitle { color: #4b5563; }
html[data-theme="light"] .pulse-page .pulse-hiw-section { border-top-color: #f0ede8; }
html[data-theme="light"] .pulse-page .pulse-hiw-section__icon { background: rgba(124,58,237,0.08); }
html[data-theme="light"] .pulse-page .pulse-hiw-section__title { color: #3b0764; }
html[data-theme="light"] .pulse-page .pulse-hiw-section__body { color: #374151; }
html[data-theme="light"] .pulse-page .pulse-hiw-section__body strong { color: #1c1917; }
html[data-theme="light"] .pulse-page .pulse-hiw-section__body em { color: #6d28d9; }
html[data-theme="light"] .pulse-page .pulse-hiw-source { background: #fafaf9; border-color: #e7e5e4; }
html[data-theme="light"] .pulse-page .pulse-hiw-source__desc { color: #6b7280; }
html[data-theme="light"] .pulse-page .pulse-hiw-pass { background: #fafaf9; border-color: #e7e5e4; }
html[data-theme="light"] .pulse-page .pulse-hiw-pass__title { color: #1c1917; }
html[data-theme="light"] .pulse-page .pulse-hiw-pass__desc { color: #6b7280; }
html[data-theme="light"] .pulse-page .pulse-hiw-table th { color: #9ca3af; border-bottom-color: #e5e7eb; }
html[data-theme="light"] .pulse-page .pulse-hiw-table td { color: #374151; border-bottom-color: #f3f4f6; }
html[data-theme="light"] .pulse-page .pulse-hiw-table__cost { color: #059669; }
