/* ===== Wiki Layout ===== */
.wiki-container {
    display: grid;
    grid-template-columns: 270px 1fr;
    gap: 24px;
    max-width: 1200px;
    margin: 90px auto 80px;
    padding: 0 24px;
    align-items: start;
    position: relative;
    z-index: 1;
}

/* ===== Sidebar ===== */
.wiki-sidebar {
    position: sticky;
    top: 78px;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(163, 240, 64, 0.2) !important;
    border-radius: 14px !important;
    padding: 16px 12px !important;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: visible;
}

/* ===== Search ===== */
.wiki-search {
    position: relative;
    margin-bottom: 14px;
}

.wiki-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #7fa04e;
    font-size: 0.78rem;
    pointer-events: none;
}

.wiki-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(163, 240, 64, 0.2);
    padding: 8px 8px 8px 32px;
    border-radius: 8px;
    color: #dff5b8;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.wiki-search input::placeholder {
    color: #7fa04e;
    opacity: 0.8;
}

.wiki-search input:focus {
    border-color: #a3f040;
    box-shadow: 0 0 8px rgba(163, 240, 64, 0.3);
}

/* ===== Group (wg) ===== */
.wg {
    margin-bottom: 2px;
}

.wg-hdr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 7px;
    cursor: pointer;
    color: #dff5b8;
    font-weight: 600;
    font-size: 0.87rem;
    user-select: none;
    transition: background 0.2s;
}

.wg-hdr:hover {
    background: rgba(255, 255, 255, 0.07);
}

.wg-hdr.wg-active {
    color: #a3f040;
    background: rgba(163, 240, 64, 0.07);
}

.wg-icon {
    width: 16px;
    text-align: center;
    font-size: 0.78rem;
    color: #a3f040;
    flex-shrink: 0;
}

.wg-label {
    flex: 1;
}

.wg-arrow {
    font-size: 0.6rem;
    opacity: 0.45;
    transition: transform 0.25s;
    flex-shrink: 0;
}

.wg:not(.wg-closed) .wg-arrow {
    transform: rotate(90deg);
}

/* ===== Kids container ===== */
.wg-kids {
    display: block;
    margin-left: 16px;
    padding-left: 10px;
    border-left: 2px solid rgba(163, 240, 64, 0.2);
    overflow: hidden;
    max-height: 600px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    margin-top: 2px;
    margin-bottom: 4px;
}

.wg.wg-closed .wg-kids {
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none;
}

.wg-kid {
    display: block;
    padding: 6px 10px;
    font-size: 0.84rem;
    color: #7fa04e;
    text-decoration: none;
    border-radius: 5px;
    margin-bottom: 1px;
    transition: background 0.15s, color 0.15s;
}

.wg-kid:hover {
    color: #dff5b8;
    background: rgba(255, 255, 255, 0.06);
}

.wg-kid.wg-active {
    color: #a3f040 !important;
    font-weight: 700;
    background: rgba(163, 240, 64, 0.07);
}

/* ===== Content ===== */
.wiki-content {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(163, 240, 64, 0.2);
    border-radius: 14px;
    padding: 38px 42px;
    min-height: 500px;
}

#wiki-title {
    font-size: clamp(1.8rem, 3.5vw, 2.4rem);
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.2;
    background: linear-gradient(135deg, #a3f040, #c5ff60);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#wiki-description {
    color: #7fa04e;
    font-size: 1rem;
    margin-bottom: 28px;
    line-height: 1.7;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(163, 240, 64, 0.15);
}

/* ===== Blocks ===== */
.wb {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(163, 240, 64, 0.1);
}

.wb:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.wb h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #dff5b8;
    margin-bottom: 9px;
}

.wb p {
    color: #7fa04e;
    line-height: 1.8;
    font-size: 0.94rem;
}

.wb-hint {
    text-align: center;
    color: #7fa04e;
    opacity: 0.5;
    font-style: italic;
    padding: 50px 0;
}

.wiki-error {
    color: #ff7070;
    border: 1px dashed rgba(255, 80, 80, 0.35);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

/* ===== Steampunk theme overrides ===== */
[data-theme="steampunk"] .wiki-sidebar {
    background: rgba(200, 119, 58, 0.06) !important;
    border-color: rgba(200, 119, 58, 0.25) !important;
}

[data-theme="steampunk"] .wiki-search input {
    border-color: rgba(200, 119, 58, 0.25);
    color: #e8d5b0;
}

[data-theme="steampunk"] .wiki-search input::placeholder {
    color: #a08060;
}

[data-theme="steampunk"] .wiki-search input:focus {
    border-color: #c8773a;
    box-shadow: 0 0 8px rgba(200, 119, 58, 0.3);
}

[data-theme="steampunk"] .wg-hdr {
    color: #e8d5b0;
}

[data-theme="steampunk"] .wg-hdr.wg-active {
    color: #d4a843;
    background: rgba(200, 119, 58, 0.1);
}

[data-theme="steampunk"] .wg-icon {
    color: #c8773a;
}

[data-theme="steampunk"] .wg-kids {
    border-left-color: rgba(200, 119, 58, 0.25);
}

[data-theme="steampunk"] .wg-kid {
    color: #a08060;
}

[data-theme="steampunk"] .wg-kid:hover {
    color: #e8d5b0;
}

[data-theme="steampunk"] .wg-kid.wg-active {
    color: #d4a843 !important;
    background: rgba(200, 119, 58, 0.08);
}

[data-theme="steampunk"] .wiki-content {
    background: rgba(200, 119, 58, 0.04);
    border-color: rgba(200, 119, 58, 0.2);
}

[data-theme="steampunk"] #wiki-title {
    background: linear-gradient(135deg, #d4a843, #f0c86a);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="steampunk"] #wiki-description {
    color: #a08060;
    border-bottom-color: rgba(200, 119, 58, 0.15);
}

[data-theme="steampunk"] .wb {
    border-bottom-color: rgba(200, 119, 58, 0.1);
}

[data-theme="steampunk"] .wb h3 {
    color: #e8d5b0;
}

[data-theme="steampunk"] .wb p {
    color: #a08060;
}

/* ===== Mobile ===== */
@media (max-width: 860px) {
    .wiki-container {
        grid-template-columns: 1fr;
        margin-top: 76px;
    }

    .wiki-sidebar {
        position: static;
        max-height: none;
    }

    .wiki-content {
        padding: 22px 18px;
        border-radius: 10px;
    }

    .wiki-fab {
        display: flex;
        position: fixed;
        bottom: 25px;
        right: 25px;
        width: 56px;
        height: 56px;
        background: var(--acc);
        color: var(--bg);
        border: none;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 20px rgba(163, 240, 64, 0.3);
        z-index: 150;
        cursor: pointer;
        transition: transform 0.2s, background 0.2s;
    }

    .wiki-fab.active {
        transform: rotate(90deg);
        background: var(--acc2);
    }

    .wiki-sidebar.mobile-open {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 140;
        background: rgba(7, 13, 3, 0.98) !important;
        padding-top: 80px !important;
        border-radius: 0 !important;
        border: none !important;
        animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }
}

.wiki-fab {
    display: none;
}