/* Plain text, simple design - Multi-Country Dashboard - Dark Theme */

/* IA Writer Duospace Font Face Declarations */
@font-face {
    font-family: 'IA Writer Quattro';
    src: url('fonts/iAWriterDuospace-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IA Writer Quattro';
    src: url('fonts/iAWriterDuospace-RegularItalic.otf') format('opentype');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'IA Writer Quattro';
    src: url('fonts/iAWriterDuospace-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IA Writer Quattro';
    src: url('fonts/iAWriterDuospace-BoldItalic.otf') format('opentype');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --text-primary: #d4d4d4;
    --text-secondary: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.2);
    --tab-active: #d4d4d4;
    --tab-inactive: #6b7280;
    --toolbar-bg: rgba(26, 26, 26, 0.95);
    --toolbar-border: #2d2d2d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    /* Hide scrollbars */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

html::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

body {
    /* Hide scrollbars */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

body::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

body {
    font-family: 'IA Writer Quattro', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(180deg,
            #1a1a1a 0%,
            #1d1d1d 25%,
            #1a1a1a 50%,
            #1d1d1d 75%,
            #1a1a1a 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Window Controls Header - Desktop Only */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 20px;
    height: 40px;
    z-index: 1000;
    -webkit-app-region: drag;
    user-select: none;
    box-sizing: border-box;
    display: none;
    /* Hide header bar on desktop */
}

#app-header.desktop-only {
    display: none;
    /* Hide header bar on desktop */
}

/* Window controls positioned to right - Windows sequence */
.window-controls {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1001;
    display: flex;
    gap: 8px;
    -webkit-app-region: no-drag;
    align-items: center;
}

@media (max-width: 768px) {
    .window-controls {
        display: none !important;
        /* Hide on mobile */
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    height: 100%;
}

.header-title {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 400;
}

.window-btn {
    background: none;
    border: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.window-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: block;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.15);
    /* White at 15% opacity */
}

/* Colored on hover only */
.window-btn.close:hover .window-dot {
    background-color: #ff5f57;
    /* Red */
}

.window-btn.minimize:hover .window-dot {
    background-color: #ffbd2e;
    /* Yellow */
}

.window-btn.maximize:hover .window-dot {
    background-color: #28ca42;
    /* Green */
}

.window-btn:hover .window-dot {
    opacity: 1;
    transform: scale(1.1);
}

.window-btn:active .window-dot {
    transform: scale(0.9);
}

/* Hide header on mobile */
@media (max-width: 768px) {
    #app-header.desktop-only {
        display: none;
    }
}

/* Hide on mobile user agent */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

.dashboard-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    scroll-snap-type: none;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: pan-y pinch-zoom;
    /* Allow vertical scroll, prevent horizontal scroll */
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .dashboard-container {
        touch-action: pan-y pinch-zoom;
        /* Only vertical scroll, no horizontal swipe */
        width: 400vw !important;
        /* 4 columns on mobile, each 100vw - force override */
        display: flex;
        overflow-x: hidden;
        /* Prevent horizontal scrollbar */
    }
}

.country-column {
    flex: 0 0 25%;
    min-width: 25%;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-right: none;
    /* No border on screen edge */
    overflow: hidden;
    /* Prevent column scrolling - chart and news handle their own scrolling */
    position: relative;
    width: 25%;
    /* Explicit width for desktop - 4 columns equally fill viewport */
    height: 100vh;
    /* Full viewport height */
    /* Hide scrollbars */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

/* Add border between columns, but not on the last one */
.country-column:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.country-column::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Winning party glow effect */
/* Winning party glow effect */
.country-column::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 35vh;
    /* Dark top for status bar matching, fading down */
    background: linear-gradient(to bottom,
            rgba(var(--winning-party-rgb, 0, 0, 0), 0.9) 0%,
            rgba(var(--winning-party-rgb, 0, 0, 0), 0.7) 10%,
            rgba(var(--winning-party-rgb, 0, 0, 0), 0.3) 40%,
            transparent 100%);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    transition: opacity 1.5s ease;
    /* Wave mask */
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120" preserveAspectRatio="none"><path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5,73.84-4.36,147.54,16.88,218.2,35.26,69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113,14.29,1200,52.47V0Z" fill="black"/></svg>');
    mask-position: bottom;
    mask-repeat: no-repeat;
    mask-size: 100% 120px;
}

/* Base class for when winner is found - triggers entrance */
.country-column.winner-found::before {
    display: none !important;
    /* Temporarily disabled */
    animation: glow-pulse 8s ease-in-out infinite;
    opacity: 0.4;
    /* Base subtle opacity */
}

@keyframes glow-pulse {

    0%,
    100% {
        opacity: 0.3;
        transform: translateX(-50%) scale(1);
    }

    50% {
        opacity: 0.5;
        /* Subtle pulse */
        transform: translateX(-50%) scale(1.05);
        /* Gentle breathe */
    }
}

/* Country column mobile styles are in the main mobile media query below */

/* Country Title - Set standard height */
.country-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px 12px;
    /* Minimal padding for text only */
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px 12px;
    /* Minimal padding for text only */
    border-bottom: 1px solid var(--border-color);
    border-top: none;
    border-left: none;
    border-right: none;
    /* No border at top edge */
    background: var(--bg-primary);
    color: var(--text-primary);
    flex-shrink: 0;
    height: 40px;
    /* Fixed height for consistency */
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

/* Animation variations to prevent uniformity */
.country-column:nth-child(1)::before {
    animation-delay: 0s, 0s;
}

.country-column:nth-child(2)::before {
    animation-delay: 2s, 2s;
}

.country-column:nth-child(3)::before {
    animation-delay: 4.5s, 4.5s;
}

.country-column:nth-child(4)::before {
    animation-delay: 1.2s, 1.2s;
}

/* .country-column:first-child .country-title rule removed as side borders are gone */

/* Chart Section - Make same height as country title */
.chart-section {
    /* flex: 1; */
    /* flex: 1; */
    height: 500px;
    /* Fixed height as requested by user - unchanged by screen size */
    flex: 0 0 auto;
    /* Don't grow/shrink */
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.country-column:first-child .chart-section {
    border-left: none;
    /* No border on left edge of first column */
}

/* Chart Tabs - Same height as country title */
.chart-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    border-left: none;
    border-right: none;
    background: var(--bg-primary);
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    height: 40px;
    /* Same height as country title */
    box-sizing: border-box;
    padding-left: 12px;
    /* Align with country title padding */
}

.chart-tabs-left {
    display: flex;
    gap: 20px;
    align-items: center;
}

.chart-duration-selector {
    display: flex;
    align-items: stretch;
    /* Full height buttons */
    height: 100%;
    /* Fill container */
    padding: 0;
    /* Remove all padding */
    position: relative;
}

.duration-btn {
    background: transparent;
    /* Remove translucent background */
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s;
    flex: 1;
    /* Fill available space equally */
    margin: 0;
    /* Remove all margins */
    padding: 0;
    /* Remove all padding */
    height: 100%;
    /* Full height of container */
    min-width: 0;
    /* Allow shrinking */
    aspect-ratio: 1;
    /* Make buttons square */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-weight: 500;
}

/* Add left divider to M button (first button) */
.duration-btn:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    z-index: 1;
}

