/**
 * WuWa Mobile Config Patcher — Documentation Site Stylesheet (v1.9.0)
 */
:root {
    /* Color Palette — Aligned with Android App "Gaming" Dark Theme */
    --bg-main: #090E0D;
    --bg-surface: #101918;
    --bg-card: #162320;
    --bg-header: #101918;
    --border-color: #223430;
    --border-accent: rgba(75, 211, 163, 0.25);

    --primary: #4BD3A3;
    --primary-dark: #2AA37D;
    --primary-text: #4BD3A3;
    --on-primary: #090E0D;

    --gold: #E7B34A;
    --gold-text: #E7B34A;
    --on-gold: #090E0D;

    --accent-cyan: #4BD3A3;
    --accent-gold: #E7B34A;
    --accent-green: #47D764;
    --accent-red: #E35D6A;

    --text-main: #F4F7F5;
    --text-muted: #A8B4AF;
    --sidebar-width: 280px;

    /* Backend Access Status Badges */
    --badge-root: #E35D6A;
    --badge-shizuku: #47D764;
    --badge-axmanager: #2AA37D;
    --badge-unauthorized: #F7C948;
    --badge-none: #A8B4AF;
    --flagged-red: #E35D6A;

    /* Focus Ring & Minimum Touch Targets */
    --focus-ring: #4BD3A3;
    --min-touch-target: 44px;
}

/* Light Theme — Aligned with Android App Light Theme */
[data-theme="light"] {
    --bg-main: #F5F7FA;
    --bg-surface: #FFFFFF;
    --bg-card: #E2E8F0;
    --bg-header: #FFFFFF;
    --border-color: #CBD5E1;
    --border-accent: rgba(13, 148, 136, 0.3);

    --primary: #0D9488;
    --primary-dark: #0F766E;
    --primary-text: #0F5A52; /* WCAG AAA 6.4:1 contrast on #F5F7FA */
    --on-primary: #FFFFFF;

    --gold: #D97706;
    --gold-text: #92400E; /* WCAG AAA 8.1:1 contrast on #F5F7FA */
    --on-gold: #FFFFFF;

    --accent-cyan: #0D9488;
    --accent-gold: #D97706;
    --accent-green: #16A34A;
    --accent-red: #DC2626;

    --text-main: #0F172A;
    --text-muted: #475569;

    --badge-root: #DC2626;
    --badge-shizuku: #16A34A;
    --badge-axmanager: #0D9488;
    --badge-unauthorized: #D97706;
    --badge-none: #64748B;
    --flagged-red: #DC2626;

    --focus-ring: #0D9488;
}

/* Accessibility Skip Link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 800;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 999999;
    text-decoration: none;
    transition: top 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.skip-link:focus {
    top: 12px;
    outline: 3px solid var(--accent-gold);
}

/* Accessible Focus Ring */
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Utility Classes (Replacing Inline Styles)
   ========================================================================== */
.subpage-header-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    min-height: var(--min-touch-target);
}

.mt-8 { margin-top: 8px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-20 { margin-top: 20px !important; }

.status-applied {
    color: var(--accent-green);
    font-weight: 800;
}

.status-failed {
    color: var(--accent-red);
    font-weight: 800;
}

.status-warning {
    color: var(--accent-gold);
    font-weight: 800;
}

.grid-col-full {
    grid-column: 1 / -1;
}

.screenshot-grid-single {
    grid-template-columns: 1fr !important;
    max-width: 580px;
    margin: 0 auto;
}

.code-block-inline {
    display: block;
    margin: 8px 0;
    word-break: break-all;
}

.is-hidden {
    display: none !important;
}

/* On-Page Table of Contents */
.toc-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.toc-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--gold-text);
    margin-bottom: 0.5rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toc-link {
    color: var(--primary-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.toc-link:hover {
    color: var(--accent-gold);
    background: rgba(231, 179, 74, 0.1);
}

/* ==========================================================================
   Header & Search Box
   ========================================================================== */
.app-header {
    height: 70px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.header-brand h1 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
}

.version-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* Hamburger toggle — injected into .app-header by initMobileNav() in js/main.js */
.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    margin-right: 8px;
    position: relative;
    z-index: 600;
}

.mobile-nav-toggle:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Theme Toggle Button */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    min-height: 44px;
    min-width: 44px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 12px;
    font-size: 14px;
    color: var(--text-muted);
}

