/* ============================================================
   TERTON NEWS — Design System
   Dark editorial aesthetic, purple accent, pill navigation
   ============================================================ */

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

:root {
    /* Surfaces */
    --bg-primary: #0d0d12;
    --bg-secondary: #13131a;
    --bg-card: #1a1a24;
    --bg-card-hover: #1f1f2c;
    --bg-elevated: #222230;
    --bg-input: #16161f;
    --bg-overlay: rgba(8, 8, 14, 0.85);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* Text */
    --text-primary: #e8e6f0;
    --text-secondary: #9894a8;
    --text-muted: #6b6780;
    --text-inverse: #0d0d12;

    /* Purple accent */
    --accent: #9366ff;
    --accent-soft: rgba(147, 102, 255, 0.15);
    --accent-softer: rgba(147, 102, 255, 0.08);
    --accent-hover: #a47fff;
    --accent-glow: rgba(147, 102, 255, 0.3);

    /* Status */
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --info: #60a5fa;

    /* Political spectrum */
    --deep-green: #059669;
    --green: #34d399;
    --neutral: #9ca3af;
    --blue: #60a5fa;
    --deep-blue: #3b82f6;

    /* Typography */
    --font-display: 'Montserrat', 'Noto Sans TC', sans-serif;
    --font-body: 'Poppins', 'Noto Sans TC', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.2s;

    /* Layout */
    --nav-height: 64px;
    --max-width: 1280px;
    --sidebar-width: 280px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        linear-gradient(rgba(147, 102, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(147, 102, 255, 0.015) 1px, transparent 1px);
    background-size: 60px 60px;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* --- Typography --- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2.5rem; line-height: 1.15; }
h2 { font-size: 1.75rem; line-height: 1.25; }
h3 { font-size: 1.25rem; line-height: 1.35; }

/* ============================================================
   PILL NAVIGATION
   ============================================================ */
.pill-nav-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    pointer-events: none;
}

.pill-nav-inner {
    display: flex;
    align-items: center;
    border-radius: 9999px;
    padding: 4px 4px 4px 6px;
    transition: all 0.35s ease;
    pointer-events: auto;
    /* Default: glassmorphism (over hero) */
    background: rgba(20, 15, 35, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
}

/* Scrolled state applied by JS */
.pill-nav-inner--scrolled {
    background: rgba(30, 20, 55, 0.95);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Logo */
.pill-logo {
    height: 32px;
    padding: 4px 10px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 4px;
    transition: transform 0.3s ease;
    background: transparent;
}

.pill-logo:hover { transform: scale(1.05); }

.pill-logo__img {
    height: 22px;
    width: auto;
    object-fit: contain;
    display: block;
}

.pill-logo__img--light { display: none; }
.pill-logo__img--dark { display: none; }
.pill-logo__img--nav { display: block; }
.pill-logo__img--nav-scrolled { display: none; }

/* Light theme scrolled: show dark logo instead of white */
[data-theme="light"] .pill-nav-inner--scrolled .pill-logo__img--nav { display: none; }
[data-theme="light"] .pill-nav-inner--scrolled .pill-logo__img--nav-scrolled { display: block; }

/* Nav items list */
.pill-items {
    display: flex;
    align-items: center;
    gap: 3px;
    list-style: none;
    height: 36px;
}

.pill-items li {
    display: flex;
    height: 100%;
}

/* Individual pill item */
.pill-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 18px;
    border-radius: 9999px;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    color: #fff;
    transition: color 0.2s ease;
    white-space: nowrap;
}

/* Circle expand on hover */
.pill-item__circle {
    position: absolute;
    left: 50%;
    bottom: 0;
    border-radius: 50%;
    pointer-events: none;
    transform: translateX(-50%) scale(0);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 0;
    background: rgba(139, 92, 246, 0.4);
}

.pill-item:hover .pill-item__circle {
    transform: translateX(-50%) scale(1.2);
}

.pill-nav-inner--scrolled .pill-item__circle {
    background: #7c3aed;
}

/* Label stack for slide animation */
.label-stack {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 1.1em;
}

.pill-item__label {
    display: block;
    text-align: center;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.pill-item__label-hover {
    position: absolute;
    z-index: 2;
    display: block;
    text-align: center;
    width: 100%;
    opacity: 0;
    color: #fff;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.pill-item:hover .pill-item__label {
    transform: translateY(-100%);
}

.pill-item:hover .pill-item__label-hover {
    opacity: 1;
    transform: translateY(0);
}

/* Active indicator dot */
.pill-item--active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    z-index: 3;
}

.pill-nav-inner--scrolled .pill-item--active::after {
    background: #a78bfa;
}

/* Alias: old nav__link--active works on pill items */
.pill-item.nav__link--active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    z-index: 3;
}

