/* ═══════════════════════════════════════════════════════════════════════════════
   FPL Pals — Design System
   Inspired by the official Fantasy Premier League visual language.
   PL purple, neon green accent, flat surfaces, clean typography.
   ═══════════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* Hide Blazor's default reconnect banner; failed reconnects soft-reload via App.razor JS */
#components-reconnect-modal {
    display: none !important;
}

/* ── CSS Custom Properties (Design Tokens) ────────────────────────────────────── */
:root {
    /* Brand */
    --color-primary: #37003c;
    --color-primary-light: #5a1060;
    --color-primary-dark: #2a002e;
    --color-accent: #00ff87;
    --color-accent-dim: #00cc6a;
    --color-magenta: #e90052;

    /* Semantic */
    --color-success: #00ff87;
    --color-warning: #f5a623;
    --color-danger: #e90052;
    --color-info: #04f5ff;

    /* Dark Theme (Default) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1e1e1e;
    --bg-card: #161616;
    --bg-card-hover: #1c1c1c;
    --bg-input: #1e1e1e;
    --bg-sidebar: #0f0f0f;

    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --text-muted: #6b6b6b;
    --text-inverse: #0a0a0a;
    --text-accent: #00ff87;

    --border-color: #2a2a2a;
    --border-light: #1f1f1f;

    /* Shadows — subtle, no glows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.6);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;
    --text-5xl: 3.5rem;

    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Bottom nav */
    --bottom-nav-height: 64px;
    --bottom-nav-offset: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    /* Z-Index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 300;
    --z-modal: 400;
    --z-toast: 500;

    /* Layout */
    --sidebar-width: 240px;
    --header-height: 56px;
    --app-header-offset: var(--header-height);
    --app-bottom-chrome: 0px;
    --max-content-width: 1200px;
}

/* ── Light Theme ──────────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg-primary: #fafafa;
    --bg-secondary: #f0f0f0;
    --bg-tertiary: #e5e5e5;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f5f5;
    --bg-input: #f0f0f0;
    --bg-sidebar: #37003c;

    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #6b6b6b;
    --text-inverse: #f0f0f0;
    --text-accent: #37003c;

    --border-color: #e0e0e0;
    --border-light: #ebebeb;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    height: 100%;
    overflow: hidden;
    /* PWA status bar / notch (black-translucent) — keep chrome black, not brand green */
    background: #000000;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: #000000;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100dvh;
    overflow: hidden;
}

/* ── Typography ───────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }

p { color: var(--text-secondary); line-height: var(--leading-relaxed); }

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--color-accent-dim); }

/* ── Layout ───────────────────────────────────────────────────────────────────── */
.page-wrapper {
    display: flex;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sticky);
}

.sidebar-brand {
    padding: var(--space-5) var(--space-5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 900;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.sidebar-brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-size: var(--text-lg);
    font-weight: 700;
    color: #ffffff;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-section-label {
    padding: var(--space-4) var(--space-3) var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
    color: var(--color-accent);
    background: rgba(0, 255, 135, 0.08);
    border-left-color: var(--color-accent);
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.3);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    height: var(--header-height);
    padding: 0 var(--space-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
    flex-shrink: 0;
    z-index: var(--z-sticky);
}

.content-body {
    padding: var(--space-8);
    max-width: var(--max-content-width);
    width: 100%;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Chat page: fill remaining space under header, no nested page scroll */
.content-body:has(.chat-shell) {
    padding: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    animation: none; /* transform animations break height fill */
}

.content-body:has(.chat-shell) > .chat-shell {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
}

.main-content:has(.chat-shell) .content-header {
    flex-shrink: 0;
}

/* ── Header Brand & Icon Buttons ─────────────────────────────────────────────── */
.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: inherit;
}

.header-brand-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 900;
    color: var(--color-primary);
}

.header-brand-logo {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.header-brand-text {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.header-icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.header-notif-btn {
    position: relative;
    overflow: visible;
}

.header-notif-btn.has-unread {
    color: var(--color-magenta);
    border-color: rgba(233, 0, 82, 0.55);
    background: rgba(233, 0, 82, 0.12);
}

.header-notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--color-magenta);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 1px rgba(233, 0, 82, 0.35);
    pointer-events: none;
    z-index: 2;
}

.sidebar-notif-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--color-magenta);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
}

/* ── Bottom Navigation ───────────────────────────────────────────────────────── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-offset);
    box-sizing: border-box;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: var(--z-sticky);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-items: center;
    justify-content: space-around;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: var(--space-2) 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: color var(--transition-fast);
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
    color: var(--color-accent);
}

.bottom-nav-item:hover {
    color: var(--text-primary);
}

.bottom-nav-icon {
    width: 22px;
    height: 22px;
}

.bottom-nav-label {
    letter-spacing: 0.02em;
}

/* ── Cards ────────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    border-color: #3a3a3a;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-6);
}

/* ── Stat Cards ───────────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--color-accent);
}

.stat-sub {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.stat-change {
    font-size: var(--text-sm);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.stat-change.positive { color: var(--color-success); }
.stat-change.negative { color: var(--color-danger); }

/* ── Buttons ──────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--text-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    min-height: 44px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-accent);
}

.btn-primary:hover {
    background: var(--color-primary-light);
    color: var(--color-accent);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: var(--space-2) var(--space-3);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
    border-radius: var(--radius-md);
}

.btn-accent {
    background: var(--color-accent);
    color: var(--color-primary);
    border: 1px solid transparent;
    font-weight: 800;
    border-radius: var(--radius-full);
}

.btn-accent:hover {
    background: var(--color-accent-dim);
    color: var(--color-primary);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    min-height: 36px;
}

/* ── Badges ───────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background: rgba(55, 0, 60, 0.3);
    color: #c080cc;
}

.badge-success {
    background: rgba(0, 255, 135, 0.12);
    color: var(--color-accent);
}

.badge-warning {
    background: rgba(245, 166, 35, 0.15);
    color: var(--color-warning);
}

.badge-danger {
    background: rgba(233, 0, 82, 0.15);
    color: var(--color-danger);
}

.badge-info {
    background: rgba(4, 245, 255, 0.12);
    color: var(--color-info);
}

.badge-muted {
    background: rgba(107, 107, 107, 0.15);
    color: var(--text-muted);
}

/* ── Inputs ───────────────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    padding: var(--space-3) var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    min-height: 44px;
}

.form-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 255, 135, 0.12);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* ── Tables ───────────────────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr:hover td {
    background: var(--bg-card-hover);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Loading States ───────────────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-tertiary) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Empty States ─────────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.4;
}

.empty-state-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--text-sm);
    max-width: 400px;
    margin: 0 auto;
}

/* ── Avatar ───────────────────────────────────────────────────────────────────── */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.avatar-lg { width: 64px; height: 64px; }
.avatar-sm { width: 28px; height: 28px; }

