:root {
    --primary: #1a365d;
    --secondary: #2c5282;
    --accent: #ed8936;
    --bg: #f7fafc;
    --text: #2d3748;
    --text-muted: #718096;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --tone-positive: #38a169;
    --tone-negative: #e53e3e;
    --tone-neutral: #a0aec0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: var(--primary);
    color: white;
    padding: 30px 40px;
    border-radius: 8px;
    margin-bottom: 24px;
    text-align: center;
}
header h1 { font-size: 2em; margin-bottom: 4px; }
header .subtitle { opacity: 0.85; font-size: 1.1em; }
header .header-nav { margin-top: 12px; }
header .header-nav a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    margin: 0 12px;
    font-size: 0.95em;
}
header .header-nav a:hover { color: white; }
a.header-link { color: white; text-decoration: none; }

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
}
.layout-entity {
    grid-template-columns: 280px 1fr;
}
@media (max-width: 768px) {
    .layout, .layout-entity {
        grid-template-columns: 1fr;
    }
}

/* Feed search bar */
.feed-search { margin-bottom: 20px; }
.feed-search form { display: flex; gap: 10px; }
.feed-search input {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    font-family: inherit;
}
.feed-search input:focus { outline: none; border-color: var(--secondary); }
.feed-search button {
    padding: 12px 24px;
    font-size: 1rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}
.feed-search button:hover { background: var(--primary); }

/* Filters sidebar */
.filters {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 20px;
}
.filters h3 { margin-bottom: 16px; font-size: 1em; color: var(--secondary); }
.filter-group { margin-bottom: 14px; }
.filter-group label {
    display: block;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.filter-group select,
.filter-group input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9em;
    background: var(--card-bg);
}
.filter-hint {
    margin-top: 12px;
    font-size: 0.75em;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
}
.btn-primary {
    background: var(--secondary);
    color: white;
    width: 100%;
    margin-top: 8px;
}
.btn-primary:hover { background: var(--primary); }
.btn-secondary {
    background: var(--card-bg);
    color: var(--secondary);
    border: 1px solid var(--border);
    display: block;
    margin: 20px auto;
}
.btn-secondary:hover { background: var(--bg); }
.btn-clear {
    background: none;
    color: var(--text-muted);
    width: 100%;
    margin-top: 8px;
    border: 1px solid var(--border);
}
.btn-clear:hover { color: var(--secondary); border-color: var(--secondary); }

/* Feed */
.feed { min-height: 400px; }
.feed-count {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.status {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Article card */
.article-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.article-card:hover { border-color: var(--secondary); }
.article-card .article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.article-card .article-title {
    font-size: 1em;
    font-weight: 600;
    line-height: 1.4;
}
.article-card .article-title a {
    color: var(--text);
    text-decoration: none;
}
.article-card .article-title a:hover { color: var(--secondary); }
.article-card .article-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
}
.article-card .article-source {
    font-weight: 500;
    color: var(--secondary);
}
.article-card .article-entities {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.article-card .co-mentions {
    margin-top: 8px;
    font-size: 0.8em;
    color: var(--text-muted);
    line-height: 1.9;
}
.tag-chip {
    display: inline-block;
    padding: 1px 8px;
    margin: 0 2px 2px 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 1em;
    cursor: pointer;
}
.tag-chip:hover {
    color: var(--secondary);
    border-color: var(--secondary);
    background: var(--card-bg);
}

/* Curation: tag-resolve affordance + node finder modal */
.tag-resolve {
    display: none;
    border: none;
    background: none;
    color: var(--accent);
    font-size: 1.05em;
    cursor: pointer;
    padding: 0 6px 0 1px;
    vertical-align: middle;
}
body.curation-enabled .tag-resolve { display: inline-block; }
.tag-resolve:hover { color: var(--secondary); }

.nf-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 54, 93, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px;
    z-index: 100;
}
.nf-modal {
    background: var(--card-bg);
    border-radius: 8px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.nf-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.nf-head h3 { color: var(--secondary); font-size: 1.1em; }
.nf-close {
    border: none;
    background: none;
    font-size: 1.5em;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}
.nf-close:hover { color: var(--text); }
.nf-tagline { font-size: 0.9em; margin-bottom: 12px; }
.nf-dim {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-left: 6px;
}
#nf-search-form { display: flex; gap: 8px; margin-bottom: 12px; }
#nf-search-form input {
    flex: 1;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
}
#nf-search-form input:focus { outline: none; border-color: var(--secondary); }
#nf-search-form button {
    padding: 9px 16px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.nf-status {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.88em;
    margin-bottom: 10px;
    background: var(--bg);
    color: var(--text-muted);
}
.nf-status.nf-ok { background: #f0fff4; color: var(--tone-positive); }
.nf-status.nf-error { background: #fff5f5; color: var(--tone-negative); }
.nf-results { display: flex; flex-direction: column; gap: 6px; }
.nf-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    text-align: left;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.9em;
}
.nf-row:hover { border-color: var(--secondary); }
.nf-row.selected { border-color: var(--secondary); background: #ebf4ff; }
.nf-row-name { font-weight: 600; }
.nf-row-meta { color: var(--text-muted); font-size: 0.85em; }
.nf-matched {
    margin-left: auto;
    font-size: 0.78em;
    color: var(--tone-positive);
}
.nf-view {
    margin-left: auto;
    font-size: 0.8em;
    color: var(--secondary);
    text-decoration: none;
    white-space: nowrap;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.nf-matched + .nf-view { margin-left: 8px; }
.nf-view:hover { border-color: var(--secondary); background: var(--bg); }
.nf-confirm {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    margin-top: 14px;
    padding: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.9em;
}
.nf-confirm button {
    padding: 8px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.nf-confirm button:disabled { opacity: 0.6; cursor: default; }

/* Tone indicator */
.tone-bar {
    width: 4px;
    min-height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}
.tone-positive { background: var(--tone-positive); }
.tone-negative { background: var(--tone-negative); }
.tone-neutral { background: var(--tone-neutral); }
.tone-value {
    font-size: 0.8em;
    font-weight: 600;
}

/* Entity badge */
.entity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78em;
    font-weight: 500;
    text-decoration: none;
    background: #ebf4ff;
    color: var(--secondary);
    border: 1px solid #bee3f8;
}
.entity-badge:hover {
    background: #bee3f8;
}
.entity-badge.type-Candidate { background: #ebf4ff; color: #2c5282; border-color: #bee3f8; }
.entity-badge.type-Committee { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.entity-badge.type-Party { background: #fce7f3; color: #9d174d; border-color: #f9a8d4; }

/* Entity card (entity.html sidebar) */
.entity-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 20px;
}
.entity-card h2 { font-size: 1.2em; margin-bottom: 8px; }
.entity-card .entity-meta {
    font-size: 0.9em;
    color: var(--text-muted);
}
.entity-card .entity-stat {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9em;
}
.entity-card .entity-link {
    display: block;
    margin-top: 16px;
    text-align: center;
    color: var(--secondary);
    font-size: 0.9em;
}

/* Event card */
.event-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 10px;
}
.event-card .event-actors {
    font-weight: 600;
    margin-bottom: 4px;
}
.event-card .event-meta {
    font-size: 0.85em;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}
.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.tab.active {
    color: var(--secondary);
    border-bottom-color: var(--secondary);
    font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Footer */
footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    font-size: 0.85em;
    color: var(--text-muted);
}
footer a { color: var(--secondary); }
