/* The Litmus - Editorial Design System */

:root {
    /* Palette */
    --burgundy: #8A123C;
    --burgundy-dark: #6d0e2f;
    --teal: #126C8A;
    --white: #FFFFFF;
    
    --paper: #FFF8F2;
    --paper-dark: #F5EDE5;
    --rule: #E8DFD5;
    
    --ink: #1C1C1C;
    --ink-secondary: #4A4A4A;
    --ink-tertiary: #888888;
    
    /* Typography */
    --serif: 'Source Serif Pro', Georgia, serif;
    --sans: 'Inter', -apple-system, sans-serif;
    
    /* Spacing */
    --xs: 0.25rem;
    --sm: 0.5rem;
    --md: 1rem;
    --lg: 1.5rem;
    --xl: 2rem;
    --2xl: 3rem;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--sans);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.5;
}

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

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--lg) var(--xl);
}

/* Center content on very wide screens */
@media (min-width: 1500px) {
    .container {
        padding: var(--lg) calc((100vw - 1400px) / 2 + var(--xl));
    }
}

/* ========== MASTHEAD ========== */
.masthead {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--sm) 0 var(--md) 0;
    border-bottom: 1px solid var(--rule);
    position: relative;
}

/* ========== MASTHEAD - FT Style Three Column ========== */
.masthead {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: var(--md) 0;
    border-bottom: 1px solid var(--rule);
    margin-bottom: var(--md);
}

.masthead-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.masthead-center {
    display: flex;
    justify-content: center;
}

.masthead-brand {
    display: flex;
    align-items: center;
    gap: var(--md);
    text-decoration: none;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.brand-name {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: 2rem;
    color: var(--ink);
    letter-spacing: 0;
}

.masthead-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sm);
}

/* Edition Picker */
.edition-picker {
    display: flex;
    gap: var(--xs);
}

.edition {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 500;
    padding: var(--xs) var(--sm);
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 3px;
    color: var(--ink-tertiary);
    cursor: pointer;
    transition: all 0.15s;
}

.edition:hover {
    border-color: var(--ink-tertiary);
    color: var(--ink-secondary);
}

.edition.active {
    background: var(--burgundy);
    border-color: var(--burgundy);
    color: white;
}

/* Subscribe Button */
.subscribe-btn {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    padding: var(--xs) var(--md);
    background: var(--ink);
    border: none;
    border-radius: 3px;
    color: white;
    cursor: pointer;
    transition: all 0.15s;
}

.subscribe-btn:hover:not(:disabled) {
    background: var(--burgundy);
}

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

/* Sign In Button */
.signin-btn {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 500;
    padding: var(--xs) var(--md);
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 3px;
    color: var(--ink-secondary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: var(--xs);
}

.signin-btn:hover {
    border-color: var(--burgundy);
    color: var(--burgundy);
}

/* Auth Container */
.auth-container {
    position: relative;
}

.auth-hidden {
    display: none !important;
}

/* User Menu Button (when signed in) */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--xs);
    padding: 4px 8px 4px 4px;
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
}

.user-menu-btn:hover {
    border-color: var(--burgundy);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: var(--xs);
    z-index: 100;
    display: none;
}

.user-dropdown.open {
    display: block;
}

.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--sm);
    padding: var(--sm) var(--md);
    background: transparent;
    border: none;
    border-radius: 4px;
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--ink-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.dropdown-item:hover {
    background: var(--paper-dark);
    color: var(--ink);
}

.dropdown-item svg {
    color: var(--ink-tertiary);
}

/* Sign In Modal */
.signin-modal {
    max-width: 400px;
}

.signin-body {
    text-align: center;
    padding: var(--xl) var(--lg);
}

.signin-subtitle {
    font-size: 0.95rem;
    color: var(--ink-secondary);
    margin-bottom: var(--xl);
}

.signin-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--md);
}

.signin-provider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--md);
    width: 100%;
    padding: var(--md) var(--lg);
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 8px;
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s;
}

.signin-provider:hover {
    border-color: var(--ink-secondary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#apple-signin {
    background: var(--ink);
    border-color: var(--ink);
    color: white;
}

#apple-signin:hover {
    background: #1a1a1a;
}