.search-box input {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 12px 8px 36px;
    min-height: 44px;
    color: var(--text-main);
    font-size: 13px;
    width: 220px;
    max-width: 100%;
    min-width: 0;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(75, 211, 163, 0.25);
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    min-height: 44px;
    min-width: 44px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.github-link:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.github-link {
    flex-shrink: 0;
}

/* .github-link-text span is wrapped around the link's text node at runtime by js/main.js so it
   can be hidden independently of the SVG icon on narrow screens (see responsive block below). */

/* ==========================================================================
   Search Dropdown Results
   ========================================================================== */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 340px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
    max-height: 380px;
    overflow-y: auto;
    z-index: 200;
}

.search-result-item {
    display: flex;
    padding: 12px 14px;
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
    cursor: pointer;
}

.search-result-item:hover, .search-result-item.selected {
    background: rgba(45, 212, 191, 0.15);
    border-left: 3px solid var(--accent-cyan);
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.result-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-gold);
}

.result-section {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--accent-cyan);
    background: rgba(45, 212, 191, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    margin-left: 8px;
}

.result-snippet {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-item mark {
    background-color: rgba(245, 158, 11, 0.25);
    color: var(--accent-gold);
    border-radius: 2px;
    padding: 0 2px;
}

.search-no-results {
    padding: 14px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

/* ==========================================================================
   Main Container & Sidebar
   ========================================================================== */
.main-container {
    display: flex;
    min-height: calc(100vh - 120px);
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
    transition: background-color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

/* Backdrop behind the off-canvas sidebar on mobile — injected by initMobileNav() in js/main.js */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 99998;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

body.nav-locked {
    overflow: hidden;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-cyan);
    margin-bottom: 12px;
    padding-left: 8px;
}

.sidebar-section ul {
    list-style: none;
}

.sidebar-section li {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    min-height: 44px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(45, 212, 191, 0.15);
    color: var(--accent-cyan);
}

/* ==========================================================================
   Content Area & Typography
   ========================================================================== */
.content-area {
    flex: 1;
    min-width: 0; 
    padding: 2rem 4%;
}

.doc-section {
    margin-bottom: 48px;
    scroll-margin-top: 90px;
}

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-gold);
}

.doc-section h3 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

.doc-section h4 {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--accent-cyan);
}

.doc-section p, .doc-section ul, .doc-section ol {
    line-height: 1.7;
    margin-bottom: 1.25rem;
    color: var(--text-main);
}

.doc-section ul, .doc-section ol {
    padding-left: 1.5rem;
}

.doc-section li {
    margin-bottom: 0.5rem;
}

.doc-section hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 2.5rem 0;
}

.author-tag {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.lead-text {
    font-size: 15px;
    color: var(--text-main);
    margin-bottom: 24px;
}

/* Formatting Tags */
code {
    background-color: rgba(45, 212, 191, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(45, 212, 191, 0.3);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9em;
}

/* ==========================================================================
   Backend Status Badges & Highlighting
   ========================================================================== */
.badge-backend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
}

.badge-root {
    background-color: rgba(227, 93, 106, 0.2);
    color: var(--badge-root);
    border: 1px solid var(--badge-root);
}

.badge-shizuku {
    background-color: rgba(71, 215, 100, 0.2);
    color: var(--badge-shizuku);
    border: 1px solid var(--badge-shizuku);
}

.badge-axmanager {
    background-color: rgba(42, 163, 125, 0.2);
    color: var(--badge-axmanager);
    border: 1px solid var(--badge-axmanager);
}

.badge-unauthorized {
    background-color: rgba(247, 201, 72, 0.2);
    color: var(--badge-unauthorized);
    border: 1px solid var(--badge-unauthorized);
}

.badge-none {
    background-color: rgba(168, 180, 175, 0.2);
    color: var(--badge-none);
    border: 1px solid var(--badge-none);
}

.guard-red-highlight, .cvar-flagged {
    color: var(--flagged-red) !important;
    font-weight: 800 !important;
}

/* ==========================================================================
   Cards & Grids
   ========================================================================== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.feature-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.25s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-cyan);
}

.card-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.feature-card h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-gold);
    margin: 0 0 6px 0;
}

.feature-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Clickable Feature Cards */
.clickable-card {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    padding-bottom: 3.5rem;
}

.clickable-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
    border-color: var(--accent-cyan);
}

