:root {
    --bg: #f6f6ef;
    --card: #fafaf3;
    --ink: #202122;
    --muted: #6d6a62;
    --line: rgba(32, 33, 34, 0.08);
    --accent: #ff6600;
    --accent-soft: rgba(255, 102, 0, 0.12);
    --down: #6b5cff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 Inter, "Segoe UI", sans-serif;
}

a { color: inherit; }

.top {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 28px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.menu-btn {
    display: none;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.logo {
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.03em;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-actions a,
.top-actions button {
    background: none;
    border: 0;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.who {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}
.admin-mark {
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 650;
}
.quiet-btn {
    padding: 0;
    border: 0;
    background: none;
    color: #b42318;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 720px) 260px;
    justify-content: center;
    gap: 28px;
    padding: 22px 20px 64px;
}

.side, .rail { padding-top: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--ink);
    font-size: 14px;
    text-decoration: none;
}

.nav-link.sub { padding-left: 28px; color: var(--muted); }

.nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-more {
    display: block;
    width: 100%;
    margin: 4px 0 8px;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.nav-label {
    margin: 16px 12px 6px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-title {
    margin: 0 0 14px;
    font-size: 22px;
}

.card {
    margin: 0 0 14px;
    padding: 16px 18px 12px;
    background: var(--card);
    border-radius: 8px;
}

.card h2, .post-full h1 {
    margin: 0 0 10px;
    font-size: 21px;
    line-height: 1.3;
}

.card h2 a, .cat { text-decoration: none; }

.card h2 a:hover, .cat:hover { color: var(--accent); }

.excerpt, .body, .comment p, .comment-card p {
    margin: 0 0 12px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.card-img {
    display: block;
    width: 100%;
    height: auto;
    margin: 12px auto;
    border-radius: 6px;
    background: #eceae3;
}

.zoom {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 28px 16px;
    background: rgba(22, 22, 20, 0.9);
}

.lightbox[hidden] { display: none; }

.lightbox img {
    max-width: min(1200px, 100%);
    max-height: calc(100vh - 56px);
    width: auto;
    height: auto;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    color: var(--muted);
    font-size: 13px;
}

.user { display: inline-flex; align-items: center; gap: 6px; }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ece7dc;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    object-fit: cover;
}

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

.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile-photo {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    background: #ece7dc;
    font-size: 32px;
    font-weight: 650;
}
.bio { margin: 8px 0 0; white-space: pre-wrap; }
.profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 14px;
}
.profile-stats strong { color: var(--ink); font-weight: 650; }
.profile-form { margin-top: 8px; box-shadow: none; padding: 0; background: transparent; }

.quiet { color: var(--muted); text-decoration: none; }

.count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.count svg {
    width: 16px;
    height: 16px;
}

.karma {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.cat { color: var(--accent); font-size: 13px; }

.vote {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.vote form { margin: 0; }

.vote button {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.vote svg { width: 16px; height: 16px; fill: currentColor; }

.vote .is-up { color: var(--accent); }
.vote .is-down { color: var(--down); }
.score { min-width: 1.2em; text-align: center; font-weight: 650; color: var(--ink); }

.rail h2 {
    margin: 8px 0 12px;
    font-size: 14px;
    font-weight: 650;
}

.rail-item, .rail-more {
    display: block;
    margin-bottom: 12px;
    color: inherit;
    text-decoration: none;
}

.rail-meta, .muted, .login-card { color: var(--muted); font-size: 13px; }

.rail-text { display: block; margin-top: 2px; font-size: 14px; }

.login-card a, .muted a { color: var(--accent); }

.comments h2 { font-size: 18px; }

.comment {
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.comment header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.cancel-edit { color: var(--accent); }
.comment-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}
.comment-delete { display: inline-flex; margin: 0; }
.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: #efeae0; color: var(--ink); }
.icon-btn.danger:hover { color: #b42318; background: #fde8e6; }
.tip:hover::after,
.tip:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 5;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    border-radius: 6px;
    background: #2b2b28;
    color: #fff;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
}
.comment-view[hidden], .comment-edit[hidden] { display: none; }
.comment-edit { display: grid; gap: 8px; margin: 6px 0 10px; }
.comment-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-pick input { display: none; }
.comment-photo {
    display: block;
    width: min(280px, 100%);
    margin: 6px 0 8px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}
.comment-photo img, img.comment-photo {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}
img.comment-photo { cursor: default; }
.comment.reply { margin-left: 28px; }
.comment.reply .comment.reply { margin-left: 16px; }
.reply-to, .reply-target {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 13px;
}
a.reply-to {
    display: block;
    color: var(--accent);
    text-decoration: none;
}
a.reply-to:hover { text-decoration: underline; }
.reply-quote {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.comment:target {
    background: #fff4e8;
    border-radius: 8px;
    scroll-margin-top: 16px;
}
.reply-target { display: flex; align-items: center; gap: 8px; }
.reply-target[hidden] { display: none; }
.bell {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.bell svg { width: 20px; height: 20px; }
.bell span {
    position: absolute;
    top: -6px;
    right: -8px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
}
a.notice {
    display: block;
    color: inherit;
    text-decoration: none;
}
.notice.is-new {
    background: #fff4e8;
    box-shadow: inset 3px 0 0 var(--accent);
}
.notice.is-seen { color: var(--muted); }
.notice.is-seen strong { color: var(--ink); }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.notice-group { margin: 4px 0 10px; font-size: 15px; }
.notice-tag {
    margin-left: 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 650;
}
.notice-line { display: block; }
.notice-body {
    display: block;
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sheet, .comments form { display: grid; gap: 10px; max-width: 560px; }

.sheet { padding: 16px 18px; background: var(--card); border-radius: 8px; }
.profile .sheet { padding: 0; background: transparent; }

label { display: grid; gap: 6px; font-size: 14px; }

.picker-label { font-size: 14px; }
.picker-btn,
.picker-list button {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.picker-list {
    max-height: min(280px, 46vh);
    margin-top: 6px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.picker-list button {
    border: 0;
    border-radius: 0;
}
.picker-list button.is-selected,
.picker-list button:hover { background: var(--accent-soft); }

input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

.btn {
    width: fit-content;
    padding: 8px 14px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.form-error { margin: 0; color: #b42318; font-size: 13px; }

.composer-form { max-width: 680px; }
.composer-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.composer-tools button, .block-tools button, .ghost-btn {
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}
.block-edit {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}
.block-tools { display: flex; align-items: center; gap: 6px; }
.block-tools span { margin-right: auto; font-size: 13px; font-weight: 650; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.yt {
    position: relative;
    display: block;
    width: 100%;
    margin: 0 0 12px;
    padding: 0;
    border: 0;
    background: #111;
    border-radius: 6px;
    cursor: pointer;
}
.yt img { display: block; width: 100%; height: auto; border-radius: 6px; }
.yt-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 64px;
    height: 44px;
    margin: -22px 0 0 -32px;
    border-radius: 12px;
    background: #ff0000;
}
.yt-play::before {
    content: "";
    position: absolute;
    left: 26px;
    top: 12px;
    border-style: solid;
    border-width: 10px 0 10px 16px;
    border-color: transparent transparent transparent #fff;
}
.embed { position: relative; padding-top: 56.25%; margin: 0 0 12px; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 6px; }
.link-card {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    margin: 0 0 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    text-decoration: none;
}
.link-card img { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; }
.link-card span { display: grid; gap: 4px; align-content: center; }
.link-card em { color: var(--muted); font-style: normal; font-size: 13px; }
.link-preview { display: grid; gap: 6px; }
.link-preview img { max-height: 140px; object-fit: cover; border-radius: 6px; }

.pager { display: flex; gap: 16px; }
.pager a { color: var(--accent); }

@media (max-width: 980px) {
    .menu-btn { display: inline-flex; }
    .top { height: 56px; min-height: 56px; gap: 10px; padding: 0 14px; }
    .top-actions { gap: 12px; }
    .who-name, .who .admin-mark { display: none; }
    .shell { grid-template-columns: 1fr; padding: 8px 18px 32px; }
    .comment-actions { margin-right: 10px; }
    .comment-actions > :last-child .tip:hover::after,
    .comment-actions > .tip:last-child:hover::after,
    .comment-actions > :last-child .tip:focus-visible::after,
    .comment-actions > .tip:last-child:focus-visible::after {
        left: auto;
        right: 0;
        transform: none;
    }
    .rail { display: none; }
    .side {
        position: fixed;
        z-index: 30;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 86vw);
        margin: 0;
        padding: 68px 14px 24px;
        background: var(--bg);
        overflow: auto;
        transform: translateX(-105%);
        visibility: hidden;
    }
    body.nav-open .side {
        transform: none;
        visibility: visible;
    }
    .nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 25;
        background: rgba(22, 22, 20, 0.45);
    }
    body.nav-open .nav-backdrop { display: block; }
}
