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

:root {
    --bg: #fafafa;
    --fg: #1a1a1a;
    --fg-dim: #666;
    --accent: #3d5afe;
    --accent-hover: #304ffe;
    --surface: #fff;
    --border: #ddd;
    --input-bg: #fff;
    --result-url: #006621;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "Fira Code", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d0d0d;
        --fg: #e0e0e0;
        --fg-dim: #888;
        --accent: #536dfe;
        --accent-hover: #8c9eff;
        --surface: #161616;
        --border: #2a2a2a;
        --input-bg: #1a1a1a;
        --result-url: #5cb85c;
    }
}

/* ── Themes ── */
[data-theme="nord"] {
    --bg: #2e3440; --fg: #d8dee9; --fg-dim: #81a1c1;
    --accent: #88c0d0; --accent-hover: #8fbcbb;
    --surface: #3b4252; --border: #4c566a; --input-bg: #3b4252;
    --result-url: #a3be8c;
}
[data-theme="solarized"] {
    --bg: #002b36; --fg: #839496; --fg-dim: #657b83;
    --accent: #268bd2; --accent-hover: #2aa198;
    --surface: #073642; --border: #586e75; --input-bg: #073642;
    --result-url: #859900;
}
[data-theme="dracula"] {
    --bg: #282a36; --fg: #f8f8f2; --fg-dim: #6272a4;
    --accent: #bd93f9; --accent-hover: #ff79c6;
    --surface: #44475a; --border: #6272a4; --input-bg: #44475a;
    --result-url: #50fa7b;
}
[data-theme="gruvbox"] {
    --bg: #282828; --fg: #ebdbb2; --fg-dim: #928374;
    --accent: #83a598; --accent-hover: #8ec07c;
    --surface: #3c3836; --border: #504945; --input-bg: #3c3836;
    --result-url: #b8bb26;
}
[data-theme="catppuccin"] {
    --bg: #1e1e2e; --fg: #cdd6f4; --fg-dim: #6c7086;
    --accent: #89b4fa; --accent-hover: #b4befe;
    --surface: #313244; --border: #45475a; --input-bg: #313244;
    --result-url: #a6e3a1;
}
[data-theme="rosepine"] {
    --bg: #191724; --fg: #e0def4; --fg-dim: #908caa;
    --accent: #c4a7e7; --accent-hover: #ebbcba;
    --surface: #1f1d2e; --border: #403d52; --input-bg: #1f1d2e;
    --result-url: #9ccfd8;
}
[data-theme="everforest"] {
    --bg: #2d353b; --fg: #d3c6aa; --fg-dim: #859289;
    --accent: #7fbbb3; --accent-hover: #83c092;
    --surface: #343f44; --border: #4f585e; --input-bg: #343f44;
    --result-url: #a7c080;
}
[data-theme="tokyonight"] {
    --bg: #1a1b26; --fg: #c0caf5; --fg-dim: #565f89;
    --accent: #7aa2f7; --accent-hover: #bb9af7;
    --surface: #24283b; --border: #414868; --input-bg: #24283b;
    --result-url: #9ece6a;
}
[data-theme="kanagawa"] {
    --bg: #1f1f28; --fg: #dcd7ba; --fg-dim: #727169;
    --accent: #7e9cd8; --accent-hover: #957fb8;
    --surface: #2a2a37; --border: #54546d; --input-bg: #2a2a37;
    --result-url: #76946a;
}
[data-theme="monokai"] {
    --bg: #272822; --fg: #f8f8f2; --fg-dim: #75715e;
    --accent: #66d9ef; --accent-hover: #a6e22e;
    --surface: #3e3d32; --border: #49483e; --input-bg: #3e3d32;
    --result-url: #a6e22e;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ── Corner gear icon (homepage) ── */
.corner-settings {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    color: var(--fg-dim);
    text-decoration: none;
    display: flex;
    align-items: center;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
    z-index: 10;
}

.corner-settings:hover {
    opacity: 1;
    color: var(--fg);
}

/* ── Home ── */
.home {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem;
    padding-bottom: 16vh;
}

.home-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    color: var(--fg-dim);
    opacity: 0;
    transition: opacity 0.3s;
}
.home-footer:hover { opacity: 0.6; }
.home-footer a { color: var(--fg-dim); text-decoration: none; }
.home-footer a:hover { color: var(--accent); }

.home-logo {
    width: clamp(220px, 30vw, 300px);
    height: auto;
    margin-bottom: 0.25rem;
    margin-left: -1.5rem;
    pointer-events: none;
    user-select: none;
}

