/* ═══════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════ */

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 1920px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
    height: 52px;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
    cursor: pointer;
}

.header-inner .logo img {
    width: 140px;
    margin-bottom: 5px;
}
.logo-light {
    display: none;
}

html.light .logo-light {
    display: block;
}

html.light .logo-dark {
    display: none;
}

/* Logo — Q icon + wordmark */
.logo-q {
    flex-shrink: 0;
}

.logo-wordmark {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.03em;
    color: #ffffff;
    font-family: var(--font-display);
}

.logo-q-letter {
    color: #0ecb81;
    font-weight: 800;
}

.logo-dot {
    color: #0ecb81;
    font-weight: 600;
}

html.light .logo-wordmark {
    color: #1a1d23;
}

html.light .logo-q polygon {
    fill: #1a1d23;
}

/* Nav */
.nav {
    display: flex;
    gap: var(--sp-1);
    margin-left: var(--sp-4);
}

.nav-item {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-item:hover {
    color: var(--text-secondary);
    background: var(--bg-surface-2);
}

.nav-item.active {
    color: var(--brand);
    background: var(--brand-dim);
    font-weight: 600;
}

/* Search */
.search-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
}

.search-field {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-disabled);
    font-size: var(--text-sm);
    pointer-events: none;
    z-index: 1;
}

.input-search {
    padding-left: 36px;
}

.search-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    font-family: var(--font-mono);
    color: var(--text-disabled);
    background: var(--bg-surface-3);
    padding: 1px 5px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-subtle);
}

/* Search dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    margin-top: var(--sp-2);
    background: var(--bg-surface-1);
    border: 1px solid var(--border-prominent);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-3);
    display: none;
    z-index: 200;
}

.search-dropdown.show {
    display: block;
    animation: dropdown-in 0.15s ease-out;
}

@keyframes dropdown-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes dropdown-in-top {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-disabled);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: var(--sp-1) var(--sp-2);
    margin-bottom: var(--sp-1);
}

.search-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-2);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.1s;
}

.search-item:hover {
    background: var(--bg-surface-3);
}

/* Header right */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.alert-btn {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    padding: var(--sp-1) var(--sp-3);
    height: 32px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.alert-btn:hover {
    background: var(--bg-surface-3);
}

.alert-count {
    background: var(--negative);
    color: #fff;
    border-radius: var(--r-pill);
    padding: 0 5px;
    font-size: 9px;
    font-weight: 700;
    line-height: 16px;
}

/* Notification dropdown */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-prominent);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    overflow: hidden;
}

.notif-dropdown.show {
    display: block;
    animation: dropdown-in-top 0.15s ease-out;
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}

.notif-mark-all-read {
    background: none;
    border: none;
    padding: 0;
    font-size: var(--text-xs);
    font-weight: 600;
    color: #c99400;
    cursor: pointer;
}

.notif-mark-all-read:hover {
    opacity: 0.85;
}

.notif-mark-all-read:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Show ~5 items without scrolling; scroll for the rest (lazy-loaded). */
.notif-list-wrap {
    max-height: 340px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.notif-loading {
    padding: var(--sp-3) var(--sp-4);
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-disabled);
}

.notif-item {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.1s;
}

.notif-item:hover {
    background: var(--bg-surface-2);
}

.notif-item.unread {
    background: rgba(45, 127, 249, 0.03);
}

.notif-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c99400;
    flex-shrink: 0;
    margin-top: 6px;
}

/* Guest state: the panel's whole body is the login entry point. */
.notif-signin {
    display: block;
    width: 100%;
    padding: var(--sp-4);
    background: none;
    border: none;
    text-align: center;
    font-family: inherit;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
    transition: background 0.1s;
}

.notif-signin:hover {
    background: var(--bg-surface-2);
}

.notif-footer {
    padding: var(--sp-2) var(--sp-4);
    text-align: center;
}

/* User menu */
.user-btn {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
    position: relative;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(var(--brand-rgb), 0.3);
    overflow: hidden;
}

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

.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-prominent);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    overflow: hidden;
}

.user-menu.show {
    display: block;
    animation: dropdown-in-top 0.15s ease-out;
}

.user-menu-header {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.1s;
}

.user-menu-item:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.user-menu-item i {
    width: 16px;
    text-align: center;
    font-size: var(--text-xs);
}

.user-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--sp-1) 0;
}

/* Guided Tour */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.75);
    transition: opacity 0.3s;
    pointer-events: auto;
}

.tour-spotlight {
    position: absolute;
    z-index: 9999;
    border-radius: var(--r-lg);
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.75);
    transition: all 0.4s ease;
    pointer-events: none;
}

.tour-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bg-surface-3);
    transition: all 0.2s;
}

.tour-dot.active {
    background: var(--brand);
    width: 16px;
    border-radius: 3px;
}

.tour-btn-skip {
    background: none;
    border: none;
    color: var(--text-disabled);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-display);
    padding: var(--sp-1) var(--sp-2);
    transition: color 0.12s;
}

.tour-btn-skip:hover {
    color: var(--text-secondary);
}

.tour-btn-next {
    background: var(--brand);
    color: #0b0e11;
    border: none;
    border-radius: var(--r-md);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-display);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    transition: all 0.12s;
}

.tour-btn-next:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

/* Ticker tape */
.ticker-tape {
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--ticker-bg);
    height: 36px;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
}

.ticker-inner {
    display: inline-flex;
    animation: ticker-move 45s linear infinite;
}

/* Pause on hover. normalizeTickerMarquee() assigns the `animation` shorthand as an
   inline style, which resets animation-play-state to `running` and outranks a plain
   stylesheet rule — hence !important. Scoped to the strip so hovering anywhere on it
   pauses, including the gaps between items. */
.ticker-tape:hover .ticker-inner,
.ticker-inner:hover {
    animation-play-state: paused !important;
}