/* Full height dividers between buttons */
.duration-btn:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-color);
    z-index: 1;
}

.duration-btn:hover {
    color: var(--text-primary);
}

.duration-btn.active {
    color: var(--text-primary);
    background: transparent;
    /* Transparent background */
    font-weight: 700;
    /* Bold active text */
    position: relative;
}

/* Thinner crosshatch pattern for active button */
.duration-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(45deg, transparent 45%, rgba(255, 255, 255, 0.08) 50%, transparent 55%),
        linear-gradient(-45deg, transparent 45%, rgba(255, 255, 255, 0.08) 50%, transparent 55%);
    background-size: 6px 6px;
    /* Smaller, thinner crosshatch */
    background-position: 0 0, 3px 3px;
    pointer-events: none;
    z-index: 0;
}

.chart-tab {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--tab-inactive);
    cursor: pointer;
    padding: 4px 0;
    text-transform: none;
    transition: color 0.2s;
}

.chart-tab-bold {
    font-weight: 700;
}

.chart-tab-regular {
    font-weight: 400;
}

.chart-tab:hover {
    color: var(--text-primary);
}

.chart-tab.active {
    color: var(--tab-active);
    font-weight: 700;
}

/* Chart Container - Add padding below to separate from chips */
.chart-container {
    flex: 1;
    min-height: 0;
    /* Allow flex item to shrink */
    max-width: 100%;
    margin: 0;
    padding: 0 0 8px 0;
    /* Minimal padding below charts */
    display: block;
    /* Remove inline spacing */
    margin: 0;
    padding: 0 0 16px 0;
    /* Reduced padding below charts (was 32px) */
    display: block;
    /* Remove inline spacing */
    border-left: none;
    border-right: none;
    background: var(--bg-primary);
    position: relative;
    box-sizing: border-box;
}

