        /* --- Basic Styles --- */
        body { font-family: sans-serif; line-height: 1.6; margin: 0; background-color: #f4f4f4; padding-top: 0; padding-bottom: 70px; /* Add padding for bottom prompt generator */ }
        .container { background-color: #fff; padding: 0 25px 25px 25px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); width: calc(100% - 50px); max-width: 1800px; margin: 0 auto; box-sizing: border-box; }

        /* --- Sticky Header --- */
        #headerContainer {
            position: sticky;
            top: 0;
            z-index: 100;
            background-color: #ffffff;
            padding: 20px 0 15px 0;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
            margin-bottom: 20px;
        }

        /* --- Title Area Layout (inside header) --- */
        #titleArea {
            display: flex;
            justify-content: space-between;
            align-items: baseline;
            margin-bottom: 15px;
            flex-wrap: wrap;
            gap: 15px;
        }
        #titleArea h1 { color: #333; text-align: left; margin: 0; font-size: 1.8em; flex-shrink: 0; }
        #searchedWordsDisplay { font-size: 0.9em; color: #555; text-align: right; flex-grow: 1; margin-left: 20px; }
        #searchedWordsDisplay { position: relative; min-width: 3em; }
        .search-info-trigger { display: inline-block; cursor: help; border-bottom: 1px dotted currentColor; outline: none; }
        .search-info-details {
            position: absolute; z-index: 180; top: calc(100% + 8px); right: 0;
            display: grid; gap: 3px; width: max-content; max-width: min(560px, 78vw);
            padding: 9px 12px; text-align: left; line-height: 1.35;
            color: #222; background: rgba(255,255,255,.98); border: 1px solid #bbb; border-radius: 7px;
            box-shadow: 0 12px 30px rgba(0,0,0,.2); opacity: 0; visibility: hidden;
            transform: translateY(-4px); pointer-events: none; transition: opacity .14s ease, transform .14s ease, visibility .14s;
        }
        #searchedWordsDisplay:hover .search-info-details,
        #searchedWordsDisplay:focus-within .search-info-details { opacity: 1; visibility: visible; transform: translateY(0); }

        /* --- Controls Area Layout (inside header) --- */
        .controls {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            align-items: center;
            border-bottom: none;
            margin-bottom: 0;
        }
        .controls .input-group { display: flex; align-items: flex-start; gap: 8px; flex-grow: 1; min-width: 250px; width: 100%; }
        #compactInputSlot { flex: 0 1 66%; min-width: 220px; }
        #wordInput { width: 100%; min-width: 0; height: 45px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; resize: none; font-size: 1em; line-height: 1.4; box-sizing: border-box; overflow: hidden; }
        #expandWordsBtn { width: 34px; min-width: 34px; height: 45px; padding: 0; }
        #expandWordsBtn span { color: #fff; font-size: 1.2rem; line-height: 1; }
        .controls .button-group { display: flex; gap: 8px; align-items: center; margin-left: auto; }
        #compactSearchActions { flex: 1 1 auto; align-items: flex-start; justify-content: flex-end; }
        .wiki-crawl-control { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
        #wikiCrawlMethod { max-width: 145px; padding: 3px 22px 3px 7px; border-radius: 5px; font-size: .72rem; cursor: pointer; }
        #viewModeButtonsContainer { border-bottom: none; padding-bottom: 0; margin-bottom: 0; display: flex; gap: 8px; }

        button { padding: 10px 15px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 1em; transition: background-color 0.2s ease; }
        button:hover { background-color: #0056b3; }
        button:active { background-color: #004085; }
        button.crawl { background-color: #28a745; }
        button.crawl:hover { background-color: #218838; }
        button.crawl:active { background-color: #1e7e34; }
        #viewModeButtonsContainer button { background-color: #6c757d; }
        #viewModeButtonsContainer button.active { background-color: #007bff; font-weight: bold; }

        /* --- Preset Word Buttons Styles --- */
        .controls .preset-words-group {
            display: flex;
            flex-direction: column;
            gap: 5px;
            align-items: flex-start;
        }
        .controls .preset-words-group .button-row {
            display: flex;
            gap: 5px;
        }
        .controls .preset-words-group button {
            padding: 8px 10px;
            font-size: 0.9em;
            background-color: #5bc0de;
            min-width: 80px;
            text-align: center;
        }
        .controls .preset-words-group button:hover {
            background-color: #31b0d5;
        }

        /* --- Expanded word editor --- */
        .word-editor-overlay { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 24px; box-sizing: border-box; background: rgba(0,0,0,.8); backdrop-filter: blur(5px); }
        .word-editor-overlay[hidden] { display: none; }
        #wordEditorDialog { width: min(1040px, 90vw); padding: 22px; box-sizing: border-box; background: #11151d; border: 1px solid #596273; border-radius: 12px; box-shadow: 0 30px 90px rgba(0,0,0,.68); }
        .word-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
        #wordEditorTitle { margin: 0; color: #f1f3f7; font-size: clamp(1.05rem, 2vw, 1.45rem); line-height: 1.3; }
        #wordEditorCloseBtn { flex: 0 0 auto; width: 34px; height: 34px; padding: 0; font-size: 1.3rem; }
        .word-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 118px; align-items: start; gap: 14px; }
        #wordEditorMain #wordInput { width: 100%; height: min(56vh, 540px); min-height: 300px; padding: 16px; overflow-y: auto; resize: none; }
        .word-editor-layout .preset-words-group { display: grid; grid-template-columns: 1fr; align-content: start; gap: 8px; }
        .word-editor-layout .preset-words-group button { width: 100%; min-width: 0; padding: 9px 8px; font-size: .78rem; }
        body.word-editor-open { overflow: hidden; }

        @media (max-width: 860px) {
            #compactSearchRow { flex-wrap: wrap; }
            #compactInputSlot { flex-basis: calc(100% - 42px); }
            #compactSearchActions { flex-basis: 100%; justify-content: flex-start; }
            .word-editor-layout { grid-template-columns: minmax(0, 1fr) 96px; }
        }


        #notifications { margin-bottom: 15px; margin-top: 10px; }

        /* --- Table Styles --- */
        #results { margin-top: 0; background-color: #f9f9f9; padding: 15px; border-radius: 5px; border: 1px solid #eee; min-height: 50px; }
        #results h2 { margin-top: 0; margin-bottom: 15px; color: #333; font-size: 1.3em; border-bottom: 1px solid #ccc; padding-bottom: 8px; }
        #results table { width: 100%; border-collapse: collapse; table-layout: auto; }
        #results td { border: 1px solid #ddd; padding: 10px; vertical-align: top; text-align: left; width: 50%; word-break: break-word; }
        #results td a { text-decoration: none; color: #0056b3; }
        #results td a:hover { text-decoration: underline; }
        .loading, .error { font-style: italic; color: #666; padding: 10px; border: 1px dashed #ccc; display: block; border-radius: 4px; margin-bottom: 10px; }
        .error { color: #dc3545; border-color: #f5c6cb; background-color: #f8d7da; }

        /* --- Cloud View Styles --- */
        #cloudViewWrapper { display: flex; margin-top: 0; border: 1px solid #ddd; border-radius: 5px; }
        #cloudControlsSidebar { width: 250px; min-width: 220px; padding: 15px; box-sizing: border-box; background-color: #f8f9fa; border-right: 1px solid #e0e0e0; max-height: 800px; overflow-y: auto; }
        #cloudControlsSidebar label { font-size: 0.9em; font-weight: bold; margin-top: 10px; display: block; }
        #cloudControlsSidebar input, #cloudControlsSidebar select, #cloudControlsSidebar button { display: block; width: calc(100% - 10px); margin-bottom: 8px; box-sizing: border-box; }
        #cloudControlsSidebar input[type="number"], #cloudControlsSidebar input[type="color"], #cloudControlsSidebar input[type="range"], #cloudControlsSidebar select { padding: 6px; border: 1px solid #ccc; border-radius: 3px; }
        #cloudControlsSidebar input[type="range"] { padding: 0; height: 10px; cursor: pointer; }
        #cloudDisplayArea {
            flex-grow: 1; padding: 10px; background-color: #fff;
            display: flex; justify-content: center; align-items: center;
            height: clamp(580px, 62vh, 760px);
            min-height: 580px;
            max-height: 760px;
            overflow: hidden;
        }
        #funky3dStage { width: 100%; height: 100%; min-height: 580px; position: relative; overflow: hidden; overscroll-behavior: contain; cursor: default; }
        #funky3dStage canvas { display: block; width: 100%; height: 100%; outline: none; overscroll-behavior: contain; }
        .funky3d-status { position: absolute; inset: 0; display: grid; place-items: center; color: #aebbd0; font: 600 0.9rem/1.4 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; }
        .funky3d-mouse-hint { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; color: #9aa0aa; font: 500 .8rem/1.3 system-ui, sans-serif; letter-spacing: .08em; text-transform: lowercase; pointer-events: none; opacity: .8; transition: opacity .16s ease, transform .16s ease; }
        .funky3d-mouse-hint.is-dismissed { opacity: 0; transform: scale(.98); }

        /* --- Main Popup styles --- */
        #simpleWikiOverlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.95); z-index: 999; }
        #simpleWikiPopup {
            display: none; position: fixed; top: 50%; left: 50%;
            transform: translate(-50%, -50%); background-color: #fff;
            padding: 20px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
            z-index: 1000; width: 80%; max-width: 700px;
            max-height: 88vh;
            overflow-y: auto; border: 1px solid #ccc;
            transition: max-width 0.3s ease-in-out;
        }
        #simpleWikiPopupHeader { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; }
        #simpleWikiPopupTitle { margin: 0; color: #333; font-size: 1.4em; flex-grow: 1; padding-right: 15px; }
        #simpleWikiPopupControls { display: flex; gap: 8px; align-items: center; }
        .popup-control-btn { font-size: 0.8em; padding: 4px 8px; background-color: #e9ecef; color: #495057; border: 1px solid #ced4da; cursor: pointer; border-radius: 3px; }
        .popup-control-btn:hover { background-color: #dee2e6; border-color: #adb5bd; }
        #simpleWikiPopupContent { line-height: 1.4; font-size: 1.25rem; }
        #simpleWikiPopupContent .loading { font-style: italic; color: #666; }
        #simpleWikiPopupContent p { margin-top: 0; margin-bottom: 1em; }
        #simpleWikiPopupContent .wikisource-content img { max-width: 100%; height: auto; }
        #simpleWikiPopupCloseBtn { font-size: 1.6em; font-weight: bold; color: #aaa; background: none; border: none; cursor: pointer; padding: 0 5px; line-height: 1; }
        #simpleWikiPopupCloseBtn:hover { color: #333; }

        /* --- Tiered Font Size Styles --- */
        .large-first-words { font-size: 1.5em; font-weight: bold; }
        .medium-next-words { font-size: 1.2em; }

        /* --- Book View Styles --- */
        #simpleWikiPopup.book-view { max-width: 1120px; width: auto; }
        #simpleWikiPopup.book-view #simpleWikiPopupContent { column-count: 2; column-gap: 40px; }

        /* --- Side Links Popup styles --- */
        #sideLinksPopup {
            display: none; position: fixed; top: 50%; right: 15px;
            transform: translateY(-50%); width: auto; min-width: 200px; /* MODIFIED: Increased min-width for new links/headers */
            max-height: 88vh; 
            background-color: #f0f0f0; padding: 15px 10px;
            border-radius: 6px; box-shadow: 0 3px 12px rgba(0,0,0,0.25);
            z-index: 1000; overflow-y: auto; display: flex;
            flex-direction: column; gap: 4px; /* MODIFIED: Reduced gap for tighter list */
            border: 1px solid #ccc;
        }
        #sideLinksPopup a { display: block; text-decoration: none; color: #0056b3; padding: 5px 8px; border-radius: 4px; font-size: 0.9em; /* MODIFIED: Slightly smaller font */ text-align: left; white-space: nowrap; border: 1px solid transparent; transition: background-color 0.2s ease, border-color 0.2s ease; }
        #sideLinksPopup a:hover { background-color: #e0e0e0; border-color: #bbb; color: #003f80; }
        #sideLinksPopup hr { border: 0; height: 1px; background-color: #ccc; margin: 6px 0; }
        #sideLinksPopup h5 { /* MODIFIED: Style for category headers */
            margin-top: 8px; margin-bottom: 3px; font-size: 0.85em; 
            font-weight: bold; color: #333; padding-left: 2px;
            border-bottom: 1px solid #ddd; padding-bottom: 2px;
        }
        #sideLinksPopup h5:first-of-type { margin-top: 0; } /* No top margin for the very first header */


        /* --- LLM Prompt Generator Styles (NEW) --- */
        #llmPromptGenerator {
            position: fixed; /* Fixed at the bottom */
            bottom: 0;
            left: 0;
            width: 100%;
            text-align: center;
            padding: 10px 15px;
            background-color: #e0e0e0; /* Slightly darker than body for distinction */
            border-top: 1px solid #c0c0c0;
            box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
            z-index: 200; /* Above regular content, below popups */
            box-sizing: border-box;
        }
        #promptThemeInput {
            width: 180px; /* Visually compact */
            margin-right: 8px;
            padding: 8px;
            border-radius: 4px;
            border: 1px solid #aaa;
            font-size: 0.9em;
        }
        #generatePromptBtn {
            padding: 8px 12px;
            font-size: 0.9em;
            background-color: #4CAF50; /* A distinct color for this action */
        }
        #generatePromptBtn:hover {
            background-color: #45a049;
        }
        #copyPromptStatus {
            margin-left: 10px;
            font-size: 0.9em;
            color: green;
            font-style: italic;
        }
