/*
 * Five high-contrast visual systems, inspired by the supplied interface
 * reference. All styles are local CSS; Lucide is used only for button icons.
 */
:root { color-scheme: dark; }

body[data-theme] {
    --void: #060810;
    --panel: rgba(10, 17, 31, .88);
    --panel-strong: #101a2e;
    --field: #09111f;
    --ink: #e8f4ff;
    --muted: #8da4bd;
    --line: rgba(119, 186, 255, .27);
    --accent: #61d9ff;
    --accent-2: #9a7bff;
    --accent-ink: #03131b;
    --glow: rgba(67, 205, 255, .38);
    --shadow: rgba(0, 0, 0, .72);
    background-color: var(--void);
    color: var(--ink);
    font-family: "Arial Narrow", "Segoe UI", system-ui, sans-serif;
    letter-spacing: .015em;
}

/* COSMIC FLUX — deep space, star map, restrained cyan navigation lights. */
body[data-theme="cosmic"] {
    --void: #020308;
    --panel: rgba(3, 7, 16, .92);
    --panel-strong: #060c18;
    --field: #040814;
    --ink: #edf6ff;
    --muted: #9bb1ca;
    --line: rgba(99, 199, 255, .3);
    --accent: #61d9ff;
    --accent-2: #ac8bff;
    --accent-ink: #001018;
    --glow: rgba(50, 191, 255, .42);
    background-image:
        radial-gradient(circle at 12% 18%, #c3e8ff 0 1px, transparent 1.6px),
        radial-gradient(circle at 80% 28%, #8fd6ff 0 1px, transparent 1.7px),
        radial-gradient(circle at 60% 72%, #fff 0 .7px, transparent 1.5px),
        radial-gradient(ellipse at 50% -20%, #091429 0%, transparent 45%),
        linear-gradient(135deg, #020308, #040914 55%, #010205);
    background-size: 227px 173px, 331px 287px, 151px 239px, auto, auto;
}

/* NEO-INDUSTRIAL — gunmetal panels, mechanical edges, safety-orange action. */
body[data-theme="industrial"] {
    --void: #080808;
    --panel: rgba(15, 15, 14, .94);
    --panel-strong: #181817;
    --field: #0c0d0c;
    --ink: #f1eee6;
    --muted: #b3aea2;
    --line: #5c5b55;
    --accent: #ff9f43;
    --accent-2: #d5c3a1;
    --accent-ink: #201005;
    --glow: rgba(255, 145, 45, .25);
    background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 1px, transparent 1px 7px);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    letter-spacing: .018em;
}

/* SPECTRUM PULSE — colour stays in the active edge, never floods the page. */
body[data-theme="spectrum"] {
    --void: #04030b;
    --panel: rgba(9, 8, 20, .93);
    --panel-strong: #110d21;
    --field: #090814;
    --ink: #f6f3ff;
    --muted: #b9afd1;
    --line: rgba(196, 157, 255, .35);
    --accent: #c8a5ff;
    --accent-2: #6ed7d7;
    --accent-ink: #140a24;
    --glow: rgba(177, 117, 255, .3);
    background-image: radial-gradient(ellipse at 50% -25%, rgba(113, 77, 186, .14), transparent 45%), linear-gradient(150deg, #04030b, #070512 58%, #030208);
}

/* ORBITAL DATA — precise monitoring console with circular data cues. */
body[data-theme="orbital"] {
    --void: #02080b;
    --panel: rgba(3, 12, 15, .93);
    --panel-strong: #06181c;
    --field: #030d10;
    --ink: #e6fbfa;
    --muted: #8ab6b7;
    --line: rgba(76, 204, 205, .3);
    --accent: #5ae5dc;
    --accent-2: #8baaff;
    --accent-ink: #001719;
    --glow: rgba(67, 234, 221, .32);
    background-image: radial-gradient(circle at 50% 8%, transparent 0 72px, rgba(85, 229, 220, .05) 73px 74px, transparent 75px 145px, rgba(85,229,220,.03) 146px 147px, transparent 148px), linear-gradient(150deg, #02080b, #030e11);
    background-size: 390px 390px, auto;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

/* BIOLUMINESCENT — darker forest-water palette with living green highlights. */
body[data-theme="bioluminescent"] {
    --void: #010704;
    --panel: rgba(2, 12, 9, .94);
    --panel-strong: #061a13;
    --field: #030d09;
    --ink: #e9fff1;
    --muted: #91bda6;
    --line: rgba(73, 192, 133, .31);
    --accent: #74f0ad;
    --accent-2: #81d7c4;
    --accent-ink: #002114;
    --glow: rgba(73, 240, 166, .29);
    background-image: radial-gradient(circle at 15% 12%, rgba(50, 199, 126, .09), transparent 23rem), radial-gradient(circle at 80% 85%, rgba(15, 123, 88, .08), transparent 28rem), linear-gradient(145deg, #010704, #020d08 55%, #000402);
}

/* SOLAR PORCELAIN — warm white ceramic surfaces with crisp blue-violet detail. */
body[data-theme="porcelain"] {
    color-scheme: light;
    --void: #e8eef3;
    --panel: rgba(255, 255, 255, .91);
    --panel-strong: #f9fbfd;
    --field: #edf3f7;
    --ink: #142231;
    --muted: #596b7d;
    --line: rgba(38, 83, 116, .24);
    --accent: #087fa8;
    --accent-2: #7452c8;
    --accent-ink: #f7fdff;
    --glow: rgba(25, 133, 173, .2);
    --shadow: rgba(36, 55, 72, .2);
    background-image: radial-gradient(circle at 14% 4%, rgba(255,255,255,.95), transparent 26rem), radial-gradient(circle at 88% 74%, rgba(99, 77, 194, .08), transparent 30rem), linear-gradient(145deg, #eef3f6, #dfe8ef);
}

/* PRISMATIC PAPER — pale editorial stock with restrained spectral accents. */
body[data-theme="prismatic"] {
    color-scheme: light;
    --void: #f1edf5;
    --panel: rgba(255, 253, 255, .92);
    --panel-strong: #fbf8fc;
    --field: #f0eaf3;
    --ink: #281b30;
    --muted: #725f79;
    --line: rgba(111, 67, 123, .23);
    --accent: #a32972;
    --accent-2: #087d91;
    --accent-ink: #fff8fc;
    --glow: rgba(170, 47, 125, .18);
    --shadow: rgba(61, 38, 68, .19);
    background-image: linear-gradient(115deg, rgba(218, 54, 142, .055), transparent 31%), linear-gradient(245deg, rgba(30, 176, 190, .06), transparent 34%), linear-gradient(145deg, #f8f5f8, #ebe5ef);
}

body[data-theme] .container {
    width: min(1800px, calc(100% - 42px));
    margin: 21px auto 0;
    padding: 0 25px 25px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 30px 85px var(--shadow), 0 0 34px color-mix(in srgb, var(--glow) 25%, transparent);
    overflow: clip;
}

body[data-theme] #headerContainer {
    padding: 20px 0 16px;
    background: color-mix(in srgb, var(--panel) 90%, transparent);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 13px 28px rgba(0, 0, 0, .25);
    backdrop-filter: blur(18px);
}

body[data-theme] #titleArea { align-items: center; gap: 14px; }
body[data-theme] #titleArea h1 {
    color: var(--ink);
    font-family: inherit;
    font-size: clamp(1.35rem, 2.6vw, 2.15rem);
    letter-spacing: -.035em;
    text-shadow: 0 0 18px var(--glow);
}
body[data-theme="industrial"] #titleArea h1 { letter-spacing: -.02em; }
body[data-theme] #searchedWordsDisplay { color: var(--muted); }
body[data-theme] .search-info-details {
    color: var(--ink); background: color-mix(in srgb, var(--panel-strong) 97%, transparent);
    border-color: var(--line); box-shadow: 0 14px 34px var(--shadow), 0 0 18px color-mix(in srgb, var(--glow) 18%, transparent);
}

#languageControl { position: relative; flex: 0 0 auto; }
body[data-theme] #languageButton {
    display: grid; place-items: center; width: 48px; height: 40px; padding: 0;
    color: var(--ink); background: var(--field); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 4px 12px var(--shadow);
}
body[data-theme] #languageButton::before { content: none; }
body[data-theme] #languageButton:hover,
body[data-theme] #languageButton[aria-expanded="true"] { background: var(--panel-strong); border-color: var(--accent); transform: translateY(-1px); }
#languageCurrentFlag { font-size: 29px; line-height: 1; }
#languageMenu {
    position: absolute; z-index: 140; top: calc(100% + 7px); left: 0;
    display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 3px;
    width: max-content; max-height: min(390px, 70vh); padding: 6px; overflow-y: auto;
    background: color-mix(in srgb, var(--panel-strong) 97%, transparent);
    border: 1px solid var(--line); border-radius: 9px;
    box-shadow: 0 18px 45px var(--shadow), 0 0 22px color-mix(in srgb, var(--glow) 22%, transparent);
    backdrop-filter: blur(18px);
}
#languageMenu[hidden] { display: none; }
body[data-theme] #languageMenu button {
    display: grid; grid-template-columns: 25px max-content; align-items: center; justify-content: start; gap: 8px;
    width: 100%; margin: 0; padding: 7px 10px; color: var(--muted); background: transparent;
    border: 1px solid transparent; border-radius: 5px; box-shadow: none; font-size: .78rem; text-align: left;
}
body[data-theme] #languageMenu button::before { content: none; }
body[data-theme] #languageMenu button:hover,
body[data-theme] #languageMenu button[aria-selected="true"] {
    color: var(--ink); background: color-mix(in srgb, var(--accent) 14%, var(--field));
    border-color: color-mix(in srgb, var(--accent) 38%, transparent); transform: none;
}
body[data-theme] #languageMenu button span:first-child { font-size: 19px; line-height: 1; }

.theme-selector {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    color: var(--muted);
    font-size: .69rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}
.theme-selector select {
    appearance: none;
    min-width: 184px;
    padding: 10px 37px 10px 13px;
    color: var(--ink);
    background: var(--field) linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 17px) 50% / 7px 7px no-repeat, linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 12px) 50% / 7px 7px no-repeat;
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: inset 0 0 14px rgba(0, 0, 0, .25);
    font: inherit;
    letter-spacing: .02em;
    text-transform: none;
    cursor: pointer;
    outline: none;
}

body[data-theme] label { color: var(--muted); }
body[data-theme] input, body[data-theme] textarea, body[data-theme] select {
    color: var(--ink);
    background-color: var(--field);
    border-color: var(--line);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
body[data-theme] input:focus, body[data-theme] textarea:focus, body[data-theme] select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), inset 0 1px 0 rgba(255,255,255,.06);
    outline: none;
}

body[data-theme] #wordEditorDialog {
    color: var(--ink);
    background: color-mix(in srgb, var(--panel-strong) 97%, transparent);
    border-color: var(--line);
    box-shadow: 0 32px 95px rgba(0,0,0,.72), 0 0 30px color-mix(in srgb, var(--glow) 24%, transparent);
}
body[data-theme] #wordEditorTitle { color: var(--ink); }
body[data-theme] #expandWordsBtn::before,
body[data-theme] #wordEditorCloseBtn::before { content: none; }

