/* San Pedro Sun Analytics - NYT/Upshot Style */

:root {
    /* NYT Color Palette - Restrained & Professional */
    --nyt-black: #121212;
    --nyt-text: #333333;
    --nyt-secondary: #666666;
    --nyt-tertiary: #999999;
    --nyt-border: #e2e2e2;
    --nyt-bg-gray: #fafafa;
    --nyt-blue: #326891;
    --nyt-blue-light: #5a8bb5;
    
    /* Data Viz Colors (Upshot style - muted) */
    --viz-blue: #6CA1C4;
    --viz-gray: #B5B5B5;
    --viz-orange: #D4956F;
    --viz-green: #7FB069;
    --viz-red: #C85C5C;
    
    --background: #ffffff;
    --button-text: #ffffff;
    --border-thin: 1px solid var(--nyt-border);
}

/* Dark Mode - NYT Style (not pure black) */
body.dark-mode,
html.dark-mode body {
    /* Dark mode color palette */
    --nyt-black: #e5e5e5;
    --nyt-text: #d4d4d4;
    --nyt-secondary: #a0a0a0;
    --nyt-tertiary: #808080;
    --nyt-border: #404040;
    --nyt-bg-gray: #1e1e1e;
    --nyt-blue: #5a8bb5;
    --nyt-blue-light: #7ba3c7;
    
    /* Dark mode background - less severe */
    --background: #1a1a1a;
    
    /* Button text color for dark mode */
    --button-text: #ffffff;
    
    --border-thin: 1px solid var(--nyt-border);
}

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

html {
    overflow-x: hidden;
    /* Prevent double-tap zoom on mobile */
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Franklin Gothic Medium', 
                 'Arial Narrow', Arial, sans-serif;
    background-color: var(--background);
    color: var(--nyt-text);
    line-height: 1.5;
    font-size: 15px;
    overflow-x: hidden;
    max-width: 100vw;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    overflow-x: hidden;
    width: 100%;
}

/* Header - NYT Nameplate Style */
header {
    background: var(--background);
    color: var(--nyt-black);
    padding: 1.5rem 0 1rem;
    border-bottom: 1px solid var(--nyt-border);
}

header h1 {
    font-family: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
    margin: 0;
    color: var(--nyt-black);
}

.subtitle {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.75rem;
    text-align: center;
    color: var(--nyt-secondary);
    margin-top: 0.5rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Navigation - NYT Style */
nav {
    background: var(--background);
    border-bottom: var(--border-thin);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

nav .container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    position: relative;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 0.875rem 1.25rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--nyt-text);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.nav-btn:hover {
    color: var(--nyt-black);
}

.nav-btn:active {
    background: transparent;
}

.nav-btn.active {
    color: var(--nyt-black);
    border-bottom-color: var(--nyt-black);
}

.nav-btn-settings {
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.nav-btn-settings:active {
    background: transparent;
}

.nav-btn-settings svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    transition: stroke 0.2s ease;
}

.nav-btn-settings:hover {
    color: var(--nyt-black);
}

.nav-btn-settings:hover svg {
    stroke: var(--nyt-black);
}

/* Main Content */
main {
    padding: 2.5rem 0;
    min-height: calc(100vh - 200px);
}

.view {
    display: none;
}

.view.active {
    margin-top: 20px;
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Typography - NYT Style */
h2 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--nyt-black);
    line-height: 1.2;
}

h3 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--nyt-black);
    line-height: 1.3;
}

/* Stats Grid - Upshot Style */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1px;
    margin-bottom: 3rem;
    background: var(--nyt-border);
    border: var(--border-thin);
}

.stat-card {
    background: var(--background);
    padding: 2rem 1.5rem;
    text-align: center;
    transition: background-color 0.2s;
}

.stat-card:hover {
    background: var(--nyt-bg-gray);
}

.stat-value {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--nyt-black);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.6875rem;
    color: var(--nyt-secondary);
    text-transform: uppercase;
    letter-spacing: 0.75px;
    font-weight: 600;
}

/* Charts Grid - Upshot Style */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
    margin-bottom: 3rem;
}

