:root {
    --bg: #f5f5f0;
    --fg: #222;
    --muted: #777;
    --accent: #ff3b00;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #111;
    --fg: #cfcfc8;
    --muted: #8a8a83;
    --accent: #ff3b00;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0 auto;
    max-width: 680px;
    padding: 40px 20px 60px;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.6 Georgia, "Times New Roman", serif;
    text-align: justify;
    overflow-wrap: anywhere;
}

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

h1 { font-size: 2em; margin: 1.2em 0 .4em; }
h2 { font-size: 1.4em; margin: 1.6em 0 .4em; }
h3 { font-size: 1.1em; margin: 1.4em 0 .3em; }

h1, h2, h3 { line-height: 1.2; }

p { margin: 0 0 1em; }

small { font-size: .8em; color: var(--muted); }

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--fg);
    color: var(--bg);
    padding: 8px 14px;
    font: 13px "Courier New", monospace;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus { left: 0; }

code,
pre,
.mono,
.meta,
.nav,
.comment,
.tag,
.number,
.label,
.lead,
.buttons,
.theme-toggle,
footer,
.list-item,
.card .meta,
.card .number {
    font-family: "Courier New", monospace;
    font-size: .95em;
}

/* --- графические приколы --- */

.comment {
    color: var(--muted);
    font-size: 13px;
    margin: 1.6em 0 .2em;
    text-align: left;
    overflow-wrap: anywhere;
}

.comment::before {
    content: "// ";
    color: var(--accent);
}

.comment .hlline {
    color: var(--fg);
    background: rgba(255, 59, 0, .12);
    padding: 0 3px;
}

h2.comment {
    display: flex;
    align-items: baseline;
    gap: 0;
    font-weight: normal;
    font-family: "Courier New", monospace;
    font-size: 13px;
    text-transform: uppercase;
    line-height: 1.6;
    margin: 2.2em 0 .2em;
    overflow-wrap: anywhere;
}

h2.comment::before {
    content: "// ";
    color: var(--accent);
    white-space: nowrap;
}

h2.comment .hlline {
    text-transform: none;
}

h2.comment .tag {
    margin-left: auto;
    padding-top: 0;
    font-weight: normal;
    text-transform: none;
}

h2.comment + * {
    margin-top: .6em;
}