.signin-terms {
    margin-top: var(--xl);
    font-size: 0.75rem;
    color: var(--ink-tertiary);
}

/* ========== MARKET STRIP ========== */
.market-strip {
    display: flex;
    gap: var(--xl);
    padding: var(--sm) 0;
    border-bottom: 1px solid var(--rule);
}

.ticker {
    display: flex;
    align-items: baseline;
    gap: var(--sm);
}

.ticker-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-tertiary);
}

.ticker-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
}

.ticker-change {
    font-size: 0.75rem;
    font-weight: 500;
}

.ticker-change.up { color: #0a7c42; }
.ticker-change.down { color: var(--burgundy); }

/* Market Activity indicator */
.ticker-activity {
    font-weight: 600;
}
.ticker-activity.frenzied { color: var(--burgundy); }
.ticker-activity.active { color: #0a7c42; }
.ticker-activity.moderate { color: var(--teal); }
.ticker-activity.quiet { color: var(--ink-tertiary); }

/* ========== SECTION NAV ========== */
.section-nav {
    display: flex;
    gap: var(--lg);
    padding: var(--md) 0;
    border-bottom: 2px solid var(--ink);
}

.section-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-tertiary);
    transition: color 0.15s;
}

.section-link:hover,
.section-link.active {
    color: var(--ink);
}

/* ========== STICKY HEADER ========== */
.sticky-header {
    position: fixed;
    top: -60px;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--xl);
    z-index: 1000;
    transition: top 0.25s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.sticky-header.visible {
    top: 0;
}

.sticky-left {
    display: flex;
    align-items: center;
    gap: var(--lg);
}

.sticky-ticker {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sticky-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--ink-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sticky-value {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
}

.sticky-change {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
}

.sticky-change.up {
    color: var(--positive);
}

.sticky-change.down {
    color: var(--negative);
}

.sticky-activity {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--positive);
    padding: 3px 8px;
    background: rgba(16, 124, 65, 0.1);
    border-radius: 4px;
}

.sticky-activity.frenzied {
    color: var(--burgundy);
    background: rgba(138, 18, 60, 0.1);
}

.sticky-activity.moderate {
    color: var(--teal);
    background: rgba(0, 128, 128, 0.1);
}

.sticky-activity.quiet {
    color: var(--ink-tertiary);
    background: rgba(0, 0, 0, 0.05);
}

.sticky-right {
    display: flex;
    align-items: center;
    gap: var(--lg);
}

.sticky-nav {
    display: flex;
    gap: var(--md);
}

.sticky-link {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ink-tertiary);
    text-decoration: none;
    transition: color 0.15s;
}

.sticky-link:hover,
.sticky-link.active {
    color: var(--ink);
}

.sticky-region {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--white);
    background: var(--ink);
    padding: 5px 12px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ========== EDITORIAL GRID ========== */
.editorial-grid {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    gap: var(--xl);
    margin-top: var(--xl);
}

/* ========== ARTICLE INDEX (Left) ========== */
.article-index {
    border-right: 1px solid var(--rule);
    padding-right: var(--xl);
}

.index-header {
    padding-bottom: var(--md);
    border-bottom: 2px solid var(--burgundy);
    margin-bottom: var(--lg);
}

.index-header-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--sm);
}

.index-title {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--burgundy);
}

.index-date {
    font-size: 0.7rem;
    color: var(--ink-tertiary);
}

/* Brief Selector Tabs */
.brief-selector {
    display: flex;
    gap: 0;
    background: var(--paper-dark);
    border-radius: 6px;
    padding: 3px;
}

.brief-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.brief-tab:hover {
    background: rgba(255,255,255,0.5);
}

.brief-tab.active {
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.brief-tab-label {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-tertiary);
}

.brief-tab.active .brief-tab-label {
    color: var(--burgundy);
}

.brief-tab-time {
    font-family: var(--sans);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--ink-tertiary);
}

.brief-tab.active .brief-tab-time {
    color: var(--ink-secondary);
}

/* Brief unavailable state */
.brief-tab.unavailable {
    opacity: 0.45;
    cursor: not-allowed;
}

.brief-tab.unavailable:hover {
    background: transparent;
}

.index-list {
    display: flex;
    flex-direction: column;
}

/* Index Cards */
.index-card {
    padding: var(--md) 0;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    transition: all 0.15s;
}