.tagline {
    color: var(--fg-dim);
    font-size: clamp(0.65rem, 1.1vw, 0.75rem);
    font-weight: 400;
    letter-spacing: 0.1em;
    opacity: 0.7;
    margin-bottom: 1.25rem;
    text-align: center;
}

/* ── Search form ── */
.search-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 580px;
}

.search-form.home-form {
    max-width: 640px;
}

/* ── Home pill input ── */
.home-input-wrap {
    width: 100%;
}

.home-form .home-input-wrap input[type="text"] {
    border-radius: 999px !important;
    padding: 1rem 3.5rem 1rem 1.5rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: border-color 0.25s, box-shadow 0.25s;
}

.home-form .home-input-wrap input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}

.home-form .search-icon {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    color: var(--fg-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
    line-height: 1;
    transition: color 0.15s;
}

.home-form .search-icon:hover {
    background: none !important;
    color: var(--accent);
}

.search-form input[type="text"] {
    flex: 1;
    height: 2.5rem;
    padding: 0 0.875rem;
    font-size: 0.9375rem;
    font-family: var(--font);
    background: var(--input-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-form input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent);
}

.search-form button {
    height: 2.5rem;
    padding: 0 1.25rem;
    font-size: 0.875rem;
    font-family: var(--font);
    font-weight: 600;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, box-shadow 0.15s;
}

.search-form button:hover {
    background: var(--accent-hover);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* ── Results header ── */
.results-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.logo-sm {
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--fg);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-sm-icon {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.search-form.inline {
    flex: 1;
    max-width: 720px;
    flex-wrap: wrap;
    align-items: center;
}

.header-spacer {
    flex: 1;
}

.header-back {
    font-size: 0.8125rem;
    color: var(--fg-dim);
    text-decoration: none;
    transition: color 0.15s;
}

.header-back:hover {
    color: var(--accent);
}

.header-settings {
    color: var(--fg-dim);
    text-decoration: none;
    display: flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.header-settings:hover {
    opacity: 1;
    color: var(--fg);
}

/* ── Search input wrap (autocomplete anchor) ── */
.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-input-wrap input[type="text"] {
    width: 100%;
}

/* ── Autocomplete dropdown ── */
.suggest-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    overflow: hidden;
}

.suggest-dropdown li {
    padding: 0.55rem 1.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.1s;
}

.suggest-dropdown li::before {
    content: "";
    display: block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center;
    flex-shrink: 0;
    opacity: 0.5;
}

.suggest-dropdown li:hover,
.suggest-dropdown li.active {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--fg);
}

.suggest-dropdown li:hover::before,
.suggest-dropdown li.active::before {
    opacity: 0.8;
}

/* ── Header selects ── */
.header-select {
    height: 2.5rem;
    padding: 0 0.625rem;
    font-size: 0.8125rem;
    font-family: var(--font);
    background: var(--input-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s;
}

.header-select:focus {
    border-color: var(--accent);
}

/* ── Search filters (time range pills) ── */
.search-filters {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0 0.25rem;
    flex-wrap: wrap;
}

.filter {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--fg-dim);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.filter:hover {
    color: var(--fg);
    border-color: var(--fg-dim);
}

.filter.active {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* ── Search tabs ── */
.search-tabs {
    display: flex;
    gap: 0;
    padding: 0.75rem 0 0;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    color: var(--fg-dim);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--fg); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

/* ── Results ── */
.results {
    max-width: 820px;
    padding: 1rem 1.5rem;
}

.results-wide { max-width: 1200px; }

/* ── Wikipedia knowledge panel (inline, above results) ── */
.wiki-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.wiki-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.wiki-header-text {
    flex: 1;
    min-width: 0;
}

.wiki-thumb {
    width: 120px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.wiki-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0;
    line-height: 1.3;
}

.wiki-extract {
    font-size: 0.875rem;
    color: var(--fg);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    max-width: 65ch;
}

.wiki-link {
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
}

.wiki-link:hover { text-decoration: underline; }

.results-meta {
    color: var(--fg-dim);
    font-size: 0.8125rem;
    padding: 0.5rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.engine-status {
    font-size: 0.75rem;
    color: var(--fg-dim);
    opacity: 0.7;
}

.engine-status-warn {
    color: #e67e80;
    opacity: 1;
}

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

.result {
    margin-bottom: 1.25rem;
    padding: 0.5rem 0.75rem;
    margin-left: -0.75rem;
    border-radius: 8px;
    transition: background 0.1s;
}

.result-focused {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.result-site {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.result-favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}

.result-breadcrumb {
    font-size: 0.8125rem;
    color: var(--fg);
    font-style: normal;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-title {
    display: block;
    font-size: 1.1rem;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 0.25rem;
    line-height: 1.35;
}

.result-title:hover { text-decoration: underline; }

.result-snippet {
    font-size: 0.875rem;
    color: var(--fg);
    line-height: 1.6;
    margin-bottom: 0.35rem;
    max-width: 68ch;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.result-source {
    font-size: 0.75rem;
    color: var(--fg-dim);
}

.view-link {
    font-size: 0.7rem;
    color: var(--fg-dim);
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    transition: color 0.15s, border-color 0.15s;
}

.view-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

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

/* ── Image grid ── */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.image-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--fg);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: border-color 0.15s;
}

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

.image-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.image-title {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── News cards ── */
.news-card { display: flex; gap: 1rem; align-items: flex-start; }

.news-thumb {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.news-body { flex: 1; min-width: 0; }
.news-body .result-title { margin-top: 0; }

.news-meta {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--fg-dim);
}

.news-age { color: var(--fg-dim); }

/* ── Video cards ── */
.video-card { display: flex; gap: 1rem; align-items: flex-start; }
.video-thumb-wrap { position: relative; flex-shrink: 0; }

.video-thumb {
    width: 200px;
    height: 112px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.video-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.6875rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-family: var(--mono);
}

.video-body { flex: 1; min-width: 0; }
.video-body .result-title { margin-top: 0; }

/* ── Loading indicator ── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── View page ── */
.view-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem;
}

.view-title {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.view-meta {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.view-source {
    color: var(--fg-dim);
    font-size: 0.875rem;
    text-decoration: none;
}

.view-source:hover { color: var(--accent); }

.view-content { font-size: 1.05rem; line-height: 1.7; }
.view-content p { margin-bottom: 1rem; }

.view-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1rem 0;
}

.view-content a { color: var(--accent); }
.view-content h2, .view-content h3 { margin: 1.5rem 0 0.75rem; }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.page-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.page-link:hover { text-decoration: underline; }
.page-num { color: var(--fg-dim); }

/* ── Settings page ── */
.settings-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
}

.settings-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.settings-desc {
    color: var(--fg-dim);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.settings-saved {
    color: var(--accent);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
}

.settings-group legend {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--fg);
    padding: 0 0.5rem;
}

.settings-hint {
    color: var(--fg-dim);
    font-size: 0.8rem;
    margin: 0.5rem 0 1rem;
    line-height: 1.4;
}

.settings-hint a {
    color: var(--accent);
    text-decoration: none;
}

.settings-hint a:hover { text-decoration: underline; }

/* ── Theme grid ── */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
}

.theme-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.theme-card:hover {
    border-color: var(--fg-dim);
    transform: translateY(-1px);
}

.theme-card-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    box-shadow: 0 0 0 1px var(--accent), 0 2px 12px color-mix(in srgb, var(--accent) 15%, transparent);
}

.theme-card-active::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center;
    background-size: 10px;
}

.theme-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-preview {
    display: flex;
    width: 64px;
    height: 28px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.theme-preview > span {
    flex: 1;
}

.theme-preview-default > span:nth-child(1) { background: #fafafa; }
.theme-preview-default > span:nth-child(2) { background: #3d5afe; }
.theme-preview-default > span:nth-child(3) { background: #0d0d0d; }

.theme-name {
    font-size: 0.75rem;
    color: var(--fg-dim);
    text-align: center;
}

.theme-card-active .theme-name { color: var(--accent); font-weight: 600; }

/* ── Settings labels ── */
.settings-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

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

.settings-label-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
}

.settings-label-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--fg-dim);
    margin-top: 0.15rem;
}

.settings-select {
    padding: 0.4rem 0.5rem;
    font-size: 0.875rem;
    font-family: var(--font);
    background: var(--input-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    min-width: 160px;
    flex-shrink: 0;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
}

.settings-save {
    padding: 0.65rem 2rem;
    font-size: 0.9rem;
    font-family: var(--font);
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.settings-save:hover { background: var(--accent-hover); }

.settings-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.guide-section summary {
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.25rem 0;
    color: var(--fg);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guide-section summary::before {
    content: "›";
    font-size: 1.1rem;
    transition: transform 0.15s;
    display: inline-block;
    color: var(--fg-dim);
}

.guide-section[open] summary::before {
    transform: rotate(90deg);
}

.guide-section summary::-webkit-details-marker { display: none; }

.guide-section .settings-hint { margin-top: 0.75rem; }
.guide-section .guide-table { margin-top: 0.75rem; }

.guide-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.guide-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.guide-table tr:last-child td { border-bottom: none; }

.guide-table td:first-child {
    white-space: nowrap;
    width: 1%;
    padding-right: 1rem;
    color: var(--fg);
    font-weight: 500;
}

.guide-table td:last-child {
    color: var(--fg-dim);
}

.guide-table kbd {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.guide-table code {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--accent);
}

.engine-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.engine-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.engine-toggle input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ── Instant answer card ── */
.instant-answer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin: 0.75rem 0 1.25rem;
}

.instant-value {
    font-size: 2rem;
    font-weight: 600;
    font-family: var(--mono);
    color: var(--accent);
    line-height: 1.2;
    margin-bottom: 0.35rem;
}

.instant-label {
    font-size: 0.85rem;
    color: var(--fg-dim);
}

/* ── Dashboard ── */
.dashboard-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.dashboard-desc {
    color: var(--fg-dim);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

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

.engine-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.engine-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.engine-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.engine-state {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.engine-state-closed {
    color: #a3be8c;
    background: color-mix(in srgb, #a3be8c 15%, transparent);
}

.engine-state-open {
    color: #e67e80;
    background: color-mix(in srgb, #e67e80 15%, transparent);
}

.engine-state-half-open {
    color: #dbbc7f;
    background: color-mix(in srgb, #dbbc7f 15%, transparent);
}

.engine-stats {
    display: flex;
    gap: 1.5rem;
}

.engine-stat {
    display: flex;
    flex-direction: column;
}

.engine-stat-val {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--mono);
}

.engine-stat-label {
    font-size: 0.7rem;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Error page ── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
}

.error-code {
    font-size: 6rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.error-message {
    font-size: 1.1rem;
    color: var(--fg-dim);
    margin-bottom: 2rem;
    max-width: 400px;
}

.error-home {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.5rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.error-home:hover {
    background: var(--accent);
    color: #fff;
}

/* ── Back to top ── */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--fg-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(0.75rem);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s, color 0.15s, border-color 0.15s, background 0.15s;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ── Theme transition (JS-triggered) ── */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease !important;
}

/* ── Mobile responsive ── */
@media (max-width: 640px) {
    /* Home */
    .home { padding: 1.5rem 1rem; padding-bottom: 12vh; }
    .home-logo { width: 200px; }
    .search-form.home-form { max-width: 100%; }
    .home-form .home-input-wrap input[type="text"] {
        padding: 0.9rem 3rem 0.9rem 1.25rem;
        font-size: 0.95rem;
    }
    .corner-settings { top: 0.75rem; right: 1rem; }

    /* Results header */
    .results-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }
    .logo-sm { font-size: 1.1rem; }
    .search-form.inline { max-width: 100%; order: 3; width: 100%; }
    .header-select { font-size: 0.75rem; padding: 0.3rem 0.4rem; }
    .header-settings { order: 2; }
    .search-form button { height: 2.25rem; padding: 0 0.875rem; font-size: 0.8125rem; }

    /* Results */
    .results { padding: 0.75rem 1rem; }
    .search-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { padding: 0.5rem 0.9rem; font-size: 0.8rem; white-space: nowrap; }
    .search-filters { gap: 0.35rem; }
    .filter { font-size: 0.75rem; padding: 0.2rem 0.6rem; }

    /* Result cards */
    .result { padding: 0.4rem 0.5rem; margin-left: -0.5rem; }
    .result-title { font-size: 1rem; }
    .result-snippet { font-size: 0.85rem; }
    .result-breadcrumb { font-size: 0.75rem; }
    .news-thumb { width: 80px; height: 56px; }
    .video-thumb { width: 140px; height: 79px; }

    /* Image grid */
    .image-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.5rem; }

    /* Instant answer */
    .instant-answer { padding: 1rem 1.25rem; }
    .instant-value { font-size: 1.5rem; }

    /* Wiki panel */
    .wiki-panel { padding: 1rem; }
    .wiki-thumb { width: 90px; height: 72px; }

    /* Settings */
    .settings-page { padding: 1.5rem 1rem; }
    .theme-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 0.5rem; }
    .settings-label { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .settings-select { min-width: 100%; }

    /* Error page */
    .error-code { font-size: 4rem; }
    .error-message { font-size: 1rem; }

    /* Dashboard */
    .dashboard-page { padding: 1.5rem 1rem; }
    .engine-grid { grid-template-columns: 1fr; }
    .engine-stats { gap: 1rem; }

    /* View page */
    .view-page { padding: 1.5rem 1rem; }
    .view-title { font-size: 1.3rem; }
    .view-content { font-size: 0.95rem; }

    /* Back to top */
    .back-to-top { bottom: 1.25rem; right: 1.25rem; width: 36px; height: 36px; }

    /* Autocomplete */
    .suggest-dropdown { border-radius: 12px; }
    .suggest-dropdown li { padding: 0.5rem 1rem; font-size: 0.85rem; }
}