.chart-wrapper {
    display: flex;
    width: 100%;
    /* Single chart width for non-US countries */
    max-width: 100%;
    height: 100%;
    /* Fill container height */
    min-height: 400px;
    /* Ensure minimum height */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    box-sizing: border-box;
    position: relative;
    /* For absolute positioned SVG */
}

/* US and Australia have two charts side-by-side, so needs 200% width */
.chart-wrapper[data-country="us"],
.chart-wrapper[data-country="australia"] {
    width: 200% !important;
    max-width: 200% !important;
    display: flex;
    flex-wrap: nowrap;
}

.chart-canvas,
.chart-svg {
    flex: 0 0 100%;
    /* Each chart takes full width of wrapper by default */
    width: 100%;
    height: 100%;
    min-height: 0;
    /* Allow flex item to shrink */
    max-width: 100%;
    margin: 0;
    padding: 0;
    display: block;
    /* Remove inline spacing */
}

/* Hide placeholders to prevent layout issues */
.chart-placeholder {
    display: none !important;
}

/* For multi-chart wrappers (200% width), charts are 50% of wrapper = 100% of column */
.chart-wrapper[data-country="us"] .chart-canvas,
.chart-wrapper[data-country="us"] .chart-svg,
.chart-wrapper[data-country="australia"] .chart-canvas,
.chart-wrapper[data-country="australia"] .chart-svg {
    flex: 0 0 50% !important;
    width: 50% !important;
    max-width: 50% !important;
}

.party-chips {
    display: flex;
    flex-direction: row;
    gap: 0;
    padding: 0;
    /* Remove all padding */
    margin: 0;
    /* Remove all margins */
    padding: 0;
    /* Remove all padding */
    margin: 0;
    /* Remove all margins */
    border-top: 1px solid var(--border-color);
    border-left: none;
    border-right: none;
    border-bottom: none;
    /* Removed to prevent double border with news section */
    font-size: 13px;
    background: transparent;
    /* Remove background */
    position: relative;
    overflow: hidden;
    /* Hide chips that don't fit */
    max-width: 100%;
    height: 40px;
    /* Same height as country title */
    flex-shrink: 0;
    box-sizing: border-box;
    justify-content: space-between;
    /* Evenly distribute across width */
}

/* Hide excess chips on smaller containers to prevent crowding */
.party-chip:nth-child(n+6) {
    display: none;
}

/* Show more chips on wider containers */
@media (min-width: 300px) {
    .party-chip:nth-child(6) {
        display: flex;
    }
}

@media (min-width: 340px) {
    .party-chip:nth-child(7) {
        display: flex;
    }
}