.chart-card {
    background: var(--background);
    padding: 1.5rem 0;
    border-top: 3px solid var(--nyt-black);
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.chart-card canvas {
    max-height: 350px;
}

/* Section */
.section {
    background: var(--background);
    padding: 2rem 0;
    border-top: var(--border-thin);
    margin-bottom: 2rem;
}

/* Keywords Cloud - Minimalist */
.keywords-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 0;
}

.keyword-tag {
    background: transparent;
    color: var(--nyt-blue);
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--nyt-blue);
    border-radius: 2px;
    font-size: 0.8125rem;
    transition: all 0.2s;
    font-weight: 500;
}

.keyword-tag:hover {
    background: var(--nyt-blue);
    color: white;
}

/* Entities List */
.entities-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1px;
    background: var(--nyt-border);
    border: var(--border-thin);
}

.entity-item {
    padding: 1rem;
    background: var(--background);
}

.entity-name {
    font-weight: 600;
    color: var(--nyt-black);
    font-size: 0.9375rem;
}

.entity-count {
    font-size: 0.8125rem;
    color: var(--nyt-secondary);
    margin-top: 0.25rem;
}

/* Search Box - Clean NYT Style */
.search-box {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

#search-input {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border: var(--border-thin);
    border-radius: 0;
    transition: border-color 0.2s;
    font-family: inherit;
}

#search-input:focus {
    outline: none;
    border-color: var(--nyt-black);
}

/* Search button as icon */
.search-btn-icon {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    background: var(--nyt-bg-gray) !important;
    color: var(--nyt-black) !important;
    border-radius: 0;
    min-width: 50px;
}

.search-btn-icon:hover {
    opacity: 0.9;
}

#search-btn {
    padding: 0.75rem 2rem;
    background: var(--nyt-black);
    color: var(--button-text);
    border: none;
    border-radius: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#search-btn:hover {
    background: var(--nyt-text);
    color: var(--button-text);
}

/* Override for icon-only button */
#search-btn.search-btn-icon {
    padding: 0 !important;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    text-transform: none;
    letter-spacing: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

/* Mode Buttons */
.mode-btn {
    padding: 0.5rem 1.5rem;
    background: transparent;
    color: var(--nyt-text);
    border: 1px solid var(--nyt-border);
    border-radius: 0;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--nyt-black);
    color: var(--button-text);
    border-color: var(--nyt-black);
}

.mode-btn:hover:not(.active) {
    border-color: var(--nyt-text);
}

/* DEPRECATED: Hide Find Articles feature and mode selector (keeping code for future)
   Browse Articles view is now Q&A only - no mode switching needed */
#ask-question-btn,
#find-articles-btn,
#search-filters,
#browse-view > div:first-of-type {
    display: none !important;
}

/* Results Container */
.results-container {
    background: var(--background);
    padding: 0;
    border-top: var(--border-thin);
}

.placeholder {
    text-align: center;
    color: var(--nyt-secondary);
    padding: 3rem 1rem;
    font-size: 0.9375rem;
    font-style: italic;
}

/* Article Card - NYT Article List Style */
.article-card {
    padding: 1.5rem 0;
    border-bottom: var(--border-thin);
    cursor: pointer;
    transition: background 0.1s;
}

.article-card:hover {
    background: var(--nyt-bg-gray);
}

.article-card:last-child {
    border-bottom: none;
}

/* Weekly Digest Topic Cards */
.digest-topic-card:hover {
    border-color: var(--nyt-blue);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.digest-topic-card h3 {
    font-family: Georgia, serif;
}

.article-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--nyt-black);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.article-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--nyt-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-excerpt {
    color: var(--nyt-text);
    line-height: 1.6;
    font-size: 0.9375rem;
}

/* Filters - Minimal NYT Style */
.filters {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-left {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.date-filters {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.filters select,
.filters input {
    padding: 0.625rem 0.875rem;
    border: var(--border-thin);
    border-radius: 0;
    font-size: 0.875rem;
    background: var(--background);
    color: var(--nyt-text);
    font-family: inherit;
}

.filters select:focus,
.filters input:focus {
    outline: none;
    border-color: var(--nyt-black);
}

.filters button {
    padding: 0.625rem 1.25rem;
    background: var(--nyt-black);
    color: var(--button-text);
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s, color 0.2s;
}

.filters button:hover {
    background: var(--nyt-text);
    color: var(--button-text);
}

#reset-filters {
    background: transparent;
    color: var(--nyt-text);
    border: 1px solid var(--nyt-border);
}

#reset-filters:hover {
    background: var(--nyt-bg-gray);
    border-color: var(--nyt-text);
}

/* Pagination - Minimal */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 2rem;
    padding: 1rem;
}

