/* Reset & Base Variables */
:root {
    --color-base: #202122;
    --color-link: #0645ad;
    --color-link-visited: #0b0080;
    --color-link-red: #ba0000;
    --color-background: #ffffff;
    --color-gray-soft: #f8f9fa;
    --color-border: #a2a9b1;
    --color-toc-bg: #f8f9fa;
    --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Lato, Helvetica, Arial, sans-serif;
    --font-family-heading: 'Linux Libertine', 'Georgia', 'Times', serif;
}

body {
    margin: 0;
    padding: 0;
    color: var(--color-base);
    background-color: var(--color-gray-soft);
    font-family: var(--font-family-base);
    font-size: 14px;
    line-height: 1.6;
}

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

a:hover {
    text-decoration: underline;
}

/* Header */
.mw-header {
    display: flex;
    align-items: center;
    background-color: #fff;
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.mw-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.mw-logo a {
    display: flex;
    align-items: center;
    color: var(--color-base);
    padding: 0 1rem;
}

.mw-logo-icon {
    font-family: var(--font-family-heading);
    font-size: 24px;
    font-weight: bold;
    margin-right: 5px;
}

.mw-logo-wordmark {
    font-family: var(--font-family-heading);
    font-size: 20px;
    font-weight: normal;
}

.mw-logo-tagline {
    font-size: 11px;
    color: #54595d;
    margin-left: 8px;
    display: none;
}

.mw-search {
    flex-grow: 1;
    max-width: 400px;
    margin: 0 20px;
    display: flex;
}

.mw-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 2px 0 0 2px;
}

.search-btn {
    border: 1px solid var(--color-border);
    border-left: none;
    background: #f8f9fa;
    cursor: pointer;
    padding: 0 10px;
}

.mw-user-tools {
    margin-left: auto;
    font-size: 13px;
}

.mw-user-tools a {
    margin-left: 10px;
}

/* Page Layout */
.mw-page-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    background: #fff;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    min-height: 100vh;
}

/* Sidebar */
.mw-sidebar {
    width: 176px;
    padding: 20px 10px;
    background-color: var(--color-gray-soft);
    border-right: 1px solid var(--color-border);
    flex-shrink: 0;
    transition: margin-left 0.3s ease;
}

.menu-section {
    margin-bottom: 1.5rem;
}

/* デスクトップではモバイル用ツールを非表示 */
.mobile-user-tools {
    display: none;
}

.menu-section h3 {
    font-size: 12px;
    color: #54595d;
    margin-bottom: 5px;
    border-bottom: 1px solid #c8ccd1;
    padding-bottom: 2px;
}

.menu-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-section li {
    margin: 4px 0;
}

.menu-section a {
    font-size: 13px;
    color: var(--color-link);
}

/* Main Content */
.mw-content {
    flex-grow: 1;
    padding: 20px 30px;
    background: #fff;
    min-width: 0;
}

.firstHeading {
    font-family: var(--font-family-heading);
    font-weight: normal;
    font-size: 1.8em;
    border-bottom: 1px solid var(--color-border);
    margin-top: 0;
    margin-bottom: 0.25em;
    padding-bottom: 0;
}

.mw-body-subheader {
    font-size: 13px;
    color: #54595d;
    margin-bottom: 1.5em;
}

.mw-parser-output {
    line-height: 1.6;
}