.pill-nav-inner--scrolled .pill-item.nav__link--active::after {
    background: #a78bfa;
}

/* Scrolled state text color */
.pill-nav-inner--scrolled .pill-item {
    color: #d4d0e8;
}

/* Divider */
.pill-divider {
    width: 1px;
    height: 18px;
    margin: 0 6px;
    flex-shrink: 0;
    background: #fff;
    opacity: 0.25;
}

.pill-nav-inner--scrolled .pill-divider {
    background: #d4d0e8;
}

/* Utility buttons (theme, lang) */
.pill-util-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.pill-util {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-display);
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: transparent;
    color: #fff;
}

.pill-nav-inner--scrolled .pill-util {
    color: #d4d0e8;
}

.pill-util:hover { transform: scale(1.1); }

/* ── Globe dropdown ── */
.pill-globe-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.pill-globe-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 160px;
    background: rgba(20, 15, 35, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
    z-index: 1001;
}

.pill-globe-wrap--open .pill-globe-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.pill-globe-dropdown__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.pill-globe-dropdown__item:hover {
    background: rgba(147, 102, 255, 0.25);
    color: #fff;
}

.pill-globe-dropdown__item--disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
    font-style: italic;
    font-weight: 400;
}

.pill-globe-dropdown__item--disabled:hover {
    background: none;
    color: rgba(255, 255, 255, 0.35);
}

.pill-globe-dropdown__flag {
    font-size: 1rem;
    line-height: 1;
}

/* Scrolled state — matches pill-nav-inner--scrolled */
.pill-nav-inner--scrolled .pill-globe-dropdown {
    background: rgba(30, 20, 55, 0.97);
    border-color: rgba(139, 92, 246, 0.25);
}

.pill-nav-inner--scrolled .pill-globe-dropdown__item {
    color: #d4d0e8;
}

.pill-nav-inner--scrolled .pill-globe-dropdown__item--disabled {
    color: rgba(212, 208, 232, 0.35);
}

