/* Dark theme (default) */
:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --bg-input: #1c1c1c;
    --border: #2e2e2e;
    --text: #f0f0f0;
    --text-muted: #888888;
    --accent: #ffffff;
    --accent-hover: #cccccc;
    --success: #22c55e;
    --error: #ef4444;
    --highlight-bg: #f0f0f0;
    --highlight-text: #0a0a0a;
    --btn-text: #0a0a0a;
}

/* Light theme */
html[data-theme="light"] {
    --bg: #f5f5f5;
    --bg-card: #ffffff;
    --bg-input: #ebebeb;
    --border: #d4d4d4;
    --text: #1a1a1a;
    --text-muted: #666666;
    --accent: #111111;
    --accent-hover: #444444;
    --success: #16a34a;
    --error: #dc2626;
    --highlight-bg: #1a1a1a;
    --highlight-text: #f5f5f5;
    --btn-text: #f5f5f5;
}

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

html { font-size: 16px; }

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

.site-header {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
}
.site-header nav { display: flex; align-items: center; gap: 1.5rem; }
.nav-logo { font-size: 1.1rem; font-weight: 700; color: var(--accent); text-decoration: none; }
.nav-link { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.nav-link:hover { color: var(--text); }

.search-container {
    max-width: 760px;
    margin: 0 auto;
    padding: 4rem 1.5rem 2rem;
}

.logo {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--accent);
    text-align: center;
    margin-bottom: 0.25rem;
}

.tagline {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.search-form { margin-bottom: 2rem; }

.search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }

.search-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: var(--btn-text);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
.search-btn:hover { background: var(--accent-hover); }

.results-section { margin-top: 1.5rem; }

.results-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

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

.results-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; }

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    transition: border-color 0.2s;
}
.result-card:hover { border-color: var(--accent); }

.result-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.25rem; flex-wrap: wrap; }

.result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.result-title a { color: var(--accent); text-decoration: none; }
.result-title a:hover { color: var(--accent-hover); text-decoration: underline; }