@keyframes ticker-move {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-4);
    border-right: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
}

/* Community Floating Bar */
.community-bar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: var(--bg-surface-1);
    border: 1px solid var(--border-brand);
    border-radius: var(--r-pill);
    cursor: pointer;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(var(--brand-rgb), 0.08);
    transition: all 0.2s ease;
    overflow: hidden;
}

.community-bar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
            rgba(var(--brand-rgb), 0.05),
            transparent 40%,
            rgba(var(--brand-rgb), 0.03));
    pointer-events: none;
}

.community-bar:hover {
    border-color: var(--brand);
    box-shadow:
        0 6px 32px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(var(--brand-rgb), 0.12);
    transform: translateY(-2px);
}

.community-bar svg {
    color: var(--brand);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.community-bar-text {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--heading-white);
    position: relative;
    z-index: 1;
}

.community-bar-divider {
    width: 1px;
    height: 14px;
    background: var(--border-prominent);
    flex-shrink: 0;
}

.community-bar-live {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
}

.community-bar-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--positive);
    flex-shrink: 0;
    animation: bar-dot-pulse 1.5s ease-in-out infinite;
}

@keyframes bar-dot-pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(var(--positive-rgb), 0.5);
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 4px rgba(var(--positive-rgb), 0);
    }
}

.community-bar-info {
    font-family: var(--font-mono);
    font-weight: 600;
    transition:
        opacity 0.2s,
        transform 0.2s;
}

.community-bar-pulse {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 60px;
    background: linear-gradient(90deg,
            transparent,
            rgba(var(--brand-rgb), 0.06),
            transparent);
    animation: bar-shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes bar-shimmer {
    0% {
        transform: translateX(-120px);
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: translateX(200px);
        opacity: 0;
    }
}

html.light .community-bar {
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(201, 148, 0, 0.1);
}

html.light .community-bar:hover {
    box-shadow:
        0 6px 32px rgba(0, 0, 0, 0.15),
        0 0 20px rgba(201, 148, 0, 0.1);
}

@media (max-width: 480px) {
    .community-bar {
        bottom: 16px;
        right: 12px;
        left: 12px;
        justify-content: center;
        padding: var(--sp-2) var(--sp-3);
    }

    .community-bar-text {
        font-size: var(--text-xs);
    }
}

.community-widget {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 900;
    width: 360px;
    height: 520px;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-prominent);
    border-radius: var(--r-xl);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: community-pop 0.25s ease-out;
}

.community-widget.hidden {
    display: none !important;
}

@keyframes community-pop {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.community-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
    flex-shrink: 0;
}

.community-widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.community-widget-input {
    padding: var(--sp-3);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
    flex-shrink: 0;
    min-width: 0;
    --emoji-popup-clearance: 48px;
}

.community-input-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-top: var(--sp-1);
    min-width: 0;
    position: relative;
}

.community-input-toolbar #comment-mood {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 0;
}

html.light .community-widget {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

@media (max-width: 480px) {
    .community-bar {
        bottom: 16px;
        right: 12px;
        left: 12px;
        justify-content: center;
        padding: var(--sp-2) var(--sp-3);
    }

    .community-widget {
        bottom: 72px;
        right: 8px;
        left: 8px;
        width: auto;
        height: 70vh;
        border-radius: var(--r-lg);
    }
}


.secondary-strip {
    border-top: 1px solid var(--border-subtle);
    background: linear-gradient(90deg,
            rgba(var(--brand-rgb), 0.025),
            transparent 50%);
    overflow: hidden;
    transition:
        height 0.2s ease,
        opacity 0.2s ease;
    height: 36px;
}

.secondary-strip.collapsed {
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.secondary-strip-inner {
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 var(--sp-4);
    gap: 0;
}

/* Live dot */
.strip-live-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--positive);
    margin-right: var(--sp-2);
    flex-shrink: 0;
    animation: strip-live-pulse 1.5s ease-in-out infinite;
}

@keyframes strip-live-pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(var(--positive-rgb), 0.5);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 0 3px rgba(var(--positive-rgb), 0);
    }
}

/* ── Chips row container ── */
.strip-chips {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

/* ── Fixed-width slot wrapper — NEVER changes size ── */
.strip-slot {
    /* Fixed widths per type — prevents any layout shift */
    flex-shrink: 0;
    /* 3D flip context */
    perspective: 400px;
    /* Clip the flip animation */
    overflow: hidden;
    border-radius: var(--r-md);
    /* height matches strip */
    height: 28px;
}

/* Fixed widths per lane */
.strip-slot[data-lane="market_state"] {
    width: 120px;
}

.strip-slot[data-lane="priority_event"] {
    width: 164px;
}

.strip-slot[data-lane="foryou"] {
    width: 156px;
}

.strip-slot[data-lane="theme_pulse"] {
    width: 148px;
}

.strip-slot[data-lane="world_catalyst"] {
    width: 152px;
}

/* ── Inner chip — fills slot, animates on flip ── */
.strip-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    height: 100%;
    padding: 0 8px;
    border-radius: var(--r-md);
    font-size: var(--text-xs);
    font-family: var(--font-display);
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    /* GPU-composited properties only */
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s;
    /* Flip transform origin */
    transform-origin: center top;
    backface-visibility: hidden;
}

.strip-chip:hover {
    background: var(--bg-surface-2);
    border-color: var(--border-default);
    color: var(--text-primary);
}

/* Category icon */
.strip-chip-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Category prefix */
.strip-chip-cat {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-disabled);
    flex-shrink: 0;
}

/* Primary text */
.strip-chip-text {
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Value mono */
.strip-chip-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 10px;
    flex-shrink: 0;
}

/* Badge */
.strip-chip-badge {
    font-size: 8px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
    font-family: var(--font-mono);
}

