/* =============================================================================
   Probably Genetic — Design System
   Based on Kalshi's design tokens, adapted with PG brand colors.
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,400&display=swap');

/* ── Design tokens — PG Brand (Light Theme) ── */
:root {
    /* Brand — matching probablygenetic.com */
    --pg-brand-primary: #fe9f77;
    --pg-brand-secondary: #8b5167;
    --pg-brand-tertiary: #9bccc8;
    --pg-brand-dark: #433e64;

    /* Surfaces (light theme — PG website) */
    --surface-x10: #f8f6f3;
    --surface-x20: #ffffff;
    --surface-x30: #f2f0ed;
    --surface-x40: #eaecf0;
    --surface-overlay: rgba(0, 0, 0, 0.3);
    --surface-foreground: #ffffff;

    /* Text (dark-based for light backgrounds) */
    --text-x10: #585056;
    --text-x20: #6e7191;
    --text-x30: #b5b0b1;
    --text-white: #ffffff;
    --text-black: rgba(0, 0, 0, 0.9);
    --text-heading: #2d284e;

    /* Fill (dark-based overlays for light theme) */
    --fill-x10: rgba(0, 0, 0, 0.08);
    --fill-x20: rgba(0, 0, 0, 0.06);
    --fill-x30: rgba(0, 0, 0, 0.05);
    --fill-x40: rgba(0, 0, 0, 0.04);
    --fill-x50: rgba(0, 0, 0, 0.03);
    --fill-x55: rgba(0, 0, 0, 0.025);
    --fill-x60: rgba(0, 0, 0, 0.015);

    /* Stroke (border colors) */
    --stroke-x30: #d0d5dd;
    --stroke-x40: #eaecf0;

    /* Status */
    --green-x10: #16a34a;
    --green-x20: rgba(22, 163, 74, 0.1);
    --green-x30: rgba(22, 163, 74, 0.2);
    --red-x10: #dc2626;
    --red-x20: rgba(220, 38, 38, 0.1);
    --red-x30: rgba(220, 38, 38, 0.15);

    /* Accent palette for race chart lines */
    --accent-purple: #7f56d9;
    --accent-blue: #3b82f6;
    --accent-teal: #0d9488;
    --accent-yellow: #d97706;
    --accent-orange: #ea580c;
    --accent-pink: #db2777;
    --accent-cyan: #0891b2;
    --accent-lime: #65a30d;

    /* Special */
    --gold: #d97706;
    --silver: #6b7280;
    --bronze: #b45309;

    /* Border radii — PG website uses rounder shapes */
    --radius-x10: 3px;
    --radius-x20: 8px;
    --radius-x30: 12px;
    --radius-x40: 15px;
    --radius-x50: 38px;

    /* Shadows — subtle, warm */
    --shadow-x10: 0 0 30px rgba(45,62,80,0.04), 0 2px 8px rgba(45,62,80,0.04);
    --shadow-x20: 0 0 40px rgba(45,62,80,0.06), 0 4px 16px rgba(45,62,80,0.05);
    --shadow-x30: 0 0 50px rgba(45,62,80,0.06), 0 8px 24px rgba(45,62,80,0.04);

    /* Spacing */
    --space-0: 0;
    --space-0-5: 4px;
    --space-1: 8px;
    --space-1-5: 12px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
    --space-6: 48px;
    --space-7: 56px;

    /* Layout */
    --max-width: 1140px;
    --nav-height: 60px;

    /* Typography — Merriweather (PG brand serif) + system sans for UI */
    --font-serif: 'Merriweather', Georgia, 'Times New Roman', serif;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;

    /* Transitions */
    --duration-fast: 50ms;
    --duration-default: 100ms;
    --duration-medium: 200ms;
    --duration-slow: 300ms;
    --duration-reveal: 600ms;
}


/* ── Reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--surface-x10);
    color: var(--text-x10);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

img { display: block; max-width: 100%; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select, textarea {
    font-family: inherit;
}


/* ── Typography ── */
.typ-headline-x20 {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-heading);
}

.typ-headline-x10 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text-heading);
}

.typ-title-x10 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.typ-emphasis-x10 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.typ-emphasis-x20 {
    font-size: 0.8rem;
    font-weight: 600;
}