/* Light theme — over hero (glass) */
[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-globe-dropdown {
    background: rgba(255, 255, 255, 0.55) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
}

[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-globe-dropdown__item {
    color: #fff !important;
}

[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-globe-dropdown__item:hover {
    background: rgba(147, 102, 255, 0.25) !important;
    color: #fff !important;
}

[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-globe-dropdown__item--disabled {
    color: rgba(255, 255, 255, 0.35) !important;
}

[data-theme="light"] .pill-globe-dropdown__item {
    color: #fff;
}

[data-theme="light"] .pill-globe-dropdown__item:hover {
    background: rgba(147, 102, 255, 0.25);
    color: #fff;
}

[data-theme="light"] .pill-globe-dropdown__item--disabled {
    color: rgba(255, 255, 255, 0.35);
}

[data-theme="light"] .pill-globe-dropdown__item--disabled:hover {
    background: none;
    color: rgba(255, 255, 255, 0.35);
}

/* Light theme — scrolled */
[data-theme="light"] .pill-nav-inner--scrolled .pill-globe-dropdown {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(139, 92, 246, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-globe-dropdown__item {
    color: #2d2640;
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-globe-dropdown__item:hover {
    background: rgba(124, 77, 255, 0.08);
    color: #7c3aed;
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-globe-dropdown__item--disabled {
    color: var(--text-muted);
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-globe-dropdown__item--disabled:hover {
    background: none;
    color: var(--text-muted);
}

/* Light theme overrides */
[data-theme="light"] .pill-globe-dropdown {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .pill-globe-dropdown__item {
    color: #2d2640;
}

[data-theme="light"] .pill-globe-dropdown__item:hover {
    background: rgba(124, 77, 255, 0.08);
    color: #7c3aed;
}

[data-theme="light"] .pill-globe-dropdown__item--disabled {
    color: var(--text-muted);
}

[data-theme="light"] .pill-globe-dropdown__item--disabled:hover {
    color: var(--text-muted);
    background: none;
}

/* Scrolled state */
.pill-nav-inner--scrolled .pill-globe-dropdown {
    background: rgba(30, 20, 55, 0.98);
    border-color: rgba(139, 92, 246, 0.2);
}

/* ── Mobile hamburger ── */
.pill-hamburger {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    background: transparent;
}

.pill-hamburger__line {
    width: 16px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.pill-nav-inner--scrolled .pill-hamburger__line {
    background: #d4d0e8;
}

/* ── Mobile drawer ── */
.pill-drawer__overlay {
    position: fixed;
    inset: 0;
    z-index: 998;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.pill-drawer__overlay--open {
    opacity: 1;
    pointer-events: auto;
}

.pill-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    z-index: 999;
    background: #1a1530;
    border-left: 1px solid rgba(139, 92, 246, 0.2);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 80px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pill-drawer--open { transform: translateX(0); }

.pill-drawer__item {
    display: block;
    padding: 14px 20px;
    border-radius: 9999px;
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    color: #d4d0e8;
    transition: all 0.2s ease;
}

.pill-drawer__item:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}

.pill-drawer__divider {
    height: 1px;
    margin: 8px 0;
    background: #fff;
    opacity: 0.1;
}

.pill-drawer__util {
    display: flex;
    gap: 8px;
    padding: 8px 0;
}

.pill-drawer__util-btn {
    flex: 1;
    padding: 12px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.15);
    color: #d4d0e8;
    transition: all 0.2s ease;
}

.pill-drawer__util-btn--disabled {
    opacity: 0.4;
    cursor: default;
    font-style: italic;
}

.pill-drawer__util-btn--disabled:hover {
    background: transparent;
    color: inherit;
}

.pill-drawer__util-btn:hover {
    background: rgba(139, 92, 246, 0.25);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main {
    min-height: calc(100vh - var(--nav-height));
    padding-top: var(--nav-height);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    margin-top: var(--space-3xl);
}

.footer__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3xl) var(--space-lg) var(--space-xl);
}

.footer__grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-2xl);
    margin-bottom: var(--space-2xl);
}

.footer__brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.footer__logo { height: 24px; width: auto; }
.footer__logo--light { display: none; }

.footer__about-text {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.7;
    max-width: 380px;
}

.footer__heading {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.footer__col { display: flex; flex-direction: column; }

.footer__link {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: var(--space-xs) 0;
    transition: color var(--duration) var(--ease);
}

.footer__link:hover { color: var(--accent); }

.footer__bottom {
    border-top: 1px solid var(--border-subtle);
    padding-top: var(--space-lg);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   SHARED COMPONENTS
   ============================================================ */

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border: none;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }

.btn--secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-default); }
.btn--secondary:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }

.btn--danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.2); }
.btn--danger:hover { background: rgba(248, 113, 113, 0.2); }

.btn--success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(52, 211, 153, 0.2); }
.btn--success:hover { background: rgba(52, 211, 153, 0.2); }

.btn--sm { padding: 6px 14px; font-size: 0.8rem; }
.btn--xs { padding: 4px 10px; font-size: 0.75rem; }
.btn--block { width: 100%; }
.btn-group { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* --- Cards --- */
.card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: var(--space-lg); transition: all var(--duration) var(--ease); }
.card:hover { border-color: var(--border-default); }
.card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-md); gap: var(--space-md); }
.card__title { font-family: var(--font-display); font-size: 1.15rem; color: var(--text-primary); }

/* --- Tags --- */
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 100px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.tag--deep-green, .tag--Deep_Green, .tag--deep_green { background: rgba(5, 150, 105, 0.15); color: var(--deep-green); border: 1px solid rgba(5, 150, 105, 0.25); }
.tag--green, .tag--Green { background: rgba(52, 211, 153, 0.12); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.2); }
.tag--neutral, .tag--Neutral { background: rgba(156, 163, 175, 0.12); color: var(--neutral); border: 1px solid rgba(156, 163, 175, 0.2); }
.tag--blue, .tag--Blue { background: rgba(96, 165, 250, 0.12); color: var(--blue); border: 1px solid rgba(96, 165, 250, 0.2); }
.tag--deep-blue, .tag--Deep_Blue, .tag--deep_blue { background: rgba(59, 130, 246, 0.15); color: var(--deep-blue); border: 1px solid rgba(59, 130, 246, 0.25); }
.tag--status-running { background: var(--success-soft); color: var(--success); }
.tag--status-stopped { background: var(--danger-soft); color: var(--danger); }