body[data-theme] button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--ink);
    background: linear-gradient(145deg, color-mix(in srgb, var(--panel-strong) 95%, white), var(--field));
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 4px 0 rgba(0,0,0,.45), 0 8px 16px rgba(0,0,0,.24);
    font-family: inherit;
    font-weight: 700;
    line-height: 1;
    transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
body[data-theme] button svg { width: 15px; height: 15px; stroke-width: 2.25; flex: 0 0 auto; }
body[data-theme] button:hover {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), 0 0 18px var(--glow), 0 5px 0 rgba(0,0,0,.45);
    transform: translateY(-2px);
}
body[data-theme] button:active { box-shadow: inset 0 2px 8px rgba(0,0,0,.34); transform: translateY(2px); }

/* Fixed three-column topic matrix: each related pair shares a vertical rail. */
body[data-theme] .controls .preset-words-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    gap: 7px;
    min-width: 300px;
}
body[data-theme] .controls .preset-words-group .button-row { display: contents; }
body[data-theme] .controls .preset-words-group button {
    width: 100%;
    min-width: 0;
    padding-inline: 9px;
}

body[data-theme="industrial"] button, body[data-theme="industrial"] .theme-selector select { border-radius: 2px; }
body[data-theme="industrial"] button::before { content: "◆"; font-size: .45rem; color: var(--accent); }
body[data-theme="industrial"] button:hover::before { color: var(--accent-ink); }
body[data-theme="industrial"] button svg { display: none; }
body[data-theme="industrial"] #wikiCrawlBtn::before,
body[data-theme="industrial"] #wikisourceCrawlBtn::before { content: none; }
body[data-theme="industrial"] #wikiCrawlBtn svg,
body[data-theme="industrial"] #wikisourceCrawlBtn svg { display: block; }
body[data-theme="orbital"] button { border-radius: 999px; }
body[data-theme="bioluminescent"] button { border-radius: 10px; }

