/*
 * WEBDEXY Search Engine
 * Main stylesheet
 *
 * Copyright (c) 2026 WEBDEXY / INETDEX
 * All rights reserved.
 */

/* -----------------------------
   Base variables
----------------------------- */

:root {
    --bg: #f5f7fb;
    --bg-soft: #eef3f9;

    --surface: #ffffff;
    --surface-soft: #f8fafd;
    --surface-muted: #eef2f7;

    --text: #172033;
    --text-soft: #435168;
    --text-muted: #68758a;
    --text-faint: #8a96a8;

    --border: #d7dfeb;
    --border-soft: #e7edf5;

    --primary: #174ea6;
    --primary-hover: #0f3d86;
    --primary-soft: #e8f0ff;

    --success: #137333;
    --warning-bg: #fff8d7;
    --warning-border: #ead37a;
    --warning-text: #332800;

    --danger: #b3261e;

    --link: #174ea6;
    --link-hover: #0b57d0;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.07);
    --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 22px 60px rgba(15, 23, 42, 0.16);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --container: 1120px;
    --search-width: 840px;

    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

html.theme-dark,
body.theme-dark {
    --bg: #0c111d;
    --bg-soft: #101827;

    --surface: #151c2c;
    --surface-soft: #101827;
    --surface-muted: #1d2638;

    --text: #edf2f7;
    --text-soft: #c8d2e2;
    --text-muted: #9ba8bc;
    --text-faint: #778399;

    --border: #2d384b;
    --border-soft: #222c3e;

    --primary: #7ba7ff;
    --primary-hover: #a9c4ff;
    --primary-soft: #172a4d;

    --success: #7bd88f;

    --warning-bg: #2b240f;
    --warning-border: #5a4a1d;
    --warning-text: #fff1b8;

    --danger: #ff8a80;

    --link: #9bbcff;
    --link-hover: #c7d8ff;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.38);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.48);
}

/* -----------------------------
   Reset and base
----------------------------- */

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

html {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 10% -10%, rgba(23, 78, 166, 0.12), transparent 28rem),
        radial-gradient(circle at 95% 0%, rgba(44, 123, 229, 0.08), transparent 25rem),
        var(--bg);
    color: var(--text);
}

body.theme-dark {
    background:
        radial-gradient(circle at 10% -10%, rgba(123, 167, 255, 0.15), transparent 28rem),
        radial-gradient(circle at 95% 0%, rgba(54, 92, 170, 0.16), transparent 25rem),
        var(--bg);
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

::selection {
    background: var(--primary-soft);
    color: var(--text);
}

/* -----------------------------
   Header
----------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(18px);
}

.header-inner {
    width: min(100% - 32px, var(--container));
    min-height: 68px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 900;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary), #3b78dc);
    color: #ffffff;
    font-weight: 950;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    font-size: 1.08rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-inline-start: 12px;
}

.site-nav a,
.site-nav-post-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.site-nav-post-form {
    display: inline-flex;
    margin: 0;
}

.site-nav a:hover,
.site-nav-post-form button:hover {
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-inline-start: auto;
}

.header-language-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.header-language-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--text-soft);
    font-size: 0.86rem;
    font-weight: 800;
    white-space: nowrap;
}

.header-language-label select {
    min-height: 38px;
    max-width: 180px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 800;
    padding: 0 34px 0 12px;
    box-shadow: var(--shadow-xs);
}

.header-language-label select:hover,
.header-language-label select:focus-visible {
    border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
    outline: none;
}


.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font-weight: 800;
    text-decoration: none;
    box-shadow: var(--shadow-xs);
}

.theme-toggle:hover {
    border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
    background: var(--primary-soft);
    color: var(--text);
    text-decoration: none;
}

[dir="rtl"] .header-actions {
    margin-inline-start: 0;
    margin-inline-end: auto;
}

[dir="rtl"] .site-nav {
    margin-inline-start: 0;
    margin-inline-end: 12px;
}

/* -----------------------------
   Main layout
----------------------------- */

.main-content,
.page-shell,
.content-page,
.settings-page,
.advanced-page {
    width: min(100% - 32px, var(--container));
    margin: 0 auto;
    padding: 36px 0 56px;
}

.search-page {
    padding-top: 46px;
}

/* -----------------------------
   Search hero
----------------------------- */

.search-hero {
    display: flex;
    justify-content: center;
    margin: 12px 0 30px;
}

.search-hero-inner {
    width: min(100%, var(--search-width));
    text-align: center;
}

.search-brand {
    margin: 0 0 12px;
    color: var(--text);
    font-size: clamp(2.8rem, 7vw, 5.4rem);
    line-height: 0.92;
    font-weight: 950;
    letter-spacing: -0.08em;
}

.search-brand-subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: clamp(1.1rem, 2.4vw, 1.55rem);
    font-weight: 800;
    line-height: 1.35;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-box-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
}

.search-box-wrap:focus-within {
    border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
    box-shadow:
        0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent),
        var(--shadow-md);
}

.search-input {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 48px;
    padding: 0 18px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 1.12rem;
}

.search-input::placeholder {
    color: var(--text-faint);
}

.search-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    min-width: 120px;
    padding: 0 24px;
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 900;
    box-shadow: var(--shadow-xs);
}

.search-button:hover {
    background: var(--primary-hover);
}

.search-form-options {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
    color: var(--text-muted);
}

.inline-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-weight: 700;
}

.inline-field select,
.inline-field input {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
}

.text-link {
    font-weight: 800;
}

.text-link-button {
    display: inline;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font: inherit;
    cursor: pointer;
}

.text-link-button:hover,
.text-link-button:focus {
    text-decoration: underline;
}

/* -----------------------------
   Suggestions
----------------------------- */

.suggest-box {
    position: absolute;
    z-index: 80;
    top: calc(100% + 8px);
    inset-inline: 10px;
    max-height: min(440px, 70vh);
    overflow: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: start;
}

.suggest-box[hidden] {
    display: none !important;
}

.suggest-item,
.suggestion-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}

.suggest-item + .suggest-item,
.suggestion-item + .suggestion-item {
    margin-top: 2px;
}

.suggest-item:hover,
.suggestion-item:hover,
.suggest-item.is-active,
.suggestion-item.is-active {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    text-decoration: none;
}

.suggest-title,
.suggestion-title {
    min-width: 0;
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggest-meta,
.suggestion-meta {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    padding: 5px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text) 7%, transparent);
}

.suggest-source-wikipedia .suggest-title,
.suggestion-source-wikipedia .suggest-title {
    color: var(--primary);
}

.suggest-source-wikipedia .suggest-meta,
.suggestion-source-wikipedia .suggest-meta {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

@media (max-width: 640px) {
    .suggest-box {
        inset-inline: 0;
        border-radius: 14px;
    }

    .suggest-item,
    .suggestion-item {
        grid-template-columns: 1fr;
        gap: 5px;
        align-items: start;
    }

    .suggest-meta,
    .suggestion-meta {
        justify-self: start;
    }
}

/* -----------------------------
   Results
----------------------------- */

.results-shell {
    width: min(100%, 960px);
    margin: 0 auto;
}

.result-stats {
    display: block;
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface) 94%, var(--surface-muted));
    color: var(--text-muted);
    font-size: 0.96rem;
    box-shadow: var(--shadow-xs);
}

.result-stats strong {
    color: var(--text-soft);
}

.result-stats-lines {
    display: grid;
    gap: 7px;
}

.result-stats-line {
    min-width: 0;
}

.result-stats-summary {
    color: var(--text-soft);
    font-size: 1rem;
    font-weight: 700;
}

.result-stats-range {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.result-stats-meta {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.result-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.result-meta-item + .result-meta-item::before {
    content: "·";
    margin: 0 8px;
    color: var(--text-muted);
}

.cache-chip,
.meta-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 800;
    white-space: nowrap;
}

.results-list {
    display: grid;
    gap: 14px;
}

.result-card {
    padding: 18px 20px;
    background: color-mix(in srgb, var(--surface) 98%, transparent);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.result-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--primary) 28%, var(--border));
    box-shadow: var(--shadow-sm);
}

.result-title {
    margin: 0;
    font-size: 1.18rem;
    line-height: 1.32;
    font-weight: 900;
}

.result-title a {
    color: var(--link);
    text-decoration: none;
}

.result-title a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.result-url {
    margin-top: 5px;
    color: var(--success);
    font-size: 0.92rem;
    word-break: break-all;
}

.result-description {
    margin: 10px 0 0;
    color: var(--text-soft);
    font-size: 0.98rem;
    line-height: 1.62;
    overflow-wrap: anywhere;
}

.result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 13px;
}

.inline-post-form {
    display: inline;
    margin: 0;
}

.result-more-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 5px 11px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 850;
}

.result-more-button:hover {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
    background: var(--primary-soft);
}

.result-more-button span {
    color: var(--text-muted);
    font-weight: 750;
}

.language-chip {
    margin-inline-start: auto;
}

/* -----------------------------
   Wikipedia info box
----------------------------- */

.wiki-info-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    margin: 0 0 18px;
    padding: 20px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 70%, var(--surface)), var(--surface));
    border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border-soft));
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.wiki-info-main {
    min-width: 0;
}

.wiki-info-label {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, var(--surface));
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 950;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.wiki-info-title {
    margin: 10px 0 8px;
    color: var(--text);
    font-size: 1.46rem;
    line-height: 1.22;
    font-weight: 950;
    letter-spacing: -0.03em;
}

.wiki-info-extract {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.64;
}

.wiki-info-link {
    display: inline-flex;
    align-items: center;
    margin-top: 12px;
    font-weight: 850;
}

.wiki-info-image {
    width: 152px;
    align-self: start;
}

.wiki-info-gallery {
    display: block;
}

.wiki-gallery-toggle {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.wiki-gallery-frame {
    position: relative;
    width: 152px;
    min-height: 132px;
}

.wiki-gallery-slide {
    display: none;
    margin: 0;
}

.wiki-gallery-slide img {
    width: 152px;
    height: 132px;
    object-fit: cover;
    border-radius: 18px;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-xs);
    background: var(--surface);
}

.wiki-gallery-controls {
    margin-top: 8px;
    min-height: 34px;
}

.wiki-gallery-control-set {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.wiki-gallery-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--surface) 88%, var(--primary-soft));
    color: var(--text);
    font-size: 1.45rem;
    line-height: 1;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
}

.wiki-gallery-arrow:hover {
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border-soft));
    color: var(--primary);
}

.wiki-gallery-count {
    min-width: 42px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 850;
    text-align: center;
}