.index-card:hover {
    background: var(--paper-dark);
    margin: 0 calc(var(--md) * -1);
    padding-left: var(--md);
    padding-right: var(--md);
}

.index-card.active {
    border-left: 3px solid var(--burgundy);
    margin-left: -3px;
    padding-left: calc(var(--md) - 3px);
}

.index-card.active .card-label {
    color: var(--burgundy);
}

.card-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--teal);
    display: block;
    margin-bottom: var(--xs);
}

.card-headline {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ink);
    margin-bottom: var(--xs);
}

/* Excerpt shown only for THE LEAD via JS */
.card-excerpt {
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--ink-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: var(--xs);
}

/* ========== THE TAKEAWAY - Rory-style Quote Box ========== */
.takeaway-quote {
    margin-top: var(--lg);
    padding: var(--lg) var(--lg) var(--md);
    padding-left: 50px;
    background: linear-gradient(135deg, var(--burgundy) 0%, var(--burgundy-dark) 100%);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.takeaway-quote::before {
    content: '"';
    position: absolute;
    top: 8px;
    left: 10px;
    font-family: Georgia, serif;
    font-size: 5rem;
    line-height: 1;
    color: rgba(255,255,255,0.25);
    pointer-events: none;
}

.takeaway-label {
    font-family: var(--sans);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.7);
    display: block;
    margin-bottom: var(--sm);
}

.takeaway-text {
    font-family: var(--serif);
    font-size: 0.95rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--white);
    margin: 0;
    position: relative;
    z-index: 1;
}

/* ========== READING PANE (Center) ========== */
.reading-pane {
    min-height: 600px;
}

/* Audio Card - Matching iOS Design */
.audio-card {
    display: flex;
    align-items: stretch;
    background: var(--white);
    border-radius: 12px;
    margin-top: 40px;
    margin-bottom: var(--xl);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
    max-width: 720px;
}

.audio-card-content {
    flex: 1;
    padding: 16px;
}

.audio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.audio-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--teal);
}

.audio-duration {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--ink-tertiary);
}

.audio-episode {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.audio-artwork {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.audio-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.audio-title {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.3;
    color: var(--ink);
    text-transform: uppercase;
    padding-top: 4px;
}

.audio-source {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.audio-show-name {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--burgundy);
}

.audio-dot {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ink-tertiary);
}

.audio-recency {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-tertiary);
}

.audio-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.audio-link {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-tertiary);
    transition: color 0.15s;
}

.audio-link:hover {
    color: var(--burgundy);
}

/* Audio Player Controls - Right Side */
.audio-player {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--teal);
    min-width: 160px;
}

.audio-play-btn {
    width: 48px;
    height: 48px;
    background: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.audio-play-btn:hover {
    transform: scale(1.08);
}

.audio-play-btn:active {
    transform: scale(0.95);
}

.audio-play-btn svg {
    width: 22px;
    height: 22px;
    fill: var(--teal);
    display: block;
}

.audio-play-btn .play-icon {
    margin-left: 3px;
}

.audio-play-btn .pause-icon {
    display: none;
}

.audio-play-btn.playing .play-icon {
    display: none;
}

.audio-play-btn.playing .pause-icon {
    display: block;
}

.hidden {
    display: none !important;
}

.audio-progress-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audio-progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
}

.audio-progress {
    height: 100%;
    width: 0%;
    background: var(--white);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.audio-times {
    display: flex;
    justify-content: space-between;
}

.audio-current-time,
.audio-total-time {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--paper);
}

#audio-element {
    display: none;
}

/* Responsive audio card */
@media (max-width: 600px) {
    .audio-card {
        flex-direction: column;
    }
    
    .audio-player {
        flex-direction: row;
        min-width: auto;
        padding: 12px 16px;
    }
    
    .audio-progress-container {
        flex: 1;
    }
}

/* Article Content */
.article-content {
    max-width: 720px;
}

/* Article Lead Image - FT Style with Gradient Overlay */
.article-image {
    position: relative;
    width: 100%;
    max-width: 720px;
    height: 360px;
    margin-bottom: var(--lg);
    border-radius: 0;
    overflow: hidden;
    background: var(--ink);
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.article-image img.loading {
    opacity: 0;
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 80px 32px 28px 32px;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.3) 40%,
        rgba(0, 0, 0, 0.85) 100%
    );
}