/* ── Per-type accent colors ── */
.strip-chip-market .strip-chip-icon {
    color: var(--text-tertiary);
}

.strip-chip-market .strip-chip-val.up {
    color: var(--positive);
}

.strip-chip-market .strip-chip-val.down {
    color: var(--negative);
}

.strip-chip-market .strip-chip-val.brand {
    color: var(--brand);
}

.strip-chip-event {
    border-left: 2px solid rgba(var(--brand-rgb), 0.4);
    padding-left: 7px;
}

.strip-chip-event .strip-chip-icon {
    color: var(--warning);
}

.strip-chip-event .strip-chip-cat {
    color: rgba(var(--brand-rgb), 0.6);
}

.strip-chip-foryou .strip-chip-icon {
    color: var(--brand);
}

.strip-chip-foryou .strip-chip-cat {
    color: rgba(var(--brand-rgb), 0.5);
}

.strip-chip-theme .strip-chip-icon {
    color: #2d7ff9;
}

.strip-chip-theme .strip-chip-cat {
    color: rgba(45, 127, 249, 0.6);
}

.strip-chip-world {
    border-left: 2px solid rgba(var(--negative-rgb), 0.3);
    padding-left: 7px;
}

.strip-chip-world .strip-chip-icon {
    color: var(--negative);
}

.strip-chip-world .strip-chip-cat {
    color: rgba(var(--negative-rgb), 0.5);
}

/* Thin separator between slots */
.strip-sep {
    width: 1px;
    height: 14px;
    background: var(--border-subtle);
    flex-shrink: 0;
    margin: 0 var(--sp-1);
}

/* ── Flip animation: content flips UP (old exits up, new enters from below) ── */
/* Exit: current chip flips away upward */
.strip-chip.flip-exit {
    animation: strip-flip-out 0.22s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes strip-flip-out {
    0% {
        transform: rotateX(0deg);
        opacity: 1;
    }

    100% {
        transform: rotateX(-90deg);
        opacity: 0;
    }
}

/* Enter: new chip flips in from below */
.strip-chip.flip-enter {
    animation: strip-flip-in 0.26s cubic-bezier(0, 0.55, 0.45, 1) forwards;
}

@keyframes strip-flip-in {
    0% {
        transform: rotateX(90deg);
        opacity: 0;
    }

    100% {
        transform: rotateX(0deg);
        opacity: 1;
    }
}

/* Flash animation for market value ticks (in-place, no flip) */
.strip-chip-val.chip-flash-up {
    animation: chip-flash-green 0.55s ease-out;
}

.strip-chip-val.chip-flash-down {
    animation: chip-flash-red 0.55s ease-out;
}

@keyframes chip-flash-green {
    0% {
        background: rgba(var(--positive-rgb), 0.3);
        border-radius: 3px;
    }

    100% {
        background: transparent;
    }
}

@keyframes chip-flash-red {
    0% {
        background: rgba(var(--negative-rgb), 0.3);
        border-radius: 3px;
    }

    100% {
        background: transparent;
    }
}

/* Timestamp + controls */
.strip-timestamp {
    font-size: 9px;
    color: var(--text-disabled);
    font-family: var(--font-mono);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
    margin-right: var(--sp-2);
}

.strip-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-disabled);
    padding: var(--sp-1);
    border-radius: var(--r-sm);
    flex-shrink: 0;
    transition: color 0.12s;
}

.strip-collapse-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-surface-2);
}

.strip-restore {
    display: none;
    align-items: center;
    gap: 4px;
    height: 18px;
    padding: 0 var(--sp-3);
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border-subtle);
    font-size: 9px;
    color: var(--text-disabled);
    cursor: pointer;
    transition: color 0.12s;
}

.strip-restore:hover {
    color: var(--text-secondary);
}

.strip-restore.visible {
    display: flex;
}

/* ── Responsive ── */
@media (max-width: 1200px) {

    /* Tablet: hide theme + world slots */
    .strip-slot[data-lane="theme_pulse"],
    .strip-slot[data-lane="world_catalyst"] {
        display: none;
    }

    .strip-sep:nth-last-child(-n + 3) {
        display: none;
    }
}

@media (max-width: 768px) {
    .secondary-strip {
        height: 30px;
    }

    .secondary-strip-inner {
        padding: 0 var(--sp-2);
    }

    .strip-slot[data-lane="theme_pulse"],
    .strip-slot[data-lane="world_catalyst"] {
        display: none;
    }

    /* Shrink fixed widths a bit on mobile */
    .strip-slot[data-lane="market_state"] {
        width: 100px;
    }

    .strip-slot[data-lane="priority_event"] {
        width: 140px;
    }

    .strip-slot[data-lane="foryou"] {
        width: 130px;
    }
}

/* Main layout */
.main {
    max-width: 1920px;
    margin: 0 auto;
    padding: var(--sp-3) var(--sp-4);
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: var(--sp-3);
    position: relative;
    z-index: 1;
    /* No overflow clipping — required for sticky children */
    overflow: visible;
}

/* Columns — must not clip sticky children */
.col-left {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
    overflow: visible;
}

.col-center {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
    overflow: visible;
}

.col-right {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-width: 0;
    overflow: visible;
}

/* ── Page-level outer dashboard sticky rail shells ── */
.dashboard-rail-sticky {
    position: sticky;
    top: var(--dashboard-sticky-top);
    max-height: var(--dashboard-rail-max-height);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    /* thin scrollbar if cards overflow viewport */
    scrollbar-width: thin;
    scrollbar-color: var(--bg-surface-3) transparent;
    /* CRITICAL: must stretch to fill flex-column parent (col-left/col-right),
     and have min-width:0 so children with mono numbers / wide content
     can shrink instead of forcing the rail wider than its column.
     align-self: stretch is the default in flex column — explicit for safety. */
    align-self: stretch;
    width: 100%;
    min-width: 0;
}