.tag {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

/* --- навигация --- */

.nav {
    font-size: 14px;
    border-bottom: 1px solid var(--muted);
    padding-bottom: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.nav a { text-decoration: none; }
.nav a:hover { color: var(--accent); }

.nav nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.nav-side {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* На мобилках ссылки уезжают в выдвижную панель, которую открывает скрытый чекбокс */

.nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip-path: inset(50%);
}

.nav-burger {
    display: none;
    width: 30px;
    height: 28px;
    border: 1px solid var(--fg);
    background: none;
    color: var(--fg);
    cursor: pointer;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.nav-burger::before {
    font: 13px/1 "Courier New", monospace;
    line-height: 1;
    content: "☰";
}

.nav-toggle:checked ~ .nav .nav-burger::before { content: "✕"; }

.nav-overlay { display: none; }

.theme-toggle {
    border: 1px solid var(--fg);
    background: none;
    color: var(--fg);
    cursor: pointer;
    width: 28px;
    height: 26px;
    font: 12px "Courier New", monospace;
    line-height: 1;
}

.theme-toggle:hover {
    background: var(--fg);
    color: var(--bg);
}

/* --- контейнеры и секции --- */

.container { margin: 0; }

main { padding: 0; }

.section { margin: 2.2em 0; }

.label {
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 .4em;
    text-align: left;
}

.lead {
    font-size: 1.05em;
    color: var(--fg);
    margin-bottom: 0.4em;
}

/* --- кнопки --- */

.buttons {
    margin: 1.4em 0;
    font-size: 0;
}

.button {
    display: inline-block;
    border: 1px solid var(--fg);
    padding: 6px 14px;
    font: 13px "Courier New", monospace;
    color: var(--fg);
    text-decoration: none;
    background: none;
    cursor: pointer;
    margin: 0 .5em .5em 0;
}

.button:hover {
    background: var(--fg);
    color: var(--bg);
}


/* --- списки --- */

.list { border-top: 1px solid var(--muted); margin: 1.2em 0; }

.list-item {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    /* gap: 16px; */
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid var(--muted);
    text-decoration: none;
}

.list-item:hover { color: var(--accent); }

.list-item .arrow { color: var(--muted); }
.list-item:hover .arrow { color: var(--accent); }

.number { color: var(--muted); font-size: 12px; }

.meta {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.tags {
    font: 12px "Courier New", monospace;
    color: var(--accent);
}

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

.tags a:hover {
    text-decoration: underline;
}

.search-input {
    width: 100%;
    max-width: 500px;
    border: 1px solid var(--muted);
    background: none;
    color: var(--fg);
    font: 14px "Courier New", monospace;
    padding: 8px 12px;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* --- карточки --- */

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 1.2em 0;
}

ul.grid {
    list-style: none;
    padding-left: 0;
}

ul.grid > li {
    border: 1px solid var(--muted);
    padding: 16px;
}

ul.grid > li:hover { border-color: var(--fg); }

.card {
    border: 1px solid var(--muted);
    padding: 16px;
}

.card h3 { margin-top: .4em; }
.card p { font-size: 14px; color: var(--muted); margin: 0; }
.card .meta { margin-bottom: .4em; }
.card .number { display: block; margin-bottom: .4em; }

.card:hover { border-color: var(--fg); }

/* --- код --- */

code {
    background: rgba(0, 0, 0, .05);
    padding: 1px 4px;
    font-size: .9em;
}

pre {
    background: rgba(0, 0, 0, .04);
    border: 1px solid var(--muted);
    padding: 14px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
}

pre code { background: none; padding: 0; }

[data-theme="dark"] code { background: rgba(255, 255, 255, .08); }
[data-theme="dark"] pre { background: rgba(255, 255, 255, .05); }

/* --- цитаты --- */

blockquote {
    margin: 2em 0;
    padding-left: 1em;
    border-left: 3px solid var(--muted);
    color: var(--muted);
    font-style: italic;
}

blockquote p { margin: 0; }

.quote {
    margin: 2em 0;
    padding-left: 1em;
    padding-top: 0.5em;
    border-left: 3px solid var(--accent);
    color: var(--fg);
    font-style: italic;
}

.quote p { margin: 0; }

.quote .author {
    display: block;
    margin-top: 10px;
    text-align: right;
    color: var(--muted);
    font-style: normal;
    font-family: "Courier New", monospace;
    font-size: 13px;
}

ul { padding-left: 1.4em; }
li { margin-bottom: .4em; }

/* --- медиа --- */

.fake-image {
    border: 1px dashed var(--muted);
    color: var(--muted);
    text-align: center;
    padding: 40px 10px;
    margin: 1.5em 0;
    font: 13px "Courier New", monospace;
}

.article img,
.article video {
    width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
}

img {
    max-width: 100%;
    height: auto;
}

.article video { background: #000; }

.youtube-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 1.5em 0;
}

.youtube-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- подсветка секции при переходе по якорю --- */

section[id],
div[id] {
    scroll-margin-top: 70px;
}

.highlight-flash {
    animation: flash 2s ease-out;
}

@keyframes flash {
    0%   { box-shadow: 0 0 0 3px var(--accent); background: rgba(255, 59, 0, .08); }
    100% { box-shadow: 0 0 0 3px transparent; background: transparent; }
}

/* --- подвал --- */

footer {
    border-top: 1px solid var(--muted);
    margin-top: 3em;
    padding-top: 12px;
    font-size: 12px;
    color: var(--muted);
    font-family: "Courier New", monospace;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

footer a { text-decoration: none; }
footer a:hover { color: var(--accent); }

.footer-links a { margin-left: 16px; }

/* --- таблицы --- */

table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

th, td {
    border: 1px solid var(--muted);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: rgba(0, 0, 0, .04);
    font-family: "Courier New", monospace;
    font-weight: normal;
    font-size: 13px;
}

[data-theme="dark"] th { background: rgba(255, 255, 255, .06); }

/* --- мобилки --- */

@media (min-width: 701px) {
    .nav-toggle { display: none; }
}

@media (max-width: 700px) {
    body.nav-open { overflow: hidden; }

    .nav {
        position: sticky;
        top: 0;
        background: var(--bg);
        padding-top: 12px;
        z-index: 70;
    }

    /* выдвижная панель сбоку */

    .nav-burger { display: flex; }

    .nav nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(300px, 84vw);
        margin: 0;
        padding: 84px 22px 22px;
        background: var(--bg);
        border-left: 1px solid var(--muted);
        box-shadow: -12px 0 32px rgba(0, 0, 0, .18);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform .25s ease;
        z-index: 60;
    }

    .nav-toggle:checked ~ .nav nav { transform: translateX(0); }

    .nav nav a {
        display: block;
        padding: 12px 4px;
        border-bottom: 1px dashed var(--muted);
        font-size: 15px;
    }

    .nav nav a:first-child { border-top: 1px dashed var(--muted); }

    .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s ease;
        z-index: 55;
    }

    .nav-toggle:checked ~ .nav-overlay { opacity: 1; pointer-events: auto; }
}

@media (max-width: 560px) {
    body { text-align: left; }

    .list-item {
        grid-template-columns: auto 1fr;
        gap: 12px;
    }

    .list-item .arrow { display: none; }

    .grid { grid-template-columns: 1fr; }

    .footer-links a {
        margin-left: 0;
        margin-right: 16px;
    }

    .button { display: block; width: 100%; text-align: center; }
}