/* --- Form Inputs --- */
.form-group { margin-bottom: var(--space-md); }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: var(--space-xs); letter-spacing: 0.01em; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-default);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.875rem;
    transition: all var(--duration) var(--ease); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b6780' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}

/* --- Tables --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th { text-align: left; padding: 12px 16px; background: var(--bg-elevated); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 1px solid var(--border-default); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-card); }
.table td:first-child { color: var(--text-primary); font-weight: 500; }

/* --- Modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(8px); z-index: 2000; display: none; align-items: center; justify-content: center; padding: var(--space-lg); }
.modal-backdrop--open { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg); width: 100%; max-width: 600px; max-height: 85vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,0.5); }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-lg); border-bottom: 1px solid var(--border-subtle); }
.modal__title { font-family: var(--font-display); font-size: 1.25rem; }
.modal__close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; line-height: 1; padding: 4px; transition: color var(--duration) var(--ease); }
.modal__close:hover { color: var(--text-primary); }
.modal__body { padding: var(--space-lg); }
.modal__footer { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: var(--space-sm); }

/* --- Section headers --- */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); gap: var(--space-md); flex-wrap: wrap; }
.section-title { font-family: var(--font-body); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.section-title::before { content: ''; display: inline-block; width: 8px; height: 8px; background: var(--accent); border-radius: 2px; margin-right: var(--space-sm); vertical-align: middle; }

/* --- Status dot --- */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: var(--space-xs); }
.status-dot--running { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot--stopped { background: var(--danger); }

/* --- Skeleton loader --- */
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }

/* --- Page container --- */
.page-container { max-width: var(--max-width); margin: 0 auto; padding: var(--space-2xl) var(--space-lg); }
.page-header { margin-bottom: var(--space-2xl); }
.page-title { font-family: var(--font-display); font-size: 2.25rem; color: var(--text-primary); margin-bottom: var(--space-sm); }
.page-subtitle { font-size: 0.95rem; color: var(--text-muted); }

/* --- Grid layouts --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }

/* --- Stat boxes --- */
.stat-box { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: var(--space-md) var(--space-lg); }
.stat-box__label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-bottom: var(--space-xs); }
.stat-box__value { font-family: var(--font-mono); font-size: 1.1rem; color: var(--text-primary); }

/* --- Misc --- */
.divider { border: none; border-top: 1px solid var(--border-subtle); margin: var(--space-2xl) 0; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.scraper-controls { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }
.scraper-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-md); }
.upload-area { border: 2px dashed var(--border-default); border-radius: var(--radius-md); padding: var(--space-lg); text-align: center; cursor: pointer; transition: all var(--duration) var(--ease); }
.upload-area:hover { border-color: var(--accent); background: var(--accent-softer); }
.upload-area__text { color: var(--text-muted); font-size: 0.85rem; }
.upload-area__preview { max-height: 150px; margin: 0 auto; border-radius: var(--radius-sm); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* --- Affiliation groups (public page) --- */
.affiliation-group { margin-bottom: var(--space-md); }
.affiliation-group:last-child { margin-bottom: 0; }
.affiliation-group__label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--space-sm); padding-bottom: var(--space-xs); border-bottom: 1px solid var(--border-subtle); }
.affiliation-group__label--deep-green, .affiliation-group__label--Deep_Green { color: var(--deep-green); border-color: rgba(5, 150, 105, 0.3); }
.affiliation-group__label--green, .affiliation-group__label--Green { color: var(--green); border-color: rgba(52, 211, 153, 0.3); }
.affiliation-group__label--neutral, .affiliation-group__label--Neutral { color: var(--neutral); border-color: rgba(156, 163, 175, 0.3); }
.affiliation-group__label--blue, .affiliation-group__label--Blue { color: var(--blue); border-color: rgba(96, 165, 250, 0.3); }
.affiliation-group__label--deep-blue, .affiliation-group__label--Deep_Blue { color: var(--deep-blue); border-color: rgba(59, 130, 246, 0.3); }

.source-item { display: flex; align-items: baseline; gap: var(--space-sm); padding: var(--space-xs) 0; font-size: 0.85rem; }
.source-item__name { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; }
.source-item__title { color: var(--text-secondary); transition: color var(--duration) var(--ease); }
.source-item__title:hover { color: var(--accent); }