.typ-emphasis-x30 {
    font-size: 0.85rem;
    font-weight: 500;
}

.typ-body-x10 {
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.5;
}

.typ-body-x20 {
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
}

.typ-body-x30 {
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.6;
}

.typ-overline-x10 {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.typ-overline-x20 {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.typ-tabular {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
}


/* ── Navigation ── */
.pg-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    height: var(--nav-height);
    padding: 0 var(--space-3);
    background: var(--surface-x10);
    border-bottom: 1px solid var(--stroke-x40);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.pg-nav__inner {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    gap: var(--space-0-5);
}

.pg-nav__brand {
    display: flex;
    align-items: center;
    margin-right: var(--space-3);
    flex-shrink: 0;
}

.pg-nav__brand img {
    height: 32px;
}

.pg-nav__links {
    display: flex;
    align-items: center;
    gap: var(--space-0-5);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.pg-nav__links::-webkit-scrollbar {
    display: none;
}

.pg-nav__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-x50);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-x20);
    white-space: nowrap;
    transition: background-color var(--duration-medium), color var(--duration-medium);
}

.pg-nav__link:hover {
    background: var(--fill-x60);
    color: var(--text-x10);
}

.pg-nav__link--active {
    color: var(--text-x10);
    background: var(--fill-x55);
}


/* ── Page container ── */
.pg-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3);
}


/* ── Section headers (like Kalshi "Elections >", "Companies >") ── */
.pg-section {
    margin-bottom: var(--space-5);
}

.pg-section__header {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
    cursor: pointer;
    transition: opacity var(--duration-medium);
}

.pg-section__header:hover {
    opacity: 0.8;
}

.pg-section__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-x10);
}

.pg-section__arrow {
    font-size: 1.1rem;
    color: var(--text-x20);
    transition: transform var(--duration-medium);
}

.pg-section__header:hover .pg-section__arrow {
    transform: translateX(4px);
}


/* ── Race card grid ── */
.pg-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: var(--space-2);
}

@media (max-width: 480px) {
    .pg-card-grid {
        grid-template-columns: 1fr;
    }
}


/* ── Race card (individual market tile) ── */
.pg-race-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: var(--space-2);
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x40);
    cursor: pointer;
    transition: border-color var(--duration-medium), transform var(--duration-default);
    overflow: hidden;
}

.pg-race-card:hover {
    border-color: var(--stroke-x30);
}

.pg-race-card:active {
    transform: scale(0.95);
    transition: transform var(--duration-fast);
}

.pg-race-card__category {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pg-brand-primary);
    margin-bottom: var(--space-0-5);
}

.pg-race-card__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-x10);
    line-height: 1.35;
    margin-bottom: var(--space-1-5);
}

.pg-race-card__entries {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.pg-race-card__entry {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--space-1);
    align-items: center;
    min-height: 36px;
}

.pg-race-card__entry-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-x10);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-race-card__entry-gene {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-x20);
    background: var(--fill-x55);
    padding: 1px 6px;
    border-radius: var(--radius-x10);
    margin-left: var(--space-0-5);
}

.pg-race-card__entry-rate {
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 50px;
    text-align: right;
}

.pg-race-card__entry-rate--positive { color: var(--green-x10); }
.pg-race-card__entry-rate--negative { color: var(--red-x10); }

.pg-race-card__pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 10px;
    border: 1px solid var(--fill-x40);
    border-radius: var(--radius-x50);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 48px;
    transition: opacity var(--duration-default), background-color var(--duration-default), transform var(--duration-default);
}

.pg-race-card__pill:hover {
    opacity: 0.8;
}

.pg-race-card__pill:active {
    transform: scale(0.9);
    transition: transform var(--duration-fast);
}

.pg-race-card__pill--green {
    color: var(--green-x10);
    background: transparent;
}

.pg-race-card__pill--red {
    color: var(--red-x10);
    background: transparent;
}

.pg-race-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-1-5);
    padding-top: var(--space-1);
    border-top: 1px solid var(--fill-x60);
}

.pg-race-card__stat {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-x20);
    font-variant-numeric: tabular-nums;
}

.pg-race-card__link {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pg-brand-primary);
}