.image-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--white);
    background: var(--burgundy);
    padding: 5px 12px;
    border-radius: 2px;
    display: inline-block;
    margin-bottom: var(--md);
}

.image-headline {
    font-family: var(--serif);
    font-size: 1.85rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--white);
    margin: 0;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    max-width: 85%;
}

@media (max-width: 768px) {
    .article-image {
        height: 280px;
    }
    
    .image-headline {
        font-size: 1.4rem;
    }
}

.article-header {
    margin-bottom: var(--xl);
    padding-bottom: var(--lg);
    border-bottom: 1px solid var(--rule);
    max-width: 720px;
}

/* When image is shown, reduce header styling */
.article-header.with-image {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--md);
}

.article-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--burgundy);
    display: block;
    margin-bottom: var(--sm);
}

.article-headline {
    font-family: var(--serif);
    font-size: 2.25rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: var(--md);
}

.article-meta {
    display: flex;
    gap: var(--md);
    font-size: 0.8rem;
    color: var(--ink-tertiary);
}

.article-byline {
    color: var(--burgundy);
    font-weight: 500;
}

/* Article Body */
.article-body {
    font-family: var(--serif);
    font-size: 1.15rem;
    line-height: 1.75;
    color: var(--ink-secondary);
    max-width: 720px;
}

.article-body p {
    margin-bottom: var(--lg);
}

.article-body p:last-child {
    margin-bottom: 0;
}

/* ========== CONTEXT SIDEBAR (Right) ========== */
.context-sidebar {
    padding-left: var(--xl);
    border-left: 1px solid var(--rule);
}

/* ========== MARKET MOOD 9-BOX ========== */
.market-mood {
    margin-bottom: var(--lg);
    overflow: hidden;
}

.mood-header {
    margin-bottom: var(--md);
}

.mood-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--burgundy);
    margin-bottom: var(--xs);
}

.mood-title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink);
}

/* 9-Box Container */
.nine-box-container {
    display: flex;
    gap: 8px;
    margin-bottom: var(--md);
    max-width: 100%;
    justify-content: center;
}

.nine-box-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    min-width: 24px;
}

.nine-box-y-axis span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 0.6rem;
    color: var(--ink-tertiary);
    white-space: nowrap;
}

.nine-box-y-axis .y-label-mid {
    font-weight: 600;
    color: var(--ink-secondary);
}

.nine-box-y-axis .y-label-top,
.nine-box-y-axis .y-label-bottom {
    font-size: 0.55rem;
}

.nine-box-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.nine-box-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 2px;
    aspect-ratio: 1 / 1;
    width: 100%;
    max-width: 280px;
    position: relative;
    background: var(--white);
    border-radius: 4px;
    overflow: hidden;
}

.nine-box-x-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--ink-tertiary);
    padding-top: 4px;
    width: 100%;
    max-width: 280px;
}

.nine-box-x-axis span:nth-child(2) {
    font-weight: 600;
    color: var(--ink-secondary);
}

/* Individual Boxes */
.box {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--sans);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    padding: 2px;
    overflow: hidden;
    min-width: 0;
    line-height: 1.2;
}

.box-neutral {
    background: rgba(232, 223, 213, 0.3);
    color: rgba(138, 18, 60, 0.5);
}

.box-positive {
    background: rgba(18, 108, 138, 0.15);
    color: var(--teal);
}

.box-positive-strong {
    background: rgba(18, 108, 138, 0.25);
    color: var(--teal);
}

.box-negative {
    background: rgba(138, 18, 60, 0.12);
    color: var(--burgundy);
}

.box-negative-strong {
    background: rgba(138, 18, 60, 0.22);
    color: var(--burgundy);
}