/* --- Toast --- */
.toast { position: fixed; bottom: var(--space-lg); right: var(--space-lg); padding: 14px 20px; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-md); font-size: 0.85rem; color: var(--text-primary); box-shadow: 0 10px 30px rgba(0,0,0,0.4); transform: translateY(120%); opacity: 0; transition: all 0.3s var(--ease); z-index: 3000; }
.toast--visible { transform: translateY(0); opacity: 1; }
.toast--success { border-color: rgba(52, 211, 153, 0.3); }
.toast--error { border-color: rgba(248, 113, 113, 0.3); }

/* --- Empty state --- */
.empty-state { text-align: center; padding: var(--space-3xl) var(--space-lg); color: var(--text-muted); }
.empty-state__icon { font-size: 2rem; margin-bottom: var(--space-md); opacity: 0.4; }
.empty-state__text { font-size: 0.95rem; }

/* --- Tabs --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-lg); overflow-x: auto; }
.tab-btn { padding: var(--space-sm) var(--space-md); background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; transition: all var(--duration) var(--ease); white-space: nowrap; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn--active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel--active { display: block; }

/* Cluster cards */
.admin-grid { display: flex; flex-direction: column; gap: var(--space-md); }
.cluster-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; transition: all var(--duration) var(--ease); }
.cluster-card:hover { border-color: var(--border-default); }
.cluster-card__header { padding: var(--space-lg) var(--space-lg) var(--space-sm); display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); }
.cluster-card__topic { font-family: var(--font-display); font-size: 1.1rem; color: var(--text-primary); }
.cluster-card__meta { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.cluster-card__body { padding: 0 var(--space-lg) var(--space-lg); }
.cluster-card__articles { display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-md); }
.cluster-article { display: flex; align-items: center; gap: var(--space-sm); font-size: 0.85rem; flex-wrap: wrap; }
.cluster-article__source { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; }
.cluster-article__title { color: var(--text-secondary); transition: color var(--duration) var(--ease); }
.cluster-article__title:hover { color: var(--accent); }
.cluster-card__inputs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); margin-top: var(--space-md); }
.cluster-card__footer { padding: var(--space-sm) var(--space-lg) var(--space-lg); display: flex; justify-content: flex-end; gap: var(--space-sm); }
.cluster-card--pending { border-left: 3px solid var(--warning); }
.cluster-card--approved { border-left: 3px solid var(--success); }

/* ============================================================
   LIGHT THEME
   ============================================================ */
[data-theme="light"] {
    --bg-primary: #ece8f4;
    --bg-secondary: #e4e0ee;
    --bg-card: #ffffff;
    --bg-card-hover: #fafafa;
    --bg-elevated: #f0f0f2;
    --bg-overlay: rgba(0, 0, 0, 0.3);
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-default: rgba(0, 0, 0, 0.12);
    --border-strong: rgba(0, 0, 0, 0.2);
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #8a8a9a;
    --accent: #7c4dff;
    --accent-soft: rgba(124, 77, 255, 0.1);
    --accent-softer: rgba(124, 77, 255, 0.05);
    --accent-hover: #6930ff;
    --accent-glow: rgba(124, 77, 255, 0.15);
    --success: #2e7d32;
    --success-soft: rgba(46, 125, 50, 0.1);
    --warning: #e65100;
    --warning-soft: rgba(230, 81, 0, 0.1);
    --danger: #c62828;
    --danger-soft: rgba(198, 40, 40, 0.1);
}

/* Light pill nav */
[data-theme="light"] .pill-nav-inner {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(255, 255, 255, 0.4);
}

[data-theme="light"] .pill-nav-inner .pill-item,
[data-theme="light"] .pill-nav-inner .pill-util,
[data-theme="light"] .pill-nav-inner .pill-divider,
[data-theme="light"] .pill-nav-inner .pill-hamburger__line {
    color: #fff;
    background-color: unset;
}