/* ── Progress bar (Kalshi-style inline bar) ── */
.pg-progress-bar {
    position: relative;
    height: 4px;
    background: var(--fill-x60);
    border-radius: var(--radius-x50);
    overflow: hidden;
    min-width: 60px;
}

.pg-progress-bar__fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    border-radius: var(--radius-x50);
    transition: width var(--duration-slow) ease-out;
}


/* ── Sidebar ── */
.pg-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 280px;
    max-width: 320px;
}

.pg-sidebar__section {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.pg-sidebar__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-x10);
    margin-bottom: var(--space-0-5);
}

.pg-sidebar__item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-0-5) var(--space-1);
    border-radius: var(--radius-x30);
    cursor: pointer;
    transition: background-color var(--duration-medium);
}

.pg-sidebar__item:hover {
    background: var(--fill-x60);
}

.pg-sidebar__rank {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-x20);
    min-width: 20px;
    font-variant-numeric: tabular-nums;
}

.pg-sidebar__name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-x10);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-sidebar__value {
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.pg-sidebar__change--up {
    color: var(--green-x10);
}

.pg-sidebar__change--down {
    color: var(--red-x10);
}


/* ── Buttons ── */
.pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity var(--duration-default), background-color var(--duration-default), transform var(--duration-default);
}

.pg-btn:hover { opacity: 0.8; }
.pg-btn:active {
    transform: scale(0.9);
    transition: transform var(--duration-fast);
}

.pg-btn--sm {
    height: 32px;
    padding: 0 var(--space-1-5);
    font-size: 0.8rem;
    border-radius: var(--radius-x50);
}

.pg-btn--md {
    height: 40px;
    padding: 0 var(--space-2);
    font-size: 0.85rem;
    border-radius: var(--radius-x30);
}

.pg-btn--lg {
    height: 48px;
    padding: 0 var(--space-3);
    font-size: 0.95rem;
    border-radius: var(--radius-x30);
}

.pg-btn--primary {
    background: var(--pg-brand-primary);
    color: var(--text-white);
}

.pg-btn--secondary {
    background: var(--fill-x55);
    color: var(--text-x10);
    border-color: var(--stroke-x40);
}

.pg-btn--ghost {
    background: transparent;
    color: var(--text-x10);
}

.pg-btn--ghost:hover {
    background: var(--fill-x60);
    opacity: 1;
}


/* ── Toggle group (Kalshi-style pill toggles) ── */
.pg-toggle-group {
    display: inline-flex;
    background: var(--fill-x60);
    border-radius: var(--radius-x50);
    padding: 3px;
    gap: 2px;
}

.pg-toggle-btn {
    padding: 6px 14px;
    border-radius: var(--radius-x50);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-x20);
    background: transparent;
    transition: all var(--duration-medium);
    white-space: nowrap;
}

.pg-toggle-btn:hover {
    color: var(--text-x10);
    background: var(--fill-x60);
}

.pg-toggle-btn--active {
    color: var(--surface-x10);
    background: var(--pg-brand-primary);
    font-weight: 700;
}


/* ── Chart container ── */
.pg-chart-container {
    position: relative;
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x40);
    padding: var(--space-3);
    overflow: hidden;
}

.pg-chart-container__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
    gap: var(--space-1);
}

.pg-chart-container__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-x10);
}

.pg-chart-area {
    width: 100%;
    height: 400px;
}

/* Chart reveal animation (Kalshi-exact) */
@keyframes chartRevealWipe {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.chart-reveal-wipe {
    transform-origin: 0 0;
    animation: chartRevealWipe 1.2s cubic-bezier(0.66, 0, 0.34, 1) forwards;
}


/* ── Event dots bar ── */
.pg-event-dots {
    display: flex;
    align-items: center;
    height: 24px;
    margin-top: var(--space-0-5);
    position: relative;
}

.pg-event-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fill-x30);
    position: absolute;
    cursor: pointer;
    transition: background-color var(--duration-medium), transform var(--duration-default);
}

.pg-event-dot:hover {
    background: var(--pg-brand-primary);
    transform: scale(1.5);
}