.dashboard-rail-sticky::-webkit-scrollbar {
    width: 3px;
}

.dashboard-rail-sticky::-webkit-scrollbar-thumb {
    background: var(--bg-surface-3);
    border-radius: 3px;
}

/* Watchlist / Portfolio / News — compact header for 300px right rail */
#watchlist-portfolio-panel .wp-panel-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

#watchlist-portfolio-panel .wp-tabs {
    min-width: 0;
    flex-wrap: nowrap;
}

#watchlist-portfolio-panel .wp-tabs .tab-pill {
    padding: 3px 7px;
    font-size: 10px;
    line-height: 1.3;
    white-space: nowrap;
}

#watchlist-portfolio-panel .wp-panel-actions {
    flex-shrink: 0;
}

#watchlist-portfolio-panel #wp-add-btn {
    padding: 3px 8px;
    font-size: 10px;
    white-space: nowrap;
}

/* Watchlist / Portfolio / News — panel height reserves gap above Community bar */
@media (min-width: 1025px) {
    .dashboard-rail-sticky--right {
        min-height: var(--dashboard-rail-max-height);
    }

    #watchlist-portfolio-panel {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        max-height: calc(var(--dashboard-rail-max-height) - var(--wp-news-community-reserve));
        min-height: calc(var(--dashboard-rail-max-height) - var(--wp-news-community-reserve));
    }

    #watchlist-portfolio-panel #wp-news,
    #watchlist-portfolio-panel #wp-watchlist,
    #watchlist-portfolio-panel #wp-portfolio {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    #watchlist-portfolio-panel #wp-news-ticker {
        flex: 1 1 auto;
        height: auto;
        min-height: 200px;
        overflow: hidden;
    }

    #watchlist-portfolio-panel #watchlist-list,
    #watchlist-portfolio-panel #portfolio-list {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* Below 1025px the outer rail drops its max-height (see "Disable outer sticky
   rails" further down), so nothing bounded the list and it grew with the row
   count — a 25-ticker watchlist ran ~900px tall and pushed the rest of the page
   down. Give it its own height budget so it scrolls in place like it does on
   desktop. .watchlist-list already carries overflow-y:auto (qscore.css). */
@media (max-width: 1024px) {
    #watchlist-portfolio-panel #watchlist-list {
        max-height: 60vh;
    }
}

/* Non-sticky items after the sticky shell (lower-priority right column cards) */
.dashboard-rail-after {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}

/* Bottom sections */
.bottom-section {
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 var(--sp-4) var(--sp-4);
    position: relative;
    z-index: 1;
}

/* Footer */
.footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-1);
    padding: var(--sp-8) var(--sp-4) var(--sp-6);
    margin-top: var(--sp-4);
}

.footer-inner {
    max-width: 1920px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.footer-links a {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--text-secondary);
}

.footer-disclaimer {
    font-size: var(--text-xs);
    color: var(--text-disabled);
    line-height: 1.6;
    max-width: 800px;
    margin-bottom: var(--sp-4);
}

.footer-copyright {
    font-size: var(--text-xs);
    color: var(--text-disabled);
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.footer-copyright a {
    color: var(--text-tertiary);
}

.footer-copyright a:hover {
    color: var(--text-secondary);
}

/* Stock spotlight */
#spotlight-card {
    container-type: inline-size;
    container-name: spotlight;
}

.spotlight-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.spotlight-ticker {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex: 0 1 auto;
    min-width: 0;
}

.spotlight-ticker-body {
    flex: 0 1 auto;
    min-width: 0;
}

.spotlight-title-row {
    min-width: 0;
}

.spotlight-name {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--heading-white);
    cursor: default;
}

.spotlight-title-badge,
.spotlight-wl-btn,
.spot-search {
    flex-shrink: 0;
}

.spotlight-right {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    flex: 0 1 auto;
    min-width: 0;
}

.spotlight-logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.spotlight-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.spotlight-price {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--text-2xl);
    color: var(--heading-white);
}

.spotlight-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, auto));
    gap: 6px 16px;
    font-size: var(--text-sm);
    flex: 0 1 auto;
    min-width: 0;
}

.spotlight-metrics__item {
    display: flex;
    align-items: baseline;
    gap: var(--sp-1);
    min-width: 0;
    white-space: nowrap;
}

.spotlight-metrics__item .text-dim {
    flex-shrink: 0;
}

.spotlight-metrics__val {
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Truncated spotlight text — hover tooltip only (no native title on click) */
.spotlight-truncate {
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
}

.spotlight-truncate.is-truncated {
    position: relative;
}

.spotlight-truncate.is-truncated:hover::after {
    content: attr(data-full);
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 30;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    background: var(--bg-surface-3);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    max-width: min(360px, 80vw);
}

/* ≥1200px viewport: keep header on one row */
@media (min-width: 1200px) {
    .spotlight-header {
        flex-wrap: nowrap;
    }

    .spotlight-ticker {
        flex: 0 1 auto;
        min-width: 0;
    }

    .spotlight-right {
        flex: 0 1 auto;
        min-width: 0;
        margin-left: auto;
    }

    #spotlight-card .qscore-container {
        flex-shrink: 0;
    }
}