.pagination button {
    padding: 0.625rem 1.5rem;
    background: var(--nyt-black);
    color: var(--button-text);
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s, color 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--nyt-text);
    color: var(--button-text);
}

.pagination button:disabled {
    background: var(--nyt-border);
    color: var(--nyt-secondary);
    cursor: not-allowed;
}

#page-info {
    font-weight: 600;
    color: var(--nyt-black);
    font-size: 0.875rem;
}

/* Insights Container - Grid Layout */
.insights-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1px;
    background: var(--nyt-border);
    border: var(--border-thin);
}

.insight-section {
    background: var(--background);
    padding: 1.5rem;
}

.insight-section.full-width {
    grid-column: 1 / -1;
}

.insight-list {
    list-style: none;
}

.insight-item {
    padding: 0.75rem 0;
    border-bottom: var(--border-thin);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

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

.insight-name {
    font-weight: 500;
    color: var(--nyt-black);
    font-size: 0.9375rem;
}

.insight-value {
    color: var(--nyt-blue);
    font-weight: 700;
    font-family: Georgia, serif;
    font-size: 1rem;
}

/* Modal - Clean NYT Style */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-content {
    background-color: var(--background);
    margin: 5% auto;
    padding: 3rem;
    border: var(--border-thin);
    border-radius: 0;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    width: 36px;
    height: 36px;
    background: var(--nyt-black);
    border-radius: 50%;
    color: var(--button-text);
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close:hover {
    opacity: 0.8;
}

/* Hide mobile close styles on desktop */
.close::before {
    display: none;
}

/* Article Detail - NYT Article Style */
#article-detail .article-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    color: var(--nyt-black);
}

#article-detail .article-content {
    line-height: 1.7;
    margin: 2rem 0;
    color: var(--nyt-text);
    font-size: 1.0625rem;
}