.result-channel {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

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

.result-snippet mark {
    background: var(--highlight-bg);
    color: var(--highlight-text);
    border-radius: 2px;
    padding: 0 0.1em;
}

.result-timestamp {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vote-form {
    margin-top: 0.75rem;
}

.vote-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.vote-btn {
    padding: 0.35rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
}

.vote-btn:hover {
    border-color: var(--accent);
}

.vote-btn--up:hover {
    border-color: var(--success);
    color: var(--success);
}

.vote-btn--down:hover {
    border-color: var(--error);
    color: var(--error);
}

.vote-btn--selected {
    border-color: var(--accent);
    color: var(--accent);
}

.vote-btn--up.vote-btn--selected {
    border-color: var(--success);
    color: var(--success);
}

.vote-btn--down.vote-btn--selected {
    border-color: var(--error);
    color: var(--error);
}

.vote-comment-input {
    flex: 1;
    min-width: 220px;
    padding: 0.4rem 0.55rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8rem;
}

.vote-comment-input:focus {
    outline: none;
    border-color: var(--accent);
}

.vote-submit-btn {
    padding: 0.4rem 0.7rem;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: var(--bg);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.vote-submit-btn:hover {
    background: var(--accent-hover);
}

.vote-selection-error {
    width: 100%;
    color: var(--error);
    font-size: 0.75rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}
.page-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-info { color: var(--text-muted); font-size: 0.875rem; }

.ingest-container {
    max-width: 600px;
    margin: 3rem auto;
    padding: 0 1.5rem;
}
.ingest-container h1 { margin-bottom: 0.5rem; }
.ingest-note { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.875rem; }

.ingest-form { display: flex; flex-direction: column; gap: 1rem; }

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.875rem; color: var(--text-muted); }
.form-input {
    padding: 0.6rem 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
}
.form-input:focus { outline: none; border-color: var(--accent); }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}
.alert-success { background: rgba(34, 197, 94, 0.1); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid var(--error); color: var(--error); }

.feedback-textarea { resize: vertical; min-height: 120px; font-family: inherit; }

.field-validation { font-size: 0.8rem; color: var(--error); }

/* Search mode selector */
.search-mode {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.25rem;
    width: fit-content;
}

.mode-option {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.875rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    user-select: none;
    position: relative;
}

.mode-option input[type="radio"] { display: none; }

.mode-option:has(input:checked) {
    background: var(--accent);
    color: var(--btn-text);
}

.mode-option:not(:has(input:checked)):hover {
    background: var(--bg-card);
    color: var(--text);
}

/* Mode badge in results */
.mode-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.mode-badge--keyword  { background: rgba(240, 240, 240, 0.08); color: var(--text); border: 1px solid rgba(240,240,240,0.2); }
.mode-badge--semantic { background: rgba(240, 240, 240, 0.08); color: var(--text-muted); border: 1px solid rgba(240,240,240,0.15); }
.mode-badge--hybrid   { background: rgba(240, 240, 240, 0.08); color: var(--accent-hover); border: 1px solid rgba(240,240,240,0.15); }

/* Search mode tooltips */
.mode-option[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    width: 200px;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.mode-option[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}

.mode-option[data-tooltip]:hover::after,
.mode-option[data-tooltip]:hover::before {
    opacity: 1;
}

.admin-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem 2rem;
}

.admin-header {
    margin-bottom: 1rem;
}

.admin-header h1 {
    font-size: 1.9rem;
    margin-bottom: 0.3rem;
}

.admin-header--with-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-note {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.admin-card {
    display: block;
    text-decoration: none;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    transition: border-color 0.2s;
}

.admin-card:hover {
    border-color: var(--accent);
}

.admin-card h2 {
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.admin-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.7rem;
}

.admin-card-link {
    font-size: 0.85rem;
    color: var(--accent);
}

.admin-section {
    margin-top: 1.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.admin-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.admin-section-header h2 {
    font-size: 1rem;
}

.admin-badge {
    display: inline-block;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fda4af;
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
}

.admin-card--dev-only {
    border-style: dashed;
}

.admin-filter-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.admin-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
}

.admin-filter-checkbox {
    justify-content: flex-end;
}

.admin-filter-checkbox label {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    margin-top: 1.8rem;
}

.admin-filter-actions {
    margin-top: 0.9rem;
    display: flex;
    gap: 0.6rem;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.admin-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 0.95rem;
}

.admin-stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.admin-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
}

.admin-stat-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.admin-panel-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
}

.admin-panel h2 {
    font-size: 1rem;
    margin-bottom: 0.6rem;
}

.admin-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.admin-list-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.admin-list-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.admin-table-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.6rem;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.admin-table th,
.admin-table td {
    border-top: 1px solid var(--border);
    padding: 0.6rem;
    vertical-align: top;
    font-size: 0.82rem;
}

.admin-table th {
    color: var(--text-muted);
    text-align: left;
    font-weight: 600;
    border-top: none;
}

.admin-mono {
    font-family: Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
}

.vote-pill {
    display: inline-block;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
    border: 1px solid var(--border);
}

.vote-pill--up {
    border-color: var(--success);
    color: var(--success);
}

.vote-pill--down {
    border-color: var(--error);
    color: var(--error);
}

.result-id-cell {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.admin-link-btn {
    width: fit-content;
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
}

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

.modal-open {
    overflow: hidden;
}

.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.admin-modal[hidden] {
    display: none;
}

.admin-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.admin-modal__panel {
    position: relative;
    width: min(900px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.admin-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-modal__header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.admin-modal__close {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    line-height: 1;
    font-size: 1.2rem;
}

.admin-modal__close:hover {
    border-color: var(--accent);
}

.admin-modal__content {
    padding: 1rem;
}

.admin-modal__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.admin-modal__meta dt {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.admin-modal__meta dd {
    margin: 0;
    font-size: 0.82rem;
    word-break: break-word;
}

.admin-modal__chunk-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}

.admin-modal__chunk pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem;
    font-family: Menlo, Monaco, Consolas, monospace;
    font-size: 0.77rem;
    line-height: 1.5;
    color: var(--text);
}

/* Theme toggle button */
.theme-toggle {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0.3rem 0.5rem;
    transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--text);
}