.wiki-info-gallery input:nth-of-type(1):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(1),
.wiki-info-gallery input:nth-of-type(2):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(2),
.wiki-info-gallery input:nth-of-type(3):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(3),
.wiki-info-gallery input:nth-of-type(4):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(4),
.wiki-info-gallery input:nth-of-type(5):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(5),
.wiki-info-gallery input:nth-of-type(6):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(6),
.wiki-info-gallery input:nth-of-type(7):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(7),
.wiki-info-gallery input:nth-of-type(8):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(8),
.wiki-info-gallery input:nth-of-type(9):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(9),
.wiki-info-gallery input:nth-of-type(10):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(10),
.wiki-info-gallery input:nth-of-type(11):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(11),
.wiki-info-gallery input:nth-of-type(12):checked ~ .wiki-gallery-frame .wiki-gallery-slide:nth-of-type(12) {
    display: block;
}

.wiki-info-gallery input:nth-of-type(1):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(1),
.wiki-info-gallery input:nth-of-type(2):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(2),
.wiki-info-gallery input:nth-of-type(3):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(3),
.wiki-info-gallery input:nth-of-type(4):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(4),
.wiki-info-gallery input:nth-of-type(5):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(5),
.wiki-info-gallery input:nth-of-type(6):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(6),
.wiki-info-gallery input:nth-of-type(7):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(7),
.wiki-info-gallery input:nth-of-type(8):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(8),
.wiki-info-gallery input:nth-of-type(9):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(9),
.wiki-info-gallery input:nth-of-type(10):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(10),
.wiki-info-gallery input:nth-of-type(11):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(11),
.wiki-info-gallery input:nth-of-type(12):checked ~ .wiki-gallery-controls .wiki-gallery-control-set:nth-of-type(12) {
    display: flex;
}

/* -----------------------------
   Pagination
----------------------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 24px;
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: 3px;
}

.pagination-form {
    display: inline;
    margin: 0;
}

.page-button {
    min-width: 31px;
    min-height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font-weight: 850;
    box-shadow: var(--shadow-xs);
}

.page-button:hover {
    background: var(--primary-soft);
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
    color: var(--text);
}

.page-button.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.page-ellipsis {
    padding: 0 2px;
    color: var(--text-muted);
}


@media (max-width: 760px) {
    .pagination {
        gap: 3px;
        justify-content: center;
        overflow-x: hidden;
    }

    .page-button {
        min-width: 29px;
        min-height: 30px;
        padding: 0 7px;
        font-size: 0.82rem;
    }

    .pagination .is-mobile-extra,
    .pagination .is-jump-page {
        display: none;
    }

    .page-ellipsis {
        padding: 0 2px;
    }
}

@media (max-width: 420px) {
    .pagination {
        gap: 2px;
    }

    .page-button {
        min-width: 27px;
        min-height: 28px;
        padding: 0 6px;
        font-size: 0.78rem;
    }
}

/* -----------------------------
   Content, settings and advanced pages
----------------------------- */

.content-card,
.settings-card,
.advanced-card,
.notice-box {
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.content-card,
.settings-card,
.advanced-card {
    padding: clamp(20px, 4vw, 34px);
}

.content-card h1,
.settings-card h1,
.advanced-card h1,
.content-page h1,
.settings-page h1,
.advanced-page h1 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1.05;
    font-weight: 950;
    letter-spacing: -0.05em;
}

.content-card h2,
.settings-card h2,
.advanced-card h2 {
    margin: 28px 0 12px;
    font-size: 1.35rem;
    line-height: 1.25;
    font-weight: 900;
}

.content-card p,
.settings-card p,
.advanced-card p {
    color: var(--text-soft);
}

.form-grid {
    display: grid;
    gap: 18px;
}

.form-section,
.settings-section,
.advanced-section {
    padding: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
}

.form-section h2,
.settings-section h2,
.advanced-section h2 {
    margin-top: 0;
}

.field-grid,
.settings-grid,
.advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field,
.setting-field,
.advanced-field {
    display: grid;
    gap: 6px;
}

.field label,
.setting-field label,
.advanced-field label {
    color: var(--text-soft);
    font-weight: 850;
}

.field input,
.field select,
.field textarea,
.setting-field input,
.setting-field select,
.setting-field textarea,
.advanced-field input,
.advanced-field select,
.advanced-field textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.field textarea,
.setting-field textarea,
.advanced-field textarea {
    min-height: 130px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.setting-field input:focus,
.setting-field select:focus,
.setting-field textarea:focus,
.advanced-field input:focus,
.advanced-field select:focus,
.advanced-field textarea:focus {
    border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 13%, transparent);
}

.help-text,
.field-help,
.setting-help {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.button-row,
.form-actions,
.settings-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.primary-button,
.secondary-button,
.submit-button,
.reset-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    font-weight: 850;
    text-decoration: none;
}

.primary-button,
.submit-button {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.primary-button:hover,
.submit-button:hover {
    background: var(--primary-hover);
    color: #ffffff;
    text-decoration: none;
}

.secondary-button,
.reset-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
}

.secondary-button:hover,
.reset-button:hover {
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}


/* -----------------------------
   Contact page
----------------------------- */

.page-narrow,
.contact-page {
    width: min(100% - 32px, 760px);
    max-width: 760px;
    margin: 0 auto;
    padding: 36px 0 56px;
}

.contact-card {
    width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.contact-page {
    display: block;
    max-width: 760px;
    overflow-x: clip;
}

.contact-card,
.contact-form,
.contact-fields,
.contact-field,
.contact-field span,
.contact-field input,
.contact-field textarea,
.notice,
.notice ul {
    min-width: 0;
}

.contact-card > * {
    max-width: 100%;
}

.notice ul {
    margin-bottom: 0;
    padding-inline-start: 1.25rem;
}

.text-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font-weight: 850;
    text-decoration: none;
}

.text-button:hover {
    background: var(--surface-muted);
    color: var(--text);
    text-decoration: none;
}

.contact-form,
.contact-fields,
.contact-field {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.contact-form {
    margin-top: 22px;
}

.contact-fields {
    display: grid;
    gap: 14px;
}

.contact-field {
    display: grid;
    gap: 6px;
    color: var(--text-soft);
    font-weight: 850;
}

.contact-field input,
.contact-field textarea {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.contact-field textarea {
    min-height: 150px;
    resize: vertical;
}

.contact-field input:focus,
.contact-field textarea:focus {
    border-color: color-mix(in srgb, var(--primary) 60%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 13%, transparent);
}

.contact-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.honeypot-field {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

.notice {
    max-width: 100%;
    margin: 18px 0;
    padding: 14px 16px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    overflow-wrap: anywhere;
}

.notice ul {
    margin: 8px 0 0;
    padding-inline-start: 22px;
}

.notice-success {
    border-color: color-mix(in srgb, var(--success) 30%, var(--border));
    background: color-mix(in srgb, var(--success) 9%, var(--surface));
}

.notice-warning {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning-text);
}

@media (max-width: 540px) {
    .page-narrow,
    .contact-page {
        width: min(100% - 22px, 760px);
        padding-top: 24px;
    }

    .contact-card {
        border-radius: 16px;
        padding: 18px;
    }

    .contact-actions,
    .contact-actions .primary-button,
    .contact-actions .text-button {
        width: 100%;
    }

    .contact-actions .primary-button,
    .contact-actions .text-button {
        justify-content: center;
    }
}

/* -----------------------------
   Notices
----------------------------- */

.notice-box {
    padding: 18px 20px;
    margin: 16px 0;
}

.notice-box h2 {
    margin: 0 0 8px;
}

.notice-box p {
    margin: 0;
    color: var(--text-soft);
}

.error-box {
    border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
    background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}

/* -----------------------------
   Cookie notice
----------------------------- */

.cookie-notice {
    position: fixed;
    z-index: 120;
    inset-inline: 20px;
    bottom: 20px;
    width: min(calc(100% - 40px), 860px);
    margin-inline: auto;
    padding: 0;
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.cookie-notice-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 18px;
}

.cookie-notice-text {
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.cookie-notice-text p {
    margin: 0;
}

.cookie-notice-actions {
    flex: 0 0 auto;
    margin: 0;
}

.cookie-notice-button {
    min-height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 850;
}

.cookie-notice-button:hover {
    background: var(--primary-hover);
}

/* -----------------------------
   Footer
----------------------------- */

.site-footer {
    margin-top: 42px;
    border-top: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
}

.footer-inner {
    width: min(100% - 32px, var(--container));
    min-height: 78px;
    margin: 0 auto;
    padding: 22px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.94rem;
}

.footer-inner a {
    color: var(--text-muted);
    font-weight: 750;
}

.footer-inner a:hover {
    color: var(--link-hover);
}

/* -----------------------------
   Utilities
----------------------------- */

.muted {
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.center {
    text-align: center;
}

code,
.code {
    padding: 0.15em 0.35em;
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text);
    font-family: var(--mono);
}

/* -----------------------------
   Responsive
----------------------------- */

@media (max-width: 860px) {
    .header-inner {
        min-height: auto;
        padding: 12px 0;
        flex-wrap: wrap;
    }

    .brand {
        flex: 0 0 auto;
    }

    .header-actions {
        margin-inline-start: auto;
        flex-wrap: wrap;
    }

    .header-language-label span {
        display: none;
    }

    .header-language-label select {
        max-width: 150px;
    }

    .site-nav {
        order: 3;
        width: 100%;
        margin-inline-start: 0;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }

    .site-nav a {
        white-space: nowrap;
    }

    .search-page {
        padding-top: 28px;
    }

    .search-box-wrap {
        align-items: stretch;
        flex-direction: column;
        border-radius: 24px;
        padding: 10px;
    }

    .search-input {
        height: 48px;
    }

    .search-button {
        width: 100%;
    }

    .suggest-box {
        inset-inline: 0;
    }

    .wiki-info-box {
        grid-template-columns: 1fr;
    }

    .wiki-info-image,
    .wiki-gallery-frame {
        width: 100%;
    }

    .wiki-gallery-frame {
        min-height: 210px;
    }

    .wiki-gallery-slide img {
        width: 100%;
        height: 210px;
        max-height: 220px;
    }

    .result-stats {
        align-items: flex-start;
        flex-direction: column;
    }

    .language-chip {
        margin-inline-start: 0;
    }

    .field-grid,
    .settings-grid,
    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .cookie-notice-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .cookie-notice-actions,
    .cookie-notice-button {
        width: 100%;
    }

    .cookie-notice-button {
        justify-content: center;
    }
}

@media (max-width: 540px) {
    .main-content,
    .page-shell,
    .content-page,
    .settings-page,
    .advanced-page,
    .header-inner,
    .footer-inner {
        width: min(100% - 22px, var(--container));
    }

    .search-brand {
        font-size: clamp(2.35rem, 15vw, 4rem);
    }

    .result-card,
    .wiki-info-box,
    .content-card,
    .settings-card,
    .advanced-card {
        border-radius: 16px;
    }

    .result-card {
        padding: 16px;
    }

    .result-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    .footer-inner {
        flex-direction: column;
    }
}

/* -----------------------------
   Reduced motion
----------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}


/* -----------------------------
   Search fallback and highlighting
----------------------------- */

.search-fallback-notice {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.search-fallback-notice p {
    margin: 6px 0 0;
}

.result-title mark,
.result-description mark {
    background: #fff3a3;
    color: inherit;
    padding: 0 0.12em;
    border-radius: 3px;
}

.theme-dark .result-title mark,
.theme-dark .result-description mark {
    background: #6b5a15;
    color: inherit;
}

/* -----------------------------
   Advanced search polished layout
----------------------------- */

.advanced-page {
    max-width: 1180px;
    overflow-x: clip;
}

.advanced-hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
    gap: 20px;
    align-items: stretch;
    margin-bottom: 22px;
}

.advanced-hero-copy,
.advanced-info-pill,
.advanced-panel {
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}

.advanced-hero-copy {
    padding: clamp(22px, 4vw, 38px);
}

.advanced-hero-copy h1 {
    margin: 0 0 12px;
    font-size: clamp(2.1rem, 4.8vw, 3.6rem);
    line-height: 1;
    letter-spacing: -0.06em;
}

.advanced-hero-copy p {
    max-width: 780px;
    margin: 0;
    color: var(--text-soft);
    font-size: 1.04rem;
    line-height: 1.65;
}

.advanced-info-pill {
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 22px;
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--primary) 16%, transparent), transparent 42%),
        color-mix(in srgb, var(--surface) 97%, transparent);
}