/* ── Dashboard ───────────────────────────────────────────────────────────────── */
.dash-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.dash-greeting {
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: var(--leading-tight);
}

.dash-header-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-shrink: 0;
}

.dash-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.dash-section {
    margin-bottom: var(--space-8);
}

.dash-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.dash-section-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-4);
}

.dash-section-header .dash-section-title {
    margin-bottom: 0;
}

.dash-team-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.dash-team-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    gap: var(--space-4);
}

.dash-team-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
    color: inherit;
}

.dash-team-info {
    min-width: 0;
    flex: 1;
}

.dash-team-name {
    font-size: var(--text-base);
    font-weight: 700;
}

.dash-team-points {
    text-align: right;
    flex-shrink: 0;
}

.dash-team-pts-value {
    font-size: var(--text-xl);
    font-weight: 800;
    color: var(--color-accent);
}

.dash-league-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.dash-league-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition-fast);
    gap: var(--space-3);
}

.dash-league-card:hover {
    border-color: var(--color-accent);
    color: inherit;
}

.dash-league-info {
    min-width: 0;
    flex: 1;
}

.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.alert-danger {
    background: rgba(233, 0, 82, 0.1);
    border: 1px solid rgba(233, 0, 82, 0.2);
    color: var(--color-danger);
}

.alert-success {
    background: rgba(0, 255, 135, 0.1);
    border: 1px solid rgba(0, 255, 135, 0.2);
    color: var(--color-success);
}

@media (max-width: 768px) {
    .dash-greeting {
        font-size: var(--text-xl);
    }

    .dash-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-2);
    }

    .dash-team-card {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }

    .dash-team-points {
        text-align: left;
        display: flex;
        align-items: center;
        gap: var(--space-2);
        padding-top: var(--space-2);
        border-top: 1px solid var(--border-light);
    }

    .dash-team-pts-value {
        font-size: var(--text-lg);
    }

    .dash-header-actions {
        width: 100%;
    }

    .dash-header-actions .btn {
        flex: 1;
    }
}

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

/* ── Home landing ─────────────────────────────────────────────────────────────── */
.home-landing {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-4) 0 var(--space-12);
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.home-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-5);
    padding: var(--space-8) 0 var(--space-6);
    min-height: min(68vh, 36rem);
    justify-content: center;
    position: relative;
}

.home-hero::before {
    content: "";
    position: absolute;
    inset: -12% -28% auto;
    height: min(70%, 320px);
    background:
        radial-gradient(ellipse at 18% 45%, rgba(55, 0, 60, 0.62), transparent 58%),
        radial-gradient(ellipse at 82% 18%, rgba(0, 255, 135, 0.16), transparent 52%);
    pointer-events: none;
    z-index: 0;
    animation: home-hero-glow 8s ease-in-out infinite alternate;
}

@keyframes home-hero-glow {
    from { opacity: 0.85; transform: scale(1); }
    to { opacity: 1; transform: scale(1.04); }
}

@keyframes home-card-glow {
    from { box-shadow: 0 0 0 1px rgba(0, 255, 135, 0.35), 0 0 24px rgba(0, 255, 135, 0.12); }
    to { box-shadow: 0 0 0 1px rgba(0, 255, 135, 0.55), 0 0 36px rgba(0, 255, 135, 0.22); }
}

@keyframes home-bubble-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.home-brand,
.home-headline,
.home-lede,
.home-cta {
    position: relative;
    z-index: 1;
}

.home-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
}

.home-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    background: var(--color-accent);
    color: var(--color-primary);
    font-size: var(--text-sm);
    font-weight: 900;
    letter-spacing: 0.04em;
}

.home-brand-logo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}

.home-brand-name {
    font-size: clamp(1.75rem, 4vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.home-headline {
    margin: 0;
    max-width: 16ch;
    font-size: clamp(2.35rem, 5.5vw, 3.4rem);
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1.05;
    color: var(--text-primary);
}

.home-lede {
    margin: 0;
    max-width: 36rem;
    font-size: var(--text-lg);
    line-height: 1.55;
    color: var(--text-secondary);
}

.home-cta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.home-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding-top: var(--space-2);
}

.home-section-title {
    margin: 0;
    font-size: clamp(1.5rem, 3vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text-primary);
}

.home-section-lede {
    margin: 0;
    max-width: 38rem;
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--text-secondary);
}

.home-plan-note {
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-muted, var(--text-secondary));
    opacity: 0.9;
}

.home-check-list {
    list-style: none;
    margin: var(--space-2) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.home-check-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-secondary);
}

.home-check {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.1rem;
    border-radius: 50%;
    background: rgba(0, 255, 135, 0.12);
    border: 1px solid rgba(0, 255, 135, 0.45);
    position: relative;
}

.home-check::after {
    content: "";
    position: absolute;
    left: 0.32rem;
    top: 0.22rem;
    width: 0.32rem;
    height: 0.55rem;
    border: solid var(--color-accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.home-check-strong {
    color: var(--color-accent);
    font-weight: 700;
}

.home-bots {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.home-prompt-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5) var(--space-6);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    background:
        linear-gradient(165deg, rgba(255, 255, 255, 0.03), transparent 40%),
        #141414;
    transition:
        border-color var(--transition-normal),
        box-shadow var(--transition-normal),
        transform var(--transition-normal),
        background var(--transition-normal);
}

.home-prompt-card:hover,
.home-prompt-card:focus-within {
    border-color: rgba(0, 255, 135, 0.45);
    box-shadow: 0 0 0 1px rgba(0, 255, 135, 0.12), 0 12px 32px rgba(0, 0, 0, 0.35);
    background:
        linear-gradient(165deg, rgba(0, 255, 135, 0.05), transparent 45%),
        #161616;
    transform: translateY(-2px);
}

.home-prompt-card--spotlight {
    border-color: rgba(0, 255, 135, 0.28);
}

.home-prompt-card--featured {
    gap: var(--space-4);
    padding: var(--space-6);
    border-color: rgba(0, 255, 135, 0.55);
    background:
        linear-gradient(145deg, rgba(0, 255, 135, 0.1), transparent 50%),
        #121212;
    animation: home-card-glow 3.5s ease-in-out infinite alternate;
}

.home-prompt-card--featured:hover,
.home-prompt-card--featured:focus-within {
    border-color: rgba(0, 255, 135, 0.75);
    transform: translateY(-3px);
}

.home-prompt-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.home-prompt-card--featured .home-section-title {
    flex: 1;
    min-width: 12rem;
}

.home-card-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-full);
    background: rgba(0, 255, 135, 0.14);
    border: 1px solid rgba(0, 255, 135, 0.45);
    color: var(--color-accent);
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.home-bot-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.home-bot-mention {
    font-size: var(--text-base);
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
}

