:root {
    --bg: #fafaf8;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-muted: #666;
    --accent: #2b4c7e;
    --accent-light: #3d6db5;
    --border: #e0ddd8;
    --tag-cat: #e8f0fe;
    --tag-cat-text: #1a56db;
    --tag-person: #fef3c7;
    --tag-person-text: #92400e;
    --tag-place: #d1fae5;
    --tag-place-text: #065f46;
    --badge-positive: #d1fae5;
    --badge-negative: #fee2e2;
    --badge-neutral: #e5e7eb;
    --badge-critical: #fef3c7;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Header */
header {
    background: var(--accent);
    color: white;
    padding: 0.8rem 0;
    box-shadow: var(--shadow);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo { text-decoration: none; color: white; }
.logo h1 { font-size: 1.6rem; letter-spacing: 0.05em; }
.subtitle { font-size: 0.8rem; opacity: 0.8; font-style: italic; }
nav { display: flex; align-items: center; gap: 0.5rem; }
nav a { color: rgba(255,255,255,0.85); text-decoration: none; margin-left: 1.5rem; font-size: 0.9rem; }
nav a:hover { color: white; }
.lang-switcher { display: flex; gap: 0.3rem; margin-left: 1rem; padding-left: 1rem; border-left: 1px solid rgba(255,255,255,0.3); }
.lang-link { font-size: 0.8rem; padding: 0.2rem 0.5rem; border-radius: 4px; margin-left: 0 !important; color: rgba(255,255,255,0.6); }
.lang-link:hover { color: white; background: rgba(255,255,255,0.1); }
.lang-link.active { color: white; background: rgba(255,255,255,0.2); font-weight: bold; }

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: calc(100vh - 150px);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* Search Hero */
.search-hero {
    text-align: center;
    padding: 3rem 0 2rem;
}
.search-hero h2 {
    font-size: 1.3rem;
    font-weight: normal;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Search Form */
.search-form { max-width: 700px; margin: 0 auto; }
.search-form.compact { max-width: 100%; }
.search-bar {
    display: flex;
    gap: 0;
    margin-bottom: 0.8rem;
}
.search-bar input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    font-size: 1.05rem;
    border: 2px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar button {
    padding: 0.8rem 1.8rem;
    background: var(--accent);
    color: white;
    border: 2px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.search-bar button:hover { background: var(--accent-light); border-color: var(--accent-light); }

.search-modes {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.search-modes label { cursor: pointer; display: flex; align-items: center; gap: 0.3rem; }
.search-modes input[type="radio"] { accent-color: var(--accent); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-number { display: block; font-size: 1.8rem; font-weight: bold; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* Browse Sections */
.browse-section { margin: 2rem 0; }
.browse-section h3 { margin-bottom: 0.8rem; font-size: 1.1rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    transition: all 0.2s;
}
.tag:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow-hover); }
.tag-count { font-size: 0.75rem; color: var(--text-muted); }

/* Search Layout */
.search-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Facet Panel */
.facet-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    align-self: start;
    position: sticky;
    top: 1rem;
}
.facet-group { margin-bottom: 1rem; }
.facet-group h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.facet-group select, .facet-group input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    background: white;
}

/* Results */
.results-panel { min-height: 300px; }
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.results-time { font-size: 0.8rem; }

.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Result Cards */
.result-cards { display: flex; flex-direction: column; gap: 0.8rem; }
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.result-card:hover { box-shadow: var(--shadow-hover); border-color: var(--accent-light); }

.result-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}
.result-newspaper { font-weight: bold; font-size: 0.85rem; color: var(--accent); }
.result-date { font-size: 0.8rem; color: var(--text-muted); }
.result-score { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }

.result-headline { font-size: 1.1rem; margin-bottom: 0.3rem; }
.result-headline a { color: var(--text); text-decoration: none; }
.result-headline a:hover { color: var(--accent); }
.result-headline-sq { font-size: 0.85rem; color: var(--text-muted); font-style: italic; margin-bottom: 0.4rem; }

.result-snippet { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 0.5rem; }

.result-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag-small {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    text-decoration: none;
}
.tag-category { background: var(--tag-cat); color: var(--tag-cat-text); }
.tag-person { background: var(--tag-person); color: var(--tag-person-text); }
.tag-place { background: var(--tag-place); color: var(--tag-place-text); }

/* Badges */
.badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: var(--badge-neutral);
    text-transform: capitalize;
}
.badge-positive { background: var(--badge-positive); color: #065f46; }
.badge-negative { background: var(--badge-negative); color: #991b1b; }
.badge-neutral { background: var(--badge-neutral); color: #374151; }
.badge-critical { background: var(--badge-critical); color: #92400e; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
}
.page-btn {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    transition: all 0.2s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-info { font-size: 0.85rem; color: var(--text-muted); }

/* Article Detail */
.article-page { max-width: 900px; margin: 0 auto; }
.article-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.article-title { font-size: 1.8rem; margin-bottom: 0.3rem; }
.article-title-sq { font-size: 1.1rem; color: var(--text-muted); font-style: italic; margin-bottom: 0.2rem; }
.article-title-it { font-size: 1rem; color: var(--text-muted); font-style: italic; margin-bottom: 1rem; }

.photo-description {
    background: #f0f0ec;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.lang-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}
.tab {
    padding: 0.6rem 1.2rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

.article-body {
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
}

.article-sidebar { margin: 1.5rem 0; }
.sidebar-section { margin-bottom: 1rem; }
.sidebar-section h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.btn-secondary {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Scanned page image */
.scan-image {
    margin: 1.5rem 0;
    text-align: center;
}
.scan-image img {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: max-height 0.3s;
}
.scan-image img.expanded {
    max-height: none;
}
.scan-caption {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    font-style: italic;
}

.related-articles { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.related-articles h3 { margin-bottom: 1rem; }

/* Page View */
.page-view { max-width: 900px; margin: 0 auto; }
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; }
.page-id { font-size: 0.8rem; color: var(--text-muted); }

/* HTMX indicator */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* Responsive */
@media (max-width: 768px) {
    .search-layout { grid-template-columns: 1fr; }
    .facet-panel { position: static; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .article-header { flex-direction: column; align-items: flex-start; }
}