/* Party chip styling - remove outline, only dividers */
.party-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    background: transparent;
    border: none;
    /* Remove all borders/outlines */
    min-width: 0;
    flex: 1;
    /* Evenly distribute across container width */
    position: relative;
    height: 100%;
    /* Full height of container */
    box-sizing: border-box;
}

/* Full height dividers between chips reaching top and bottom of container */
.party-chip:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    /* Reach top of container */
    bottom: 0;
    /* Reach bottom of container */
    width: 1px;
    background: var(--border-color);
    z-index: 1;
}

.chip-text {
    white-space: nowrap;
    font-size: 16px;
    /* Match chart title size */
    font-weight: 400;
    /* Normal weight text */
    opacity: 1;
    /* Text always at full opacity - not faded */
    color: inherit;
    /* Use parent color - full color */
}

/* =====================================================
   Raw Poll Table (Behind News Drawer - "Peek Behind")
   ===================================================== */
.raw-poll-table-container {
    position: relative;
    width: 100%;
    height: 300px;
    background: var(--bg-primary);
    z-index: 1;
    /* Behind headlines-section (1100) */
    border-top: 1px solid var(--border-color);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    margin-top: 0;
}

.raw-poll-table-container::-webkit-scrollbar {
    display: none;
}

.raw-poll-table-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 5;
}

.raw-poll-table {
    display: flex;
    flex-direction: column;
}

.raw-poll-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    font-size: 11px;
    border-bottom: 1px solid var(--border-color);
    gap: 4px;
}

.raw-poll-row:hover {
    background: var(--bg-secondary);
}

.raw-poll-cell {
    flex: 1;
    text-align: center;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.raw-poll-cell.pollster {
    flex: 2.5;
    text-align: left;
    font-weight: 500;
    color: var(--text-primary);
}

.raw-poll-cell.date {
    flex: 0 0 45px;
    text-align: left;
    color: var(--text-secondary);
}

.raw-poll-cell.party-value {
    flex: 0 0 auto;
    min-width: 40px;
    font-weight: 500;
}

/* News Section - Bottom Sheet Implementation */
.headlines-section {
    /* Absolute positioning to overlay chart */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    z-index: 1100;
    /* Above everything else */

    /* Initial state - fills remaining space (calculated dynamically in JS) */
    /* Height will be set by JavaScript based on chart section height */

    /* Styling - only left and right borders to avoid doubling with chart-section */
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: none;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);

    /* Scrolling - hidden by default (locked until expanded) */
    overflow-y: hidden;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    /* Prevent elastic scrolling chaining */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */

    /* Transitions */
    transition: height 0.4s cubic-bezier(0.19, 1, 0.22, 1), top 0.4s cubic-bezier(0.19, 1, 0.22, 1);

    /* Performance */
    will-change: height, top;
    transform: translateZ(0);
    /* Force GPU acceleration */

    /* Bottom fade effect */
    mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
}

/* Expanded state - allow scrolling */
.headlines-section.expanded {
    overflow-y: auto;
}

/* While dragging/snapping, keep hidden */
.headlines-section.dragging {
    overflow-y: hidden !important;
    transition: none !important;
    /* Disable transition during direct manipulation */
}

/* Snapping animation - Elastic */
.headlines-section.snapping {
    transition: height 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1), top 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1) !important;
}

.headlines-section::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