/* 1200–1599px: fluidly scale font/gap when space gets tight */
@media (min-width: 1200px) and (max-width: 1599px) {
    .spotlight-header {
        --spot-s: clamp(0.78, calc(0.78 + (100vw - 1200px) / 400), 1);
        --spot-s-left: clamp(0.72, calc(0.72 + (100vw - 1200px) / 500), 0.9);
        gap: calc(var(--sp-2) * var(--spot-s));
    }

    .spotlight-ticker {
        gap: calc(var(--sp-4) * var(--spot-s));
    }

    .spotlight-right {
        gap: calc(var(--sp-3) * var(--spot-s));
    }

    .spotlight-name {
        font-size: calc(var(--text-lg) * var(--spot-s-left));
    }

    .spotlight-logo {
        width: calc(44px * var(--spot-s));
        height: calc(44px * var(--spot-s));
    }

    .spotlight-price {
        font-size: calc(var(--text-2xl) * var(--spot-s-left));
    }

    .spotlight-metrics {
        font-size: calc(var(--text-sm) * var(--spot-s));
        gap: calc(6px * var(--spot-s)) calc(12px * var(--spot-s));
    }

    #spotlight-card #spotlight-change {
        font-size: calc(var(--text-md) * var(--spot-s)) !important;
    }

    #spotlight-card #spotlight-date {
        font-size: calc(var(--text-xs) * var(--spot-s)) !important;
    }

    #spotlight-card .spotlight-wl-btn {
        font-size: calc(10px * var(--spot-s));
        padding: calc(3px * var(--spot-s)) calc(10px * var(--spot-s));
    }

    #spotlight-card .qscore-ring,
    #spotlight-card .qscore-ring svg {
        width: calc(56px * var(--spot-s)) !important;
        height: calc(56px * var(--spot-s)) !important;
    }

    #spotlight-card .qscore-val {
        font-size: calc(var(--text-lg) * var(--spot-s));
    }

    #spotlight-card .qscore-label-text {
        font-size: calc(var(--text-xs) * var(--spot-s));
    }

    #spotlight-card #qscore-label {
        font-size: calc(var(--text-xs) * var(--spot-s)) !important;
    }
}

/* Prefer card width over viewport for scale factor (center column ≠ viewport) */
@supports (container-type: inline-size) {
    @container spotlight (min-width: 0) {
        @media (min-width: 1200px) and (max-width: 1599px) {
            .spotlight-header {
                --spot-s: clamp(0.78, calc(0.78 + (100cqi - 620px) / 380), 1);
                --spot-s-left: clamp(0.72, calc(0.72 + (100cqi - 620px) / 480), 0.9);
            }
        }
    }
}

/* <1200px: allow two-row layout (ticker top, metrics + Q-Score bottom) */
@media (max-width: 1199px) and (min-width: 769px) {
    .spotlight-ticker {
        flex: 1 1 100%;
    }

    .spotlight-right {
        flex: 1 1 100%;
        justify-content: space-between;
    }
}

/* Spotlight watchlist button */
.spotlight-wl-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: var(--sp-1);
}

.spotlight-wl-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.spotlight-wl-btn.active {
    background: var(--brand-dim);
    border-color: var(--brand);
    color: var(--brand);
}

.spotlight-wl-btn.active svg {
    fill: var(--brand);
}

/* Spotlight mobile: full-width stacked layout */
@media (max-width: 768px) {
    .spotlight-header {
        flex-direction: column;
        align-items: stretch;
    }

    .spotlight-ticker {
        width: 100%;
    }

    .spotlight-right {
        width: 100%;
        justify-content: space-between;
        padding-top: var(--sp-2);
        border-top: 1px solid var(--border-subtle);
        margin-top: var(--sp-1);
    }

    .spotlight-metrics {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--sp-1) var(--sp-3);
        font-size: var(--text-xs);
        flex: 1;
    }

    .spotlight-price {
        font-size: var(--text-xl);
    }
}

@media (max-width: 480px) {
    .spotlight-ticker {
        gap: var(--sp-2);
    }

    .spotlight-logo {
        width: 36px;
        height: 36px;
    }

    .spotlight-price {
        font-size: var(--text-lg);
    }

    .spotlight-right {
        flex-direction: column;
        align-items: stretch;
        gap: var(--sp-3);
    }

    .spotlight-metrics {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--sp-2);
    }
}

/* Chart */
/* Chart — balanced height to align with sidebar panels */
.chart-wrap {
    display: flex;
    flex-direction: column;
    height: 560px;
    min-height: 560px;
}

#chart-container {
    cursor: crosshair;
    flex: 1;
    min-height: 0;
}

#rsi-container {
    cursor: crosshair;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border-subtle);
}

.chart-ohlc {
    display: flex;
    gap: var(--sp-3);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

/* Quick stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--sp-2);
}

.stat-cell {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--sp-2) var(--sp-3);
    text-align: center;
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--text-disabled);
    margin-bottom: 2px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Stock detail tabs */
.detail-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--sp-3);
}

.detail-tab {
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-tertiary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-tab:hover {
    color: var(--text-secondary);
}

.detail-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.detail-pane {
    display: none;
}

.detail-pane.active {
    display: block;
    animation: fade-in 0.2s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Market insight tables */
.insight-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-3);
}

.insight-table-header {
    display: grid;
    grid-template-columns: 1fr 40px 60px 56px 56px;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-disabled);
}

.insight-row {
    display: grid;
    grid-template-columns: 1fr 40px 60px 56px 56px;
    gap: var(--sp-1);
    padding: var(--sp-2);
    align-items: center;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.12s;
    font-size: var(--text-sm);
}

.insight-row:hover {
    background: rgba(var(--brand-rgb), 0.03);
}

/* Adv/Dec + Sector */
.market-row-2 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-3);
    margin-top: var(--sp-3);
}

/* The three cards are stretched to the tallest one by the grid, so their
   content areas become flex columns and the last child fills the leftover
   space. Without this the Barometer (3 rows) left a large hole under itself
   next to Adv/Dec and Sector Performance (~11 rows each). */
.market-row-2 > .card {
    display: flex;
    flex-direction: column;
}

/* Market Barometer 3×3 grid */
.barometer-head,
.barometer-row {
    display: grid;
    grid-template-columns: 52px repeat(3, 1fr);
    gap: var(--sp-1);
}