/* Trail SVG */
.mood-trail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.trail-line {
    fill: none;
    stroke: url(#trailGradient);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Dots */
.mood-dot {
    position: absolute;
    border-radius: 50%;
    z-index: 3;
    transform: translate(-50%, -50%);
}

.mood-dot-teal {
    width: 16px;
    height: 16px;
    background: var(--teal);
    border: 2px solid var(--white);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.mood-dot-burgundy {
    width: 14px;
    height: 14px;
    background: var(--burgundy);
    border: 2px solid var(--white);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.mood-dot-start {
    width: 10px;
    height: 10px;
    background: var(--teal);
    opacity: 0.3;
}

/* Description */
.mood-description {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--ink-secondary);
    margin-bottom: var(--md);
}

/* Legend */
.mood-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--ink-tertiary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot-teal {
    background: var(--teal);
}

.legend-dot-burgundy {
    background: var(--burgundy);
}

/* Active zone highlight */
.box.active-zone {
    outline: 2px solid var(--ink);
    outline-offset: -2px;
    z-index: 1;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: var(--sm);
    border-bottom: 2px solid var(--teal);
    margin-bottom: var(--lg);
}

.sidebar-title {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--teal);
}

.sidebar-date {
    font-size: 0.7rem;
    color: var(--ink-tertiary);
}

/* Week Ahead Cards */
.week-ahead-list {
    display: flex;
    flex-direction: column;
    gap: var(--sm);
}

.week-card {
    padding: var(--md);
    background: var(--white);
    border-left: 3px solid var(--teal);
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: all 0.15s;
}

.week-card:hover {
    background: var(--paper-dark);
    transform: translateX(2px);
}

.week-card.active {
    background: var(--paper-dark);
    border-left-color: var(--burgundy);
}

.week-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--teal);
    margin-bottom: var(--xs);
}

.week-card.active .week-label {
    color: var(--burgundy);
}

.week-headline {
    font-family: var(--serif);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    margin-bottom: var(--xs);
}

.week-excerpt {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--ink-tertiary);
}

/* Context Items */
.context-list {
    display: flex;
    flex-direction: column;
}

.context-item {
    display: flex;
    gap: var(--sm);
    padding: var(--md) 0;
    border-bottom: 1px solid var(--rule);
}

.context-rank {
    font-family: var(--serif);
    font-size: 1.25rem;
    color: var(--rule);
    flex-shrink: 0;
    width: 28px;
}

.context-headline {
    font-family: var(--serif);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    margin-bottom: var(--xs);
}

.context-excerpt {
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--ink-tertiary);
}

/* ===== ETF Flows Section ===== */
.etf-flows {
    margin-top: var(--lg);
    padding-top: var(--lg);
    border-top: 1px solid var(--rule);
}

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

.etf-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--burgundy);
}

.etf-date {
    font-family: var(--sans);
    font-size: 0.7rem;
    color: var(--ink-tertiary);
}

.etf-main {
    display: flex;
    align-items: center;
    gap: var(--sm);
    margin-bottom: var(--sm);
}

.etf-bar-container {
    flex: 1;
    height: 20px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
}

.etf-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.etf-bar.etf-inflow {
    background: var(--teal);
}

.etf-bar.etf-outflow {
    background: var(--burgundy);
}

.etf-amount {
    font-family: var(--sans);
    font-size: 1rem;
    font-weight: 700;
    min-width: 70px;
    text-align: right;
}

.etf-amount.positive {
    color: var(--teal);
}

.etf-amount.negative {
    color: var(--burgundy);
}

.etf-week {
    display: flex;
    gap: 4px;
    margin-bottom: var(--xs);
}

.etf-day {
    flex: 1;
    height: 6px;
    border-radius: 2px;
    background: var(--surface);
    cursor: help;
    transition: transform 0.15s;
}

.etf-day:hover {
    transform: scaleY(1.5);
}

.etf-day.inflow {
    background: var(--teal);
    opacity: 0.6;
}

.etf-day.inflow.strong {
    opacity: 1;
}

.etf-day.outflow {
    background: var(--burgundy);
    opacity: 0.6;
}

.etf-day.outflow.strong {
    opacity: 1;
}

.etf-insight {
    font-family: var(--serif);
    font-size: 0.8rem;
    font-style: italic;
    color: var(--ink-secondary);
    margin: 0;
    line-height: 1.4;
}

/* ===== The Number Section ===== */
.the-number {
    margin-bottom: var(--lg);
    padding-bottom: var(--lg);
    border-bottom: 1px solid var(--rule);
    text-align: center;
}

.number-header {
    margin-bottom: var(--sm);
}

.number-label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--burgundy);
}