.advanced-info-pill strong {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 950;
}

.advanced-info-pill span,
.advanced-note {
    color: var(--text-muted);
    line-height: 1.5;
}

.advanced-form-pro {
    display: grid;
    gap: 18px;
    width: 100%;
    min-width: 0;
}

.advanced-panel {
    padding: clamp(18px, 3vw, 30px);
    overflow: hidden;
}

.advanced-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.advanced-panel-head h2 {
    margin: 0 0 6px;
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    letter-spacing: -0.03em;
}

.advanced-panel-head p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
}

.advanced-note {
    flex: 0 0 min(320px, 40%);
    padding: 10px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--surface-soft);
    font-size: 0.9rem;
}

.advanced-main-grid,
.advanced-heading-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 190px) minmax(130px, 160px);
    gap: 14px;
    align-items: end;
}

.advanced-heading-grid {
    grid-template-columns: minmax(0, 1fr) repeat(3, minmax(110px, 1fr));
}

.advanced-control,
.advanced-field-query,
.advanced-field-boost {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.advanced-control span,
.advanced-field-query span,
.advanced-field-boost span {
    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 900;
}

.advanced-control input,
.advanced-control select,
.advanced-field-query input,
.advanced-field-boost input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}

.advanced-control input:focus,
.advanced-control select:focus,
.advanced-field-query input:focus,
.advanced-field-boost input:focus {
    border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 13%, transparent);
}

.advanced-control-wide {
    min-width: 0;
}

.advanced-field-table {
    display: grid;
    gap: 10px;
}

.advanced-field-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(110px, 150px);
    gap: 12px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--surface-soft);
}

.advanced-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 2px 0;
}

.advanced-actions .text-button {
    min-height: 42px;
    padding: 0 8px;
}

html[dir="rtl"] .advanced-page,
body[dir="rtl"] .advanced-page {
    direction: rtl;
}

@media (max-width: 860px) {
    .advanced-hero-panel,
    .advanced-main-grid,
    .advanced-heading-grid,
    .advanced-field-line {
        grid-template-columns: 1fr;
    }

    .advanced-panel-head {
        display: grid;
    }

    .advanced-note {
        flex: none;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .advanced-page {
        width: min(100% - 20px, var(--container));
    }

    .advanced-hero-copy,
    .advanced-info-pill,
    .advanced-panel {
        border-radius: 18px;
        padding: 16px;
    }

    .advanced-actions .primary-button,
    .advanced-actions .secondary-button {
        width: 100%;
    }
}

/* Combined H1-H6 search field and compact heading boost controls. */
.advanced-heading-grid {
    grid-template-columns: minmax(0, 1fr);
}

.advanced-heading-boosts {
    display: grid;
    grid-template-columns: repeat(6, minmax(82px, 1fr));
    gap: 10px;
    margin-top: 14px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--surface-soft);
}

.advanced-heading-boost {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.advanced-heading-boost span {
    color: var(--text-soft);
    font-size: 0.86rem;
    font-weight: 900;
    text-align: center;
}

.advanced-heading-boost input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
    text-align: center;
}

.advanced-heading-boost input:focus {
    border-color: color-mix(in srgb, var(--primary) 62%, var(--border));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 13%, transparent);
}

@media (max-width: 860px) {
    .advanced-heading-boosts {
        grid-template-columns: repeat(3, minmax(82px, 1fr));
    }
}

@media (max-width: 520px) {
    .advanced-heading-boosts {
        grid-template-columns: repeat(2, minmax(82px, 1fr));
    }
}

.theme-toggle-form {
    margin: 0;
    padding: 0;
    display: inline-flex;
}

.theme-toggle-form .theme-toggle {
    cursor: pointer;
    font: inherit;
}

/* Wikipedia result-style link presentation */
.wiki-info-title a {
    color: inherit;
    text-decoration: none;
}

.wiki-info-title a:hover,
.wiki-info-title a:focus-visible {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.wiki-info-url {
    margin-top: 10px;
    color: var(--success);
    font-size: 0.92rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.wiki-info-url a {
    color: inherit;
    text-decoration: none;
}

.wiki-info-url a:hover,
.wiki-info-url a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Combined Wikipedia result card */
.wiki-result-card {
    border-color: color-mix(in srgb, var(--primary) 18%, var(--border-soft));
}

.wiki-result-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
}

.result-url a {
    color: inherit;
    text-decoration: none;
}

.result-url a:hover,
.result-url a:focus-visible {
    text-decoration: underline;
}

@media (max-width: 760px) {
    .wiki-result-layout {
        grid-template-columns: 1fr;
    }
}

/* Full Wikipedia reader page */
.wiki-reader-page {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: 1.5rem;
}

.wiki-reader-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.wiki-reader-header {
    padding: 1.5rem 1.6rem 1.1rem;
    border-bottom: 1px solid var(--border-color, #d7dde8);
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.16), transparent);
}

.wiki-reader-header h1 {
    margin: 0.35rem 0 0.7rem;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.wiki-reader-source-url {
    margin-top: 0.65rem;
    overflow-wrap: anywhere;
}

.wiki-reader-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
    margin-top: 0.95rem;
}

.wiki-language-switcher {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1rem;
    font-size: 0.94rem;
}

.wiki-language-switcher strong {
    margin-inline-end: 0.2rem;
}

.wiki-language-switcher a {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 999px;
    padding: 0.28rem 0.62rem;
    text-decoration: none;
    background: rgba(148, 163, 184, 0.12);
}

.wiki-language-switcher a:hover,
.wiki-language-switcher a:focus-visible {
    text-decoration: underline;
}

.wiki-read-more {
    margin-top: 0.75rem;
}

.wiki-read-more-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 999px;
    padding: 0.4rem 0.75rem;
    text-decoration: none;
    font-weight: 700;
    background: rgba(148, 163, 184, 0.12);
}

.wiki-read-more-link:hover,
.wiki-read-more-link:focus-visible {
    text-decoration: underline;
}

.wiki-article-content {
    padding: 1.5rem 1.6rem 2rem;
    font-size: 1.02rem;
    line-height: 1.72;
    overflow-wrap: anywhere;
}

.wiki-article-content > :first-child {
    margin-top: 0;
}

.wiki-article-content h2,
.wiki-article-content h3,
.wiki-article-content h4 {
    line-height: 1.22;
    margin: 2rem 0 0.65rem;
    padding-top: 0.25rem;
}