#article-detail .article-content p {
    margin-bottom: 1.25rem;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.tag {
    background: transparent;
    border: 1px solid var(--nyt-border);
    padding: 0.25rem 0.625rem;
    border-radius: 0;
    font-size: 0.75rem;
    color: var(--nyt-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sentiment-badge {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    border-radius: 0;
    font-size: 0.75rem;
    font-weight: 700;
    margin: 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sentiment-positive {
    background: transparent;
    color: var(--viz-green);
    border: 1px solid var(--viz-green);
}

.sentiment-negative {
    background: transparent;
    color: var(--viz-red);
    border: 1px solid var(--viz-red);
}

.sentiment-neutral {
    background: transparent;
    color: var(--nyt-secondary);
    border: 1px solid var(--nyt-border);
}

/* Insight Subsection Headers */
.insight-subsection-header {
    background: var(--nyt-bg-gray);
    padding: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-family: Georgia, 'Times New Roman', serif;
}

/* Button Style System */
.btn-primary {
    background: var(--nyt-black);
    color: var(--button-text);
    border: none;
    padding: 0.625rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    border-radius: 0;
}

/* In dark mode, btn-primary has light background, so use dark text */
body.dark-mode .btn-primary {
    color: #121212;
}

.btn-primary:hover {
    background: var(--nyt-text);
    color: var(--button-text);
}

body.dark-mode .btn-primary:hover {
    color: #121212;
}

.btn-secondary {
    background: var(--nyt-secondary);
    color: var(--button-text);
    border: none;
    padding: 0.625rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    border-radius: 0;
}

.btn-secondary:hover {
    background: #4b5563;
    color: var(--button-text);
}

.btn-tertiary {
    background: var(--nyt-bg-gray);
    color: var(--nyt-black);
    border: 1px solid var(--nyt-border);
    padding: 0.625rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0;
}

.btn-tertiary:hover {
    background: #e5e7eb;
    border-color: var(--nyt-text);
}

/* Q&A Styling */
.qa-answer-section {
    background: var(--background);
    border: 2px solid var(--nyt-border);
    padding: 2rem;
    margin-bottom: 0rem;
}

.qa-answer-text {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--nyt-text);
}

.qa-source-list {
    margin-top: 2rem;
    border-top: var(--border-thin);
    padding-top: 2rem;
}

.qa-source-item {
    padding: 1.5rem 0;
    border-bottom: var(--border-thin);
    border-left: 3px solid var(--nyt-black);
    padding-left: 1rem;
}

/* Compact Source Styling */
.qa-sources-compact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.qa-source-compact {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0.5rem;
    align-items: start;
    padding: 0.5rem 0.625rem;
    border-left: 2px solid var(--nyt-light-gray);
    cursor: pointer;
    transition: all 0.15s ease;
}

.qa-source-compact:hover {
    background: var(--nyt-bg-gray);
    border-left-color: var(--nyt-blue);
}

.qa-source-compact .source-number {
    font-family: Georgia, serif;
    font-weight: 700;
    font-size: 0.8125rem;
    color: var(--nyt-secondary);
    padding-top: 0.125rem;
}

.qa-source-compact .source-content {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.qa-source-compact .source-date {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.6875rem;
    color: var(--nyt-secondary);
    line-height: 1.2;
}

.qa-source-compact .source-title {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8125rem;
    line-height: 1.3;
    color: var(--nyt-black);
}

/* Follow-up Questions Section */
.qa-follow-up-section {
    margin-top: 0rem;
    padding-top: 1rem;
    border-top: 1px solid var(--nyt-light-gray);
}

.qa-follow-up-questions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.follow-up-question-btn {
    background: transparent;
    border: 1px solid var(--nyt-light-gray);
    border-left: 2px solid var(--nyt-blue);
    padding: 0.75rem 1rem;
    text-align: left;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    color: var(--nyt-blue);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 0;
}

.follow-up-question-btn:hover {
    background: var(--nyt-bg-gray);
    border-left-width: 3px;
}

/* Source Article Styling */
.source-article {
    padding-top: 1.5rem;
    border-left: 3px solid var(--nyt-black);
    padding-left: 1rem;
    margin-bottom: 1rem;
}

.source-date {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.75rem;
    color: var(--nyt-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Article Badges */
.article-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 0.5rem;
    border-radius: 2px;
}

.badge-type {
    background: var(--viz-blue);
    color: white;
}

.badge-scope {
    background: var(--viz-green);
    color: white;
}

.badge-sentiment-positive {
    background: var(--viz-green);
    color: white;
}

.badge-sentiment-negative {
    background: var(--viz-red);
    color: white;
}

.badge-sentiment-neutral {
    background: var(--viz-gray);
    color: white;
}

/* Footer - NYT Style */
footer {
    background: var(--background);
    color: var(--nyt-secondary);
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
    border-top: var(--border-thin);
    font-size: 0.8125rem;
}

footer a {
    color: var(--nyt-blue);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Hide insights tab on all screen sizes */
.nav-btn[data-view="insights"] {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    .container {
        overflow-x: hidden;
    }

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

    /* Fix dropdown positioning issue on mobile */
    .filters select,
    .filters input {
        position: relative;
        transform: none;
        will-change: auto;
    }

    .filters {
        position: relative;
    }

    /* Hide dashboard on mobile */
    .nav-btn[data-view="dashboard"] {
        display: none;
    }
    
    .nav-btn {
        padding: 0.75rem 0.875rem;
        font-size: 0.75rem;
    }
    
    header h1 {
        font-size: 1.625rem;
        line-height: 1.2;
    }
    
    /* Hide view titles on mobile (redundant with nav) */
    .view h2 {
        display: none;
    }
    
    /* Tighter spacing for loading animation */
    .loading-animation {
        padding: 2rem 1rem;
        gap: 1.5rem;
        min-height: 200px;
    }
    
    /* Smaller badges on mobile */
    .article-badge {
        font-size: 0.625rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* Line break before sentiment badge only */
    .badge-sentiment-positive,
    .badge-sentiment-negative,
    .badge-sentiment-neutral {
        display: block;
        margin-top: 0.25rem;
        width: fit-content;
    }
    
    /* Center and tighten button group in current view */
    #current-view > div[style*="margin-bottom"] {
        margin: 1.2rem auto !important;
        justify-content: center;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters select,
    .filters input,
    .filters button {
        width: 100%;
    }
    
    /* Fullscreen modal on mobile */
    .modal-content {
        margin: 0;
        padding: 1rem;
        width: 100%;
        height: 100%;
        height: -webkit-fill-available;
        max-width: 100%;
        max-height: 100%;
        border: none;
        overflow-y: auto;
    }
    
    /* Back arrow instead of X on mobile */
    .close {
        left: 1rem;
        right: auto;
        top: 1rem;
        font-size: 1.75rem;
        font-weight: 400;
    }
    
    .close-desktop {
        display: none !important;
    }
    
    .close::before {
        content: '← Back';
        font-size: 1rem;
        font-weight: 500;
        display: inline !important;
    }
    
    /* Smaller article title in modal on mobile only */
    #article-detail .article-title,
    #article-detail h2 {
        font-size: 1.0625rem !important;
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }
    
    /* Prevent zoom on input focus */
    input[type="text"],
    input[type="search"],
    textarea {
        font-size: 16px !important;
    }
    
    /* Tighter Q&A answer section - use more screen space */
    .qa-answer-section {
        padding: 1rem 0.5rem !important;
        border-left: none !important;
        border-right: none !important;
    }
    
    .qa-answer-text {
        font-size: 0.9375rem !important;
        line-height: 1.5 !important;
    }
    
    /* Tighter note container - fill more space */
    .qa-answer-section > div[style*="padding"] {
        padding: 0.5rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Digest topic cards - fill more horizontal space on mobile */
    .digest-topic-card {
        padding: 1rem 0.75rem !important;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-left: none !important;
        border-right: none !important;
        border-radius: 0 !important;
    }
    
    /* Reduce margins in Q&A sections */
    .qa-follow-up-section {
        margin-top: 1rem !important;
        padding-top: 0.75rem !important;
    }
    
    .qa-source-list {
        margin-top: 0.75rem !important;
        padding-top: 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .qa-source-list h4 {
        margin-bottom: 0.5rem !important;
    }
    
    .qa-sources-compact {
        margin-bottom: 0.5rem !important;
    }
}

@media (max-width: 450px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .insights-container {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    /* Keep search box horizontal - input and button stay on same line */
    .search-box {
        gap: 0.5rem;
    }
    
    #search-input {
        flex: 1 1 0;
        min-width: 0;
    }
    
    #search-btn {
        flex-shrink: 0;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
}

/* Loading Spinner - Minimal */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 2px solid var(--nyt-border);
    border-top: 2px solid var(--nyt-black);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Skeleton Loaders */
.skeleton {
    background: var(--nyt-bg-gray);
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

body.dark-mode .skeleton::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
}

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

.skeleton-line {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

.skeleton-line.long {
    width: 100%;
}

.skeleton-title {
    height: 1.5rem;
    width: 85%;
    margin-bottom: 0.75rem;
}

.skeleton-badge {
    height: 1.25rem;
    width: 4rem;
    border-radius: 12px;
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.skeleton-card {
    padding: 1.5rem 0;
    border-bottom: var(--border-thin);
}

.skeleton-card:last-child {
    border-bottom: none;
}

.skeleton-qa-answer {
    padding: 1.5rem;
    background: var(--background);
    border-left: 3px solid var(--nyt-blue);
    margin-bottom: 1.5rem;
}

.skeleton-digest-card {
    padding: 1.5rem;
    border: var(--border-thin);
    border-radius: 4px;
    margin-bottom: 2rem;
}

.skeleton-chart {
    height: 300px;
    background: var(--background);
    border: var(--border-thin);
    border-radius: 4px;
    padding: 1rem;
    margin-bottom: 2rem;
}

/* Enhanced Loading Animation for Q&A - Text Worm Effect */
.loading-animation {
    text-align: center;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    animation: fadeIn 0.3s ease-in;
    min-height: 300px;
}

.loading-spinner {
    position: relative;
    width: 100px;
    height: 130px;
    background: var(--background);
    border: 2.5px solid var(--nyt-black);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    gap: 0;
}

/* Individual newspaper lines that wave */
.newspaper-line {
    width: 100%;
    height: 2px;
    background: var(--nyt-text);
    margin-bottom: 8px;
    transform: scaleX(0);
    transform-origin: left;
    animation: wormLine 3s ease-in-out infinite;
}

/* Thicker lines for headlines */
.newspaper-line:nth-child(1),
.newspaper-line:nth-child(2) {
    height: 3px;
    background: var(--nyt-black);
    margin-bottom: 6px;
}

/* Slightly lighter subhead */
.newspaper-line:nth-child(3) {
    background: var(--nyt-secondary);
    margin-bottom: 10px;
}

@keyframes wormLine {
    0% {
        transform: scaleX(0);
        transform-origin: left;
        opacity: 0.3;
    }
    20% {
        transform: scaleX(1);
        transform-origin: left;
        opacity: 1;
    }
    80% {
        transform: scaleX(1);
        transform-origin: left;
        opacity: 1;
    }
    100% {
        transform: scaleX(0);
        transform-origin: right;
        opacity: 0.3;
    }
}

.loading-message {
    font-size: 1rem;
    color: var(--nyt-secondary);
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    min-height: 1.5rem;
    transition: opacity 0.3s ease-in-out;
    margin: 0;
    letter-spacing: 0.02em;
}

/* Developer Panel */
.dev-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 11px;
}

.dev-panel-toggle {
    width: 40px;
    height: 40px;
    background: var(--nyt-black);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

.dev-panel-toggle:hover {
    background: var(--nyt-blue);
    transform: scale(1.05);
}

.dev-toggle-icon {
    color: white;
    font-size: 18px;
    user-select: none;
}

.dev-panel-content {
    position: absolute;
    bottom: 50px;
    left: 0;
    background: white;
    border: 1px solid var(--nyt-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    width: 320px;
    max-height: 400px;
    overflow: hidden;
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.dev-panel.active .dev-panel-content {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.dev-panel-header {
    padding: 12px 16px;
    background: var(--nyt-bg-gray);
    border-bottom: 1px solid var(--nyt-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dev-panel-header h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--nyt-black);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dev-panel-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--nyt-secondary);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.dev-panel-close:hover {
    color: var(--nyt-black);
}

.dev-info-grid {
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: white;
}

.dev-info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dev-info-item.full-width {
    grid-column: 1 / -1;
}

.dev-label {
    color: var(--nyt-tertiary);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.dev-value {
    color: var(--nyt-text);
    font-size: 11px;
    font-weight: 500;
    word-break: break-all;
    line-height: 1.3;
}

#dev-branch {
    color: var(--nyt-blue);
    font-weight: 700;
}

#dev-commit {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: var(--nyt-secondary);
}

#dev-env {
    text-transform: uppercase;
    font-weight: 700;
}

#dev-env.development {
    color: var(--viz-orange);
}

#dev-env.production {
    color: var(--viz-green);
}

.dev-tools {
    padding: 12px 16px;
    background: var(--nyt-bg-gray);
    border-top: 1px solid var(--nyt-border);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.dev-tool-btn {
    background: var(--background);
    border: 1px solid var(--nyt-border);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    color: var(--nyt-text);
    white-space: nowrap;
}

.dev-tool-btn:hover {
    background: var(--nyt-blue);
    border-color: var(--nyt-blue);
    color: white;
}

/* Hide dev panel on mobile */
@media (max-width: 768px) {
    .dev-panel {
        display: none;
    }
}

/* Settings Page */
.settings-container {
    max-width: 800px;
    margin: 0 auto;
}

.settings-section {
    background: var(--background);
    border: var(--border-thin);
    padding: 2rem;
    margin-bottom: 2rem;
}

.settings-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-family: Georgia, serif;
    color: var(--nyt-black);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: var(--border-thin);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-item-label label {
    font-weight: 600;
    color: var(--nyt-black);
    font-size: 0.9375rem;
}

.settings-item-description {
    font-size: 0.8125rem;
    color: var(--nyt-secondary);
    line-height: 1.4;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    margin-left: 1rem;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    -webkit-tap-highlight-color: transparent;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--nyt-border);
    transition: 0.3s;
    border-radius: 26px;
    -webkit-tap-highlight-color: transparent;
}

.toggle-slider:active {
    background-color: var(--nyt-border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--nyt-blue);
}

.toggle-switch input:checked + .toggle-slider:active {
    background-color: var(--nyt-blue);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px var(--nyt-blue);
}