.number-value {
    font-family: var(--serif);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
    margin-bottom: var(--xs);
}

.number-context {
    font-family: var(--serif);
    font-size: 0.85rem;
    color: var(--ink-secondary);
    line-height: 1.4;
    margin: 0;
}

/* Sidebar Divider */
.sidebar-divider {
    height: 1px;
    background: var(--rule);
    margin: var(--xl) 0;
}

/* Newsletter */
.newsletter {
    background: var(--paper-dark);
    padding: var(--md);
    border-radius: 4px;
}

.newsletter-title {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--xs);
}

.newsletter-desc {
    font-size: 0.75rem;
    color: var(--ink-tertiary);
    margin-bottom: var(--md);
}

.newsletter-form {
    display: flex;
}

.newsletter-input {
    flex: 1;
    padding: var(--sm);
    border: 1px solid var(--rule);
    border-right: none;
    border-radius: 3px 0 0 3px;
    font-size: 0.8rem;
    outline: none;
}

.newsletter-input:focus {
    border-color: var(--burgundy);
}

.newsletter-submit {
    padding: var(--sm) var(--md);
    background: var(--burgundy);
    border: 1px solid var(--burgundy);
    border-radius: 0 3px 3px 0;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s;
}

.newsletter-submit:hover {
    background: var(--burgundy-dark);
}

/* ========== FOOTER ========== */
.footer {
    margin-top: var(--2xl);
    padding-top: var(--lg);
    border-top: 1px solid var(--rule);
    text-align: center;
}

.footer-tagline {
    font-family: var(--serif);
    font-style: italic;
    color: var(--ink-secondary);
    margin-bottom: var(--xs);
}

.footer-legal {
    font-size: 0.7rem;
    color: var(--ink-tertiary);
}

/* ========== RESPONSIVE ========== */

/* Large tablets and small laptops */
@media (max-width: 1200px) {
    .editorial-grid {
        grid-template-columns: 260px 1fr;
    }
    
    .context-sidebar {
        display: none;
    }
}

/* iPad Pro landscape and similar (1024px) */
@media (max-width: 1024px) {
    .container {
        padding: var(--lg) var(--lg);
    }
    
    .editorial-grid {
        grid-template-columns: 240px 1fr;
        gap: var(--lg);
    }
    
    .audio-card {
        max-width: 100%;
    }
    
    .article-image {
        max-width: 100%;
    }
    
    .masthead {
        padding: var(--sm) 0;
    }
}

/* iPad portrait (768px - 900px) */
@media (max-width: 900px) {
    .editorial-grid {
        grid-template-columns: 1fr;
    }
    
    .article-index {
        border-right: none;
        border-bottom: 1px solid var(--rule);
        padding-right: 0;
        padding-bottom: var(--xl);
        margin-bottom: var(--xl);
    }
    
    .index-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--md);
    }
    
    .index-card {
        border-bottom: none;
        padding: var(--md);
        background: var(--paper-dark);
        border-radius: 4px;
    }
    
    .index-card:hover {
        margin: 0;
    }
}

@media (max-width: 600px) {
    .container {
        padding: var(--md);
    }
    
    .masthead {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--md);
    }
    
    .market-strip {
        flex-wrap: wrap;
        gap: var(--md);
    }
    
    .section-nav {
        overflow-x: auto;
        gap: var(--md);
        padding-bottom: var(--sm);
    }
    
    /* Sticky header mobile - hide some elements */
    .sticky-header {
        padding: 0 var(--md);
    }
    
    .sticky-ticker:nth-child(3) {
        display: none; /* Hide MKT on mobile */
    }
    
    .sticky-nav {
        display: none; /* Hide nav links, just show region */
    }
    
    .sticky-label {
        font-size: 0.65rem;
    }
    
    .sticky-value {
        font-size: 0.75rem;
    }
    
    .index-list {
        grid-template-columns: 1fr;
    }
    
    .article-headline {
        font-size: 1.75rem;
    }
    
    .article-body {
        font-size: 1.05rem;
    }
    
    .audio-bar {
        flex-wrap: wrap;
    }
    
    .audio-info {
        order: -1;
        flex-basis: calc(100% - 60px);
    }
}

/* ========== UTILITIES ========== */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.hidden {
    display: none;
}