.pg-event-dot--fda { background: #22c55e; }
.pg-event-dot--publication { background: #a855f7; }
.pg-event-dot--guidelines { background: #3b82f6; }
.pg-event-dot--guideline { background: #3b82f6; }
.pg-event-dot--testing_program { background: #14b8a6; }
.pg-event-dot--testing { background: #14b8a6; }
.pg-event-dot--clinical_trial { background: #f59e0b; }
.pg-event-dot--discovery { background: #ec4899; }
.pg-event-dot--advocacy { background: #f97316; }
.pg-event-dot--drug_development { background: #6366f1; }
.pg-event-dot--newborn_screening { background: #06b6d4; }


/* ── Collapsible section (Kalshi Market Rules style) ── */
.pg-collapsible {
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    overflow: hidden;
}

.pg-collapsible__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-1) var(--space-1-5);
    background: var(--fill-x60);
    color: var(--text-x10);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--duration-medium);
}

.pg-collapsible__trigger:hover {
    background: var(--fill-x55);
}

.pg-collapsible__chevron {
    transition: transform var(--duration-slow);
    font-size: 0.7rem;
    color: var(--text-x20);
}

.pg-collapsible[open] .pg-collapsible__chevron {
    transform: rotate(180deg);
}

.pg-collapsible__content {
    padding: var(--space-1-5);
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-x20);
}


/* ── Subscribe CTA ── */
.pg-subscribe {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-2);
    background: var(--surface-x30);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x40);
}

.pg-subscribe__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-x10);
}

.pg-subscribe__desc {
    font-size: 0.8rem;
    color: var(--text-x20);
    line-height: 1.5;
}

.pg-subscribe__form {
    display: flex;
    gap: var(--space-1);
}

.pg-subscribe__input {
    flex: 1;
    height: 40px;
    padding: 0 var(--space-1-5);
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    color: var(--text-x10);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--duration-medium);
}

.pg-subscribe__input:focus {
    border-color: var(--pg-brand-primary);
}

.pg-subscribe__input::placeholder {
    color: var(--text-x30);
}


/* ── Footer ── */
.pg-footer {
    border-top: 1px solid var(--stroke-x40);
    padding: var(--space-5) var(--space-3);
    margin-top: var(--space-7);
}

.pg-footer__inner {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    max-width: var(--max-width);
    margin: 0 auto;
}

.pg-footer__col-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-x10);
    margin-bottom: var(--space-1-5);
}

.pg-footer__link {
    display: block;
    font-size: 0.85rem;
    color: var(--text-x20);
    padding: var(--space-0-5) 0;
    transition: color var(--duration-medium);
}

.pg-footer__link:hover {
    color: var(--text-x10);
}

.pg-footer__bottom {
    max-width: var(--max-width);
    margin: var(--space-5) auto 0;
    padding-top: var(--space-3);
    border-top: 1px solid var(--stroke-x40);
    font-size: 0.75rem;
    color: var(--text-x30);
    line-height: 1.6;
}

.pg-footer__copyright {
    font-weight: 600;
    color: var(--text-x20);
    margin-bottom: var(--space-1);
}


/* ── Homepage layout (content + sidebar) ── */
.pg-home-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-3);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3);
}

@media (max-width: 960px) {
    .pg-home-layout {
        grid-template-columns: 1fr;
    }

    .pg-sidebar {
        display: none;
    }
}


/* ── Race page layout (content + sidebar) ── */
.pg-race-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: var(--space-3);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3);
}

@media (max-width: 960px) {
    .pg-race-layout {
        grid-template-columns: 1fr;
    }
}


/* ── Loading states ── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.pg-skeleton {
    background: linear-gradient(90deg, var(--fill-x60) 25%, var(--fill-x55) 50%, var(--fill-x60) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
    border-radius: var(--radius-x20);
}


/* ── ClinVar fetch loading animation ── */
.pg-fetch-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    gap: 20px;
}

.pg-fetch-loader__ring {
    position: relative;
    width: 64px;
    height: 64px;
}

.pg-fetch-loader__ring svg {
    width: 100%;
    height: 100%;
    animation: pg-ring-spin 2.5s linear infinite;
}