.home-bot-name {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    opacity: 0.85;
}

.home-bot-pitch {
    margin: 0;
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--text-secondary);
}

.home-try-label {
    margin: var(--space-1) 0 0;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.home-prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.home-prompt-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(0, 255, 135, 0.22);
    background: rgba(0, 255, 135, 0.06);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    transition:
        border-color var(--transition-fast),
        background var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast);
}

.home-prompt-chip:hover,
.home-prompt-chip:focus-visible {
    border-color: rgba(0, 255, 135, 0.65);
    background: rgba(0, 255, 135, 0.14);
    color: var(--color-accent);
    transform: translateY(-1px);
    outline: none;
}

.home-card-cta {
    margin-top: var(--space-1);
    width: fit-content;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.home-card-cta:hover,
.home-card-cta:focus-visible {
    color: var(--color-accent-dim);
    border-bottom-color: currentColor;
    outline: none;
}

.home-featured-cta {
    margin-top: var(--space-2);
    width: fit-content;
    padding: var(--space-3) var(--space-6);
}

.home-chat {
    gap: var(--space-5);
}

.home-chat-mock {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    background:
        linear-gradient(180deg, rgba(55, 0, 60, 0.28), transparent 55%),
        #121212;
}

.home-chat-bubble {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: min(92%, 28rem);
    padding: var(--space-3) var(--space-4);
    border-radius: 14px 14px 14px 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    animation: home-bubble-in 0.55s ease both;
}

.home-chat-bubble:nth-child(1) { animation-delay: 0.05s; }
.home-chat-bubble:nth-child(2) { animation-delay: 0.18s; }
.home-chat-bubble:nth-child(3) { animation-delay: 0.3s; align-self: flex-end; border-radius: 14px 14px 4px 14px; }

.home-chat-bubble--bot {
    border-color: rgba(0, 255, 135, 0.35);
    background:
        linear-gradient(135deg, rgba(0, 255, 135, 0.1), transparent 60%),
        #1a1a1a;
    box-shadow: 0 0 18px rgba(0, 255, 135, 0.08);
}

.home-chat-bubble-author {
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--color-accent);
}

.home-chat-bubble:not(.home-chat-bubble--bot) .home-chat-bubble-author {
    color: var(--text-muted);
}

.home-chat-bubble-text {
    font-size: var(--text-sm);
    line-height: 1.45;
    color: var(--text-primary);
}

.home-chat-checks {
    margin-top: 0;
}

.home-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.home-chat-actions .btn-secondary {
    border-radius: var(--radius-full);
}

.home-tease {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
}

.home-tease-row {
    display: grid;
    grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr);
    gap: var(--space-4);
    align-items: baseline;
    padding: var(--space-5) 0;
    border-bottom: 1px solid var(--border-color);
}

.home-tease-label {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.02em;
}

.home-tease-copy {
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--text-secondary);
}

.home-close {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    background:
        linear-gradient(135deg, rgba(55, 0, 60, 0.45), transparent 60%),
        var(--bg-card);
}

.home-close-text {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.home-close-link {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--color-accent);
    text-decoration: none;
}

.home-close-link:hover {
    color: var(--color-accent-dim);
}

@media (prefers-reduced-motion: reduce) {
    .home-hero::before,
    .home-prompt-card--featured,
    .home-chat-bubble {
        animation: none;
    }

    .home-prompt-card:hover,
    .home-prompt-card:focus-within,
    .home-prompt-chip:hover,
    .home-prompt-chip:focus-visible {
        transform: none;
    }
}

[data-theme="light"] .home-prompt-card {
    background:
        linear-gradient(165deg, rgba(55, 0, 60, 0.04), transparent 40%),
        var(--bg-card);
}

[data-theme="light"] .home-prompt-card:hover,
[data-theme="light"] .home-prompt-card:focus-within {
    background:
        linear-gradient(165deg, rgba(0, 204, 106, 0.08), transparent 45%),
        var(--bg-card-hover);
}

[data-theme="light"] .home-prompt-card--featured {
    background:
        linear-gradient(145deg, rgba(0, 204, 106, 0.12), transparent 50%),
        var(--bg-card);
    animation: none;
    box-shadow: 0 0 0 1px rgba(0, 204, 106, 0.35), 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .home-chat-mock {
    background:
        linear-gradient(180deg, rgba(55, 0, 60, 0.08), transparent 55%),
        var(--bg-secondary);
}

[data-theme="light"] .home-chat-bubble {
    background: var(--bg-card);
}

[data-theme="light"] .home-chat-bubble--bot {
    background:
        linear-gradient(135deg, rgba(0, 204, 106, 0.1), transparent 60%),
        var(--bg-card);
}

/* ── Site footer ──────────────────────────────────────────────────────────────── */
.site-footer {
    margin-top: var(--space-12);
    padding: var(--space-8) var(--space-6);
    border-radius: var(--radius-lg);
    background: #1a0a2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

[data-theme="light"] .site-footer {
    background: var(--color-primary);
    border-color: rgba(255, 255, 255, 0.12);
}

.site-footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2) var(--space-6);
    margin-bottom: var(--space-4);
}

.site-footer-link {
    color: rgba(255, 255, 255, 0.75);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.site-footer-link:hover {
    color: var(--color-accent);
}

.site-footer-copy {
    margin: 0;
    color: rgba(255, 255, 255, 0.45);
    font-size: var(--text-xs);
    line-height: var(--leading-relaxed);
    max-width: 36rem;
    margin-inline: auto;
}

/* Chat fills the viewport — keep footer out of the way */
.content-body:has(.chat-shell) > .site-footer {
    display: none;
}

/* Home: keep footer flush with landing content rhythm */
.content-body:has(.home-landing) > .site-footer {
    margin-top: var(--space-8);
}

@media (max-width: 768px) {
    .content-body:has(.home-landing) > .site-footer {
        margin-top: var(--space-10);
        padding: var(--space-6) var(--space-4);
    }
}

.legal-page {
    max-width: 40rem;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.legal-lede {
    margin: 0;
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
}

.legal-contact {
    margin: var(--space-2) 0 0;
}

.legal-contact-email {
    display: inline-block;
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-accent);
    word-break: break-all;
}

.legal-contact-email:hover {
    color: var(--color-accent-dim);
}

/* Legacy hero kept for any residual references */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-8);
    background: linear-gradient(170deg, var(--color-primary) 0%, var(--bg-primary) 60%);
    position: relative;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 720px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: rgba(0, 255, 135, 0.1);
    border: 1px solid rgba(0, 255, 135, 0.2);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--color-accent);
    font-weight: 500;
    margin-bottom: var(--space-6);
}

.hero-title {
    font-size: var(--text-5xl);
    font-weight: 900;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-6);
    line-height: 1.1;
    color: #ffffff;
}

.hero-title .gradient-text {
    color: var(--color-accent);
}