body[data-theme] button.crawl, body[data-theme] #generatePromptBtn {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
}
body[data-theme] #wikiCrawlMethod {
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 3px 10px rgba(0,0,0,.18);
}
body[data-theme] #wikiCrawlMethod:focus { outline: 1px solid var(--accent); outline-offset: 1px; }
body[data-theme] button.crawl:hover, body[data-theme] #generatePromptBtn:hover {
    color: var(--ink);
    background: var(--accent-2);
    border-color: var(--accent-2);
}
body[data-theme] #viewModeButtonsContainer button {
    color: var(--muted);
    background: transparent;
    box-shadow: none;
}
body[data-theme] #viewModeButtonsContainer button.active {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 16px var(--glow);
}
body[data-theme] #funkyVariantButtons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 4px;
}
body[data-theme] #funkyVariantButtons .funky-variant {
    min-width: 38px;
    padding-inline: 10px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.08rem;
}
body[data-theme] #funkyVariantButtons .funky-variant::before { content: none; }
body[data-theme] #funkyVariantButtons .funky-variant.active {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--glow);
}
body[data-theme] #mouseModeButtons {
    display: grid;
    grid-template-columns: repeat(2, 34px);
    justify-content: center;
    gap: 6px;
    margin-top: 6px;
}
body[data-theme] #mouseModeButtons .mouse-mode {
    width: 34px;
    min-width: 34px;
    height: 30px;
    padding: 6px;
}
body[data-theme] #mouseModeButtons .mouse-mode svg { width: 15px; height: 15px; margin: 0; }
body[data-theme] #mouseModeButtons .mouse-mode::before { content: none; }
body[data-theme] #mouseModeButtons .mouse-mode.active {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--glow);
}
body[data-theme] #viewOrderToggle .toggle-ordered { display: none; }
body[data-theme] #viewOrderToggle.is-ordered .toggle-random { display: none; }
body[data-theme] #viewOrderToggle.is-ordered .toggle-ordered { display: block; }