.pg-fetch-loader__ring circle {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.pg-fetch-loader__ring circle:first-child {
    stroke: var(--fill-x55);
}

.pg-fetch-loader__ring circle:last-child {
    stroke: var(--pg-brand-primary);
    stroke-dasharray: 140;
    stroke-dashoffset: 80;
    animation: pg-ring-dash 2.5s ease-in-out infinite;
}

.pg-fetch-loader__label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    color: var(--text-x20);
    text-transform: uppercase;
}

.pg-fetch-loader__countdown {
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--pg-brand-primary);
    font-family: var(--font-mono);
}

.pg-fetch-loader__bar-wrap {
    width: 180px;
    height: 3px;
    background: var(--fill-x55);
    border-radius: 2px;
    overflow: hidden;
}

.pg-fetch-loader__bar {
    height: 100%;
    background: var(--pg-brand-primary);
    border-radius: 2px;
    transition: width 1s linear;
}

@keyframes pg-ring-spin {
    to { transform: rotate(360deg); }
}

@keyframes pg-ring-dash {
    0%   { stroke-dashoffset: 140; }
    50%  { stroke-dashoffset: 40; }
    100% { stroke-dashoffset: 140; }
}


/* ── Tooltip ── */
.pg-tooltip {
    position: absolute;
    z-index: 50;
    padding: var(--space-1) var(--space-1-5);
    background: var(--surface-x30);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    font-size: 0.75rem;
    color: var(--text-x10);
    line-height: 1.4;
    box-shadow: var(--shadow-x20);
    pointer-events: none;
    white-space: nowrap;
}


/* ── Search input (shared) ── */
.pg-search {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.pg-search__input {
    width: 100%;
    height: 40px;
    padding: 0 var(--space-2) 0 36px;
    background: var(--fill-x60);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x50);
    color: var(--text-x10);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--duration-medium), background-color var(--duration-medium);
}

.pg-search__input:focus {
    border-color: var(--pg-brand-primary);
    background: var(--surface-x20);
}

.pg-search__input::placeholder {
    color: var(--text-x30);
}

.pg-search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-x30);
    pointer-events: none;
}

.pg-search__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    box-shadow: var(--shadow-x20);
    max-height: 320px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.pg-search__dropdown--open {
    display: block;
}

.pg-search__item {
    display: flex;
    align-items: center;
    padding: var(--space-1) var(--space-1-5);
    cursor: pointer;
    transition: background-color var(--duration-medium);
}

.pg-search__item:hover,
.pg-search__item--highlighted {
    background: var(--fill-x60);
}


/* ── Badge / tag ── */
.pg-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-x50);
    font-size: 0.7rem;
    font-weight: 600;
}

.pg-badge--brand {
    background: rgba(254, 159, 119, 0.16);
    color: var(--pg-brand-primary);
}

.pg-badge--green {
    background: var(--green-x20);
    color: var(--green-x10);
}

.pg-badge--neutral {
    background: var(--fill-x55);
    color: var(--text-x20);
}


/* ── Responsive utilities ── */
@media (max-width: 768px) {
    .pg-container {
        padding: var(--space-2) var(--space-1);
    }

    .pg-footer__inner {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }

    .pg-card-grid {
        grid-template-columns: 1fr;
    }

    .pg-nav__brand img {
        height: 28px;
    }
}

@media (max-width: 480px) {
    .typ-headline-x20 {
        font-size: 1.35rem;
    }

    .pg-race-layout {
        padding: var(--space-2) var(--space-1);
    }
}

/* ── Page layout (single column with header) ── */
.pg-page-layout {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3) var(--space-2);
}

.pg-page-header {
    margin-bottom: var(--space-3);
}

/* ── Toggle group wrap variant ── */
.pg-toggle-group--wrap {
    flex-wrap: wrap;
}

/* ── Table ── */
.pg-table-container {
    overflow-x: auto;
    border-radius: var(--radius-x30);
    border: 1px solid var(--stroke-x40);
    background: var(--surface-x20);
}

.pg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pg-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.pg-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-x30);
    background: var(--surface-x30);
    border-bottom: 1px solid var(--stroke-x40);
    white-space: nowrap;
}

.pg-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--fill-x60);
    color: var(--text-x10);
    vertical-align: middle;
}

