:root {
    --primary-color: #3d4b6e;
    --secondary-color: #515a6a;
    --h2-color: #557ef9;
    --h3-color: #6e8b54;
    --text-color: #495458;
    --border-color: #796d8e;
    --container-bg: #ebebeb;
    --shadow-color: rgb(255 255 255 / 84%);
    --toc-active: #898989;
}

body {
    font-family: "M PLUS Rounded 1c", sans-serif;
    font-weight: 500;
    margin: 0;
    display: flex;
    min-height: 100vh;
    background-color: var(--secondary-color);
    color: var(--text-color);
}

#content strong,
#content b {
    font-weight: 900;
    color: #333;
}

.container {
    display: flex;
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-shadow: 0 0 10px var(--shadow-color);
    background-color: var(--container-bg);
    border-radius: 5px;
}

nav {
    width: 25%;
    padding: 20px;
    border-right: 1px solid var(--border-color);
    min-height: calc(100vh - 40px - 40px);
    box-sizing: border-box;
}

nav h1 {
    margin-top: 0;
    color: var(--primary-color);
}

nav h1:before {
    content: none !important;
}

nav h1:after {
    bottom: 0px !important;
}

nav ul {
    list-style: none;
    padding: 0;
}

nav li a {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s, color 0.3s;
    position: relative;
    padding-left: 30px;
}

nav li a::before {
    content: "\f0da";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-color);
}

nav li a:hover {
    background-color: var(--primary-color);
    color: #fff;
}

nav li a:hover::before,
nav li:target>a::before {
    color: #fff;
}

main {
    width: 75%;
    padding: 20px;
    overflow-y: auto;
    line-height: 1.6;
}

main ul {
    list-style: none;
    padding-left: 20px;
}

main ul li {
    position: relative;
    padding-left: 25px;
}

main ul li::before {
    content: "\f00c";
    /* チェックマーク */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 0;
    top: 2px;
    color: var(--primary-color);
}

main ol {
    list-style: none;
    counter-reset: item;
    padding-left: 20px;
}

main ol li {
    counter-increment: item;
    position: relative;
    padding-left: 30px;
}

main ol li::before {
    content: counter(item) ".";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--text-color);
}

h1,
h2,
h3 {

    color: var(--primary-color);
    position: relative;
    padding-left: 10px;
    list-style: none;
}

h2 {
    color: var(--h2-color);
    padding-left: 25px;
}

h3 {
    color: var(--h3-color);
    padding-left: 35px;
}


h1:before,
h2:before,
h3:before {
    content: "";
    position: absolute;
    top: 45%;
    left: 0px;
    transform: translateY(-50%);
    width: 5px;
    height: 38px;
    background-color: var(--primary-color);
}

h2:before {
    left: 15px;
    background-color: var(--h2-color);
}

h3:before {
    left: 25px;
    background-color: var(--h3-color);

}

h1:after,
h2:after,
h3:after {
    content: "";
    position: absolute;
    bottom: 9px;
    left: 0px;
    width: 50%;
    height: 1px;
    background-color: var(--primary-color);
}

h2:after {
    background-color: var(--h2-color);
    bottom: 2px;
    left: 15px;
}

h3:after {
    background-color: var(--h3-color);
    bottom: -3px;
    left: 25px;
}



h1:target::before,
h2:target::before,
h3:target::before {
    background-color: #fff;
    border: 2px solid var(--primary-color);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 5px;
    box-shadow: 0 0 5px var(--shadow-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

th,
td {
    padding: 8px;
    border: 1px solid var(--border-color);
    text-align: left;
}

p {
    margin-left: 15px;
}

.copy-code-button {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 4px 8px;
    font-size: 12px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s, background-color 0.3s;
    font-family: sans-serif;
    /* コード用フォントと分ける */
    z-index: 1;
}

.copy-code-button:hover {
    opacity: 1;
    background-color: var(--h2-color);
}

.copy-code-button.copied {
    background-color: var(--h3-color);
    opacity: 1;
}

pre {
    position: relative;
    padding-top: 35px;
    background-color: #f5f5f5;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    margin-left: 30px;
    overflow-x: auto;
}

code {
    font-family: monospace;
    font-size: 14px;
    white-space: pre-wrap;
}

#toc-toggle {
    display: none;
}

#toc {
    position: static;
    transform: translateX(0);
    left: 0;
    height: auto;
    overflow-y: visible;
}

#toc a.active {
    background-color: var(--toc-active);
    color: #fff;
}

@media (min-width: 769px) {

    /* デスクトップ表示時 */
    .container {
        display: flex;
    }

    #toc {
        position: sticky;
        top: 20px;
        height: calc(100vh - 40px);
        overflow-y: auto;
    }

    #toc-toggle {
        display: none;
    }
}

@media (max-width: 768px) {
    img {
        max-width: 90%;
    }

    #toc-toggle {
        display: block;
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 10;
        background-color: var(--primary-color);
        color: #fff;
        border: none;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
    }

    #toc-toggle i {
        font-size: 1.2em;
    }

    #toc {
        position: fixed;
        top: 0;
        left: -280px;
        width: 250px;
        height: 100%;
        overflow-y: auto;
        background: #fff;
        z-index: 9;
        box-shadow: 0 0 10px var(--shadow-color);
        padding: 20px;
        box-sizing: border-box;
        transition: transform 0.3s ease-in-out;
    }

    #toc.active {
        transform: translateX(280px);
    }

    .container {
        flex-direction: column;
        padding: 10px;
    }

    nav {
        width: 100%;
        border-right: none;
    }

    main {
        width: 100%;
        padding: 20px 10px 10px;
    }
}

nav li a.h1-link::before {
    content: "";
}

nav li a.h1-link>i {
    margin-right: 5px;
}

nav li ul {
    margin-left: 15px;
    list-style: none;
    padding: 0;
}

nav li li a {
    border-bottom: none;
    padding-left: 25px;
}

nav li li a::before {
    content: "\f0da";
}

nav li li li a {
    padding-left: 30px;
}