.barometer-head {
    margin-bottom: var(--sp-1);
}

.barometer-col-label {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-disabled);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.barometer-grid {
    flex: 1;
    display: grid;
    grid-auto-rows: minmax(48px, 1fr);
    gap: var(--sp-1);
    min-height: 0;
}

.barometer-row-label {
    display: flex;
    align-items: center;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.barometer-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    padding: var(--sp-2) var(--sp-1);
}

.barometer-cell-value {
    font-family: var(--font-mono);
    font-size: var(--text-md);
    font-weight: 700;
}

/* Options flow */
.flow-row {
    display: grid;
    grid-template-columns: 50px 50px 56px 50px 60px 56px 56px;
    gap: var(--sp-1);
    align-items: center;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.12s;
}

.flow-row:hover {
    background: rgba(45, 127, 249, 0.04);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Onboarding hints */
.hint {
    position: fixed;
    z-index: 300;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-brand);
    border-radius: var(--r-lg);
    padding: var(--sp-3) var(--sp-4);
    box-shadow: var(--shadow-lg);
    max-width: 240px;
    display: none;
    animation: hint-in 0.3s ease-out;
}

.hint.show {
    display: block;
}

@keyframes hint-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hint-arrow {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--bg-surface-1);
    border-left: 1px solid var(--border-brand);
    border-top: 1px solid var(--border-brand);
    transform: rotate(45deg);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 1440px) {
    .main {
        grid-template-columns: 300px 1fr 280px;
    }
}

@media (max-width: 1200px) {
    .main {
        grid-template-columns: 280px 1fr 260px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {

    /* Stack all 3 columns vertically — show everything */
    .main {
        grid-template-columns: 1fr;
        gap: var(--sp-2);
    }

    /* Reorder: center first (chart), then left+right side by side */
    .col-center {
        order: 1;
    }

    .col-left {
        order: 2;
        display: flex !important;
    }

    .col-right {
        order: 3;
        display: flex !important;
    }

    .nav {
        display: none;
    }

    .input-search {
        width: 180px;
    }

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

    .market-row-2 {
        grid-template-columns: 1fr;
    }

    .chart-wrap {
        height: auto;
        min-height: 300px;
    }

    /* Disable outer sticky rails below 1024px */
    .dashboard-rail-sticky {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

@media (max-width: 768px) {
    .header-inner {
        padding: 0 var(--sp-2);
        height: 48px;
        gap: var(--sp-2);
    }

    .input-search {
        width: 110px;
        font-size: var(--text-sm);
        padding: var(--sp-1) var(--sp-2);
        padding-left: 28px;
    }

    .search-kbd {
        display: none;
    }

    .search-icon {
        left: 8px;
        font-size: 10px;
    }

    .search-dropdown {
        width: calc(100vw - 24px);
        left: 12px;
        right: 12px;
        transform: none;
    }

    .btn-upgrade {
        display: none;
    }

    .user-info-text {
        display: none;
    }

    .logo-wordmark {
        font-size: 14px;
    }

    .logo-q {
        width: 20px;
        height: 20px;
    }

    .main {
        padding: var(--sp-2);
        gap: var(--sp-2);
    }

    .card {
        padding: var(--sp-3);
    }

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

    .stat-cell {
        padding: var(--sp-1) var(--sp-2);
    }

    .chart-wrap {
        height: auto;
        min-height: 260px;
    }

    #chart-container {
        min-height: 180px;
    }

    .chart-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--sp-2);
        padding: var(--sp-2);
    }

    .chart-ohlc {
        display: none;
    }

    .qscore-ring {
        width: 44px;
        height: 44px;
    }

    .qscore-ring svg {
        width: 44px;
        height: 44px;
    }

    .qscore-val {
        font-size: var(--text-md) !important;
    }

    .detail-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .detail-tab {
        white-space: nowrap;
        padding: var(--sp-2) var(--sp-3);
    }

    .insight-table-header {
        font-size: 9px;
    }

    .insight-row {
        font-size: var(--text-xs);
    }

    .notif-dropdown {
        width: calc(100vw - 24px);
        right: -12px;
        max-height: 70vh;
        overflow-y: auto;
    }

    .alert-btn span:not(.alert-count) {
        display: none;
    }

    .theme-toggle-btn {
        width: 30px;
        height: 30px;
        font-size: var(--text-sm);
    }

    .ticker-tape {
        height: 30px;
    }

    .ticker-item {
        font-size: 10px;
        padding: 0 var(--sp-2);
    }

    /* Show left+right as 2-col grid on tablet */
    .col-left,
    .col-right {
        width: 100%;
    }
}

@media (max-width: 640px) {

    /* Stack left and right into single column on phone */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .overview-metrics {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .news-grid {
        grid-template-columns: 1fr !important;
    }

    .footer-links {
        gap: var(--sp-3);
        flex-wrap: wrap;
    }
}

/* ── News Hub — same column widths for Market & Your Feed ── */
#news-market,
#news-personal {
    width: 100%;
}
.news-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: var(--sp-4);
    width: 100%;
}
.news-grid > * {
    min-width: 0;
}
.news-digest-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    animation: fade-in 0.2s ease;
    cursor: pointer;
    transition: border-color 0.12s;
}
.news-digest-card:hover { border-color: var(--border-prominent); }
.news-digest-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    font-size: 8px;
    font-weight: 700;
}
.news-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bg-surface-3);
    cursor: pointer;
    transition: all 0.15s;
}
.news-dot.active {
    background: var(--brand);
    box-shadow: 0 0 4px rgba(var(--brand-rgb), 0.3);
}
.news-digest-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-2);
}
.news-digest-metric {
    padding: var(--sp-2);
    background: var(--bg-surface-3);
    border-radius: var(--r-sm);
}
.news-digest-metric__label {
    font-size: 9px;
    color: var(--text-disabled);
    text-transform: uppercase;
    margin-bottom: 1px;
}
.news-digest-metric__value {
    font-size: var(--text-sm);
    color: var(--text-primary);
}