/* Expanded state - reaches up to country title */
.headlines-section.expanded {
    /* top and height set by JS */
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

/* .country-column:first-child .headlines-section rule removed */

/* News Header with bottom divider */
.headlines-section-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 10;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    /* Add top divider */
    /* Add bottom divider */
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-height: 32px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.headlines-section-header:hover {
    background: var(--bg-secondary);
}

.headlines-section-header:active {
    background: rgba(255, 255, 255, 0.05);
}

/* News Items with fixed height and 2-line headlines */
/* News Items with fixed height and 2-line headlines */
a.headline-item {
    text-decoration: none;
    color: inherit;
    display: block;
    /* Ensure it behaves like a block */
}

.headline-item {
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-top: 1px solid var(--border-color);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 80px;
    /* Fixed minimum height for consistency */
    height: 80px;
    /* Fixed height for all items */
    max-height: 80px;
    box-sizing: border-box;
    justify-content: space-between;
    text-decoration: none !important;
    /* Force removal of underline */
    color: inherit !important;
    /* Force color inheritance */
}

/* Remove visited link colors */
a.headline-item:visited,
a.headline-item:active,
a.headline-item:link {
    color: inherit;
    text-decoration: none;
}

/* Remove top border from first item if there's a headlines header */
.headlines-section-header+.headline-item:first-child {
    border-top: none;
}

.headline-item:first-of-type {
    border-top: none;
}

.headline-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.headline-item:hover:not(.loading) {
    background: var(--bg-secondary);
}

/* Headline meta container with publisher and date */
.headline-meta {
    display: flex;
    justify-content: space-between;
    /* Publisher left, Date right */
    align-items: center;
    font-size: 11px;
    color: var(--text-tertiary);
    /* Same color for both */
    font-weight: 500;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
}



.headline-date {
    opacity: 0.8;
}



/* Headline text - limited to 2 lines */
.headline-text {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-primary);
    margin: 0;
    flex: 1;

    /* Limit to 2 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;

    /* Fallback for non-webkit browsers */
    max-height: calc(1.3em * 2);
    /* 2 lines at 1.3 line-height */
}

/* Fade Gradient for News Header */
.headlines-section-header::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, var(--bg-primary), transparent);
    pointer-events: none;
    z-index: 9;
}

/* Return to Top FAB */
.scroll-to-top-fab {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--tab-active);
    color: var(--bg-primary);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
}

.scroll-to-top-fab.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-to-top-fab:active {
    transform: scale(0.95);
}

/* Responsive: 2 columns at medium screens */
@media (max-width: 1200px) {
    .country-column {
        flex: 0 0 50%;
        min-width: 50%;
    }
}

/* Mobile floating toolbar - Apple-style rounded navbar */
.mobile-toolbar {
    display: none;
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toolbar-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 6px 10px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    z-index: 2500;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
    max-width: calc(100% - 40px);
}

.mobile-toolbar-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 6px;
}

