@charset "utf-8";

/* ★★★ Root Variables ★★★ */
:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --text-color-base: #222;
    --text-color-header: #333;
    --bg-color-base: #fdfdfd;
    --bg-color-accent: #f2f2f2;
    --bg-color-empty: #ccc;
    --bg-color-header: #bcc9f7;
    --bg-color-highlight: #f7c9c9;
    --bg-color-main: #e6f5db;
    --bg-color-th: #f7bcc9;
    --border-color-base: #ccc;
    --border-color-accent: #3b7b85;
    --border-color-cell: #565656;
    --indent-size: 1.5;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-color-base: #eee;
        --text-color-header: #eee;
        --bg-color-base: #121212;
        --bg-color-accent: #2c2c2c;
        --bg-color-empty: #555;
        --bg-color-header: #2c4a52;
        --bg-color-highlight: #5a3a3a;
        --bg-color-main: #2a3a2a;
        --bg-color-th: #5a3a3a;
        --border-color-base: #555;
        --border-color-accent: #a8e0e8;
        --border-color-cell: #aeaeae;
    }
}


/* ★★★ <html> etc. ★★★ */
html {
    font-size: clamp(16px, 2.5dvw, 18px);
    box-sizing: border-box;
    scroll-behavior: smooth;
    color-scheme: light dark;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}


/* ★★★ <body> ★★★ */
body {
    /* ★★ STYLE ★★ */
    font-family: var(--font-sans);
    color: var(--text-color-base);
    background-color: var(--bg-color-base);
    line-height: 1.6;
    margin: 0;
    padding: 1.5rem;
    overflow-wrap: break-word;
    max-width: 100dvw;
    /* ★★ COUNTER ★★ */
    counter-reset: h2-counter;
}
@media print {
    body:has(dialog[open]) > *:not(dialog[open]) {
        display: none !important;
    }
}


/* ★★★ <h2> & <h3> & <h4> ★★★ */
body h2 {
    /* ★★ STYLE ★★ */
    background-color: var(--bg-color-header);
    color: var(--text-color-header);
    padding: 0.5rem 1rem;
    border-bottom: 3px solid var(--border-color-accent);
    border-radius: 4px 4px 0 0;
    margin-top: 2rem;
    /* ★★ COUNTER ★★ */
    counter-reset: h3-counter;
}
body h2::before {
    counter-increment: h2-counter;
    content: "[" counter(h2-counter) "] ";
}
body h3 {
    /* ★★ STYLE ★★ */
    padding: 0.3rem 0.5rem;
    border-bottom: 2px double var(--border-color-base);
    margin-top: 1.5rem;
    /* ★★ COUNTER ★★ */
    counter-reset: h4-counter;
}
body h3::before {
    counter-increment: h3-counter;
    content: "[" counter(h2-counter) "-" counter(h3-counter) "] ";
}
body h4 {
    /* ★★ STYLE ★★ */
    padding: 0.3rem;
    border-bottom: 1px dotted var(--border-color-base);
    margin-top: 1.5rem;
}
body h4::before {
    counter-increment: h4-counter;
    content: "[" counter(h2-counter) "-" counter(h3-counter) "-" counter(h4-counter) "] ";
}


/* ★★★ STYLE OF <div id="toc"> etc. ★★★ */
#toc {
    margin: 1rem auto;
    padding: 1rem;
    background: var(--bg-color-base);
    border: 1px solid var(--border-color-base);
    border-radius: 8px;
}
#toc ol {
    counter-reset: toc-li;
    list-style-type: none;
    padding-left: 0;
}
#toc ol li::before {
    counter-increment: toc-li;
    content: "[" counters(toc-li,"-") "] ";
}


/* ★★★ STYLE OF <div class="scrollable-wrapper"> ★★★ */
div.scrollable-wrapper {
    overflow-x: auto;
    width: 100%;
}
@media print {
    div.scrollable-wrapper {
        overflow-x: visible;
        break-before: always;
        break-after: always;
    }
}


/* ★★★ STYLE OF <div class="main-content"> ★★★ */
div.main-content {
    width: fit-content;
    border: 1px solid var(--border-color-base);
    border-radius: 8px;
    background: var(--bg-color-main);
    box-shadow: 0 4px 8px var(--shadow-color);
    padding: 1.5rem;
    margin: 1rem 0;
}


/* ★★★ STYLE OF <div class="sub-content"> ★★★ */
div.sub-content {
    width: auto;
    padding: 1rem;
    border-left: 3px solid var(--border-color-accent);
}