.hero-subtitle {
    font-size: var(--text-xl);
    color: rgba(255, 255, 255, 0.7);
    max-width: 560px;
    margin: 0 auto var(--space-10);
    line-height: var(--leading-relaxed);
}

.hero-actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-20);
    width: 100%;
    max-width: 800px;
}

.hero-feature {
    padding: var(--space-6);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: border-color var(--transition-normal), transform var(--transition-normal);
}

.hero-feature:hover {
    border-color: rgba(0, 255, 135, 0.3);
    transform: translateY(-3px);
}

.hero-feature-icon {
    color: var(--color-accent);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-feature-title {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: #ffffff;
}

.hero-feature-text {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.5);
}

/* ── Help Button & Panel ──────────────────────────────────────────────────────── */
.help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.help-btn:hover {
    background: var(--color-primary);
    color: var(--color-accent);
    border-color: var(--color-primary);
}

.help-panel {
    margin-top: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.help-panel ol {
    list-style: decimal;
    padding-left: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.help-panel code {
    display: inline-block;
    margin-top: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: var(--text-xs);
    word-break: break-all;
}

.fpl-entry-help {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.fpl-entry-help--compact {
    margin-bottom: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.fpl-entry-help-title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-primary);
}

.fpl-entry-help-lead {
    margin: 0 0 var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.fpl-entry-help-steps {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    counter-reset: fpl-help-step;
}

.fpl-entry-help-steps > li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: var(--space-3);
    align-items: start;
    counter-increment: fpl-help-step;
}

.fpl-entry-help-steps > li::before {
    content: counter(fpl-help-step);
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--color-primary);
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fpl-entry-help-step {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.fpl-entry-help-step-label {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
}

.fpl-entry-help-step-body {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.fpl-entry-help-step-body a {
    font-weight: 600;
    word-break: break-all;
}

.fpl-entry-help-example {
    display: block;
    margin-top: var(--space-1);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    font-family: ui-monospace, 'Cascadia Code', 'Courier New', monospace;
    font-size: var(--text-xs);
    color: var(--text-primary);
    word-break: break-all;
}

.fpl-entry-help-note {
    margin: var(--space-4) 0 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.45;
}

.fpl-entry-help-note code {
    font-family: ui-monospace, 'Cascadia Code', 'Courier New', monospace;
}

.fpl-entry-help--compact .fpl-entry-help-title {
    font-size: var(--text-sm);
}

.fpl-entry-help--compact .fpl-entry-help-steps > li::before {
    width: 22px;
    height: 22px;
    font-size: 11px;
}

.fpl-entry-help--compact .fpl-entry-help-steps > li {
    grid-template-columns: 22px 1fr;
}

/* ── Auto-Connect Section ────────────────────────────────────────────────────── */
.auto-connect-section {
    margin-bottom: var(--space-5);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(56, 189, 248, 0.25);
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.auto-connect-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    min-width: 0;
}

.auto-connect-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.auto-connect-title {
    font-size: var(--text-base);
    font-weight: 700;
    margin: 0;
    min-width: 0;
}

.auto-connect-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent);
    flex-shrink: 0;
}

.auto-connect-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-3);
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.league-team-lookup {
    min-width: 0;
}

.league-lookup-row {
    display: flex;
    gap: var(--space-2);
    align-items: stretch;
    min-width: 0;
}

.league-lookup-row .form-input {
    flex: 1;
    min-width: 0;
}

.league-lookup-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.link-team-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-5);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.link-team-divider::before,
.link-team-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-subtle, rgba(255, 255, 255, 0.12));
}

.team-search-wrap {
    position: relative;
}

.team-search-results {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    position: absolute;
    left: 0;
    right: 0;
    z-index: var(--z-dropdown);
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-secondary, #1a1f2e);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.team-search-results li + li {
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.team-search-result {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.team-search-result:hover,
.team-search-result:focus-visible {
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    outline: none;
}

.team-search-result-name {
    font-weight: 600;
    font-size: var(--text-sm);
}

.team-search-result-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.auto-connect-section .btn {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    white-space: normal;
    height: auto;
    min-height: 44px;
    line-height: 1.35;
    padding-left: var(--space-3);
    padding-right: var(--space-3);
}

.auto-connect-section .text-xs {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.auto-connect-url-box {
    min-width: 0;
}

.auto-connect-url-box .form-input {
    font-size: var(--text-xs);
    max-width: 100%;
}

.auto-connect-waiting {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    min-width: 0;
}

.auto-connect-instructions {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    min-width: 0;
}

.auto-connect-instructions > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.auto-connect-url-example {
    display: block;
    margin-top: 4px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: break-all;
}

.auto-connect-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.auto-connect-success {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    font-weight: 600;
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #fff;
    font-weight: 700;
    border: none;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-accent:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-accent:active {
    transform: translateY(0);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.btn-ghost:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.link-team-card {
    max-width: min(560px, 100%);
    box-sizing: border-box;
    overflow-x: hidden;
}

.link-team-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    color: var(--text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.link-team-divider::before,
.link-team-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ── Page Title Bar (shared across pages) ────────────────────────────────────── */
.page-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.page-title {
    font-size: var(--text-xl);
    font-weight: 800;
    line-height: var(--leading-tight);
}

.page-title-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── Info Banner ─────────────────────────────────────────────────────────────── */
.info-banner {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

/* ── League List ─────────────────────────────────────────────────────────────── */
.league-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.league-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    gap: var(--space-3);
}

.league-list-item:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
    color: inherit;
}

.league-list-info {
    min-width: 0;
    flex: 1;
}

.league-list-name {
    font-size: var(--text-base);
    font-weight: 700;
}

.league-list-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Card Section Titles ─────────────────────────────────────────────────────── */
.card-section-title {
    font-size: var(--text-lg);
    font-weight: 700;
    margin-bottom: var(--space-4);
}

.card-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.card-section-header .card-section-title {
    margin-bottom: 0;
}

.card-sub-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

/* ── Compact Stats (inline league header stats) ─────────────────────────────── */
.compact-stats {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.compact-stat {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.compact-stat-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.compact-stat-value {
    font-weight: 700;
    color: var(--color-accent);
}

/* ── Portal Layout ───────────────────────────────────────────────────────────── */
.portal-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.portal-user-card {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 255, 135, 0.2);
    background: rgba(0, 255, 135, 0.04);
    margin-bottom: var(--space-6);
}

.portal-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-4);
}

/* ── Standings Rows ──────────────────────────────────────────────────────────── */
.standings-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.standings-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    transition: background var(--transition-fast);
}

.standings-row:hover {
    background: var(--bg-card-hover);
}

.standings-row-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.standings-row-link:hover {
    border-color: var(--color-accent);
    color: inherit;
}

.table-row-link:hover td {
    background: var(--bg-card-hover);
}

.standings-row-me {
    border: 1px solid rgba(0, 255, 135, 0.2);
    background: rgba(0, 255, 135, 0.04);
}

tr.standings-row-me td {
    background: rgba(0, 255, 135, 0.06);
}

.standings-rank {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.standings-info {
    flex: 1;
    min-width: 0;
}

.standings-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.standings-score {
    text-align: right;
    flex-shrink: 0;
}

/* ── Snapshot Rows ───────────────────────────────────────────────────────────── */
.snapshot-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.snapshot-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

/* ── Team Stats Grid ─────────────────────────────────────────────────────────── */
.team-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

/* ── Analytics Grid (league gameweek analytics cards) ───────────────────────── */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-3);
}

.stat-sub {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.dash-link-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.1s ease;
}

.dash-link-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.pl-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.fixture-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.fixture-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--text-sm);
}