.pg-table__row {
    transition: background var(--duration-fast);
}

.pg-table__row:hover {
    background: var(--fill-x50);
}

.pg-table__rank {
    width: 40px;
    text-align: center !important;
    color: var(--text-x30) !important;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.pg-table__num {
    text-align: right !important;
    white-space: nowrap;
}

.pg-table__disease {
    min-width: 180px;
}

.pg-table__drugs {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

/* ── Gene tag ── */
.pg-gene-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 6px;
    background: var(--fill-x50);
    border-radius: var(--radius-x10);
    color: var(--text-x20);
}

/* ── Badge variants ── */
.pg-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-x50);
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--fill-x50);
    color: var(--text-x20);
    white-space: nowrap;
}

.pg-badge--green {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.pg-badge--coral {
    background: rgba(254, 159, 119, 0.15);
    color: var(--pg-brand-primary);
}

/* ── Company card ── */
.pg-company-card {
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x40);
    overflow: hidden;
    transition: transform var(--duration-default), box-shadow var(--duration-default);
}

.pg-company-card:hover {
    box-shadow: var(--shadow-x10);
}

.pg-company-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2);
    border-bottom: 1px solid var(--fill-x60);
}

.pg-company-card__drugs {
    display: flex;
    flex-direction: column;
}

.pg-company-card__drug {
    display: block;
    padding: 10px var(--space-2);
    border-bottom: 1px solid var(--fill-x60);
    text-decoration: none;
    color: inherit;
    transition: background var(--duration-fast);
}

.pg-company-card__drug:last-child {
    border-bottom: none;
}

.pg-company-card__drug:hover {
    background: var(--fill-x50);
}

.pg-company-card__drug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

/* Company tile (listing page + portfolio cards) */
.pg-company-tile {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--surface-x10);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    padding: var(--space-2);
    transition: border-color var(--duration-fast), background var(--duration-fast);
}
.pg-company-tile:hover {
    border-color: var(--pg-brand-primary);
    background: var(--surface-x20);
}
.pg-company-tile__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.pg-company-tile__name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-x10);
    line-height: 1.3;
}
.pg-company-tile__stat {
    text-align: right;
    flex-shrink: 0;
}
.pg-company-tile__stat-value {
    display: block;
    font-weight: 700;
    font-size: 1.2rem;
    line-height: 1.2;
}
.pg-company-tile__stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-x30);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pg-stat--green .pg-company-tile__stat-value { color: var(--green-x10); }
.pg-stat--red .pg-company-tile__stat-value { color: #ef4444; }
.pg-disease-tile__gene {
    display: inline-block;
    background: var(--fill-x10);
    color: var(--text-x10);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.pg-company-tile__meta {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-x30);
}

/* Info tip (?) icon with custom tooltip */
.pg-info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--fill-x10);
    color: var(--text-x20);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
    flex-shrink: 0;
    position: relative;
    outline: none;
}
.pg-info-tip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    right: -8px;
    padding: var(--space-1) var(--space-1-5);
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-x10);
    line-height: 1.5;
    box-shadow: var(--shadow-x20);
    white-space: normal;
    max-width: 320px;
    width: max-content;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.pg-info-tip[data-tooltip]:hover::after,
.pg-info-tip[data-tooltip]:focus::after {
    opacity: 1;
}

/* ── Kalshi-style chart (kc-*) ── */
.kc-chart-wrap {
    position: relative;
    overflow: hidden;
    margin-top: 22px;
}

/* Y-axis label — subtle, positioned top-right of chart, above the chart canvas */
.kc-y-label {
    position: absolute;
    top: -18px;
    right: 0;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-x30);
    cursor: help;
    z-index: 2;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-bottom: 1px dotted var(--text-x30);
    padding-bottom: 1px;
    transition: color var(--duration-medium);
}
.kc-y-label:hover {
    color: var(--text-x10);
}

/* Small toggle variant */
.pg-toggle-group--sm {
    padding: 2px;
    gap: 1px;
}
.pg-toggle-btn--sm {
    padding: 3px 10px;
    font-size: 0.7rem;
    height: auto;
}