/* ★★★ STYLE OF <table> etc. ★★★ */
table {
    display: table;
    width: 100%;
    min-width: fit-content;
    border-collapse: collapse;
    margin: 1.5rem 0;
    overflow: hidden;
}
caption {
    white-space: nowrap;
    font-weight: bold;
    font-size: 1.2rem;
    padding: 0.8rem;
    background-color: var(--bg-color-header);
    color: var(--text-color-header);
    text-align: center;
}
tbody > tr:nth-child(odd) > td {
    background-color: var(--bg-color-base);
}
tbody > tr:nth-child(even) > td {
    background-color: var(--bg-color-accent);
}
th,
td {
    border: 1px solid var(--border-color-cell);
    empty-cells: show;
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    line-height: 1.4;
}
th {
    background-color: var(--bg-color-th);
    color: var(--text-color-header);
    font-weight: 700; /* bold */
    text-align: center;
    vertical-align: middle;
}
td {
    color: var(--text-color-base);
    text-align: left;
}
td.empty {
    background-color: var(--bg-color-empty);
}


/* ★★★ STYLE OF <table class="fixed"> ★★★ */
table.fixed {
    table-layout: fixed;
    min-width: 40rem;
}
table.fixed th,
table.fixed td {
    white-space: normal;
}


/* ★★★ STYLE OF <strong> ★★★ */
strong {
    background-image: linear-gradient(
        to bottom,
        transparent 60%,
        var(--bg-color-highlight) 60%);
    }
    color: var(--text-color-base);
    box-decoration-break: clone;
}


/* ★★★ STYLE OF <dt> ★★★ */
dt {
    font-weight: bold;
    margin-top: 1rem;
}


/* ★★★ STYLE OF <sup> AND <sub> ★★★ */
sup,
sub {
    font-size: 80%;
    line-height: 0;
}


/* ★★★ STYLE OF <code> ★★★ */
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background-color: var(--bg-color-accent);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}
tbody tr:nth-child(even) > td code {
    background-color: var(--bg-color-base);
}
code:has(div){
    display: block;
    width: max-content;
}
code > div {
    white-space: pre;
}
code .indent-margin {
    margin-left: 0rem;
    padding-left: calc(var(--indent-size) * 1rem);
}


/* ★★★ STYLE OF <dl>, <ol> AND <ul> ★★★ */
dl,
ol,
ul {
    margin-left: 0rem;
}
:is(dd, li).has-list-only > :is(dl, ol, ul) {
    margin-left: calc(var(--indent-size) * -1rem);
}
dt {
    font-weight: bold;
}
dd,
li {
    margin-left: calc(var(--indent-size) * 1rem);
}
ol > li {
    list-style-type: decimal;
    list-style-position: outside;
}
dd > ul > li,
ol > li > ul > li,
ul > li {
    list-style-type: disc;
    list-style-position: outside;
}
ul > li > ul > li,
ul > li > ul > li > ul > li > ul > li,
ul > li > ul > li > ul > li > ul > li > ul > li > ul > li {
    list-style-type: circle;
    list-style-position: outside;
}


/* ★★★ STYLE FOR class="indent-margin" ★★★ */
.indent-margin:not(code) {
    margin-left: calc(var(--indent-size) * 1rem);
}



/* ★★★ STYLE FOR class="flex-center" ★★★ */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ★★★ STYLE FOR class="flex-vert-center" ★★★ */
.flex-vert-center {
    display: flex;
    align-items: center;
}


/* ★★★ STYLE FOR class="flex-horiz-center" ★★★ */
.flex-horiz-center {
    display: flex;
    justify-content: center;
}


/* ★★★ STYLE FOR class="display-block" ★★★ */
.display-block {
    display: block;
    margin: 0.5rem auto;
}


/* ★★★ STYLE OF BUTTONS ★★★ */
button,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-color-header);
    background-color: var(--bg-color-header);
    border: 1px solid var(--border-color-accent);
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow-color);
    transition: opacity 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    vertical-align: middle;
}
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover {
    opacity: 0.85;
}
button:active,
input[type="button"]:active,
input[type="submit"]:active,
input[type="reset"]:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--shadow-color);
}
button:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled {
    background-color: var(--bg-color-empty);
    border-color: var(--border-color-base);
    color: var(--text-color-base);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}