.fixture-row:last-child {
    border-bottom: none;
}

.fixture-home { text-align: right; font-weight: 600; }
.fixture-away { text-align: left; font-weight: 600; }
.fixture-score { text-align: center; color: var(--text-muted); min-width: 48px; }

.insight-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--text-sm);
}

.insight-row:last-child {
    border-bottom: none;
}

/* Premier League Hub — mobile-friendly insight categories (tap → modal) */
.pl-insight-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.pl-insight-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    width: 100%;
    text-align: left;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    color: inherit;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.pl-insight-list-item:hover,
.pl-insight-list-item:focus-visible {
    border-color: var(--color-accent);
    outline: none;
}

.pl-insight-list-item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pl-insight-list-item-title {
    font-weight: 700;
    font-size: var(--text-base);
}

.pl-insight-list-item-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pl-insight-list-item-chevron {
    flex-shrink: 0;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--text-muted);
}

.pl-insight-modal {
    width: min(480px, calc(100vw - 1.5rem));
}

.pl-insight-modal .insight-row {
    padding: var(--space-3) 0;
}

.ai-usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-4);
}

.ai-usage-block {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

/* ── Chip Tags ───────────────────────────────────────────────────────────────── */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chip-tag {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    font-size: var(--text-sm);
    font-weight: 500;
}

@media (max-width: 768px) {
    .page-title {
        font-size: var(--text-lg);
    }

    .page-title-actions {
        width: 100%;
    }

    .page-title-actions .btn {
        flex: 1;
    }

    .portal-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
    }

    .portal-layout {
        grid-template-columns: 1fr;
    }

    .team-stats,
    .analytics-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: var(--space-2);
    }

    .league-list-item {
        padding: var(--space-3);
    }
}

@media (max-width: 480px) {
    .team-stats,
    .portal-stats {
        grid-template-columns: 1fr;
    }
}

/* ── Auth Pages ───────────────────────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: var(--space-4);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-logo {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 900;
    color: var(--color-primary);
}

.auth-logo-img {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    border-radius: var(--radius-md);
    object-fit: cover;
    display: block;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.auth-title {
    font-size: var(--text-xl);
    font-weight: 800;
    margin-bottom: var(--space-2);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: var(--space-6) 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

@media (max-width: 480px) {
    .auth-card {
        padding: var(--space-5);
        border-radius: var(--radius-lg);
    }
}

/* ── Admin ───────────────────────────────────────────────────────────────────── */
.admin-request-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.admin-request-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    flex-wrap: wrap;
}

.admin-request-info {
    min-width: 0;
    flex: 1;
}

.admin-request-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.admin-user-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.admin-compact-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-grid-shell {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    overflow: hidden;
}

.admin-grid-scroll {
    max-height: min(420px, 55vh);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.admin-grid thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 10px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.admin-grid tbody td {
    padding: 10px 12px;
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.admin-grid tbody tr:last-child td {
    border-bottom: none;
}

.admin-grid tbody tr:hover td {
    background: var(--bg-card-hover);
}

.admin-grid-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-grid-col-status {
    width: 88px;
}

.admin-grid-col-action {
    width: 84px;
    text-align: right;
}

.admin-grid-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.admin-grid-pager-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.admin-compact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.admin-compact-main {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    flex: 1;
}

.admin-compact-name {
    font-weight: 600;
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Full-viewport modal — escapes content-body overflow by using fixed + high z-index */
.admin-modal-root {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.55);
    -webkit-overflow-scrolling: touch;
}

/* Must sit above .admin-modal-root (2000) when confirming delete from a detail modal */
.admin-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.65);
}

.admin-modal {
    width: min(440px, calc(100vw - 2rem));
    max-height: min(80dvh, 640px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.admin-modal-heading {
    min-width: 0;
}

.admin-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.admin-modal-body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    overflow-y: auto;
    min-height: 0;
    flex: 1;
}

.admin-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4) var(--space-4);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.admin-detail-backdrop {
    display: none;
}

.admin-detail-panel {
    display: none;
}

.admin-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.admin-detail-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.admin-detail-body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.admin-detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4) var(--space-4);
    border-top: 1px solid var(--border-color);
}

.admin-user-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.admin-user-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
}

.admin-user-card-identity {
    min-width: 0;
    flex: 1;
}

.admin-user-card-status {
    text-align: right;
    flex-shrink: 0;
}

.admin-user-card-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}

.admin-user-meta-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.admin-user-card-meta .form-input {
    max-width: 140px;
    width: 100%;
}

.admin-user-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

@media (max-width: 768px) {
    .admin-request-card {
        flex-direction: column;
    }

    .admin-request-actions {
        width: 100%;
    }

    .admin-request-actions .btn {
        flex: 1;
    }

    .admin-modal-root {
        padding: var(--space-3);
        align-items: center;
    }

    .admin-modal {
        width: 100%;
        max-height: min(85dvh, 100%);
    }

    .admin-user-card-meta {
        grid-template-columns: 1fr;
    }

    .admin-user-card-actions {
        justify-content: stretch;
    }

    .admin-user-card-actions .btn {
        width: 100%;
    }

    .admin-user-card-meta .form-input {
        max-width: none;
    }
}

/* ── Settings ────────────────────────────────────────────────────────────────── */
.settings-toggle-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.settings-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background var(--transition-fast);
    min-height: 44px;
}

.settings-toggle:hover {
    background: var(--bg-card-hover);
}

.settings-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-accent);
    flex-shrink: 0;
}

.settings-sub-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.admin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
}

.admin-metric {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.admin-metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.admin-metric-value {
    font-size: 1.15rem;
    font-weight: 700;
}

@media (max-width: 900px) {
    .admin-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.settings-sub-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    flex-wrap: wrap;
}

.settings-sub-info {
    min-width: 0;
    flex: 1;
}

.settings-sub-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .settings-toggle-list {
        grid-template-columns: 1fr;
    }

    .settings-sub-item {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-sub-actions {
        margin-top: var(--space-2);
    }
}

/* ── Notifications ───────────────────────────────────────────────────────────── */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.notif-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast);
}