body[data-theme] #results, body[data-theme] #cloudViewWrapper, body[data-theme] #cloudControlsSidebar, body[data-theme] #cloudDisplayArea {
    color: var(--ink);
    background: color-mix(in srgb, var(--field) 93%, transparent);
    border-color: var(--line);
}
body[data-theme] #funky3dStage {
    background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 48%), #020307;
    border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
    border-radius: 10px;
    box-shadow: inset 0 0 80px rgba(0,0,0,.82), 0 0 28px color-mix(in srgb, var(--glow) 18%, transparent);
}
body[data-theme="porcelain"] #funky3dStage,
body[data-theme="prismatic"] #funky3dStage {
    background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 52%), #e8edf2;
    border-color: color-mix(in srgb, var(--accent) 28%, transparent);
    box-shadow: inset 0 0 75px rgba(45, 65, 85, .14), 0 10px 30px var(--shadow);
}
body[data-theme] #results h2, body[data-theme] #simpleWikiPopupHeader { color: var(--ink); border-color: var(--line); }
body[data-theme] #results td {
    color: var(--ink);
    background: color-mix(in srgb, var(--panel-strong) 72%, transparent);
    border-color: var(--line);
}
body[data-theme] #results tr:hover td { background: color-mix(in srgb, var(--accent) 10%, var(--panel-strong)); }
body[data-theme] #results td a, body[data-theme] #sideLinksPopup a { color: var(--accent); }
body[data-theme] #results td a:hover, body[data-theme] #sideLinksPopup a:hover { color: var(--accent-2); }

body[data-theme] #simpleWikiPopup, body[data-theme] #sideLinksPopup, body[data-theme] #llmPromptGenerator {
    color: var(--ink);
    background: var(--panel-strong);
    border-color: var(--line);
    box-shadow: 0 22px 60px var(--shadow), 0 0 25px color-mix(in srgb, var(--glow) 24%, transparent);
}
body[data-theme] #sideLinksPopup a:hover { background: var(--field); border-color: var(--accent); }
body[data-theme] #sideLinksPopup h5 { color: var(--muted); border-color: var(--line); }
body[data-theme] .popup-control-btn { color: var(--ink); background: var(--field); }
body[data-theme] #simpleWikiPopupCloseBtn { color: var(--muted); background: transparent; box-shadow: none; }
body[data-theme] .loading { color: var(--muted); border-color: var(--line); }
body[data-theme] .error { color: #fff; background: #40171d; border-color: #e95b70; }

@media (max-width: 700px) {
    body[data-theme] .container { width: calc(100% - 18px); margin-top: 9px; border-radius: 10px; }
    .theme-selector { width: 100%; justify-content: space-between; margin-left: 0; }
    .theme-selector select { min-width: min(230px, 70vw); }
    #languageMenu { grid-template-columns: 1fr; max-width: min(310px, 88vw); }
}