/* ========== SETTINGS MODAL ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--paper);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--lg);
    border-bottom: 1px solid var(--rule);
}

.modal-title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--ink-tertiary);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--paper-dark);
    color: var(--ink);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--lg);
}

.modal-footer {
    padding: var(--md) var(--lg);
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: flex-end;
}

/* Settings Section */
.settings-section {
    margin-bottom: var(--xl);
}

.settings-label {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--burgundy);
    margin-bottom: var(--sm);
}

.settings-help {
    font-size: 0.85rem;
    color: var(--ink-secondary);
    margin-bottom: var(--xs);
}

.settings-selected {
    font-size: 0.85rem;
    color: var(--ink-secondary);
    margin-bottom: var(--md);
}

/* Coin Search */
.coin-search {
    display: flex;
    align-items: center;
    gap: var(--sm);
    padding: var(--sm) var(--md);
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 8px;
    margin-bottom: var(--md);
}

.coin-search svg {
    color: var(--ink-tertiary);
    flex-shrink: 0;
}

.coin-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--ink);
    outline: none;
}

.coin-search input::placeholder {
    color: var(--ink-tertiary);
}

/* Coin List */
.coin-list {
    max-height: 320px;
    overflow-y: auto;
}

.coin-item {
    display: flex;
    align-items: center;
    padding: var(--sm) 0;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    transition: background 0.1s;
}

.coin-item:hover {
    background: var(--paper-dark);
    margin: 0 calc(var(--sm) * -1);
    padding-left: var(--sm);
    padding-right: var(--sm);
}

.coin-item.locked {
    opacity: 0.5;
    cursor: default;
}

.coin-item.locked:hover {
    background: transparent;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
}

.coin-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: var(--sm);
    object-fit: cover;
}

.coin-info {
    flex: 1;
}

.coin-name {
    font-weight: 600;
    color: var(--ink);
    font-size: 0.95rem;
}

.coin-symbol {
    font-size: 0.75rem;
    color: var(--ink-tertiary);
    text-transform: uppercase;
}

.coin-check {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin-check.selected {
    background: var(--teal);
    color: white;
}

.coin-check.unselected {
    border: 2px dashed var(--ink-tertiary);
}

.coin-check.locked {
    background: var(--teal);
    color: white;
}

/* Button */
.btn-primary {
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    padding: var(--sm) var(--lg);
    background: var(--burgundy);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: #6d0f30;
}

/* ========== YOUR COINS SECTION ========== */
/* ===== Relative Performance Section ===== */
.relative-performance {
    margin-top: var(--lg);
    padding-top: var(--lg);
    border-top: 1px solid var(--rule);
}

.relative-header {
    margin-bottom: var(--md);
}

.relative-label {
    display: block;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--burgundy);
    margin-bottom: var(--xs);
}

.relative-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.relative-row {
    display: grid;
    grid-template-columns: 50px 48px 1fr 52px;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.relative-row.market-row {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.rel-name {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
}

.market-row .rel-name {
    color: var(--ink-secondary);
}

.rel-change {
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 500;
    text-align: right;
    color: var(--ink-secondary);
}

.rel-bar-container {
    position: relative;
    height: 16px;
    background: var(--surface);
    border-radius: 2px;
}

.rel-baseline {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--ink-tertiary);
}

.rel-bar {
    position: absolute;
    top: 3px;
    height: 10px;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.rel-bar.outperform {
    left: 50%;
    background: var(--teal);
}

.rel-bar.underperform {
    right: 50%;
    background: #c9a87c; /* Muted gold/tan - neutral underperform */
}

.rel-vs {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: right;
}

.rel-vs.positive {
    color: var(--teal);
}

.rel-vs.negative {
    color: var(--ink-tertiary);
}

.rel-vs.baseline {
    color: var(--ink-tertiary);
    font-style: italic;
}

.no-coins {
    font-size: 0.8rem;
    color: var(--ink-tertiary);
    padding: var(--sm) 0;
}

.no-coins a {
    color: var(--teal);
    text-decoration: none;
}

.no-coins a:hover {
    text-decoration: underline;
}

.coin-error {
    font-size: 0.8rem;
    color: var(--burgundy);
    padding: var(--sm) 0;
}