@media (max-width: 480px) {
    .header-inner {
        height: 44px;
        gap: var(--sp-1);
    }

    .logo-wordmark {
        font-size: 12px;
    }

    .logo-q {
        width: 18px;
        height: 18px;
    }

    .input-search {
        width: 90px;
        font-size: 10px;
    }

    .search-dropdown {
        width: calc(100vw - 16px);
        left: 8px;
        right: 8px;
    }

    .main {
        padding: var(--sp-1);
        gap: var(--sp-2);
    }

    .card {
        padding: var(--sp-2);
        border-radius: var(--r-md);
    }

    .card-inner {
        padding: var(--sp-2);
    }

    .card-title {
        font-size: var(--text-base);
    }

    .card-title i {
        font-size: var(--text-xs);
    }

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

    .stat-cell {
        padding: var(--sp-1);
    }

    .stat-label {
        font-size: 9px;
    }

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

    .tab-pills {
        flex-wrap: wrap;
        gap: var(--sp-1);
    }

    .tab-pill {
        font-size: 10px;
        padding: 3px 8px;
    }

    .tab-item {
        font-size: 10px;
        padding: var(--sp-1) var(--sp-2);
    }

    .detail-tab {
        font-size: 10px;
        padding: var(--sp-1) var(--sp-2);
    }

    .list-row {
        padding: var(--sp-1) var(--sp-2);
        gap: var(--sp-2);
    }

    .ticker-logo {
        width: 24px;
        height: 24px;
        font-size: 8px;
    }

    .ticker-logo-sm {
        width: 20px;
        height: 20px;
        font-size: 7px;
    }

    .footer-disclaimer {
        font-size: 9px;
    }

    .footer-copyright {
        font-size: 9px;
        flex-direction: column;
        gap: var(--sp-1);
    }

    .onboard-container {
        padding: var(--sp-4) var(--sp-2);
    }

    .onboard-title {
        font-size: var(--text-lg);
    }

    .onboard-options.cols-2,
    .onboard-options.cols-3 {
        grid-template-columns: 1fr;
    }

    .onboard-summary-grid {
        grid-template-columns: 1fr;
    }

    .user-menu {
        right: -8px;
        width: 200px;
    }
}

/* Responsive helpers for inner grids */
@media (max-width: 768px) {
    .news-grid {
        grid-template-columns: 1fr !important;
    }

    .overview-metrics {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .flow-row {
        font-size: var(--text-xs);
    }

    .screener-filters {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }

    .screener-table {
        font-size: var(--text-xs);
        display: block;
        overflow-x: auto;
    }

    .screener-table th,
    .screener-table td {
        padding: var(--sp-1) var(--sp-2);
        white-space: nowrap;
    }

    #community-feed {
        max-height: 280px;
    }

    .comment-card {
        padding: var(--sp-2);
    }

    .sentiment-btn {
        padding: var(--sp-1) var(--sp-1);
        font-size: 9px;
    }

    .sentiment-btn i {
        font-size: var(--text-xs);
    }

    .scroll-x-inner {
        min-width: 0 !important;
    }

    /* Ensure all paywall banners fit */
    .paywall-banner {
        font-size: var(--text-xs);
        padding: var(--sp-2) var(--sp-3);
    }

    .paywall-banner span {
        font-size: var(--text-xs);
    }

    /* Modal full-width on mobile */
    /* Onboarding mobile */
    .onboard-option {
        padding: var(--sp-3) var(--sp-2);
    }

    .onboard-option-icon {
        width: 36px;
        height: 36px;
        font-size: var(--text-md);
    }

    .onboard-chip {
        font-size: var(--text-xs);
        padding: var(--sp-1) var(--sp-2);
    }
}

/* Community / Social — adapted for narrow sidebar */
.sentiment-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--sp-2) var(--sp-1);
    border-radius: var(--r-md);
    border: 1px solid var(--negative-dim);
    background: transparent;
    color: var(--negative);
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 0;
}

.sentiment-btn i {
    font-size: var(--text-sm);
}

.sentiment-btn:hover {
    background: var(--negative-dim);
}

.sentiment-btn.voted {
    background: var(--negative-dim);
    border-color: var(--negative);
    box-shadow: 0 0 0 2px var(--negative-dim);
}

.sentiment-btn-neutral {
    border-color: var(--warning-dim);
    color: var(--warning);
}

.sentiment-btn-neutral:hover {
    background: var(--warning-dim);
}

.sentiment-btn-neutral.voted {
    background: var(--warning-dim);
    border-color: var(--warning);
    box-shadow: 0 0 0 2px var(--warning-dim);
}

.sentiment-btn-positive {
    border-color: var(--positive-dim);
    color: var(--positive);
}

.sentiment-btn-positive:hover {
    background: var(--positive-dim);
}

.sentiment-btn-positive.voted {
    background: var(--positive-dim);
    border-color: var(--positive);
    box-shadow: 0 0 0 2px var(--positive-dim);
}

.mood-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-tertiary);
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.mood-tag:hover {
    border-color: var(--negative);
    color: var(--negative);
    background: var(--negative-dim);
}

.mood-tag.active {
    border-color: var(--negative);
    color: var(--negative);
    background: var(--negative-dim);
}

.mood-tag-neutral:hover {
    border-color: var(--warning);
    color: var(--warning);
    background: var(--warning-dim);
}

.mood-tag-neutral.active {
    border-color: var(--warning);
    color: var(--warning);
    background: var(--warning-dim);
}