/* Light pill nav needs white text over hero (iridescence is colorful) */
[data-theme="light"] .pill-hamburger__line { background: #fff; }
[data-theme="light"] .pill-divider { background: #fff; }

[data-theme="light"] .pill-nav-inner--scrolled {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(139, 92, 246, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-item { color: #2d2640; }
[data-theme="light"] .pill-nav-inner--scrolled .pill-util { color: #2d2640; }
[data-theme="light"] .pill-nav-inner--scrolled .pill-divider { background: #2d2640; }
[data-theme="light"] .pill-nav-inner--scrolled .pill-hamburger__line { background: #2d2640; }
[data-theme="light"] .pill-nav-inner--scrolled .pill-item__circle { background: #7c3aed; }

[data-theme="light"] .pill-logo__img--dark { display: none; }
[data-theme="light"] .pill-logo__img--light { display: block; }

[data-theme="light"] .pill-drawer {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .pill-drawer__item { color: #2d2640; }
[data-theme="light"] .pill-drawer__item:hover { background: rgba(139, 92, 246, 0.06); color: #7c3aed; }
[data-theme="light"] .pill-drawer__divider { background: #000; }
[data-theme="light"] .pill-drawer__util-btn { background: rgba(139, 92, 246, 0.08); color: #2d2640; }

[data-theme="light"] .footer { background: #ffffff; border-top: 1px solid rgba(139, 92, 246, 0.08); }
[data-theme="light"] .footer__logo--dark { display: none; }
[data-theme="light"] .footer__logo--light { display: block; }

[data-theme="light"] .form-input, [data-theme="light"] .form-textarea, [data-theme="light"] .form-select {
    background: #ffffff; border-color: rgba(0,0,0,0.15); color: var(--text-primary);
}

[data-theme="light"] .table thead { background: #eeeef0; }
[data-theme="light"] .table tbody tr:hover { background: #f5f5f7; }
[data-theme="light"] .tab-btn { color: var(--text-secondary); }
[data-theme="light"] .tab-btn--active { color: var(--accent); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .pill-items, .pill-divider, .pill-util-group { display: none !important; }
    .pill-hamburger { display: flex !important; }
    .pill-nav-inner { padding: 4px 6px; }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .footer__grid { grid-template-columns: 1fr; gap: var(--space-xl); }
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.35rem; }
    .page-container { padding: var(--space-xl) var(--space-md); }
    .settings-grid { grid-template-columns: 1fr; }
    .cluster-card__inputs { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }
    .card { padding: var(--space-md); }
}

/* About dropdown */
.pill-item-wrap {
    position: relative;
    display: flex;
    height: 100%;
}

.pill-item-wrap--has-dropdown:hover .pill-dropdown {
    opacity: 1;
    visibility: visible;
}

.pill-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 180px;
    padding-top: 6px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s var(--ease);
    z-index: 1001;
}

.pill-dropdown__inner {
    background: rgba(20, 15, 35, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    padding: 4px;
}

.pill-dropdown__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.pill-dropdown__item:hover {
    background: rgba(147, 102, 255, 0.25);
    color: #fff;
}

/* Scrolled state */
.pill-nav-inner--scrolled .pill-dropdown__inner {
    background: rgba(30, 20, 55, 0.97);
    border-color: rgba(139, 92, 246, 0.25);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

.pill-nav-inner--scrolled .pill-dropdown__item {
    color: #d4d0e8;
}

/* Light theme — over hero */
[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-dropdown__inner {
    background: rgba(255, 255, 255, 0.55) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
}

[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-dropdown__item {
    color: #fff !important;
}

[data-theme="light"] .pill-nav-inner:not(.pill-nav-inner--scrolled) .pill-dropdown__item:hover {
    background: rgba(147, 102, 255, 0.25) !important;
    color: #fff !important;
}

/* Light theme — scrolled */
[data-theme="light"] .pill-nav-inner--scrolled .pill-dropdown__inner {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(139, 92, 246, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-dropdown__item {
    color: #2d2640;
}

[data-theme="light"] .pill-nav-inner--scrolled .pill-dropdown__item:hover {
    background: rgba(124, 77, 255, 0.08);
    color: #7c3aed;
}

@media (max-width: 768px) {
    .pill-dropdown { display: none !important; }
}

[data-theme="light"] .drawer-open .pill-nav-inner .pill-hamburger__line {
    background: #2d2640 !important;
}

[data-theme="light"] .drawer-open .pill-nav-inner .pill-logo__img--nav {
    display: none !important;
}

[data-theme="light"] .drawer-open .pill-nav-inner .pill-logo__img--nav-scrolled {
    display: block !important;
}