@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Work+Sans:wght@500;600&display=swap');

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-alt: #f9f9fb;
    --text: #1f2430;
    --muted: #6b728a;
    --border: #d9dce5;
    --border-strong: #c2c6d6;
    --accent: #4b61d1;
    --accent-dark: #3c4ea5;
    --accent-soft: #edf0ff;
    --legacy-light: #f0f0f0;
    --legacy-mid: #d0d0d0;
    --legacy-dark: #464b5e;
    --page-gradient-start: #fbfbfd;
    --page-gradient-mid: var(--legacy-light);
    --page-gradient-end: var(--bg);
    --shadow-soft: 0 8px 24px rgba(31, 36, 48, 0.1);
    --shadow-subtle: 0 2px 8px rgba(31, 36, 48, 0.06);
    --radius-lg: 18px;
    --radius-md: 12px;
}

body.theme-dark {
    --bg: #0a0d16;
    --surface: #161a28;
    --surface-alt: #1f2334;
    --text: #f2f4ff;
    --muted: #a8b2d5;
    --border: #2a2f44;
    --border-strong: #3b4360;
    --accent: #8aa4ff;
    --accent-dark: #6f85dd;
    --accent-soft: rgba(138, 164, 255, 0.18);
    --legacy-light: #1c2031;
    --legacy-mid: #2b3146;
    --legacy-dark: #e8ebff;
    --page-gradient-start: #05070e;
    --page-gradient-mid: #0f1423;
    --page-gradient-end: #05060b;
    --shadow-soft: 0 16px 32px rgba(1, 3, 9, 0.6);
    --shadow-subtle: 0 4px 20px rgba(1, 3, 9, 0.4);
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 2.5rem 1.5rem 3rem;
    background: linear-gradient(180deg, var(--page-gradient-start) 0%, var(--page-gradient-mid) 35%, var(--page-gradient-end) 100%);
    color: var(--text);
    font-family: 'Roboto', sans-serif;
    line-height: 1.7;
    transition: background 0.4s ease, color 0.2s ease;
}

::selection {
    background: var(--accent);
    color: #fff;
}

p {
    font-size: 1rem;
    margin: 0 0 1rem;
    color: var(--text);
}

a {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease, box-shadow 0.2s ease;
}

a:hover {
    color: var(--accent-dark);
}

a:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 3px;
    border-radius: 6px;
}

code {
    font-family: 'Roboto Mono', 'Fira Code', monospace;
    font-size: 0.9rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    background: var(--surface-alt);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 2rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--legacy-mid);
    overflow: hidden;
}

th,
td {
    border: 1px solid var(--legacy-mid);
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
}

th {
    background: var(--legacy-light);
    font-weight: 600;
    letter-spacing: 0.02em;
}

tr:nth-child(even) td {
    background: var(--surface-alt);
}

ul {
    margin: 0.35rem 0 1rem 1.2rem;
    padding: 0;
}

ul li {
    margin-bottom: 0.35rem;
}

ol {
    margin: 0.6rem 0 1.2rem 1.4rem;
    padding-left: 1rem;
}

ol li {
    margin-bottom: 0.35rem;
}

h1,
h2,
h3,
h4,
h5 {
    font-family: 'Work Sans', 'Roboto', sans-serif;
    color: var(--text);
    margin: 1.8rem 0 0.5rem;
    line-height: 1.3;
}

h1 {
    font-size: 2.1rem;
}

h2 {
    font-size: 1.8rem;
}

h3 {
    font-size: 1.45rem;
}

h4 {
    font-size: 1.2rem;
}

h5 {
    font-size: 1rem;
    letter-spacing: 0.01em;
}

.content h1 {
    font-size: 1.4rem;
    margin-top: 1rem;
}

.content h2 {
    font-size: 1.25rem;
}

.content h3 {
    font-size: 1.15rem;
}

.content h4 {
    font-size: 1.05rem;
}

.mainpage {
    max-width: 1200px;
    margin: 0 auto;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-alt) 100%);
    border: 1px solid var(--legacy-mid);
    border-radius: var(--radius-lg);
    padding: 2.5rem 3rem 3rem;
    box-shadow: var(--shadow-soft);
}

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--legacy-mid);
    padding-bottom: 1.2rem;
}

.header > a {
    text-decoration: none;
    color: inherit;
}