.country-flag-btn {
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    touch-action: manipulation;
    /* Remove tap delay */
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s, background-color 0.2s;
    line-height: 1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.country-flag-btn .flag-icon {
    width: 28px;
    height: 28px;
    display: block;
    filter: grayscale(100%);
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s, filter 0.2s;
    background-size: 28px 28px;
    background-repeat: no-repeat;
    background-position: center;
}

.country-flag-btn.active .flag-icon {
    opacity: 1;
    filter: grayscale(100%) brightness(1.3);
}

.country-flag-btn:active .flag-icon {
    transform: scale(0.95);
}

.country-flag-btn.active {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.country-flag-btn.active svg {
    stroke: var(--text-primary);
    stroke-width: 2;
}

.country-flag-btn:active {
    transform: scale(0.95);
    background-color: rgba(255, 255, 255, 0.15);
}

/* Gradient fade above toolbar */
.gradient-fade {
    display: block;
    /* Visible on all devices */
    position: fixed;
    bottom: 0;
    /* Start from very bottom */
    left: 0;
    right: 0;
    height: 120px;
    /* Taller fade */
    background: linear-gradient(to top, var(--bg-primary) 30%, rgba(26, 26, 26, 0.9) 60%, transparent 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
    z-index: 2000;
    /* Increased z-index to sit above content (1100) but below toolbar (2500) */
}

/* Responsive: 1 column on mobile with swipe */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        /* Prevent body horizontal scroll */
        width: 100%;
        max-width: 100vw;
    }

    .dashboard-container {
        overflow-x: hidden;
        width: 400vw;
        /* 4 columns, each 100vw */
        max-width: 400vw;
    }

    .country-column {
        flex: 0 0 100vw;
        /* Each column is exactly 100vw on mobile */
        min-width: 100vw;
        width: 100vw;
        /* Full viewport width */
        max-width: 100vw;
        /* Prevent overflow */
        padding: 0;
        /* No padding - fill viewport completely */
        padding-bottom: calc(90px + env(safe-area-inset-bottom));
        /* Space for floating toolbar only */
        box-sizing: border-box;
        border-right: none;
        /* Remove border on mobile */
        overflow-x: hidden;
        /* Prevent horizontal overflow */
        overflow-y: auto;
        /* Allow vertical scrolling */
        position: relative;
    }

    .country-title {
        font-size: 16px;
        -webkit-app-region: drag;
        /* Make draggable for PWA on mobile */
        user-select: none;
        cursor: default;
    }

    .chart-section {
        margin: 0;
        /* NO MARGIN on mobile */
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
        padding: 0;
        /* NO PADDING on mobile */
    }

    .chart-container {
        /* Height handled by flex/percentage like desktop */
        height: 100%;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0 0 32px 0;
        /* Increased padding to prevent crowding */
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
    }

    .chart-wrapper {
        width: 200%;
        max-width: 200%;
        height: 100%;
        /* Fill container height */
        margin: 0;
        padding: 0;
        /* NO PADDING on mobile */
        box-sizing: border-box;
        overflow: hidden;
    }

    .chart-canvas,
    .chart-svg {
        height: 100%;
        width: 50%;
        max-width: 50%;
        box-sizing: border-box;
        display: block;
    }

    /* Fix for countries with single chart to avoid squishing */
    .chart-wrapper:not([data-country="us"]):not([data-country="australia"]) {
        width: 100%;
        max-width: 100%;
    }

    .chart-wrapper:not([data-country="us"]):not([data-country="australia"]) .chart-canvas,
    .chart-wrapper:not([data-country="us"]):not([data-country="australia"]) .chart-svg {
        width: 100%;
        max-width: 100%;
    }

    .party-chips {
        width: 100%;
        max-width: 100%;
        overflow-x: scroll;
        /* Allow horizontal scroll */
        overflow-y: hidden;
        margin: 0;
        padding: 0;
        /* Remove mobile specific padding to match desktop */
        height: 40px;
        /* Match desktop height */
        flex-shrink: 0;
        display: flex;
        align-items: center;
        scrollbar-width: none;
        /* Hide scrollbar Firefox */
        -ms-overflow-style: none;
        /* Hide scrollbar IE/Edge */
        white-space: nowrap;
    }

    .party-chips::-webkit-scrollbar {
        display: none;
        /* Hide scrollbar Chrome/Safari */
    }

    /* Party chip mobile overrides removed to match desktop */

    .mobile-toolbar {
        display: block;
    }

    .gradient-fade {
        display: block;
    }

    .headlines-section {
        margin: 0;
        margin-top: 0;
        /* Removed overlap to prevent covering chips */
        padding: 0;
        /* NO PADDING on mobile */
        overflow-x: hidden;
        word-wrap: break-word;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .headline-item {
        padding: 12px;
        /* Keep text padding only */
    }

    .headline-item {
        max-width: 100%;
        width: 100%;
        overflow-wrap: break-word;
        word-break: break-word;
        box-sizing: border-box;
    }

    .headline-text {
        max-width: 100%;
        width: 100%;
        overflow-wrap: break-word;
        word-break: break-word;
        box-sizing: border-box;
    }
}

/* Headline Modal */
.headline-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.headline-modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    z-index: 1;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    /* Hide scrollbars */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.modal-content::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 16px;
    display: none;
}

.modal-header {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.modal-publisher {
    font-weight: 600;
}

.modal-date {
    color: var(--text-secondary);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.4;
}

.modal-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 85vh;
    }

    .modal-title {
        font-size: 18px;
    }
}