.notif-item:hover {
    border-color: var(--text-muted);
}

.notif-info {
    min-width: 0;
    flex: 1;
}

.notif-title {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

/* ── Animations ───────────────────────────────────────────────────────────────── */
@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Opacity-only: transform on .content-body breaks position:fixed children (chat FAB). */
@keyframes fade-in-soft {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scale-in {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.animate-fade-in {
    animation: fade-in 0.4s ease-out forwards;
}

.content-body.animate-fade-in {
    animation: fade-in-soft 0.35s ease-out forwards;
}

.animate-scale-in {
    animation: scale-in 0.3s ease-out forwards;
}

.delay-1 { animation-delay: 0.1s; opacity: 0; }
.delay-2 { animation-delay: 0.2s; opacity: 0; }
.delay-3 { animation-delay: 0.3s; opacity: 0; }
.delay-4 { animation-delay: 0.4s; opacity: 0; }
.delay-5 { animation-delay: 0.5s; opacity: 0; }

/* ── Hamburger Button (visible only on mobile) ───────────────────────────────── */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.hamburger-line {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
}

/* ── Sidebar Overlay ─────────────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: calc(var(--z-sticky) - 1);
}

/* ── Floating Action Button (Chat) ───────────────────────────────────────────── */
.fab-chat {
    position: fixed;
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    right: calc(var(--space-6) + env(safe-area-inset-right, 0px));
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    /* Above personal AI dock / bottom nav */
    z-index: calc(var(--z-sticky) + 35);
    transition: background var(--transition-fast), transform var(--transition-fast);
    text-decoration: none;
    /* Keep out of any parent overflow/scroll context quirks */
    pointer-events: auto;
}

.fab-chat:hover {
    background: var(--color-primary-light);
    color: var(--color-accent);
    transform: scale(1.08);
}

button.fab-chat {
    border: none;
    cursor: pointer;
}

.fab-chat--open {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.fab-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--color-magenta);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--bg-primary);
}

/* ── Discord-style Chat Shell ────────────────────────────────────────────────── */
.chat-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    background: var(--bg-secondary);
    overflow: hidden;
}

.chat-shell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
    min-height: 52px;
}

.chat-shell-header-meta {
    min-width: 0;
}

