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

:root {
    /* ECHT. Kommunikation brand (approximated from the supplied logo band; swap for exact values) */
    --primary-color: #1E7DB6;        /* wordmark blue: buttons, links, primary accents */
    --primary-dark: #16639A;         /* hover state for the blue */
    --accent-color: #F26A3D;         /* chevron orange: highlights, tags */
    --accent-soft: #FDE9E0;          /* light orange tint for tag backgrounds */
    --header-bg: #FCE5DA;            /* light peach header band */
    --secondary-color: #5A6B78;      /* neutral slate for secondary buttons */
    --secondary-dark: #46545F;
    --background: #f5f5f5;
    --surface: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;
    --success: #4caf50;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 8px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Brand band: flat peach background, logo left, app name as a small blue caption */
.header-brand {
    width: 100%;
    min-height: 100px;
    background: var(--header-bg);
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 18px 30px;
    box-sizing: border-box;
}

.brand-logo {
    height: 60px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 28px;
    border-left: 2px solid var(--accent-color);
}

h1.app-name {
    color: var(--primary-color);
    font-size: 1.9em;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin: 0;
    line-height: 1.1;
}

.subtitle {
    color: var(--primary-dark);
    font-size: 0.95em;
    margin: 0;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

h2 {
    font-size: 1.5em;
    margin: 0 0 12px 0;
    color: var(--text-primary);
}

section {
    background: var(--surface);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

/* Search Form */
.search-form {
    display: grid;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-primary);
}

input[type="text"],
input[type="url"],
input[type="datetime-local"],
select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

input[type="checkbox"] {
    width: auto;
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

.btn-link {
    background: none;
    border: none;
    color: var(--secondary-color);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9em;
    padding: 0;
    margin-left: 10px;
}

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

.btn-info-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    width: 18px;
    height: 18px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    font-size: 0.75em;
    font-style: normal;
    cursor: pointer;
    transition: background 0.2s;
    vertical-align: middle;
    line-height: 1;
}

.btn-info-inline:hover {
    background: rgba(255,255,255,0.5);
}

#search-btn {
    justify-self: start;
    margin-top: 10px;
}

.btn-searching {
    background: #9e9e9e !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

.btn-searching:hover {
    background: #9e9e9e !important;
    box-shadow: none !important;
}

/* AI Configuration Section */
.ai-config-section {
    background: #fff9e6;
    border-left: 4px solid var(--secondary-color);
}

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

.provider-badge {
    background: var(--secondary-color);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
}

.ai-features {
    margin: 20px 0;
    padding: 15px;
    background: white;
    border-radius: 4px;
}

.ai-features h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
}

.ai-features label {
    display: block;
    margin-bottom: 10px;
    font-weight: normal;
}

.ai-features input[type="checkbox"] {
    margin-right: 8px;
}

.config-note {
    background: white;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
    border-left: 3px solid var(--secondary-color);
}

.config-note code {
    background: var(--background);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.config-note ul {
    margin: 10px 0 0 20px;
}

/* Sources Section */
.sources-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.sources-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sources-footer {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}

.source-counter {
    font-size: 0.85em;
    color: var(--text-secondary);
    background: var(--background);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.sources-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
}

.source-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 7px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
    transition: background 0.2s;
}

.source-item:hover {
    background: var(--background);
}

.source-item.disabled {
    opacity: 0.45;
}

.source-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.source-name {
    font-weight: 400;
    color: var(--text-primary);
    font-size: 0.82em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.source-type {
    font-size: 0.7em;
    color: var(--text-secondary);
    background: var(--border-color);
    padding: 1px 5px;
    border-radius: 10px;
    white-space: nowrap;
}

.source-delete {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1em;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.source-delete:hover {
    color: var(--primary-color);
}

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Article index status + per-source health dots */
.index-status {
    white-space: nowrap;
}

.health-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    background: #c8cdd2;
}

.health-ok   { background: #4caf50; }
.health-fail { background: var(--accent-color); box-shadow: 0 0 0 2px var(--accent-soft); }
.health-unknown { background: #c8cdd2; }

/* Publish date states on article cards */
.date-exact strong { color: var(--text-primary); }
.date-estimated { color: var(--text-secondary); }
.date-unknown { color: var(--text-secondary); font-style: italic; }

/* Sort control in the results header */
.sort-control {
    font-size: 0.9em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sort-control select {
    width: auto;
    padding: 4px 8px;
    font-size: 0.95em;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface);
}

/* Search log panel: the backend's per-step summary of the last search */
.search-log {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 14px;
    margin-bottom: 16px;
    font-size: 0.9em;
}

.search-log summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
}

.search-log ul {
    list-style: none;
    margin: 8px 0 2px;
    padding: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    color: var(--text-primary);
}

.search-log li {
    padding: 2px 0;
}

.relevance-info {
    font-size: 0.65em;
    font-weight: 400;
    color: var(--text-secondary);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 7px;
    vertical-align: middle;
    cursor: default;
    letter-spacing: 0.01em;
}

.article-count {
    font-size: 0.9em;
    color: var(--text-secondary);
    background: var(--background);
    padding: 5px 15px;
    border-radius: 20px;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.article-item {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--background);
    transition: all 0.3s;
}

.article-item:hover {
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.article-headline {
    font-size: 1.2em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.article-headline a {
    color: inherit;
    text-decoration: none;
}

.article-headline a:hover {
    color: var(--primary-color);
}

.article-meta {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.score-high {
    color: #4caf50 !important;
    font-weight: 600;
}

.score-medium {
    color: #ff9800 !important;
    font-weight: 600;
}

.score-low {
    color: #f44336 !important;
    font-weight: 600;
}

.matched-terms {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.9em;
}

.match-term {
    background: var(--accent-soft);
    color: var(--accent-color);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

.article-summary {
    color: var(--text-secondary);
    line-height: 1.5;
}

.article-entities {
    margin-top: 10px;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.empty-state,
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1.1em;
}

.searching {
    text-align: center;
    padding: 40px 20px;
}

/* Brand scanner: the ECHT. chevron sweeps back and forth over a peach band,
   leaving an orange glow with a faint blue trail (same sweep as the old KITT bar) */
.brand-scanner {
    position: relative;
    width: 100%;
    height: 52px;
    background: var(--header-bg);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 auto 22px;
    border: 1px solid #F3CDBB;
    box-shadow: inset 0 1px 3px rgba(242, 106, 61, 0.12);
}

/* Track line the chevron runs along */
.brand-scanner .scan-track {
    position: absolute;
    left: 24px;
    right: 24px;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: linear-gradient(90deg,
        rgba(30, 125, 182, 0) 0%,
        rgba(30, 125, 182, 0.35) 15%,
        rgba(30, 125, 182, 0.35) 85%,
        rgba(30, 125, 182, 0) 100%);
    border-radius: 1px;
}

/* Sweeping glow behind the chevron */
.brand-scanner::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 110px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(ellipse at center,
        rgba(242, 106, 61, 0.55) 0%,
        rgba(242, 106, 61, 0.28) 40%,
        rgba(30, 125, 182, 0.10) 70%,
        transparent 100%
    );
    animation: brand-scan 1.3s ease-in-out infinite alternate;
}

/* The chevron itself: three strokes like the logo mark */
.brand-scanner::after {
    content: '\276F\276F\276F';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 34px;
    font-size: 22px;
    line-height: 1;
    letter-spacing: -6px;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(242, 106, 61, 0.6);
    animation: brand-scan 1.3s ease-in-out infinite alternate, brand-flip 2.6s steps(1) infinite;
}

@keyframes brand-scan {
    0%   { left: -55px; }
    100% { left: calc(100% - 55px); }
}

/* Chevron points in the direction of travel: flips on each return */
@keyframes brand-flip {
    0%   { transform: translateY(-50%) scaleX(1); }
    50%  { transform: translateY(-50%) scaleX(-1); }
    100% { transform: translateY(-50%) scaleX(1); }
}

.kitt-label {
    font-size: 0.72em;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 14px;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s;
    display: flex;
    flex-direction: column;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-footer .btn {
    white-space: nowrap;
    min-width: 100px;
    font-size: 1em;
    font-weight: 500;
}

/* ── Articles section in brand colours: peach background, blue type ──────── */
.results-section {
    background: var(--header-bg);
    border: 1px solid #F3CDBB;
    color: var(--primary-dark);
}

.results-section h2,
.results-section .article-count,
.results-section .sort-control {
    color: var(--primary-color);
}

.results-section .relevance-info {
    color: var(--primary-dark);
    background: rgba(255, 255, 255, 0.6);
    border-color: #F3CDBB;
}

.results-section .article-item {
    background: rgba(255, 255, 255, 0.72);
    border-color: #F3CDBB;
    color: var(--primary-dark);
}

.results-section .article-item:hover {
    background: rgba(255, 255, 255, 0.92);
    border-color: var(--primary-color);
}

.results-section .article-headline,
.results-section .article-headline a {
    color: var(--primary-color);
}

.results-section .article-headline a:hover {
    color: var(--accent-color);
}

.results-section .article-meta,
.results-section .article-summary,
.results-section .matched-terms {
    color: var(--primary-dark);
}

.results-section .date-estimated,
.results-section .date-unknown {
    color: var(--primary-dark);
    opacity: 0.75;
}

.results-section .empty-state,
.results-section .empty-state h3,
.results-section .empty-state p {
    color: var(--primary-dark);
}

.results-section .search-log {
    background: rgba(255, 255, 255, 0.6);
    border-color: #F3CDBB;
}

.results-section .search-log summary,
.results-section .search-log ul {
    color: var(--primary-dark);
}

.results-section .sort-control select {
    color: var(--primary-dark);
    border-color: #F3CDBB;
}

/* ── Sources section: one header line, collapsible list ───────────────────── */
.sources-header {
    flex-wrap: nowrap;
    margin-bottom: 0;
}

.sources-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.sources-actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.sources-actions .btn {
    padding: 6px 12px;
    font-size: 0.9em;
    white-space: nowrap;
}

.sources-panel {
    margin-top: 12px;
}

.sources-panel[hidden] {
    display: none !important;
}

@media (max-width: 1100px) {
    .sources-header {
        flex-wrap: wrap;
    }
    .sources-actions {
        flex-wrap: wrap;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header-brand {
        min-height: 80px;
        padding: 12px 16px;
        gap: 16px;
    }

    .brand-logo {
        height: 44px;
    }

    .header-text {
        padding-left: 16px;
        gap: 1px;
    }

    h1.app-name {
        font-size: 1.4em;
    }

    .subtitle {
        font-size: 0.8em;
    }

    section {
        padding: 20px;
    }

    .sources-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sources-list {
        grid-template-columns: 1fr;
    }

    .article-meta {
        flex-direction: column;
        gap: 5px;
    }
}

/* Search progress indicator */
.search-progress {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 0.95em;
}

.progress-icon {
    font-size: 1.2em;
    min-width: 24px;
}

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

.progress-step.active .progress-text {
    color: var(--text-primary);
    font-weight: 500;
}

.progress-step.completed .progress-icon {
    opacity: 0.5;
}

.progress-step.completed .progress-text {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Discovered Sources Modal */
.discovered-sources-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
}

.discovered-source-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--background);
    border-radius: 4px;
    transition: background 0.2s;
}

.discovered-source-item:hover {
    background: #e8f5e9;
}

.discovered-source-item:last-child {
    margin-bottom: 0;
}

.discovered-source-item input[type="checkbox"] {
    width: auto;
    margin-top: 2px;
    cursor: pointer;
}

.discovered-source-item label {
    flex: 1;
    line-height: 1.4;
}