.mood-tag-positive:hover {
    border-color: var(--positive);
    color: var(--positive);
    background: var(--positive-dim);
}

.mood-tag-positive.active {
    border-color: var(--positive);
    color: var(--positive);
    background: var(--positive-dim);
}

/* ── Emoji picker (community chat input) ── */
.community-input-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    margin-left: auto;
    position: static;
}

.community-post-btn,
.comment-cancel-btn {
    padding: var(--sp-1) var(--sp-2);
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Edit mode: keep single row, compact mood tags + action buttons */
.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .community-input-toolbar {
    gap: 8px;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) #comment-mood {
    gap: 6px;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .community-input-actions {
    gap: 6px;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .mood-tag {
    padding: 2px 4px;
    font-size: 8px;
    gap: 1px;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .community-post-btn {
    padding: 3px 5px;
    font-size: 9px;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .comment-cancel-btn {
    padding: 3px 0px;
    font-size: 8px;
    min-width: 0;
    text-align: center;
    flex-shrink: 0;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .emoji-picker-wrap {
    flex-shrink: 0;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .emoji-picker-btn {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.community-widget-input:has(#comment-cancel-btn:not(.hidden)) .emoji-picker-btn svg {
    width: 16px;
    height: 16px;
}

.emoji-picker-wrap {
    position: static !important;
}

.emoji-picker-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: var(--r-md);
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.emoji-picker-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: rgba(64, 144, 255, 0.08);
}

.emoji-picker-btn:active {
    transform: scale(0.92);
}

.emoji-picker-btn.is-open {
    border-color: var(--brand);
    color: var(--brand);
    background: rgba(64, 144, 255, 0.12);
    box-shadow: 0 0 0 2px rgba(64, 144, 255, 0.15);
}

.emoji-picker-popup {
    position: absolute;
    bottom: calc(100% + var(--emoji-popup-clearance, 48px));
    left: 50%;
    right: auto;
    z-index: 20;
    width: 272px;
    max-height: 160px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--sp-2);
    background: var(--bg-surface-1);
    border: 1px solid var(--border-prominent);
    border-radius: var(--r-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    transform-origin: bottom center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.emoji-picker-popup.hidden {
    display: none !important;
}

.emoji-picker-popup.is-closing {
    opacity: 0;
    transform: translateX(-50%) translateY(6px) scale(0.96);
    pointer-events: none;
}

html.light .emoji-picker-popup {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.emoji-picker-section+.emoji-picker-section {
    margin-top: var(--sp-2);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--border-subtle);
}

.emoji-picker-section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-disabled);
    margin-bottom: var(--sp-1);
    padding: 0 2px;
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.emoji-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.1s ease;
}

.emoji-picker-item:hover {
    background: var(--bg-surface-2);
}

.emoji-picker-item:active {
    transform: scale(0.88);
    background: rgba(64, 144, 255, 0.12);
}

.comment-card {
    padding: var(--sp-2);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    transition: border-color 0.15s;
    position: relative;
}

.comment-card:hover {
    border-color: var(--border-default);
}

.comment-card-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
    flex-wrap: nowrap;
    min-width: 0;
    overflow: visible;
}

.comment-card-username {
    font-size: var(--text-sm);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 0 1 auto;
}

.comment-card-meta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    overflow: visible;
}

.comment-time {
    font-size: 9px;
    color: var(--text-disabled);
    white-space: nowrap;
}

.comment-edited-tag {
    font-size: 8px;
    color: var(--text-disabled);
    font-style: italic;
    white-space: nowrap;
}

.comment-card-menu-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    overflow: visible;
}

.comment-card:has(.comment-card-menu.is-open) {
    z-index: 10;
    overflow: visible;
}

.comment-card-menu-wrap:has(.comment-card-menu.is-open) {
    z-index: 50;
}

.comment-card-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-disabled);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.comment-card:hover .comment-card-menu-btn,
.comment-card-menu-btn[aria-expanded="true"] {
    opacity: 1;
}

.comment-card-menu-btn:hover {
    color: var(--text-secondary);
    background: var(--bg-surface-1);
}

.comment-card-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 30;
    min-width: 88px;
    padding: 4px;
    background: var(--bg-surface-1);
    border: 1px solid var(--border-prominent);
    border-radius: var(--r-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.comment-card-menu.is-open {
    display: block;
}

.comment-card-menu-item {
    display: block;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    text-align: left;
    cursor: pointer;
}

.comment-card-menu-item:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.comment-cancel-btn {
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-display);
    transition: border-color 0.15s ease, color 0.15s ease;
}

.comment-cancel-btn:hover {
    border-color: var(--text-disabled);
    color: var(--text-primary);
}

.comment-cancel-btn.hidden {
    display: none !important;
}

html.light .comment-card-menu {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.comment-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-1);
}

.comment-action {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--text-xs);
    color: var(--text-disabled);
    cursor: pointer;
    transition: color 0.15s;
    background: none;
    border: none;
    font-family: var(--font-display);
}

.comment-action:hover {
    color: var(--text-secondary);
}

.comment-action.liked {
    color: var(--brand);
}

.comment-mood-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 5px;
    border-radius: var(--r-pill);
    font-size: 8px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Horizontal scroll container for narrow panels */
.scroll-x {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.scroll-x::-webkit-scrollbar {
    height: 5px;
}

.scroll-x::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-x::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--r-sm);
}

.scroll-x-inner {
    min-width: max-content;
}

/* Theme toggle */
.theme-toggle-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    font-size: var(--text-md);
}

.theme-toggle-btn:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.theme-toggle-btn .icon-sun,
.theme-toggle-btn .icon-moon {
    transition: all 0.3s ease;
    position: absolute;
}

.theme-toggle-btn .icon-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.theme-toggle-btn .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

html.light .theme-toggle-btn .icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

html.light .theme-toggle-btn .icon-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}