/* Logo overlaid inside chart area, top-left */
.kc-watermark-inset {
    position: absolute;
    bottom: 28px;
    right: 48px;
    width: 32px;
    height: 32px;
    opacity: 0.5;
    z-index: 2;
    pointer-events: none;
}

/* Legacy: Logo in header area (keep for backward compat) */
.kc-watermark {
    width: 28px;
    height: 28px;
    opacity: 1;
    flex-shrink: 0;
    margin-left: auto;
}

/* Legend — compact, Kalshi-style */
.kc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 6px 0;
    font-size: 0.78rem;
    align-items: center;
}
.kc-legend__item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: opacity var(--duration-medium);
}
.kc-legend__item:hover {
    opacity: 0.7;
}
.kc-legend__item--hidden {
    opacity: 0.3;
}
.kc-legend__item--hidden .kc-legend__name {
    text-decoration: line-through;
}
.kc-legend__item--hidden .kc-legend__value {
    text-decoration: line-through;
}
.kc-legend__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kc-legend__name {
    color: var(--text-x20);
    font-weight: 400;
    font-size: 0.75rem;
}
.kc-legend__value {
    font-weight: 700;
    font-size: 0.78rem;
}

/* Date label — follows crosshair, above chart (Kalshi-style) */
.kc-date-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-x10);
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.12s;
    white-space: nowrap;
}
.kc-date-label--visible {
    opacity: 1;
}

/* Fade overlay — subtle, matches background to dim only lines */
.kc-fade {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    background: rgba(248, 246, 243, 0.45);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.08s;
}
.kc-fade--visible {
    opacity: 1;
}

/* Crosshair labels — card-style tooltip with submitter breakdown */
.kc-crosshair-label {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 6px 10px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(4px);
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-size: 0.72rem;
    white-space: nowrap;
    transform: translateY(-50%);
}
.kc-crosshair-label__row {
    display: flex;
    align-items: center;
    gap: 5px;
}
.kc-crosshair-label__dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.kc-crosshair-label__name {
    color: var(--text-x20);
    font-weight: 400;
}
.kc-crosshair-label__val {
    font-weight: 700;
    font-size: 0.85rem;
}
.kc-crosshair-subs {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(0,0,0,0.06);
}
.kc-crosshair-sub {
    font-size: 0.6rem;
    color: var(--text-x20);
    font-family: var(--font-sans);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}
.kc-crosshair-sub em {
    font-style: normal;
    font-weight: 600;
    color: var(--text-x10);
}

/* Live dots — subtle soft glow */
@keyframes kc-glow {
    0%, 100% { box-shadow: 0 0 3px 1px currentColor; }
    50% { box-shadow: 0 0 6px 3px currentColor; }
}
.kc-live-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
    transform: translate(-50%, -50%);
    animation: kc-glow 2.5s ease-in-out infinite;
}

/* Event timeline bubbles — inside chart, along x-axis */
.kc-events {
    position: absolute;
    bottom: 28px;
    left: 0;
    right: 0;
    height: 16px;
    pointer-events: none;
    z-index: 2;
}
.kc-event-bubble {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0,0,0,0.12);
    border: 1px solid rgba(0,0,0,0.08);
    cursor: pointer;
    pointer-events: auto;
    transform: translateX(-50%);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    z-index: 2;
}
.kc-event-bubble:hover,
.kc-event-bubble--active {
    background: var(--pg-brand-primary);
    border-color: var(--pg-brand-primary);
    box-shadow: 0 0 6px 2px rgba(254, 159, 119, 0.5);
}
.kc-event-bubble--highlight {
    background: rgba(254, 159, 119, 0.6);
    border-color: var(--pg-brand-primary);
}