.mw-parser-output h2 {
    font-family: var(--font-family-heading);
    font-weight: normal;
    border-bottom: 1px solid var(--color-border);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.mw-parser-output h3 {
    font-weight: bold;
    margin-top: 1.2em;
}

/* Infobox */
.infobox {
    float: right;
    clear: right;
    margin: 0 0 1em 1em;
    width: 300px;
    background: #f8f9fa;
    border: 1px solid var(--color-border);
    padding: 5px;
    font-size: 90%;
}

.infobox-title {
    text-align: center;
    font-size: 125%;
    font-weight: bold;
    background-color: #efefef;
    padding: 5px;
}

.infobox-subtitle {
    text-align: center;
    font-size: 90%;
    margin-bottom: 5px;
}

.infobox-images {
    display: flex;
    text-align: center;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.infobox-image-item {
    flex: 1;
    padding: 0 5px;
}

.infobox-image-item img {
    max-width: 100%;
    height: auto;
    border: 1px solid #ccc;
}

.infobox-table {
    width: 100%;
    border-collapse: collapse;
}

.infobox-table th,
.infobox-table td {
    padding: 4px;
    vertical-align: top;
    border-bottom: 1px solid #eaecf0;
}

.infobox-table th {
    text-align: left;
    width: 35%;
}

/* Thumbnails */
.thumb.tright {
    float: right;
    clear: right;
    margin: 0.5em 0 1em 1.4em;
    background-color: transparent;
}

.thumbinner {
    border: 1px solid #c8ccd1;
    padding: 3px;
    background-color: #f8f9fa;
    font-size: 94%;
    text-align: center;
    overflow: hidden;
}

.thumbimage {
    max-width: 100%;
    height: auto;
    border: 1px solid #eaecf0;
}

.thumbcaption {
    padding: 3px;
    text-align: left;
    line-height: 1.4em;
    color: #202122;
}

/* TOC */
.toc {
    display: table;
    padding: 7px;
    margin: 1em 0;
    border: 1px solid #a2a9b1;
    background-color: #f8f9fa;
    font-size: 95%;
}

.toctitle {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toctitle h2 {
    margin: 0;
    font-family: var(--font-family-base);
    font-size: 100%;
    font-weight: bold;
    border: none;
}

.toctogglespan {
    margin-left: 10px;
    font-size: 90%;
}

.toctogglelabel {
    cursor: pointer;
    color: var(--color-link);
}

.toctogglecheckbox:checked~ul {
    display: none;
}

.toctogglecheckbox:checked~.toctitle .toctogglelabel::after {
    content: '[表示]';
}

.toctogglelabel::after {
    content: '[非表示]';
}

.toc ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    padding-left: 1.5em;
}

.toc>ul {
    padding-left: 0;
    margin-top: 10px;
}

.tocnumber {
    color: #202122;
}

.toctext {
    color: var(--color-link);
}

.toc-active {
    background-color: #eaf3ff;
    font-weight: bold;
}

/* Footer */
.mw-footer {
    border-top: 1px solid var(--color-border);
    margin-top: 3em;
    padding: 1.5em 0;
    font-size: 0.85em;
}

.mw-footer ul {
    list-style: none;
    margin: 0 0 1em 0;
    padding: 0;
}

.mw-footer li {
    display: inline-block;
    margin-right: 1em;
}

/* Responsive */
@media screen and (min-width: 1000px) {
    .mw-logo-tagline {
        display: inline;
    }
}

@media screen and (max-width: 768px) {
    .mw-sidebar {
        position: fixed;
        left: -250px;
        top: 48px;
        height: calc(100vh - 48px);
        z-index: 99;
        background: #f8f9fa;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
    }

    .mw-sidebar.active {
        left: 0;
    }

    .mw-page-container {
        border: none;
    }

    .infobox {
        float: none;
        width: 100%;
        margin: 1em 0;
        box-sizing: border-box;
    }

    .thumb.tright {
        float: none;
        width: 100%;
        margin: 1em 0;
    }

    .thumbinner {
        width: 100% !important;
        box-sizing: border-box;
    }

    .mw-content {
        padding: 10px 15px;
    }

    /* モバイル・ヘッダー調整 */
    .mw-header {
        justify-content: flex-start;
        padding: 0.5rem;
        gap: 10px;
    }

    .mw-logo a {
        padding: 0;
    }

    .mw-logo-icon {
        display: none;
    }

    .mw-search {
        margin: 0 0 0 auto;
        flex-grow: 0;
        width: auto;
    }

    .mw-search input {
        display: none;
    }

    .search-btn {
        border: none;
        background: transparent;
        font-size: 1.2rem;
        padding: 0.5rem;
    }

    .mw-user-tools {
        display: none;
    }

    /* サイドバー内のモバイルユーザーメニューを表示 */
    .mobile-user-tools {
        display: block;
    }
}

/* Donation Popup */
.donation-popup {
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    background-color: #fff;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-top: 3px solid var(--color-link);
}

.donation-popup.show {
    bottom: 0;
}

.donation-popup-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 30px;
    text-align: center;
    position: relative;
}

.donation-popup h3 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--color-base);
}

.donation-popup p {
    font-size: 0.95rem;
    color: #54595d;
    margin-bottom: 20px;
}

.donation-btn {
    display: inline-block;
    background-color: var(--color-link);
    color: #fff;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.2s;
}

.donation-btn:hover {
    background-color: var(--color-link-visited);
    color: #fff;
    text-decoration: none;
}

.later-btn {
    display: block;
    margin: 10px auto 0;
    background: none;
    border: none;
    color: #54595d;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.close-btn:hover {
    color: #000;
}