.wiki-article-content h2 {
    border-bottom: 1px solid var(--border-color, #d7dde8);
    padding-bottom: 0.35rem;
    font-size: 1.65rem;
}

.wiki-article-content h3 {
    font-size: 1.32rem;
}

.wiki-article-content p {
    margin: 0.85rem 0;
}

.wiki-article-content a {
    overflow-wrap: anywhere;
}

.wiki-article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.wiki-article-content figure,
.wiki-article-content .thumb,
.wiki-article-content .tright,
.wiki-article-content .tleft {
    max-width: min(100%, 360px);
    margin: 0.8rem 0 1rem 1rem;
}

.wiki-article-content .tright,
.wiki-article-content .thumb.tright {
    float: right;
}

.wiki-article-content .tleft,
.wiki-article-content .thumb.tleft {
    float: left;
    margin: 0.8rem 1rem 1rem 0;
}

.wiki-article-content .thumbcaption,
.wiki-article-content figcaption {
    font-size: 0.86rem;
    color: var(--muted-text, #64748b);
    line-height: 1.45;
    margin-top: 0.35rem;
}

.wiki-article-content table {
    max-width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}

.wiki-article-content th,
.wiki-article-content td {
    border: 1px solid var(--border-color, #d7dde8);
    padding: 0.45rem 0.55rem;
    vertical-align: top;
}

.wiki-article-content .infobox {
    float: right;
    width: min(100%, 320px);
    margin: 0 0 1rem 1.2rem;
    font-size: 0.92rem;
    background: rgba(148, 163, 184, 0.08);
}

.wiki-article-content ul,
.wiki-article-content ol {
    padding-inline-start: 1.4rem;
}

.wiki-article-content::after {
    content: "";
    display: block;
    clear: both;
}

.theme-dark .wiki-reader-card {
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

@media (max-width: 760px) {
    .wiki-reader-page {
        padding: 0.85rem;
    }

    .wiki-reader-header,
    .wiki-article-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .wiki-article-content .infobox,
    .wiki-article-content .tright,
    .wiki-article-content .tleft,
    .wiki-article-content .thumb.tright,
    .wiki-article-content .thumb.tleft {
        float: none;
        width: 100%;
        max-width: 100%;
        margin: 1rem 0;
    }
}

/* Local Wikipedia JSON/XML article reader image strip */
.wiki-reader-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    padding: 0 1.6rem 1.25rem;
}

.wiki-reader-images figure {
    margin: 0;
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.08);
}

.wiki-reader-images img {
    display: block;
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.wiki-reader-images figcaption {
    padding: 0.45rem 0.55rem;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--muted-text, #64748b);
}

@media (max-width: 760px) {
    .wiki-reader-images {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .wiki-reader-images img {
        height: 120px;
    }
}

/* Wikipedia result actions */
.wiki-action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 0.75rem;
}

.wiki-action-row .result-url {
    margin-top: 0;
    min-width: min(100%, 260px);
    flex: 1 1 320px;
}

.wiki-action-row .wiki-read-more-link,
.wiki-action-row .result-more-button {
    min-height: 30px;
    white-space: nowrap;
}

.wiki-info-gallery a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.wiki-image-viewer {
    margin: 1rem 0 1.4rem;
    padding: 1rem;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: var(--surface-soft);
}

.wiki-image-viewer figure {
    margin: 0;
    text-align: center;
}

.wiki-image-viewer img {
    display: block;
    max-width: 100%;
    max-height: 72vh;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: 14px;
}

.wiki-image-viewer figcaption {
    margin-top: 0.65rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.wiki-image-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 0.85rem;
}

.wiki-image-controls a,
.wiki-image-controls span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
}

/* Space between the combined Wikipedia card and the normal Solr result list. */
.wiki-result-card + .results-list,
.wiki-result-card + .empty-state,
.wiki-result-card + .pagination-wrap {
    margin-top: 18px;
}

.wiki-result-card {
    margin-bottom: 18px;
}

/* POST-only internal wiki navigation */
.link-button,
.wiki-language-button,
.wiki-title-button,
.wiki-image-button,
.wiki-gallery-arrow {
    font: inherit;
    color: inherit;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.wiki-title-post-form {
    display: inline;
}

.wiki-title-button {
    color: var(--link-color, #2563eb);
    font-weight: 800;
    text-align: start;
    text-decoration: none;
}

.wiki-title-button:hover,
.wiki-title-button:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.wiki-read-more-link.link-button {
    color: var(--text-color, inherit);
}

.wiki-language-switcher form {
    display: inline-flex;
}

.wiki-language-button {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 999px;
    padding: 0.28rem 0.62rem;
    text-decoration: none;
    background: rgba(148, 163, 184, 0.12);
}

.wiki-language-button:hover,
.wiki-language-button:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.wiki-image-post-form {
    margin: 0;
}

.wiki-image-button {
    display: block;
    width: 100%;
    text-align: inherit;
}

.wiki-image-button img {
    transition: transform 160ms ease, filter 160ms ease;
}

.wiki-image-button:hover img,
.wiki-image-button:focus-visible img {
    transform: scale(1.015);
    filter: saturate(1.05);
}

.wiki-info-gallery .wiki-image-post-form,
.wiki-info-gallery .wiki-image-button {
    display: block;
    width: 100%;
    height: 100%;
}

/* Dedicated local Wikipedia image page */
.wiki-image-page {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: 1.5rem;
}

.wiki-image-card {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.wiki-image-header {
    padding: 1.5rem 1.6rem 1.1rem;
    border-bottom: 1px solid var(--border-color, #d7dde8);
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.16), transparent);
}

.wiki-image-header h1 {
    margin: 0.35rem 0 0.7rem;
    font-size: clamp(1.9rem, 3.6vw, 3.1rem);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.wiki-image-header-actions {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.wiki-image-viewer-standalone {
    margin: 1.2rem 1.4rem;
}

.wiki-image-controls form {
    display: inline-flex;
}

.wiki-image-controls button.wiki-gallery-arrow,
.wiki-gallery-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-height: 34px;
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    font-size: 1.45rem;
    line-height: 1;
}

.wiki-image-controls button.wiki-gallery-arrow:hover,
.wiki-image-controls button.wiki-gallery-arrow:focus-visible,
.wiki-gallery-arrow:hover,
.wiki-gallery-arrow:focus-visible {
    background: rgba(148, 163, 184, 0.24);
}

.wiki-image-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 0.75rem;
    padding: 0 1.4rem 1.4rem;
}

.wiki-image-strip .wiki-image-post-form {
    border: 1px solid var(--border-color, #d7dde8);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.08);
}

.wiki-image-strip .wiki-image-post-form.is-active {
    outline: 3px solid color-mix(in srgb, var(--primary, #2563eb) 55%, transparent);
    outline-offset: 2px;
}

.wiki-image-strip img {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
}

.theme-dark .wiki-image-card {
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

@media (max-width: 760px) {
    .wiki-image-page {
        padding: 0.85rem;
    }

    .wiki-image-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .wiki-image-viewer-standalone {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .wiki-image-strip {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .wiki-image-strip img {
        height: 92px;
    }
}


.wiki-main-image-post-form,
.wiki-main-image-post-form .wiki-image-button {
    display: block;
    width: 100%;
}

.wiki-content-image-post-form {
    display: inline-block;
    margin: 0.25rem 0;
    vertical-align: top;
}

.wiki-content-image-button {
    display: inline-block;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.wiki-content-image-button img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    transition: transform 160ms ease, filter 160ms ease;
}

.wiki-content-image-button:hover img,
.wiki-content-image-button:focus-visible img {
    transform: scale(1.01);
    filter: saturate(1.05);
}

.wiki-image-article-link {
    margin-top: 0.9rem;
    text-align: center;
}

/* Compact combined Wikipedia result card */
.wiki-result-card {
    margin-bottom: 22px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.wiki-result-layout {
    gap: 16px;
}

.wiki-source-line {
    gap: 6px;
    min-height: 22px;
    padding: 2px 8px;
    font-size: 0.74rem;
    line-height: 1.25;
    text-transform: none;
    letter-spacing: 0.01em;
}

.wiki-source-separator {
    color: var(--text-muted, #64748b);
    font-weight: 800;
}

.wiki-info-title {
    margin: 7px 0 6px;
    font-size: 1.28rem;
    line-height: 1.18;
}

.wiki-info-extract {
    line-height: 1.52;
    margin-bottom: 0;
}

.wiki-action-row {
    margin-top: 0.55rem;
    gap: 6px 10px;
}

.wiki-action-row .result-url {
    flex: 1 1 360px;
    font-size: 0.88rem;
    line-height: 1.35;
}

.wiki-action-row .wiki-read-more-link,
.wiki-action-row .result-more-button {
    min-height: 28px;
    padding: 0.22rem 0.55rem;
    font-size: 0.86rem;
    line-height: 1.2;
}

.wiki-read-more-link.link-button {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-soft, #d7dde8);
    border-radius: 999px;
    color: var(--primary, #2563eb);
    font-weight: 850;
    text-decoration: none;
}

.wiki-read-more-link.link-button:hover,
.wiki-read-more-link.link-button:focus-visible {
    background: color-mix(in srgb, var(--primary) 9%, transparent);
    text-decoration: none;
}

@media (max-width: 760px) {
    .wiki-result-card {
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .wiki-info-title {
        font-size: 1.14rem;
    }

    .wiki-action-row .result-url {
        flex-basis: 100%;
    }
}

/* Compact result URL row: URL and language on one line */
.result-url-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 5px;
}

.result-url-row .result-url {
    margin-top: 0;
    min-width: 0;
    flex: 1 1 auto;
}

.result-url-language {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 750;
}

.result-url-language::before {
    content: "·";
    margin-inline-end: 10px;
    color: var(--text-faint, var(--text-muted));
}


.result-file-chip {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.result-file-chip::before {
    content: "·";
    margin-inline-end: 8px;
    color: var(--text-faint, var(--text-muted));
    font-weight: 800;
}

.result-pdf-chip {
    color: var(--primary);
}

/* Make the Wikipedia read-more action use the same visual language as More from Wikipedia. */
.wiki-read-more-button.result-more-button {
    text-decoration: none;
}

.wiki-read-more-button.result-more-button:hover,
.wiki-read-more-button.result-more-button:focus-visible {
    text-decoration: none;
}

@media (max-width: 640px) {
    .result-url-row {
        align-items: flex-start;
    }

    .result-url-language::before {
        margin-inline-end: 8px;
    }
}

/* Compact result URL line: URL, language and domain expansion action stay together. */
.result-url-row {
    gap: 6px 8px;
}

.result-url-row .result-url {
    flex: 0 1 auto;
    max-width: 100%;
}

.result-url-row .language-chip,
.result-url-row .result-url-language {
    margin-inline-start: 0;
}

.result-url-action-form {
    display: inline-flex;
    align-items: center;
}

.result-url-more-button {
    min-height: 26px;
    padding: 3px 9px;
    font-size: 0.82rem;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .result-url-more-button {
        white-space: normal;
        text-align: start;
    }
}

/* WEBDEXY local Wikipedia article source line. */
.wiki-reader-source-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 7px;
    word-break: break-word;
}

.wiki-reader-source-line a {
    color: var(--success);
    text-decoration: none;
}

.wiki-reader-source-line a:hover,
.wiki-reader-source-line a:focus-visible {
    text-decoration: underline;
}

/* Wider local Wikipedia article layout. The article page should read closer to Wikipedia and avoid a large image strip above the text. */
.wiki-reader-page {
    width: min(100%, 1480px);
    padding: 1.2rem clamp(0.75rem, 2vw, 2rem);
}

.wiki-reader-card {
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.wiki-reader-header {
    padding: 1.15rem clamp(1rem, 2.2vw, 2rem) 0.95rem;
}

.wiki-reader-header h1 {
    font-size: clamp(2rem, 3vw, 3rem);
    letter-spacing: -0.025em;
}

.wiki-reader-image-link-row {
    padding: 0.9rem clamp(1rem, 2.2vw, 2rem) 0;
}

.wiki-reader-images-button {
    min-height: 32px;
}

.wiki-article-content {
    padding: 1.15rem clamp(1rem, 2.2vw, 2rem) 2.2rem;
    font-size: 1.03rem;
    line-height: 1.68;
}

@media (min-width: 1180px) {
    .wiki-article-content .infobox {
        width: min(34%, 390px);
    }

    .wiki-article-content figure,
    .wiki-article-content .thumb,
    .wiki-article-content .tright,
    .wiki-article-content .tleft {
        max-width: min(42%, 430px);
    }
}

/* Local POST navigation for internal Wikipedia article links. */
.wiki-inline-link-form {
    display: inline;
    margin: 0;
    padding: 0;
}

.wiki-inline-link-button {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--link-color, #2563eb);
    font: inherit;
    line-height: inherit;
    text-align: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wiki-inline-link-button:hover,
.wiki-inline-link-button:focus-visible {
    color: var(--link-hover-color, #1d4ed8);
}

/* Keep article images compact on WEBDEXY Wiki article pages.
   Large Wikipedia lead/infobox images should not dominate the top of the page;
   the full gallery belongs on wiki-image.php. */
.wiki-article-content .wiki-content-image-post-form {
    max-width: min(100%, 260px);
}

.wiki-article-content .wiki-content-image-button {
    max-width: 100%;
}

.wiki-article-content .wiki-content-image-button img {
    width: auto;
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
}

.wiki-article-content .infobox .wiki-content-image-post-form,
.wiki-article-content .thumb .wiki-content-image-post-form,
.wiki-article-content figure .wiki-content-image-post-form {
    max-width: min(100%, 220px);
}

.wiki-article-content .infobox .wiki-content-image-button img,
.wiki-article-content .thumb .wiki-content-image-button img,
.wiki-article-content figure .wiki-content-image-button img {
    max-height: 150px;
}

.wiki-article-content .infobox {
    width: min(100%, 300px);
}

@media (max-width: 760px) {
    .wiki-article-content .wiki-content-image-post-form,
    .wiki-article-content .infobox .wiki-content-image-post-form,
    .wiki-article-content .thumb .wiki-content-image-post-form,
    .wiki-article-content figure .wiki-content-image-post-form {
        max-width: min(100%, 220px);
    }

    .wiki-article-content .wiki-content-image-button img {
        max-height: 145px;
    }
}

/* WEBDEXY local Wikipedia image page article reference */
.wiki-image-article-reference-form {
    margin: 0 0 0.8rem;
}

.wiki-image-article-reference {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(120, 120, 120, 0.22);
    border-radius: 14px;
    background: rgba(120, 120, 120, 0.08);
    color: inherit;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
}

.wiki-image-article-reference:hover,
.wiki-image-article-reference:focus-visible {
    background: rgba(120, 120, 120, 0.14);
    outline: none;
}

.wiki-image-article-reference-label {
    font-weight: 700;
    margin-right: 0.25rem;
}

.wiki-image-article-reference-title {
    font-weight: 600;
}

.wiki-image-article-reference-url {
    display: block;
    margin-top: 0.25rem;
    overflow-wrap: anywhere;
    font-size: 0.92rem;
    opacity: 0.82;
}

/* Faster and cleaner dark presentation for local WEBDEXY Wiki pages. */
.theme-dark .wiki-reader-page,
.theme-dark .wiki-image-page {
    color: var(--text);
}

.theme-dark .wiki-reader-card,
.theme-dark .wiki-image-card {
    background: linear-gradient(180deg, rgba(21, 28, 44, 0.98), rgba(13, 19, 31, 0.98));
    border-color: rgba(125, 148, 180, 0.26);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.46);
}

.theme-dark .wiki-reader-header,
.theme-dark .wiki-image-header {
    background:
        linear-gradient(180deg, rgba(123, 167, 255, 0.13), rgba(21, 28, 44, 0.18)),
        rgba(15, 23, 42, 0.62);
    border-bottom-color: rgba(125, 148, 180, 0.22);
}

.theme-dark .wiki-reader-header h1,
.theme-dark .wiki-image-header h1 {
    color: #f8fbff;
}

.theme-dark .wiki-reader-source-line,
.theme-dark .wiki-reader-meta,
.theme-dark .wiki-image-article-reference-url,
.theme-dark .wiki-article-content .thumbcaption,
.theme-dark .wiki-article-content figcaption {
    color: #b9c6d8;
}

.theme-dark .wiki-reader-source-line a,
.theme-dark .wiki-image-article-reference-url,
.theme-dark .wiki-article-content a,
.theme-dark .wiki-inline-link-button {
    color: #a9c8ff;
}

.theme-dark .wiki-language-button,
.theme-dark .wiki-reader-images-button,
.theme-dark .wiki-image-article-reference,
.theme-dark .wiki-read-more-link {
    background: rgba(123, 167, 255, 0.12);
    border-color: rgba(123, 167, 255, 0.28);
    color: #dce8ff;
}

.theme-dark .wiki-language-button:hover,
.theme-dark .wiki-language-button:focus-visible,
.theme-dark .wiki-reader-images-button:hover,
.theme-dark .wiki-reader-images-button:focus-visible,
.theme-dark .wiki-image-article-reference:hover,
.theme-dark .wiki-image-article-reference:focus-visible,
.theme-dark .wiki-read-more-link:hover,
.theme-dark .wiki-read-more-link:focus-visible {
    background: rgba(123, 167, 255, 0.20);
    border-color: rgba(123, 167, 255, 0.42);
}

.theme-dark .wiki-article-content h2 {
    border-bottom-color: rgba(125, 148, 180, 0.26);
}

.theme-dark .wiki-article-content table,
.theme-dark .wiki-article-content .infobox,
.theme-dark .wiki-article-content figure,
.theme-dark .wiki-article-content .thumb {
    background: rgba(10, 15, 25, 0.36);
    border-color: rgba(125, 148, 180, 0.24);
}

.theme-dark .wiki-article-content th,
.theme-dark .wiki-article-content td {
    border-color: rgba(125, 148, 180, 0.24);
}

.theme-dark .wiki-article-content th {
    background: rgba(123, 167, 255, 0.10);
}

.theme-dark .wiki-content-image-button,
.theme-dark .wiki-image-button {
    background: rgba(10, 15, 25, 0.34);
    border-color: rgba(125, 148, 180, 0.22);
}

.theme-dark .wiki-image-viewer-standalone figure {
    background: rgba(10, 15, 25, 0.42);
    border-color: rgba(125, 148, 180, 0.24);
}

.theme-dark .wiki-image-strip .wiki-image-post-form.is-active {
    outline-color: rgba(155, 188, 255, 0.85);
}

/* Keep the local Wikipedia image page stable while images are changed in-place. */
.wiki-image-page .wiki-image-viewer-standalone {
    scroll-margin-top: 1rem;
}

.wiki-image-page .wiki-image-viewer-standalone figure {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: min(72vh, 720px);
}

.wiki-image-page .wiki-image-viewer-standalone img {
    object-fit: contain;
    max-height: min(64vh, 660px);
}

.wiki-image-page .wiki-image-viewer-standalone figcaption {
    min-height: 1.45em;
}

.wiki-image-page .wiki-image-controls {
    min-height: 42px;
}

.wiki-image-page .wiki-image-strip {
    scroll-margin-top: 1rem;
}

/* ------------------------------------------------------------
   WEBDEXY Wiki article page visual polish - light and dark mode
   ------------------------------------------------------------ */
.wiki-reader-page {
    width: min(100%, 1460px);
    padding: clamp(0.75rem, 1.8vw, 1.6rem);
}

.wiki-reader-card {
    border-radius: 16px;
    border-color: color-mix(in srgb, var(--border) 82%, transparent);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--surface) 94%, var(--primary-soft)), var(--surface) 18rem),
        var(--surface);
    box-shadow: 0 16px 46px rgba(15, 23, 42, 0.10);
}

.wiki-reader-header {
    display: grid;
    gap: 0.85rem;
    padding: clamp(1.05rem, 2vw, 1.65rem) clamp(1.05rem, 2.4vw, 2rem) clamp(0.95rem, 1.6vw, 1.25rem);
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--primary-soft) 72%, transparent), transparent 42%),
        linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 92%, var(--surface)), color-mix(in srgb, var(--surface) 98%, transparent));
}

.wiki-reader-header h1 {
    max-width: 1050px;
    margin: 0;
    font-size: clamp(2rem, 3.8vw, 4rem);
    line-height: 1.04;
    letter-spacing: -0.045em;
    color: var(--text);
}

.wiki-reader-source-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    max-width: 100%;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.35;
}

.wiki-reader-source-line a {
    max-width: min(100%, 980px);
    overflow-wrap: anywhere;
    color: var(--link);
    text-decoration: none;
}

.wiki-reader-source-line a:hover,
.wiki-reader-source-line a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.wiki-reader-meta {
    margin-top: 0;
    gap: 0.5rem 0.75rem;
}

.wiki-reader-meta .meta-chip,
.wiki-reader-images-button,
.wiki-language-button,
.wiki-read-more-link {
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
    background: color-mix(in srgb, var(--surface) 90%, var(--primary-soft));
    color: var(--text-soft);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.wiki-reader-meta .text-link-button {
    min-height: 32px;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    background: color-mix(in srgb, var(--surface) 92%, var(--surface-muted));
    color: var(--text-soft);
    text-decoration: none;
}

.wiki-reader-meta .text-link-button:hover,
.wiki-reader-meta .text-link-button:focus-visible {
    background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface));
    color: var(--link);
}

.wiki-language-switcher {
    align-items: center;
    gap: 0.42rem;
    margin-top: 0.05rem;
    padding-top: 0.65rem;
    border-top: 1px solid color-mix(in srgb, var(--border-soft) 90%, transparent);
}

.wiki-language-switcher strong {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.wiki-language-button {
    min-height: 30px;
    padding: 0.28rem 0.68rem;
    color: var(--link);
    font-size: 0.9rem;
    font-weight: 650;
}

.wiki-language-button:hover,
.wiki-language-button:focus-visible,
.wiki-reader-images-button:hover,
.wiki-reader-images-button:focus-visible {
    background: color-mix(in srgb, var(--primary-soft) 82%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
    text-decoration: none;
}

.wiki-reader-image-link-row {
    padding: 0.85rem clamp(1.05rem, 2.4vw, 2rem);
    border-bottom: 1px solid color-mix(in srgb, var(--border-soft) 92%, transparent);
    background: color-mix(in srgb, var(--surface-soft) 68%, var(--surface));
}

.wiki-reader-images-button {
    min-height: 34px;
    padding: 0.36rem 0.82rem;
    color: var(--link);
    font-weight: 750;
}

.wiki-article-content {
    padding: clamp(1.1rem, 2.2vw, 2rem) clamp(1.05rem, 2.8vw, 2.35rem) clamp(1.6rem, 3vw, 2.6rem);
    font-size: clamp(1rem, 0.33vw + 0.96rem, 1.12rem);
    line-height: 1.74;
    color: var(--text);
}

.wiki-article-content p {
    max-width: 940px;
    margin: 0.78rem 0;
}

.wiki-article-content h2,
.wiki-article-content h3,
.wiki-article-content h4 {
    max-width: 980px;
    color: var(--text);
    scroll-margin-top: 1.25rem;
}

.wiki-article-content h2 {
    margin-top: 2.25rem;
    padding-bottom: 0.42rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    font-size: clamp(1.45rem, 1.1vw + 1.1rem, 2rem);
    letter-spacing: -0.02em;
}

.wiki-article-content h3 {
    margin-top: 1.6rem;
    font-size: clamp(1.2rem, 0.65vw + 1rem, 1.48rem);
}

.wiki-article-content a,
.wiki-inline-link-button {
    color: var(--link);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 2px;
}

.wiki-article-content a:hover,
.wiki-article-content a:focus-visible,
.wiki-inline-link-button:hover,
.wiki-inline-link-button:focus-visible {
    color: var(--link-hover);
}

.wiki-article-content .infobox,
.wiki-article-content table,
.wiki-article-content figure,
.wiki-article-content .thumb {
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-soft) 88%, var(--surface));
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.055);
}

.wiki-article-content .infobox {
    width: min(100%, 330px);
    margin: 0.1rem 0 1.1rem 1.4rem;
    padding: 0.45rem;
    font-size: 0.9rem;
    line-height: 1.45;
}

.wiki-article-content table:not(.infobox) {
    width: auto;
    max-width: 100%;
    margin: 1.1rem 0;
    border-radius: 12px;
}

.wiki-article-content th,
.wiki-article-content td {
    padding: 0.5rem 0.62rem;
    border-color: color-mix(in srgb, var(--border) 84%, transparent);
}

.wiki-article-content th {
    background: color-mix(in srgb, var(--surface-muted) 74%, var(--surface));
    color: var(--text-soft);
}

.wiki-article-content .thumbcaption,
.wiki-article-content figcaption {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.wiki-content-image-button img,
.wiki-article-content img {
    border: 1px solid color-mix(in srgb, var(--border-soft) 86%, transparent);
    background: var(--surface);
}

.wiki-content-image-button:hover img,
.wiki-content-image-button:focus-visible img {
    transform: translateY(-1px) scale(1.012);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.14);
}

/* Dark-mode tuning for the local wiki reader. */
body.theme-dark .wiki-reader-card,
html.theme-dark .wiki-reader-card {
    background:
        linear-gradient(180deg, rgba(20, 31, 52, 0.98), rgba(13, 19, 31, 0.995) 18rem),
        var(--surface);
    border-color: rgba(132, 154, 187, 0.24);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.48);
}

body.theme-dark .wiki-reader-header,
html.theme-dark .wiki-reader-header {
    background:
        radial-gradient(circle at top left, rgba(123, 167, 255, 0.18), transparent 45%),
        linear-gradient(180deg, rgba(22, 34, 57, 0.96), rgba(14, 21, 35, 0.88));
    border-bottom-color: rgba(132, 154, 187, 0.22);
}

body.theme-dark .wiki-reader-header h1,
html.theme-dark .wiki-reader-header h1,
body.theme-dark .wiki-article-content h2,
html.theme-dark .wiki-article-content h2,
body.theme-dark .wiki-article-content h3,
html.theme-dark .wiki-article-content h3,
body.theme-dark .wiki-article-content h4,
html.theme-dark .wiki-article-content h4 {
    color: #f7fbff;
}

body.theme-dark .wiki-reader-source-line,
html.theme-dark .wiki-reader-source-line,
body.theme-dark .wiki-language-switcher strong,
html.theme-dark .wiki-language-switcher strong,
body.theme-dark .wiki-article-content .thumbcaption,
html.theme-dark .wiki-article-content .thumbcaption,
body.theme-dark .wiki-article-content figcaption,
html.theme-dark .wiki-article-content figcaption {
    color: #aebbd0;
}

body.theme-dark .wiki-reader-source-line a,
html.theme-dark .wiki-reader-source-line a,
body.theme-dark .wiki-article-content a,
html.theme-dark .wiki-article-content a,
body.theme-dark .wiki-inline-link-button,
html.theme-dark .wiki-inline-link-button {
    color: #a9c8ff;
}

body.theme-dark .wiki-article-content a:hover,
html.theme-dark .wiki-article-content a:hover,
body.theme-dark .wiki-inline-link-button:hover,
html.theme-dark .wiki-inline-link-button:hover {
    color: #d3e2ff;
}

body.theme-dark .wiki-reader-meta .meta-chip,
html.theme-dark .wiki-reader-meta .meta-chip,
body.theme-dark .wiki-language-button,
html.theme-dark .wiki-language-button,
body.theme-dark .wiki-reader-images-button,
html.theme-dark .wiki-reader-images-button,
body.theme-dark .wiki-reader-meta .text-link-button,
html.theme-dark .wiki-reader-meta .text-link-button {
    background: rgba(123, 167, 255, 0.12);
    border-color: rgba(123, 167, 255, 0.26);
    color: #dce8ff;
}

body.theme-dark .wiki-language-button:hover,
html.theme-dark .wiki-language-button:hover,
body.theme-dark .wiki-reader-images-button:hover,
html.theme-dark .wiki-reader-images-button:hover,
body.theme-dark .wiki-reader-meta .text-link-button:hover,
html.theme-dark .wiki-reader-meta .text-link-button:hover {
    background: rgba(123, 167, 255, 0.20);
    border-color: rgba(123, 167, 255, 0.42);
}

body.theme-dark .wiki-reader-image-link-row,
html.theme-dark .wiki-reader-image-link-row {
    background: rgba(10, 15, 25, 0.36);
    border-bottom-color: rgba(132, 154, 187, 0.18);
}

body.theme-dark .wiki-article-content .infobox,
html.theme-dark .wiki-article-content .infobox,
body.theme-dark .wiki-article-content table,
html.theme-dark .wiki-article-content table,
body.theme-dark .wiki-article-content figure,
html.theme-dark .wiki-article-content figure,
body.theme-dark .wiki-article-content .thumb,
html.theme-dark .wiki-article-content .thumb {
    background: rgba(10, 15, 25, 0.46);
    border-color: rgba(132, 154, 187, 0.22);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

body.theme-dark .wiki-article-content th,
html.theme-dark .wiki-article-content th {
    background: rgba(123, 167, 255, 0.11);
    color: #dbe6f8;
}

body.theme-dark .wiki-article-content th,
html.theme-dark .wiki-article-content th,
body.theme-dark .wiki-article-content td,
html.theme-dark .wiki-article-content td {
    border-color: rgba(132, 154, 187, 0.24);
}

body.theme-dark .wiki-content-image-button img,
html.theme-dark .wiki-content-image-button img,
body.theme-dark .wiki-article-content img,
html.theme-dark .wiki-article-content img {
    border-color: rgba(132, 154, 187, 0.20);
    background: rgba(10, 15, 25, 0.52);
}

@media (min-width: 1180px) {
    .wiki-article-content .infobox {
        width: min(34vw, 360px);
    }

    .wiki-article-content figure,
    .wiki-article-content .thumb,
    .wiki-article-content .tright,
    .wiki-article-content .tleft {
        max-width: min(34vw, 430px);
    }
}

@media (max-width: 860px) {
    .wiki-reader-page {
        padding: 0.65rem;
    }

    .wiki-reader-card {
        border-radius: 13px;
    }

    .wiki-reader-header,
    .wiki-article-content,
    .wiki-reader-image-link-row {
        padding-left: 0.95rem;
        padding-right: 0.95rem;
    }

    .wiki-reader-header h1 {
        font-size: clamp(1.85rem, 9vw, 2.65rem);
    }

    .wiki-reader-meta,
    .wiki-language-switcher {
        gap: 0.42rem;
    }

    .wiki-article-content p,
    .wiki-article-content h2,
    .wiki-article-content h3,
    .wiki-article-content h4 {
        max-width: 100%;
    }

    .wiki-article-content .infobox,
    .wiki-article-content .tright,
    .wiki-article-content .tleft,
    .wiki-article-content .thumb.tright,
    .wiki-article-content .thumb.tleft {
        float: none;
        width: 100%;
        max-width: 100%;
        margin: 1rem 0;
    }
}

/* ------------------------------------------------------------
   Fix unreadable Wikipedia article text in dark mode.
   Wikipedia HTML often ships old classes and inline colors/backgrounds.
   These overrides keep local WEBDEXY wiki pages readable.
   ------------------------------------------------------------ */
html.theme-dark .wiki-reader-page,
body.theme-dark .wiki-reader-page,
html.theme-dark .wiki-article-content,
body.theme-dark .wiki-article-content,
html.theme-dark .wiki-article-content p,
body.theme-dark .wiki-article-content p,
html.theme-dark .wiki-article-content li,
body.theme-dark .wiki-article-content li,
html.theme-dark .wiki-article-content dd,
body.theme-dark .wiki-article-content dd,
html.theme-dark .wiki-article-content dt,
body.theme-dark .wiki-article-content dt,
html.theme-dark .wiki-article-content blockquote,
body.theme-dark .wiki-article-content blockquote,
html.theme-dark .wiki-article-content div,
body.theme-dark .wiki-article-content div,
html.theme-dark .wiki-article-content span,
body.theme-dark .wiki-article-content span {
    color: #e8eef8 !important;
}

html.theme-dark .wiki-article-content small,
body.theme-dark .wiki-article-content small,
html.theme-dark .wiki-article-content .reference,
body.theme-dark .wiki-article-content .reference,
html.theme-dark .wiki-article-content .mw-editsection,
body.theme-dark .wiki-article-content .mw-editsection,
html.theme-dark .wiki-article-content .noprint,
body.theme-dark .wiki-article-content .noprint,
html.theme-dark .wiki-article-content .hatnote,
body.theme-dark .wiki-article-content .hatnote,
html.theme-dark .wiki-article-content .thumbcaption,
body.theme-dark .wiki-article-content .thumbcaption,
html.theme-dark .wiki-article-content figcaption,
body.theme-dark .wiki-article-content figcaption {
    color: #b8c4d6 !important;
}

html.theme-dark .wiki-article-content a,
body.theme-dark .wiki-article-content a,
html.theme-dark .wiki-article-content a:visited,
body.theme-dark .wiki-article-content a:visited,
html.theme-dark .wiki-inline-link-button,
body.theme-dark .wiki-inline-link-button {
    color: #9fc4ff !important;
}

html.theme-dark .wiki-article-content a:hover,
body.theme-dark .wiki-article-content a:hover,
html.theme-dark .wiki-inline-link-button:hover,
body.theme-dark .wiki-inline-link-button:hover {
    color: #d7e6ff !important;
}

html.theme-dark .wiki-article-content table,
body.theme-dark .wiki-article-content table,
html.theme-dark .wiki-article-content .infobox,
body.theme-dark .wiki-article-content .infobox,
html.theme-dark .wiki-article-content .wikitable,
body.theme-dark .wiki-article-content .wikitable,
html.theme-dark .wiki-article-content .toc,
body.theme-dark .wiki-article-content .toc,
html.theme-dark .wiki-article-content .navbox,
body.theme-dark .wiki-article-content .navbox,
html.theme-dark .wiki-article-content .sidebar,
body.theme-dark .wiki-article-content .sidebar,
html.theme-dark .wiki-article-content .thumb,
body.theme-dark .wiki-article-content .thumb,
html.theme-dark .wiki-article-content figure,
body.theme-dark .wiki-article-content figure,
html.theme-dark .wiki-article-content [style*="background"],
body.theme-dark .wiki-article-content [style*="background"] {
    background-color: #101827 !important;
    background-image: none !important;
    color: #e8eef8 !important;
    border-color: rgba(148, 163, 184, 0.34) !important;
}

html.theme-dark .wiki-article-content th,
body.theme-dark .wiki-article-content th,
html.theme-dark .wiki-article-content .infobox th,
body.theme-dark .wiki-article-content .infobox th,
html.theme-dark .wiki-article-content .wikitable th,
body.theme-dark .wiki-article-content .wikitable th {
    background-color: #17243a !important;
    color: #f4f8ff !important;
    border-color: rgba(148, 163, 184, 0.38) !important;
}

html.theme-dark .wiki-article-content td,
body.theme-dark .wiki-article-content td,
html.theme-dark .wiki-article-content .infobox td,
body.theme-dark .wiki-article-content .infobox td,
html.theme-dark .wiki-article-content .wikitable td,
body.theme-dark .wiki-article-content .wikitable td {
    color: #e8eef8 !important;
    border-color: rgba(148, 163, 184, 0.30) !important;
}

html.theme-dark .wiki-article-content code,
body.theme-dark .wiki-article-content code,
html.theme-dark .wiki-article-content pre,
body.theme-dark .wiki-article-content pre {
    background: #0b1220 !important;
    color: #f4f8ff !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
}

html.theme-dark .wiki-article-content .mw-parser-output .plainlinks,
body.theme-dark .wiki-article-content .mw-parser-output .plainlinks,
html.theme-dark .wiki-article-content .mw-parser-output,
body.theme-dark .wiki-article-content .mw-parser-output {
    color: #e8eef8 !important;
}

html.theme-dark .wiki-article-content hr,
body.theme-dark .wiki-article-content hr {
    border-color: rgba(148, 163, 184, 0.30) !important;
}


/* Compact Wikipedia language selector */
.wiki-language-select-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-color, #d7dee8);
    border-radius: 0.85rem;
    background: var(--surface-muted, #f6f8fb);
}

.wiki-language-select-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-muted, #506070);
}

.wiki-language-select {
    min-width: 11rem;
    max-width: min(100%, 20rem);
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border-color, #cfd8e3);
    border-radius: 0.7rem;
    background: var(--surface, #ffffff);
    color: var(--text-color, #16202a);
    font: inherit;
}

.wiki-language-select-button {
    border: 1px solid var(--accent-color, #2563eb);
    border-radius: 999px;
    background: var(--accent-color, #2563eb);
    color: #fff;
    padding: 0.42rem 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.wiki-language-select-button:hover,
.wiki-language-select-button:focus-visible {
    filter: brightness(1.05);
}

body.dark-mode .wiki-language-select-form,
html.dark-mode .wiki-language-select-form,
[data-theme="dark"] .wiki-language-select-form {
    border-color: #334155;
    background: #111827;
}

body.dark-mode .wiki-language-select-label,
html.dark-mode .wiki-language-select-label,
[data-theme="dark"] .wiki-language-select-label {
    color: #d1d5db;
}

body.dark-mode .wiki-language-select,
html.dark-mode .wiki-language-select,
[data-theme="dark"] .wiki-language-select {
    border-color: #475569;
    background: #0f172a;
    color: #f8fafc;
}

/* WEBDEXY Wiki: force language switcher into one compact selectable row */
.wiki-reader-header .wiki-language-select-form {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 720px !important;
    margin: 0.65rem 0 0 !important;
    padding: 0.42rem 0.55rem !important;
    gap: 0.45rem !important;
    overflow: hidden !important;
}

.wiki-reader-header .wiki-language-select-label {
    flex: 0 0 auto !important;
    margin: 0 !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

.wiki-reader-header .wiki-language-select {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 2.35rem !important;
    padding: 0.35rem 2rem 0.35rem 0.65rem !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
}

.wiki-reader-header .wiki-language-select-button {
    flex: 0 0 auto !important;
    min-height: 2.35rem !important;
    padding: 0.35rem 0.75rem !important;
    white-space: nowrap !important;
}

.wiki-reader-header .wiki-language-switcher,
.wiki-reader-header .wiki-language-button {
    display: none !important;
}

@media (max-width: 520px) {
    .wiki-reader-header .wiki-language-select-form {
        max-width: 100% !important;
        gap: 0.35rem !important;
        padding: 0.38rem 0.45rem !important;
    }

    .wiki-reader-header .wiki-language-select-label {
        font-size: 0.78rem !important;
    }

    .wiki-reader-header .wiki-language-select-button {
        padding-inline: 0.6rem !important;
    }
}


/* WEBDEXY v105: robust local Wikipedia reader dark mode fix */
html.theme-dark .wiki-reader-page,
body.theme-dark .wiki-reader-page,
html.theme-dark .wiki-reader-card,
body.theme-dark .wiki-reader-card,
html.theme-dark .wiki-reader-header,
body.theme-dark .wiki-reader-header,
html.theme-dark .wiki-article-content,
body.theme-dark .wiki-article-content,
html[data-effective-theme="dark"] .wiki-reader-page,
body[data-effective-theme="dark"] .wiki-reader-page,
html[data-effective-theme="dark"] .wiki-reader-card,
body[data-effective-theme="dark"] .wiki-reader-card,
html[data-effective-theme="dark"] .wiki-reader-header,
body[data-effective-theme="dark"] .wiki-reader-header,
html[data-effective-theme="dark"] .wiki-article-content,
body[data-effective-theme="dark"] .wiki-article-content {
    background: #0f172a !important;
    background-color: #0f172a !important;
    color: #e5edf8 !important;
    border-color: #334155 !important;
}

html.theme-dark .wiki-article-content *:not(img):not(svg):not(path),
body.theme-dark .wiki-article-content *:not(img):not(svg):not(path),
html[data-effective-theme="dark"] .wiki-article-content *:not(img):not(svg):not(path),
body[data-effective-theme="dark"] .wiki-article-content *:not(img):not(svg):not(path) {
    background-image: none !important;
    color: inherit;
    border-color: rgba(148, 163, 184, 0.35) !important;
}

html.theme-dark .wiki-article-content .mw-parser-output,
body.theme-dark .wiki-article-content .mw-parser-output,
html.theme-dark .wiki-article-content .infobox,
body.theme-dark .wiki-article-content .infobox,
html.theme-dark .wiki-article-content .wikitable,
body.theme-dark .wiki-article-content .wikitable,
html.theme-dark .wiki-article-content table,
body.theme-dark .wiki-article-content table,
html.theme-dark .wiki-article-content figure,
body.theme-dark .wiki-article-content figure,
html.theme-dark .wiki-article-content .thumb,
body.theme-dark .wiki-article-content .thumb,
html[data-effective-theme="dark"] .wiki-article-content .mw-parser-output,
body[data-effective-theme="dark"] .wiki-article-content .mw-parser-output,
html[data-effective-theme="dark"] .wiki-article-content .infobox,
body[data-effective-theme="dark"] .wiki-article-content .infobox,
html[data-effective-theme="dark"] .wiki-article-content .wikitable,
body[data-effective-theme="dark"] .wiki-article-content .wikitable,
html[data-effective-theme="dark"] .wiki-article-content table,
body[data-effective-theme="dark"] .wiki-article-content table,
html[data-effective-theme="dark"] .wiki-article-content figure,
body[data-effective-theme="dark"] .wiki-article-content figure,
html[data-effective-theme="dark"] .wiki-article-content .thumb,
body[data-effective-theme="dark"] .wiki-article-content .thumb {
    background: #111827 !important;
    background-color: #111827 !important;
    color: #e5edf8 !important;
}

html.theme-dark .wiki-article-content th,
body.theme-dark .wiki-article-content th,
html[data-effective-theme="dark"] .wiki-article-content th,
body[data-effective-theme="dark"] .wiki-article-content th {
    background: #1e293b !important;
    background-color: #1e293b !important;
    color: #f8fafc !important;
}

html.theme-dark .wiki-article-content td,
body.theme-dark .wiki-article-content td,
html[data-effective-theme="dark"] .wiki-article-content td,
body[data-effective-theme="dark"] .wiki-article-content td {
    background: #0f172a !important;
    background-color: #0f172a !important;
    color: #e5edf8 !important;
}

html.theme-dark .wiki-article-content a,
body.theme-dark .wiki-article-content a,
html.theme-dark .wiki-article-content a:visited,
body.theme-dark .wiki-article-content a:visited,
html.theme-dark .wiki-inline-link-button,
body.theme-dark .wiki-inline-link-button,
html[data-effective-theme="dark"] .wiki-article-content a,
body[data-effective-theme="dark"] .wiki-article-content a,
html[data-effective-theme="dark"] .wiki-article-content a:visited,
body[data-effective-theme="dark"] .wiki-article-content a:visited,
html[data-effective-theme="dark"] .wiki-inline-link-button,
body[data-effective-theme="dark"] .wiki-inline-link-button {
    color: #93c5fd !important;
}

html.theme-dark .wiki-language-select-form,
body.theme-dark .wiki-language-select-form,
html[data-effective-theme="dark"] .wiki-language-select-form,
body[data-effective-theme="dark"] .wiki-language-select-form {
    background: #111827 !important;
    border-color: #334155 !important;
}

html.theme-dark .wiki-language-select,
body.theme-dark .wiki-language-select,
html[data-effective-theme="dark"] .wiki-language-select,
body[data-effective-theme="dark"] .wiki-language-select {
    background: #0f172a !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

/* Keep the Wikipedia result language chip in the action row next to the buttons. */
.wiki-action-row .wiki-action-language {
    margin-inline-start: 0;
    min-height: 28px;
    padding: 0.22rem 0.65rem;
    font-size: 0.86rem;
    line-height: 1.2;
}

/* v107: Keep the Wikipedia info-box language chip compact beside the action buttons. */
.wiki-action-row {
    align-items: center;
    gap: 6px 8px;
}

.wiki-action-row .inline-post-form {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.wiki-action-row .wiki-action-language {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    margin-inline-start: 0 !important;
    white-space: nowrap;
}

.wiki-action-row .wiki-info-url {
    min-width: 0;
    flex: 1 1 260px;
    max-width: 100%;
}

@media (max-width: 640px) {
    .wiki-action-row .wiki-info-url {
        flex-basis: 100%;
    }

    .wiki-action-row .inline-post-form,
    .wiki-action-row .wiki-action-language {
        flex: 0 0 auto;
    }
}


/* WEBDEXY v108: keep the source URL on the local Wikipedia reader readable.
   The generic wiki-info-label badge uses uppercase, but URLs must preserve their real case. */
.wiki-reader-card .wiki-reader-source-line,
.wiki-reader-card .wiki-reader-source-line span,
.wiki-reader-card .wiki-reader-source-line a {
    text-transform: none !important;
    letter-spacing: normal;
}

.wiki-reader-card .wiki-reader-source-line {
    padding: 0;
    border-radius: 0;
    background: transparent;
    font-weight: 650;
}

/* WEBDEXY v109: force readable source URLs and keep the wiki language selector in the action row. */
.wiki-reader-source-line,
.wiki-reader-source-line *,
.wiki-reader-source-url-link,
.wiki-image-article-reference-url {
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wiki-reader-meta .wiki-language-select-form-inline {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.wiki-reader-meta .wiki-language-select-label {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 650;
}

.wiki-reader-meta .wiki-language-select {
    min-height: 32px;
    max-width: 145px;
    border-radius: 999px;
    padding: 0.22rem 1.8rem 0.22rem 0.7rem;
    font-size: 0.9rem;
}

.wiki-reader-meta .wiki-language-select-button {
    min-height: 32px;
    border-radius: 999px;
    padding: 0.28rem 0.72rem;
}

.wiki-article-content a:has(img),
.wiki-article-content .wiki-content-image-button {
    cursor: zoom-in;
}


/* WEBDEXY v110: Wikipedia reader image clicks use JS buttons, not nested forms. */
.wiki-content-image-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: zoom-in;
    appearance: none;
}

.wiki-content-image-button img {
    display: block;
    max-width: 100%;
    height: auto;
}

.wiki-reader-source-url-link,
.wiki-image-article-reference-url {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
    overflow-wrap: anywhere;
}


/* WEBDEXY v111: source URLs and article image links. */
.wiki-reader-source-url-link,
.wiki-reader-source-url-link *,
.wiki-reader-source-url-text {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
    overflow-wrap: anywhere;
    white-space: normal;
}

.wiki-content-image-link {
    display: inline-block;
    max-width: 100%;
    color: inherit;
    text-decoration: none;
    cursor: zoom-in;
}

.wiki-content-image-link img {
    cursor: zoom-in;
}


/* WEBDEXY v112: In the Wikipedia info box, keep language beside the action buttons.
   The source URL belongs below the buttons, not in the first action line. */
.wiki-result-card .wiki-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
}

.wiki-result-card .wiki-action-row .inline-post-form,
.wiki-result-card .wiki-action-row .wiki-action-language {
    order: 1;
    flex: 0 0 auto;
}

.wiki-result-card .wiki-action-row .wiki-info-url {
    order: 2;
    flex: 0 0 100%;
    margin-top: 2px;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wiki-result-card .wiki-action-row .wiki-info-url a {
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wiki-article-content a.wiki-content-image-link,
.wiki-article-content a.wiki-content-image-link:visited {
    display: inline-block;
    cursor: zoom-in;
    text-decoration: none !important;
}

/* WEBDEXY v112: Never uppercase readable Wikipedia source URLs. */
.wiki-reader-source-line,
.wiki-reader-source-line *,
.wiki-image-source-line,
.wiki-image-source-line *,
.wiki-reader-source-url-link,
.wiki-reader-source-url-link *,
.wiki-reader-source-url-text,
.wiki-image-source-url-link,
.wiki-image-source-url-link *,
.wiki-image-source-url-text {
    text-transform: none !important;
    letter-spacing: normal !important;
}


/* WEBDEXY v113 hard fixes: compact wiki info actions, readable source URLs and reliable image-link cursor. */
.wiki-result-card .wiki-action-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px 8px !important;
}

.wiki-result-card .wiki-action-row .inline-post-form,
.wiki-result-card .wiki-action-row .wiki-action-language,
.wiki-result-card .wiki-action-row .language-chip {
    order: 1 !important;
    flex: 0 0 auto !important;
    margin-inline-start: 0 !important;
    margin-left: 0 !important;
    width: auto !important;
    max-width: max-content !important;
}

.wiki-result-card .wiki-info-source-url,
.wiki-result-card .wiki-info-url {
    display: block !important;
    margin-top: 6px !important;
    color: var(--success) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wiki-source-readable-link,
.wiki-source-readable-link *,
.wiki-source-readable-code,
.wiki-reader-source-line,
.wiki-reader-source-line *,
.wiki-reader-source-url-link,
.wiki-reader-source-url-link *,
.wiki-reader-source-url-text,
.wiki-image-article-reference-url,
.wiki-image-article-reference-url * {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
}

.wiki-article-content img,
.wiki-article-content a:has(img),
.wiki-article-content .wiki-content-image-link {
    cursor: zoom-in !important;
}


/* WEBDEXY v114 hard override: index wiki action row must stay on one visual row. */
.wiki-actions-force-inline {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px 8px !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
}
.wiki-actions-force-inline .inline-post-form,
.wiki-actions-force-inline .wiki-action-language,
.wiki-actions-force-inline .language-chip {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    white-space: nowrap !important;
}
.wiki-source-force-readable,
.wiki-source-force-readable *,
.wiki-reader-source-url-link,
.wiki-reader-source-url-link *,
.wiki-reader-source-url-text {
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
}
.wiki-article-content a[data-webdexy-image-link="v114"] {
    cursor: zoom-in !important;
}


/* WEBDEXY v116: make the Wikipedia infobox visually match normal result cards except for the image. */
.wiki-result-card {
    border-color: var(--border-soft) !important;
    background: var(--surface) !important;
    box-shadow: var(--shadow-xs) !important;
}

.wiki-result-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--primary) 28%, var(--border)) !important;
    box-shadow: var(--shadow-sm) !important;
}

.wiki-result-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
}

.wiki-result-card .wiki-info-title,
.wiki-result-card .result-title.wiki-info-title {
    margin: 0 !important;
    font-size: 1.18rem !important;
    line-height: 1.32 !important;
    font-weight: 900 !important;
    letter-spacing: 0 !important;
}

.wiki-result-card .wiki-title-button {
    color: var(--link) !important;
    font-weight: 900 !important;
    line-height: inherit !important;
    text-align: start !important;
}

.wiki-result-card .wiki-title-button:hover,
.wiki-result-card .wiki-title-button:focus-visible {
    color: var(--link-hover) !important;
    text-decoration: underline !important;
}

.wiki-result-card .wiki-info-extract {
    margin: 10px 0 0 !important;
    color: var(--text-soft) !important;
    font-size: 0.98rem !important;
    line-height: 1.62 !important;
}

.wiki-result-card .wiki-result-url-row {
    display: flex !important;
    align-items: baseline !important;
    flex-wrap: wrap !important;
    gap: 6px 8px !important;
    margin-top: 5px !important;
}

.wiki-result-card .wiki-info-url,
.wiki-result-card .wiki-info-source-url {
    margin-top: 0 !important;
    color: var(--success) !important;
    font-size: 0.92rem !important;
    line-height: inherit !important;
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
}

.wiki-result-card .wiki-source-readable-link,
.wiki-result-card .wiki-source-readable-text {
    color: inherit !important;
    font: inherit !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-variant: normal !important;
}

.wiki-result-card .wiki-source-readable-link:hover,
.wiki-result-card .wiki-source-readable-link:focus-visible {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
}

.wiki-result-card .wiki-action-language {
    margin-inline-start: 0 !important;
}

.wiki-result-card .wiki-result-meta {
    margin-top: 13px !important;
}

.wiki-result-card .wiki-info-image {
    width: 124px !important;
}

.wiki-result-card .wiki-gallery-frame {
    width: 124px !important;
    min-height: 96px !important;
}

.wiki-result-card .wiki-gallery-slide img {
    width: 124px !important;
    height: 96px !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}

@media (max-width: 720px) {
    .wiki-result-layout {
        grid-template-columns: 1fr !important;
    }

    .wiki-result-card .wiki-info-image,
    .wiki-result-card .wiki-gallery-frame,
    .wiki-result-card .wiki-gallery-slide img {
        width: 100% !important;
    }

    .wiki-result-card .wiki-gallery-slide img {
        height: auto !important;
        max-height: 220px !important;
        object-fit: contain !important;
    }
}

.page-arrow {
    min-width: 42px;
    font-size: 1.35rem;
    line-height: 1;
}

/* Compact long result URLs without changing the real target href. */
.result-url {
    word-break: normal;
    overflow-wrap: anywhere;
}

.result-url a {
    display: inline;
}

.result-url-root-domain {
    font-weight: 950;
    color: color-mix(in srgb, var(--success) 72%, var(--text));
}

.result-url-protocol,
.result-url-host,
.result-url-path {
    overflow-wrap: anywhere;
}

.result-url-path {
    color: color-mix(in srgb, var(--success) 82%, var(--text-muted));
}


/* Keep protocol and host visible; only the path may wrap on narrow screens. */
.result-url-protocol,
.result-url-host {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}

.result-url-path {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.result-url-more-button {
    white-space: nowrap;
}

/* v210: user-facing search hints use one yellow notice style. */
.notice-box.search-fallback-notice,
.notice-box.search-notice-box,
.notice-box:not(.error-box):not(.wiki-reader-not-found) {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.notice-box.search-fallback-notice p,
.notice-box.search-notice-box p,
.notice-box:not(.error-box):not(.wiki-reader-not-found) p {
    color: var(--warning-text);
}

.search-notice-box p + p {
    margin-top: 6px;
}

/* Compact two-line search statistics. */
.result-stats-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.result-stats-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.result-stats-summary {
    color: var(--text-muted);
    font-weight: 700;
}

.result-stats-range {
    color: var(--text-muted);
    font-size: 0.9rem;
}


/* JavaScript-enhanced language switcher: keep the submit button for no-JavaScript browsers. */
.language-submit-button {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-weight: 800;
    box-shadow: var(--shadow-xs);
}

html.js-enabled .language-submit-button {
    display: none;
}

/* Keep RTL content away from the viewport edge and improve reading width. */
html[dir="rtl"] .main-content,
html[dir="rtl"] .page-shell,
html[dir="rtl"] .content-page,
html[dir="rtl"] .settings-page,
html[dir="rtl"] .advanced-page,
html[dir="rtl"] .contact-page {
    width: min(calc(100% - 40px), var(--container));
    padding-inline: 4px;
}

html[dir="rtl"] .content-card,
html[dir="rtl"] .settings-card,
html[dir="rtl"] .advanced-panel,
html[dir="rtl"] .contact-card,
html[dir="rtl"] .result-card,
html[dir="rtl"] .results-shell,
html[dir="rtl"] .search-panel {
    margin-inline: auto;
}

.result-title a,
.result-title {
    overflow-wrap: anywhere;
}

@media (max-width: 520px) {
    html[dir="rtl"] .main-content,
    html[dir="rtl"] .page-shell,
    html[dir="rtl"] .content-page,
    html[dir="rtl"] .settings-page,
    html[dir="rtl"] .advanced-page,
    html[dir="rtl"] .contact-page {
        width: min(calc(100% - 24px), var(--container));
        padding-inline: 2px;
    }
}

/* Footer legal links */
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.4rem;
    font-size: 0.92rem;
}

.footer-links a {
    color: inherit;
    text-decoration: none;
    opacity: 0.85;
}

.footer-links a:hover,
.footer-links a:focus-visible {
    opacity: 1;
    text-decoration: underline;
}


/* Center the public footer consistently. */
.site-footer,
.footer-inner {
    text-align: center;
}

.footer-inner {
    margin-inline: auto;
}

.language-boost-notice {
    max-width: var(--container);
    margin-inline: auto;
}


/* v266: keep both footer lines centered on all screen widths. */
.footer-inner {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.footer-inner p {
    width: 100%;
    margin: 0;
    text-align: center;
}
.footer-links {
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Ensure every search result card keeps the full list width even with long URLs or mixed inline metadata. */
.results-list {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
}

.result-card {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.result-title,
.result-title a,
.result-description,
.result-url-row,
.result-url,
.result-url a {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.result-title a,
.result-url a {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.result-url-row {
    width: 100%;
}

.result-url-row .result-url {
    flex: 1 1 260px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.result-url-row .language-chip,
.result-url-row .result-url-language,
.result-url-action-form,
.result-file-chip {
    flex: 0 0 auto;
}

@media (max-width: 640px) {
    .result-url-row .result-url {
        flex-basis: 100%;
    }
}