.pagetitle {
    display: inline-flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pagetitle h2 {
    margin: 0;
    font-size: 2rem;
    letter-spacing: -0.02em;
}

.pagetitle h4 {
    margin: 0;
    font-weight: 500;
    color: var(--muted);
}

.menu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.menu li {
    display: flex;
    gap: 0.4rem;
}

.menu li a {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1.25rem;
    border-radius: 999px;
    background: var(--legacy-light);
    color: var(--legacy-dark);
    border: 1px solid var(--legacy-mid);
    font-size: 0.95rem;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.menu li a:hover {
    background: var(--surface-alt);
    color: var(--accent-dark);
    box-shadow: var(--shadow-subtle);
}

.menu li a.active,
.menu li a:focus {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 10px 22px rgba(75, 97, 209, 0.3);
}

.description,
.desc {
    font-size: 0.98rem;
    font-style: italic;
    color: var(--muted);
    margin: 0.2rem 0 1rem;
}

.post,
.mypost,
.lesson {
    display: block;
    width: 100%;
    border: 1px solid var(--legacy-mid);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: 1.35rem 1.6rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-subtle);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post:hover,
.mypost:hover,
.lesson:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(31, 36, 48, 0.12);
}

.mypost {
    border-width: 2px;
    border-color: var(--accent);
}

.lesson {
    border-left: 6px solid transparent;
    background: linear-gradient(135deg, rgba(75, 97, 209, 0.08), var(--legacy-light));
}

.lesson h4 {
    margin-top: 0;
    font-size: 1.2rem;
}

.lesson.current {
    border-left-color: var(--accent);
    box-shadow: 0 14px 32px rgba(75, 97, 209, 0.18);
    background: linear-gradient(135deg, rgba(75, 97, 209, 0.15), var(--surface));
}

.lesson ol {
    margin-top: 0.9rem;
}

.lesson h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.lesson h5 li {
    list-style-position: inside;
}

.lesson ol li {
    padding: 0.4rem 0.6rem;
    border-left: 3px solid var(--legacy-mid);
    border-radius: 8px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.lesson ol li:hover {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.lesson ol li i {
    color: var(--accent);
    margin-right: 0.35rem;
}

.lesson ol li a {
    color: inherit;
}

.output,
.input {
    display: block;
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px dashed var(--legacy-mid);
    background: var(--legacy-light);
    margin: 0.8rem 0 1.2rem;
}

.output {
    font-size: 0.85rem;
    font-family: 'Roboto Mono', monospace;
}

.output input[type=text] {
    width: 100%;
}

.footer {
    max-width: 1200px;
    margin: 2rem auto 1rem;
    background: var(--surface);
    padding: 1.5rem 3rem;
    border-radius: var(--radius-lg);
    color: var(--muted);
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--legacy-mid);
}

.bottombox {
    background: var(--legacy-light);
    padding: 1.75rem 2rem;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--legacy-mid);
}

dl.short {
    margin-top: 0.4rem;
    margin-bottom: 1rem;
}

dl.short dt {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.2rem;
}

dl.short dd {
    margin-left: 0;
    color: var(--muted);
}

dl.short code {
    padding: 0.2rem 0.4rem;
}

button,
input[type=submit] {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
    border: none;
    color: #fff;
    padding: 0.75rem 1.6rem;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(75, 97, 209, 0.25);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:hover,
input[type=submit]:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(75, 97, 209, 0.28);
}

button:disabled,
input[type=submit]:disabled {
    cursor: not-allowed;
    background: var(--border-strong);
    box-shadow: none;
}

.theme-toggle {
    margin-left: 0.6rem;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--legacy-mid);
    background: var(--surface-alt);
    color: var(--legacy-dark);
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle i {
    font-size: 0.95rem;
}

.theme-toggle:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 2px;
}

.theme-toggle:hover {
    background: var(--legacy-light);
    border-color: var(--border-strong);
    transform: none;
    box-shadow: none;
}

body.theme-dark .theme-toggle {
    color: var(--text);
}

input[type=text],
input[type=password],
input[type=number],
input[type=file],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    box-sizing: border-box;
    font-size: 1rem;
    font-family: inherit;
    border-radius: 12px;
    border: 1px solid var(--legacy-mid);
    background: var(--legacy-light);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input[type=number] {
    max-width: 220px;
    font-family: monospace;
}

input.shorttext {
    width: 40%;
}

textarea {
    min-height: 160px;
    resize: vertical;
}

input[type=text]:focus,
input[type=password]:focus,
input[type=number]:focus,
input[type=file]:focus,
textarea:focus {
    border-color: var(--accent);
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(75, 97, 209, 0.18);
}

.fa-solid {
    color: var(--accent);
}

@media (max-width: 1024px) {
    .mainpage {
        padding: 2rem;
    }

    .footer {
        padding: 1.2rem 2rem;
    }
}

@media (max-width: 720px) {
    body {
        padding: 1.5rem 1rem 2rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .menu {
        width: 100%;
    }

    .menu ul {
        justify-content: flex-start;
    }

    .mainpage {
        padding: 1.5rem;
    }

    table,
    th,
    td {
        font-size: 0.9rem;
    }

    input.shorttext,
    textarea,
    input[type=number] {
        width: 100%;
        max-width: 100%;
    }
}