.chat-shell-eyebrow {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.chat-shell-title {
    font-size: var(--text-lg);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.chat-shell-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.chat-messages {
    position: relative;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    padding: var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
}

.chat-messages-empty {
    margin-top: auto;
    margin-bottom: auto;
    flex: 0 0 auto;
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
}

.chat-messages-empty strong {
    color: var(--text-secondary);
}

.chat-jump-pill {
    position: absolute;
    bottom: var(--space-3);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    font-family: var(--font-sans);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.chat-jump-pill:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

/* Message rows (Discord-style) */
.chat-msg {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: var(--space-3);
    padding: 2px var(--space-2);
    border-radius: var(--radius-lg);
    animation: chat-msg-in 180ms ease;
}

.chat-msg:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-msg-own {
    background: rgba(0, 255, 135, 0.04);
}

.chat-msg-own:hover {
    background: rgba(0, 255, 135, 0.07);
}

.chat-msg-bot {
    background: rgba(55, 0, 60, 0.18);
}

.chat-msg-bot:hover {
    background: rgba(55, 0, 60, 0.28);
}

.chat-msg-grouped {
    grid-template-columns: 44px 1fr;
    padding-top: 0;
    padding-bottom: 0;
}

.chat-msg-grouped .chat-msg-avatar-slot {
    visibility: hidden;
}

.chat-msg-avatar-slot {
    padding-top: 2px;
}

.chat-msg-body {
    position: relative;
    min-width: 0;
}

.chat-msg-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: 2px;
    padding-right: 28px;
}

.chat-msg-author {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.chat-msg-author-block {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.chat-msg-team {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.chat-msg-time {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.chat-msg-edited {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}

.chat-msg-content {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: var(--text-sm);
    line-height: 1.45;
    color: var(--text-primary);
}

.chat-msg-content-deleted {
    color: var(--text-muted);
    font-style: italic;
}

.chat-msg-reply-quote {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 0 var(--space-2);
    padding: 6px 10px;
    border: none;
    border-left: 3px solid var(--color-accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-sans);
    overflow: hidden;
    box-sizing: border-box;
}

.chat-msg-reply-quote:hover {
    background: rgba(255, 255, 255, 0.08);
}

.chat-msg-reply-quote-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.chat-msg-reply-quote-text {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.chat-msg-actions {
    display: flex;
    justify-content: flex-start;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity var(--transition-fast);
    margin-top: 2px;
}

.chat-msg:hover .chat-msg-actions,
.chat-msg:focus-within .chat-msg-actions {
    opacity: 1;
}

.chat-msg-reply-btn {
    min-height: 28px;
    padding: 0 var(--space-2);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
}

.chat-msg-reply-btn:hover {
    color: var(--color-accent);
    background: rgba(0, 255, 135, 0.08);
}

.chat-msg-delete-btn:hover {
    color: var(--color-danger);
    background: rgba(233, 0, 82, 0.12);
}

.chat-msg-x {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    padding: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.chat-msg-x svg {
    width: 14px;
    height: 14px;
}

.chat-msg:hover .chat-msg-x,
.chat-msg:focus-within .chat-msg-x {
    opacity: 1;
}

.chat-msg-x:hover {
    color: var(--color-danger);
    background: rgba(233, 0, 82, 0.12);
}

.chat-msg-flash {
    animation: chat-msg-flash 1.1s ease;
}

@keyframes chat-msg-flash {
    0%, 100% { background: transparent; }
    35% { background: rgba(0, 255, 135, 0.12); }
}

.chat-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.chat-dialog {
    width: min(360px, 100%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.chat-dialog-title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-lg);
    font-weight: 800;
}

.chat-dialog-text {
    margin: 0 0 var(--space-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.chat-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    filter: brightness(1.08);
}

.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    padding: 6px 8px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-accent);
    background: var(--bg-tertiary);
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-reply-bar-body {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-reply-bar-meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-reply-bar-meta strong {
    color: var(--color-accent);
    font-weight: 700;
}

.chat-reply-bar-preview {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.chat-reply-bar-clear {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex: 0 0 28px;
}

.chat-reply-bar-clear svg {
    width: 14px;
    height: 14px;
}

.chat-reply-bar-clear:hover {
    color: var(--color-danger);
    background: rgba(233, 0, 82, 0.12);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar-bot {
    padding: 0;
    border-width: 2px;
    background: transparent;
}

.chat-avatar-bot--banter { border-color: #ff8a3d; }
.chat-avatar-bot--analyst { border-color: #4aa3d9; }
.chat-avatar-bot--recap { border-color: #2ec4a0; }
.chat-avatar-bot--assistant { border-color: #00ff87; }
.chat-avatar-bot--advisor { border-color: #6fcf6f; }
.chat-avatar-bot--default { border-color: #5a1060; }

.chat-bot-face {
    width: 100%;
    height: 100%;
    display: block;
}

.chat-bot-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--color-primary);
    color: var(--color-accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.6;
    vertical-align: middle;
}

.chat-role-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.6;
    vertical-align: middle;
}

.chat-role-pro {
    background: rgba(0, 255, 135, 0.15);
    color: var(--color-accent);
    border: 1px solid rgba(0, 255, 135, 0.35);
}

.chat-role-admin {
    background: rgba(4, 245, 255, 0.12);
    color: var(--color-info);
    border: 1px solid rgba(4, 245, 255, 0.35);
}

.plan-picker-dialog {
    max-width: 480px;
    width: calc(100% - 2rem);
    max-height: min(90dvh, 720px);
    overflow-y: auto;
}

.plan-tier-card-form {
    display: contents;
}

.plan-tier-card-form .plan-tier-card {
    width: 100%;
}

.plan-tier-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.plan-tier-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-family: var(--font-sans);
}

.plan-tier-card:hover:not(:disabled) {
    border-color: var(--color-accent);
}

.plan-tier-card-featured {
    border-color: rgba(0, 255, 135, 0.45);
    background: linear-gradient(160deg, rgba(0, 255, 135, 0.08), var(--bg-tertiary) 55%);
}

.plan-tier-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
}

.plan-tier-name {
    font-weight: 800;
    font-size: var(--text-sm);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.plan-tier-badge {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-inverse);
    background: var(--color-accent);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.plan-tier-price {
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--color-accent);
    line-height: 1.1;
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.plan-tier-price-note {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
}

.plan-tier-tagline {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.plan-tier-bullets {
    margin: var(--space-1) 0 0;
    padding-left: 1.1rem;
    list-style: disc;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plan-tier-bullets li {
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.4;
}

.plan-tier-cta {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--color-accent);
}

.plan-tier-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.personal-pro-upgrade-backdrop {
    z-index: calc(var(--z-sticky) + 40);
}

.personal-pro-upgrade-dialog {
    max-width: 420px;
}

.personal-pro-tier-card {
    cursor: pointer;
}

.personal-pro-tier-card[aria-disabled="true"] {
    cursor: default;
    pointer-events: none;
}

.personal-pro-tier-card .plan-tier-price {
    font-size: clamp(1.75rem, 6vw, 2.25rem);
}

.personal-pro-tier-card .plan-tier-bullets {
    width: 100%;
}

/* Keep legacy sell helpers for any remaining surfaces */
.personal-ai-sell {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.personal-ai-sell-price {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.personal-ai-sell-amount {
    font-size: clamp(2rem, 8vw, 2.75rem);
    font-weight: 900;
    line-height: 1;
    color: var(--color-accent);
}

.personal-ai-sell-once {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.personal-ai-sell-headline {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 800;
    line-height: 1.25;
    color: var(--text-primary);
}

.personal-ai-sell-subhead {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.personal-ai-sell-bullets {
    margin: 0;
    padding-left: 1.1rem;
    list-style: disc;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.personal-ai-sell-bullets li {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.personal-ai-sell-cta {
    width: 100%;
}

.personal-pro-sell .personal-ai-sell-amount {
    font-size: 2.25rem;
}

.personal-ai-log {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: 360px;
    overflow-y: auto;
}

.personal-ai-turn {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.personal-ai-turn-user {
    border-left: 3px solid var(--color-accent);
}

.personal-ai-turn-assistant {
    border-left: 3px solid var(--color-info);
}

.personal-ai-role {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.personal-ai-text {
    font-size: var(--text-sm);
    line-height: 1.5;
    white-space: pre-wrap;
}

.personal-ai-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.personal-ai-rivals {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.personal-ai-rival {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.personal-ai-rival input {
    margin-top: 3px;
}

.personal-ai-backdrop {
    position: fixed;
    top: var(--app-header-offset);
    right: 0;
    bottom: var(--app-bottom-chrome);
    left: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: calc(var(--z-sticky) + 25);
}

.personal-ai-dock {
    position: fixed;
    top: var(--app-header-offset);
    right: 0;
    bottom: var(--app-bottom-chrome);
    width: min(420px, 100vw);
    max-height: calc(100dvh - var(--app-header-offset) - var(--app-bottom-chrome));
    z-index: calc(var(--z-sticky) + 30);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.personal-ai-dock-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-4) var(--space-3);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.personal-ai-dock-header-meta {
    min-width: 0;
}

.personal-ai-dock-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.personal-ai-dock-locked {
    padding: var(--space-6) var(--space-4);
    overflow-y: auto;
    min-height: 0;
    flex: 1;
}

.personal-ai-dock-controls {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    max-height: 40%;
    overflow-y: auto;
}

.personal-ai-rivals--compact {
    max-height: 100px;
}

.personal-ai-dock-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    -webkit-overflow-scrolling: touch;
}

.personal-ai-msg-content {
    white-space: pre-wrap;
}

.personal-ai-dock-compose {
    flex-shrink: 0;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.personal-ai-dock-compose-row {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
}

.personal-ai-dock-input {
    flex: 1;
    resize: none;
    min-height: 44px;
}

.personal-ai-dock-send {
    flex-shrink: 0;
    height: 44px;
}

@media (max-width: 640px) {
    .personal-ai-dock {
        width: 100vw;
        border-left: none;
    }
}

/* Composer */
.chat-compose {
    position: relative;
    z-index: 20;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    padding: var(--space-3) var(--space-4);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    /* Must stay visible so @ mention / + menus can open upward over messages */
    overflow: visible;
    box-sizing: border-box;
}

.chat-compose-status {
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.chat-compose-row {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.chat-bot-picker {
    position: relative;
    flex-shrink: 0;
}

.chat-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    font-family: var(--font-sans);
}

.chat-icon-btn svg {
    width: 20px;
    height: 20px;
}

.chat-icon-btn:hover:not(:disabled) {
    color: var(--color-accent);
    border-color: var(--color-primary-light);
    background: var(--color-primary);
}

.chat-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-bot-add-btn.is-open {
    background: var(--color-primary);
    border-color: var(--color-primary-light);
    color: var(--color-accent);
    transform: rotate(45deg);
}

.chat-bot-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    min-width: 220px;
    max-width: min(280px, 70vw);
    max-height: min(360px, 45vh);
    overflow-y: auto;
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-bot-menu-title {
    padding: 6px 10px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.chat-bot-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-sans);
    transition: background var(--transition-fast);
}

.chat-bot-menu-item:hover:not(:disabled) {
    background: var(--bg-card-hover);
}

.chat-bot-menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-bot-menu-item .chat-avatar {
    width: 32px;
    height: 32px;
}

.chat-bot-menu-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.chat-bot-menu-name {
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1.2;
}

.chat-bot-menu-handle {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-input-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.chat-mention-menu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    max-height: min(280px, 40vh);
    overflow-y: auto;
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-bot-menu-item.is-active,
.chat-mention-menu .chat-bot-menu-item:hover {
    background: var(--bg-card-hover);
}

.chat-bot-menu-item.is-locked {
    opacity: 0.85;
}

.chat-bot-plan-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #011e26;
    background: #00ff87;
}

.chat-upgrade-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid rgba(0, 255, 135, 0.2);
    background: linear-gradient(90deg, rgba(0, 255, 135, 0.1), transparent);
}

@media (max-width: 640px) {
    .chat-upgrade-banner {
        flex-direction: column;
        align-items: stretch;
    }
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    border-radius: var(--radius-xl);
    padding: 12px 14px;
    line-height: 1.4;
}

.chat-send-btn {
    flex: 0 0 44px;
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-accent);
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    color: var(--color-accent);
}

.chat-send-busy {
    font-size: var(--text-lg);
    font-weight: 700;
    line-height: 1;
}

/* Typing indicator */
.chat-typing-row {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: var(--space-3);
    padding: var(--space-2);
    align-items: center;
}

.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
}

.chat-typing-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-left: var(--space-2);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: #c080cc;
    animation: chat-typing-bounce 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes chat-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .hamburger-btn {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    :root {
        --text-5xl: 2.5rem;
        --text-4xl: 2rem;
        --text-3xl: 1.5rem;
        --app-header-offset: 48px;
        --app-bottom-chrome: var(--bottom-nav-offset);
    }

    .bottom-nav {
        display: flex;
    }

    /* Chat sits flush above the bottom tab bar */
    .main-content:has(.chat-shell) {
        height: calc(100dvh - var(--bottom-nav-offset));
        max-height: calc(100dvh - var(--bottom-nav-offset));
    }

    .page-wrapper:has(.chat-shell) {
        height: 100dvh;
        max-height: 100dvh;
    }

    .hamburger-btn {
        display: none !important;
    }

    .content-header {
        padding: 0 var(--space-3);
        gap: var(--space-2);
        height: 48px;
    }

    .content-body {
        padding: var(--space-4);
        padding-bottom: calc(var(--space-4) + var(--bottom-nav-offset));
    }

    .content-body:has(.chat-shell) {
        padding-bottom: 0;
        overflow: hidden;
        height: 100%;
        max-height: 100%;
    }

    .chat-shell {
        border-bottom: 1px solid var(--border-color);
    }

    .chat-compose {
        padding-bottom: var(--space-3);
    }

    .card {
        padding: var(--space-4);
    }

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

    .stat-card {
        padding: var(--space-4);
    }

    .stat-value {
        font-size: var(--text-2xl);
    }

    .hero-features {
        grid-template-columns: 1fr;
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .home-tease-row {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .home-cta .btn,
    .home-chat-actions .btn,
    .home-featured-cta {
        width: 100%;
        justify-content: center;
    }

    .home-hero {
        min-height: auto;
        padding: var(--space-6) 0 var(--space-4);
    }

    .home-prompt-card,
    .home-prompt-card--featured {
        padding: var(--space-5);
    }

    .home-prompt-chip {
        font-size: var(--text-xs);
    }

    .breadcrumb-text {
        display: none;
    }

    .username-text {
        display: none;
    }

    .header-actions {
        gap: var(--space-2);
    }

    .header-brand-text {
        display: none;
    }

    .chat-shell-header {
        flex-wrap: wrap;
    }

    .chat-compose-row {
        align-items: flex-end;
    }

    .chat-msg-actions,
    .chat-msg-x {
        opacity: 1;
    }

    .fab-chat {
        /* Sit just above the bottom tab bar, viewport-fixed */
        bottom: calc(var(--bottom-nav-offset) + var(--space-3));
        right: calc(var(--space-4) + env(safe-area-inset-right, 0px));
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    .hide-mobile {
        display: none !important;
    }

    .sidebar-brand {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --text-5xl: 2rem;
        --text-4xl: 1.75rem;
        --text-3xl: 1.25rem;
    }

    .content-body {
        padding: var(--space-3);
        padding-bottom: calc(var(--space-3) + var(--bottom-nav-offset));
    }

    .content-body:has(.chat-shell) {
        padding-bottom: 0;
    }

    .card {
        padding: var(--space-3);
        border-radius: var(--radius-md);
    }

    .btn-lg {
        padding: var(--space-3) var(--space-6);
        font-size: var(--text-sm);
    }
}

/* ── Reduced Motion ───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Scrollbar ────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Utility Classes ──────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--text-primary); }
.font-mono { font-family: 'Courier New', monospace; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4 { padding: var(--space-4); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-2xl { max-width: 42rem; }
.min-h-\[80vh\] { min-height: 80vh; }
.min-h-\[96px\] { min-height: 96px; }
.h-64 { height: 16rem; }
.h-\[70vh\] { height: 70vh; }
.hidden { display: none; }
.shrink-0 { flex-shrink: 0; }
.overflow-y-auto { overflow-y: auto; }
.whitespace-pre-wrap { white-space: pre-wrap; }
.rounded-md { border-radius: var(--radius-md); }
.rounded-xl { border-radius: var(--radius-lg); }
.mx-auto { margin-left: auto; margin-right: auto; }
.space-y-3 > * + * { margin-top: var(--space-3); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.tracking-wider { letter-spacing: 0.05em; }
.border { border: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }

/* Grid utilities */
.grid { display: grid; }
.md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.lg\:grid-cols-\[1\.5fr_1fr\] { grid-template-columns: 1.5fr 1fr; }
.lg\:grid-cols-\[2fr_1fr\] { grid-template-columns: 2fr 1fr; }
.pr-2 { padding-right: var(--space-2); }

/* Alert surfaces */
.bg-danger\/10 { background: rgba(233, 0, 82, 0.1); }
.border-danger\/20 { border-color: rgba(233, 0, 82, 0.2); }
.bg-success\/10 { background: rgba(0, 255, 135, 0.1); }
.border-success\/20 { border-color: rgba(0, 255, 135, 0.2); }
.bg-white\/5 { background: rgba(255, 255, 255, 0.05); }
.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.border-primary\/30 { border-color: rgba(55, 0, 60, 0.3); }
.bg-primary\/10 { background: rgba(55, 0, 60, 0.1); }

@media (max-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: 1fr; }
    .lg\:grid-cols-\[1\.5fr_1fr\] { grid-template-columns: 1fr; }
    .lg\:grid-cols-\[2fr_1fr\] { grid-template-columns: 1fr; }
}