/* Event detail panel */
.kc-event-detail {
    margin-top: 6px;
    font-size: 0.8rem;
}
.kc-event-detail__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.kc-event-detail__date {
    font-size: 0.72rem;
    color: var(--text-x30);
}
.kc-event-detail__nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
}
.kc-event-detail__nav a {
    color: var(--pg-brand-primary);
    text-decoration: none;
    cursor: pointer;
}
.kc-event-detail__nav a:hover {
    text-decoration: underline;
}
.kc-event-detail__close {
    background: none;
    border: none;
    color: var(--text-x30);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    line-height: 1;
}
.kc-event-detail__title {
    font-weight: 600;
    color: var(--text-x10);
    margin-bottom: 4px;
}
.kc-event-detail__desc {
    color: var(--text-x20);
    line-height: 1.5;
}
.kc-event-detail__ref {
    margin-top: 6px;
}
.kc-event-detail__ref a {
    color: var(--pg-brand-primary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
}
.kc-event-detail__ref a:hover {
    text-decoration: underline;
}
.kc-event-detail__meta {
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-x30);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* PubMed and Tweet event bubble variants */
.kc-event-bubble--pubmed {
    background: rgba(109, 40, 217, 0.4);
    border-color: rgba(109, 40, 217, 0.5);
}
.kc-event-bubble--tweet {
    background: rgba(59, 130, 246, 0.4);
    border-color: rgba(59, 130, 246, 0.5);
}

/* AI warning — separate banner */
.kc-ai-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-top: 6px;
    background: var(--fill-x50);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x20);
    font-size: 0.72rem;
    color: var(--text-x20);
}
.kc-ai-warning__actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.kc-ai-warning a {
    color: var(--pg-brand-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.72rem;
}
.kc-ai-warning__close {
    background: none;
    border: none;
    color: var(--text-x30);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 2px;
    line-height: 1;
}

/* Per-product dual-axis charts */
.kc-product-chart {
    background: var(--surface-x10);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x30);
    padding: var(--space-2);
    margin-bottom: var(--space-2);
}
.kc-product-chart__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}
.kc-product-chart__title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-x10);
}
.kc-product-chart__subtitle {
    font-size: 0.75rem;
    color: var(--text-x30);
    margin-top: 2px;
}
.kc-product-chart__legend {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-x20);
    flex-shrink: 0;
}
.kc-product-chart__legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.kc-product-chart__canvas {
    width: 100%;
    height: 250px;
}


/* =============================================================================
   Insights / LinkedIn Posts
   ============================================================================= */

.pg-page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-3) var(--space-2);
}

.pg-page-header {
    margin-bottom: var(--space-2);
}

/* ── Insight card (listing) ── */
.pg-insight-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x40);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, background 0.15s;
    margin-bottom: var(--space-1);
}
.pg-insight-card:hover {
    border-color: var(--pg-brand-primary);
    background: var(--surface-x30);
}
.pg-insight-card__content {
    min-width: 0;
    flex: 1;
}
.pg-insight-card__title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-x10);
    margin-bottom: 4px;
}
.pg-insight-card__subtitle {
    font-size: 0.82rem;
    color: var(--text-x20);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pg-insight-card__footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.pg-insight-card__date {
    font-size: 0.75rem;
    color: var(--text-x30);
}
.pg-insight-card__tag {
    font-size: 0.68rem;
    color: var(--text-x20);
    background: var(--fill-x10);
    padding: 2px 8px;
    border-radius: var(--radius-x30);
}
.pg-insight-card__arrow {
    font-size: 1.3rem;
    color: var(--text-x30);
    flex-shrink: 0;
    transition: color 0.15s, transform 0.15s;
}
.pg-insight-card:hover .pg-insight-card__arrow {
    color: var(--pg-brand-primary);
    transform: translateX(3px);
}

/* ── Insight detail ── */
.pg-back-link {
    display: inline-block;
    color: var(--text-x20);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: var(--space-2);
    transition: color 0.15s;
}
.pg-back-link:hover {
    color: var(--pg-brand-primary);
}

.pg-insight__header {
    margin-bottom: var(--space-2);
}
.pg-insight__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-x20);
    margin-bottom: 12px;
}

.pg-insight__body p {
    line-height: 1.65;
}
.pg-insight__body h3 {
    color: var(--text-x10);
}
.pg-insight__body ul {
    color: var(--text-x10);
}
.pg-insight__body li {
    line-height: 1.5;
}

.pg-insight__methodology {
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--text-x20);
}
.pg-insight__methodology strong {
    color: var(--text-x10);
}

.pg-insight__cta {
    background: var(--surface-x20);
    border: 1px solid var(--stroke-x40);
    border-radius: var(--radius-x40);
    padding: var(--space-2);
}