.tech-link {
    position: absolute;
    bottom: 20px;
    left: 20px;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    font-weight: 700;
    transition: color 0.2s ease;
}

.clickable-card:hover .tech-link {
    color: var(--accent-gold);
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 13.5px;
}

.alert-important {
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: var(--text-main);
}

.alert-tip {
    background-color: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--text-main);
}

.alert-warning {
    background-color: rgba(45, 212, 191, 0.12);
    border: 1px solid rgba(45, 212, 191, 0.4);
    color: var(--text-main);
}

.alert-title {
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: var(--accent-gold);
}

/* Method Cards */
.method-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}

.method-card h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-cyan);
    margin: 0 0 12px 0;
}

.step-list {
    margin: 16px 0 24px 24px;
}

.step-list li {
    margin-bottom: 10px;
    font-size: 14px;
}

/* Tables & Frozen Column Table */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: var(--bg-surface);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    font-size: 13px;
}

.doc-table th, .doc-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.doc-table th {
    background-color: var(--bg-card);
    font-weight: 700;
    color: var(--accent-gold);
}

/* Auto-applied around plain .doc-table elements by initResponsiveTables() in js/main.js */
.table-scroll {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin: 20px 0;
    -webkit-overflow-scrolling: touch;
}

.table-scroll .doc-table {
    margin: 0;
    border: none;
    border-radius: 0;
    min-width: 480px;
}

.frozen-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin: 20px 0;
}

.frozen-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.frozen-table th, .frozen-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.frozen-table th {
    background-color: var(--bg-card);
    color: var(--accent-gold);
    font-weight: 700;
}

.frozen-table th.frozen-col, .frozen-table td.frozen-col {
    position: sticky;
    left: 0;
    background-color: var(--bg-surface);
    z-index: 10;
    border-right: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--accent-gold);
}

.frozen-table th.frozen-col {
    background-color: var(--bg-card);
}