/* ★★★ STYLE OF <select> ★★★ */
select {
    display: inline-block;
    field-sizing: content;
    min-width: 5rem;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-color-base);
    background-color: var(--bg-color-base);
    border: 1px solid var(--border-color-base);
    border-radius: 4px;
    cursor: pointer;
    background-image: 
        linear-gradient(45deg, transparent 50%, var(--text-color-base) 50%),
        linear-gradient(135deg, var(--text-color-base) 50%, transparent 50%);
    background-position: 
        calc(100% - 15px) calc(50% + 2px),
        calc(100% - 10px) calc(50% + 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    vertical-align: middle;
}
select:focus {
    outline: none;
    border-color: var(--border-color-accent);
    box-shadow: 0 0 0 2px var(--bg-color-header);
}


/* ★★★ STYLE OF <details class="custom-dropdown"> ★★★ */
details.custom-dropdown {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}
details.custom-dropdown > summary {
    list-style: none;
    padding: 0.5rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-color-header);
    background-color: var(--bg-color-accent);
    border: 1px solid var(--border-color-base);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: background-color 0.2s ease;
}
details.custom-dropdown > summary::-webkit-details-marker {
    display: none;
}
details.custom-dropdown > summary::after {
    content: "▼";
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}
details.custom-dropdown[open] > summary::after {
    transform: rotate(180deg);
}
details.custom-dropdown > .dropdown-content {
    position: absolute;
    top: calc(100% + 0.3rem);
    left: 0;
    min-width: 100%;
    background-color: var(--bg-color-base);
    border: 1px solid var(--border-color-base);
    border-radius: 4px;
    box-shadow: 0 4px 8px var(--shadow-color);
    padding: 0.5rem;
    z-index: 100;
    white-space: nowrap;
}


/* ★★★ STYLE OF <input> AND <textarea> ★★★ */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
textarea {
    display: inline-block;
    field-sizing: content;
    min-width: 5rem;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-color-base);
    background-color: var(--bg-color-base);
    border: 1px solid var(--border-color-base);
    border-radius: 4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    vertical-align: middle;
}
textarea {
    resize: both;
    min-height: 2.5rem;
}
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-color-accent);
    box-shadow: 0 0 0 2px var(--bg-color-header);
}
input::placeholder,
textarea::placeholder {
    color: var(--bg-color-empty);
}


/* ★★★ STYLE OF <input type="radio"> AND <input type="checkbox"> ★★★ */
input[type="radio"],
input[type="checkbox"] {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    width: 1.2rem;
    height: 1.2rem;
    margin-right: 0.5rem;
    cursor: pointer;
    vertical-align: middle;
}


/* ★★★ STYLE OF <details> ★★★ */
details:not(.custom-dropdown) {
    background-color: var(--bg-color-base);
    border: 1px solid var(--border-color-base);
    border-radius: 8px;
    width: fit-content;
    margin: 0.5rem 0rem;
    overflow: hidden;
}
details:not(.custom-dropdown) > summary {
    font-weight: bold;
    padding: 0.5rem;
    background-color: var(--bg-color-accent);
    color: var(--text-color-header);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
details:not(.custom-dropdown) > summary:hover {
    background-color: var(--bg-color-empty);
}
details:not(.custom-dropdown)[open] > summary {
    border-bottom: 1px solid var(--border-color-base);
}
details:not(.custom-dropdown) > div,
details:not(.custom-dropdown) > p {
    padding: 1rem 1.2rem;
}


/* ★★★ STYLE OF <dialog> ★★★ */
dialog {
    background-color: var(--bg-color-base);
    color: var(--text-color-base);
    border: 2px solid var(--border-color-accent);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow-color);
    padding: 1.5rem;
    min-height: 10rem;
    min-width: 10rem;
    height: fit-content;
    width: fit-content;
    max-height: min(90dvh, 35rem);
    max-width: min(90dvw, 35rem);
    overflow: auto;
    overscroll-behavior: contain;
    margin: auto;
}
dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
@media print {
    dialog[open] {
        position: static;
        border: none;
        box-shadow: none;
        padding: 0rem;
        max-height: none;
        max-width: none;
        margin: 0rem;
    }
}


/* ★★★ STYLE OF <hr> ★★★ */
hr {
    margin: 1.5rem auto;
    width: 80%;
    border-style: dashed;
}
hr[data-for-content] {
    text-align: center;
    overflow: visible;
}
hr[data-for-content]::after {
    content: attr(data-for-content);
    color: var(--text-color-base);
    font-size: 1rem;
    display: inline-block;
    background-color: var(--bg-color-base);
    padding: 0rem 0.5rem;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
}