/* Editor Modes & Utilities Grids */
.editor-modes-container, .utilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.editor-mode-box, .util-item {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.mode-tag {
    display: inline-block;
    background-color: rgba(45, 212, 191, 0.15);
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.editor-mode-box ul {
    list-style: none;
    font-size: 13px;
    padding-left: 0;
}

.editor-mode-box li {
    margin-bottom: 8px;
    position: relative;
    padding-left: 16px;
}

.editor-mode-box li::before {
    content: "•";
    color: var(--accent-gold);
    position: absolute;
    left: 0;
}

.util-item h4 {
    color: var(--accent-gold);
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 6px 0;
}

.util-item p {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* ==========================================================================
   Code Blocks & Copy Button
   ========================================================================== */
.code-block {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin: 16px 0;
    position: relative;
}

.code-header {
    background-color: var(--bg-card);
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.code-block pre {
    padding: 16px;
    overflow-x: auto;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12.5px;
    color: var(--accent-gold);
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    min-height: 44px;
    min-width: 44px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.copy-code-btn.copied {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

/* ==========================================================================
   Responsive Screenshot Grids (Strict User Formatting Constraint)
   ========================================================================== */
.screenshot-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
    align-items: start;
}

.screenshot-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.screenshot-card:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
}

.screenshot-img {
    width: 100%;
    height: auto;
    display: block;
    border-bottom: 1px solid var(--border-color);
}

.screenshot-caption {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
    padding: 1.25rem 1.25rem 0.25rem;
}

.screenshot-subtext {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0 1.25rem 1.25rem;
    line-height: 1.5;
}

/* ==========================================================================
   Dual-Tab Modal Architecture
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(6, 16, 14, 0.92);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-window {
    background: var(--bg-surface);
    width: 94%;
    max-width: 650px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-window {
    transform: scale(1);
}

.modal-header {
    background: var(--bg-header);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--accent-gold);
    font-weight: 800;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
}

.close-btn:hover {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

.modal-tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 6px 16px 0;
    gap: 8px;
}

.modal-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    padding: 10px 14px;
    min-height: 44px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.modal-tab:hover {
    color: var(--text-main);
}

.modal-tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

.modal-body {
    padding: 1.5rem;
    line-height: 1.6;
    color: var(--text-main);
    font-size: 13.5px;
    overflow-y: auto;
    flex: 1;
}

.modal-section-block h4 {
    color: var(--accent-gold);
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 10px;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--primary-dark));
    color: var(--on-primary);
    text-decoration: none;
    padding: 10px 18px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    transition: opacity 0.2s ease;
}

.btn-primary:hover {
    opacity: 0.9;
}

.ai-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    background: linear-gradient(135deg, var(--accent-cyan), var(--primary-dark));
    color: var(--on-primary);
    border: 1px solid var(--border-color);
    padding: clamp(8px, 1.2vw, 10px) clamp(14px, 2vw, 18px);
    min-height: 44px;
    border-radius: 30px;
    font-size: clamp(12px, 1.4vw, 13.5px);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-chat-fab:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.5);
}

.ai-chat-window {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: clamp(320px, 30vw, 420px);
    max-width: 92vw;
    height: clamp(420px, 65vh, 600px);
    max-height: min(80vh, 80dvh);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
    z-index: 9001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ai-chat-header {
    background: var(--bg-header);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    gap: 8px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-avatar {
    font-size: 20px;
    flex-shrink: 0;
}

.header-info h4 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 800;
    color: var(--gold-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-status {
    font-size: 10.5px;
    color: var(--primary-text);
    font-weight: 600;
    white-space: nowrap;
}

.chat-header-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 6px;
    transition: color 0.2s ease;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-header-btn:hover {
    color: var(--text-main);
}

.ai-chat-settings {
    background: var(--bg-card);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    flex-shrink: 0;
}

.ai-chat-settings h5 {
    color: var(--gold-text);
    margin-bottom: 4px;
}

.ai-chat-settings p {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 8px;
}

.ai-chat-settings input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 10px;
    min-height: 44px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.settings-btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-chat-action {
    background: var(--accent-cyan);
    color: var(--on-primary);
    border: none;
    padding: 8px 14px;
    min-height: 44px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-chat-secondary {
    background: var(--bg-main);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    min-height: 44px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    min-width: 0;
}

.msg-user {
    align-self: flex-end;
}

.msg-user .msg-bubble {
    background: var(--accent-cyan);
    color: var(--on-primary);
    border-radius: 12px 12px 2px 12px;
    padding: 8px 12px;
    font-size: 12.5px;
}

.msg-ai {
    align-self: flex-start;
}

.msg-ai .msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 12px 12px 12px 2px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.5;
}

/* Bubble overflow fix (word-break / long strings / code) */
.msg-bubble {
    max-width: 100%;
    overflow-x: hidden;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

.msg-bubble code,
.msg-bubble pre {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
    box-sizing: border-box;
}

.msg-system {
    align-self: center;
}

.msg-bubble-system {
    background: rgba(231, 179, 74, 0.15);
    color: var(--gold-text);
    border: 1px solid rgba(231, 179, 74, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    text-align: center;
}

.chat-doc-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--primary-text);
    font-weight: 700;
    text-decoration: underline;
    font-size: 12px;
    word-break: break-all;
}

.prompt-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.prompt-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 8px 12px;
    min-height: 44px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.prompt-chip:hover {
    border-color: var(--accent-cyan);
    background: rgba(75, 211, 163, 0.15);
}

.ai-chat-input-row {
    background: var(--bg-header);
    border-top: 1px solid var(--border-color);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ai-chat-input-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 12.5px;
    box-sizing: border-box;
}

.ai-chat-input-row input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

.ai-chat-send-btn {
    background: var(--accent-cyan);
    color: var(--on-primary);
    border: none;
    padding: 8px 16px;
    min-height: 44px;
    min-width: 44px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-send-btn:hover {
    opacity: 0.9;
}

/* ==========================================================================
   Language Selector UI
   ========================================================================== */
.lang-selector-wrapper {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.lang-selector-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 12px;
    min-height: 44px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-selector-container:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.lang-select-code {
    margin-right: 6px;
    text-transform: uppercase;
}

.lang-select-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.lang-arrow {
    font-size: 10px;
    color: var(--text-muted);
}

/* ==========================================================================
   Consolidated Responsive Breakpoints
   Standard Tiers: 1280px | 900px (off-canvas sidebar) | 768px (tablet/mobile) | 375px (small phone)
   ========================================================================== */

/* ---- Tier 1: 1280px (Desktop / Laptop refinements) ---- */
@media screen and (max-width: 1280px) {
    .content-area {
        padding: 1.5rem 3%;
    }
}

/* ---- Tier 2: 900px (Off-canvas sidebar drawer trigger) ---- */
@media screen and (max-width: 900px) {
    .mobile-nav-toggle {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 60px;
        height: calc(100vh - 60px);
        width: min(85vw, 320px);
        z-index: 99999;
        background: var(--bg-surface);
        transform: translateX(-100%);
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.7);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .main-container {
        min-height: calc(100vh - 100px);
    }
}

/* ---- Tier 3: 768px (Tablet & Standard Mobile Viewports) ---- */
@media screen and (max-width: 768px) {
    .app-header {
        padding: 0 12px;
    }

    .header-brand {
        gap: 8px;
        min-width: 0;
    }

    .header-brand h1 {
        font-size: 15px;
        max-width: 38vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .version-badge {
        display: none;
    }

    .header-actions {
        gap: 6px;
    }

    .theme-toggle-btn .theme-text,
    .github-link-text,
    .lang-select-code {
        display: none;
    }

    .theme-toggle-btn,
    .github-link,
    .lang-selector-container {
        padding: 8px 10px;
    }

    .search-box {
        flex: 1 1 auto;
    }

    .search-box input {
        width: 100%;
    }

    .search-dropdown {
        position: fixed;
        top: 60px;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
    }

    .content-area {
        padding: 1.2rem 4%;
    }

    .screenshot-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .modal-window {
        width: 94%;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header, .modal-footer {
        padding: 0.85rem 1rem;
    }

    .ai-chat-fab {
        bottom: 16px;
        right: 16px;
        padding: 8px 14px;
        font-size: 12px;
        z-index: 99990;
    }

    .ai-chat-window {
        position: fixed;
        top: 60px;
        bottom: 12px;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
        height: auto;
        max-height: none;
        z-index: 99995;
    }
}

/* ---- Tier 4: 375px (Compact Mobile & Small Phone Safety Net) ---- */
@media screen and (max-width: 375px) {
    .brand-logo {
        width: 32px;
        height: 32px;
    }

    .header-brand h1 {
        max-width: 28vw;
        font-size: 14px;
    }

    .screenshot-grid,
    .features-grid,
    .editor-modes-container,
    .utilities-grid {
        grid-template-columns: 1fr;
    }

    .doc-table th, .doc-table td,
    .frozen-table th, .frozen-table td {
        padding: 8px 10px;
        font-size: 11.5px;
    }

    .ai-chat-window {
        bottom: 60px;
        right: 8px;
        left: 8px;
        height: min(65vh, 65dvh);
    }

    .ai-status {
        display: none;
    }

    .ai-chat-fab {
        width: 52px;
        height: 52px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        bottom: 16px;
        right: 16px;
    }

    .ai-chat-fab .fab-label {
        display: none;
    }

    .ai-chat-fab .fab-icon {
        font-size: 22px;
    }
}