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

html {
    -webkit-text-size-adjust: 100%;
    font-size: calc(16px * var(--font-scale));
}

body {
    margin: 0;
    font-family: var(--font-mono);
    font-size: .9375rem;
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    background-image: repeating-linear-gradient(0deg, var(--scanline) 0 1px, transparent 1px 3px);
    min-height: 100vh;
}

a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

a:hover {
    border-bottom-color: var(--link);
}

h1, h2, h3, h4 {
    line-height: 1.25;
    margin: 0 0 .6em;
    font-weight: 700;
    letter-spacing: -.02em;
}

p {
    margin: 0 0 1em;
}

code, pre, kbd {
    font-family: var(--font-mono);
}

::selection {
    background: var(--selection);
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.muted {
    color: var(--text-dim);
}

.small {
    font-size: .82em;
}

.hidden {
    display: none !important;
}

.sep {
    color: var(--text-faint);
}

.nowrap {
    white-space: nowrap;
}

.empty {
    padding: 2rem 0;
    color: var(--text-dim);
}

/* ===== page frame ===== */
.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.site-head {
    padding: 22px 0 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 26px;
}

.brand-line {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .08em;
    color: var(--text);
    border: 0;
}

.brand-mark {
    color: var(--accent);
    margin-right: 6px;
}

.tagline {
    color: var(--text-dim);
    font-size: .85rem;
}

.prompt {
    color: var(--text-dim);
    font-size: .85rem;
    margin-left: auto;
}

.cursor {
    color: var(--accent);
    animation: blink 1.2s steps(2, start) infinite;
}

@keyframes blink {
    to { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .cursor { animation: none; }
}

.head-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.font-controls {
    display: inline-flex;
    gap: 4px;
}

.font-btn {
    font-family: inherit;
    background: transparent;
    cursor: pointer;
    line-height: 1.2;
    padding: 1px 6px;
}

.font-btn:disabled {
    opacity: .4;
    cursor: default;
}

.font-btn:disabled:hover {
    border-color: var(--line-strong);
    color: var(--text-dim);
}

.font-value {
    font-size: .8rem;
    color: var(--text-dim);
    min-width: 4ch;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 1px 8px;
    font-size: .8rem;
    color: var(--text-dim);
    border-bottom-color: var(--line-strong);
    white-space: nowrap;
    background: transparent;
}

.chip:hover,
.chip.active {
    color: var(--accent-2);
    border-color: var(--accent);
    border-bottom-color: var(--accent);
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.nav > a {
    color: var(--text);
    font-size: .9rem;
    text-transform: lowercase;
}

.nav > a::before {
    content: "./";
    color: var(--text-faint);
}

.nav > a:hover {
    color: var(--accent-2);
}

.nav-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2px 8px;
    background: var(--bg-2);
}

.nav-search .ps {
    color: var(--accent);
}

.nav-search input {
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: .85rem;
    width: 210px;
    min-width: 0;
    flex: 1 1 auto;
    padding: 2px 0;
}

.nav-search .link-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.nav-search input::placeholder {
    color: var(--text-faint);
}

.nav-search input:focus {
    outline: none;
}

.link-btn {
    background: none;
    border: 0;
    color: var(--text-dim);
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
    padding: 0;
}

.link-btn:hover {
    color: var(--accent-2);
}

.link-btn.danger:hover {
    color: var(--danger);
}

/* ===== layout ===== */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 30px;
    align-items: start;
}

.main {
    min-width: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 16px;
}

/* ===== windows ===== */
.window {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    overflow: hidden;
}

.window-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
    font-size: .75rem;
    color: var(--text-dim);
    letter-spacing: .04em;
}

.dots {
    display: inline-flex;
    gap: 5px;
}

.dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-strong);
    display: block;
}

.dots i:first-child { background: #ff5f56; }
.dots i:nth-child(2) { background: #ffbd2e; }
.dots i:nth-child(3) { background: #27c93f; }

.window-body {
    padding: 16px;
}

.window.compact .window-body {
    padding: 10px 14px;
}

/* ===== sidebar ===== */
.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree .sub {
    padding-left: 16px;
    border-left: 1px dashed var(--line-strong);
    margin-left: 5px;
}

.tree-item > a {
    display: flex;
    gap: 6px;
    align-items: baseline;
    color: var(--text);
    font-size: .86rem;
    padding: 2px 0;
    border-bottom: 0;
}

.tree-item > a:hover {
    color: var(--accent-2);
}

.tree-item .muted {
    margin-left: auto;
    font-size: .75rem;
}

.tree-mark {
    color: var(--accent);
    font-size: .7rem;
    transition: transform .15s;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    font-size: .78rem;
    color: var(--text-dim);
    border: 1px solid transparent;
    border-bottom-color: transparent;
}

.tag:hover {
    color: var(--accent-2);
}

.tag .muted {
    font-size: .9em;
}

.more {
    display: inline-block;
    margin-top: 10px;
    font-size: .78rem;
    color: var(--text-dim);
}

.archive-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: .82rem;
}

.archive-list li {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
}

.archive-list a {
    color: var(--text);
}

/* ===== page head ===== */
.page-head {
    margin-bottom: 22px;
}

.crumb {
    color: var(--text-faint);
    font-size: .78rem;
    letter-spacing: .04em;
    margin-bottom: 6px;
}

.page-head h1 {
    font-size: 1.6rem;
    margin-bottom: .2em;
}

.page-head .sub {
    color: var(--text-dim);
    margin-bottom: .4em;
}

.head-meta {
    font-size: .78rem;
}

/* ===== post cards ===== */
.posts {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.post-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-left: 2px solid var(--line-strong);
    background: var(--panel);
    border-radius: var(--radius);
    padding: 16px 18px;
    transition: border-color .15s, transform .15s;
}

.post-card:hover {
    border-left-color: var(--accent);
}

.post-meta {
    font-size: .78rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.post-meta a {
    color: var(--text-dim);
}

.post-meta a:hover {
    color: var(--accent-2);
}

.badge {
    font-size: .68rem;
    border: 1px solid var(--line-strong);
    padding: 0 5px;
    border-radius: 2px;
    color: var(--accent-2);
    text-transform: uppercase;
}

.post-title {
    font-size: 1.15rem;
    margin: 6px 0 6px;
    overflow-wrap: anywhere;
}

.post-title a {
    color: var(--text);
    border-bottom: 0;
}

.post-title a:hover {
    color: var(--accent-2);
}

.post-summary {
    color: var(--text-dim);
    font-size: .9rem;
    margin-bottom: 10px;
    max-width: 75ch;
    overflow-wrap: anywhere;
}

.post-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: .76rem;
    color: var(--text-faint);
}

.meta-item::before {
    content: "[";
}

.meta-item::after {
    content: "]";
}

.post-tags {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.read-more {
    margin-left: auto;
    font-size: .8rem;
}

/* ===== pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 0 8px;
    font-size: .85rem;
    flex-wrap: wrap;
}

.pagination a,
.pagination .current {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.pagination .current {
    border-color: var(--accent);
    color: var(--accent-2);
}

/* ===== tag / archive grids ===== */
.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.tag-card,
.archive-card {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--text);
}

.tag-card:hover,
.archive-card:hover {
    border-color: var(--accent);
    color: var(--accent-2);
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.archive-days {
    margin-bottom: 18px;
}

/* ===== article ===== */
.post-full {
    max-width: 860px;
}

.post-head {
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--line-strong);
}

.post-h1 {
    font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem);
    margin: 8px 0 10px;
}

.post-lead {
    color: var(--text-dim);
    font-size: 1rem;
    max-width: 75ch;
}

.note {
    border: 1px dashed var(--warn);
    color: var(--warn);
    padding: 6px 10px;
    font-size: .82rem;
    border-radius: var(--radius);
}

.prose {
    font-size: .95rem;
    overflow-wrap: break-word;
}

.prose > * {
    max-width: 82ch;
}

.prose h2,
.prose h3,
.prose h4 {
    margin-top: 1.6em;
    color: var(--text);
}

.prose h2 { font-size: 1.3rem; }
.prose h3 { font-size: 1.1rem; }

.prose a {
    color: var(--link);
    border-bottom: 1px dotted var(--link);
}

.prose ul,
.prose ol {
    padding-left: 1.4em;
}

.prose li {
    margin-bottom: .35em;
}

.prose blockquote {
    margin: 1.2em 0;
    padding: .2em 0 .2em 14px;
    border-left: 2px solid var(--accent);
    color: var(--text-dim);
}

.prose img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: zoom-in;
    display: block;
    margin: 1em auto;
}

.prose figure {
    margin: 1.2em 0;
}

.prose video,
.prose audio {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin: 1em 0;
}

.prose iframe {
    max-width: 100%;
    aspect-ratio: 16/9;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
    margin: 1em 0;
}

.prose th,
.prose td {
    border: 1px solid var(--line);
    padding: 4px 8px;
    text-align: left;
}

.prose th {
    background: var(--panel-2);
}

.prose :not(pre) > code {
    background: var(--code-bg);
    border: 1px solid var(--code-line);
    padding: 0 4px;
    border-radius: 3px;
    font-size: .88em;
    color: var(--accent-2);
}

.prose pre {
    background: var(--code-bg);
    border: 1px solid var(--code-line);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 14px;
    overflow-x: auto;
    font-size: .82rem;
    line-height: 1.55;
    margin: 1.2em 0;
}

.prose pre code {
    background: none;
    border: 0;
    padding: 0;
    color: var(--text);
    font-size: inherit;
}

/* ===== files ===== */
.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.file-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--line);
    font-size: .86rem;
}

.file-row:last-child {
    border-bottom: 0;
}

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

.file-name {
    color: var(--text);
}

.file-size,
.file-dl {
    margin-left: auto;
    font-size: .75rem;
}

.file-dl {
    margin-left: 0;
    min-width: 90px;
    text-align: right;
}

/* ===== post footer / nav ===== */
.post-foot-full {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin: 26px 0 10px;
    padding-top: 14px;
    border-top: 1px dashed var(--line-strong);
}

.post-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn {
    font: inherit;
    font-size: .85rem;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 4px 10px;
    cursor: pointer;
    display: inline-block;
    border-bottom-width: 1px;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent-2);
}

.btn.primary {
    border-color: var(--accent);
    color: var(--accent-2);
    background: var(--accent-soft);
}

.btn.danger {
    border-color: var(--danger);
    color: var(--danger);
    background: transparent;
}

.btn.small-btn {
    padding: 1px 8px;
    font-size: .78rem;
}

.btn.like {
    font-size: .85rem;
}

.btn.like.liked {
    border-color: var(--danger);
    color: var(--danger);
}

.updated {
    font-size: .75rem;
}

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 22px 0 34px;
    font-size: .85rem;
}

.post-nav a {
    display: flex;
    flex-direction: column;
    max-width: 46%;
    color: var(--text);
    border: 0;
}

.post-nav a:hover {
    color: var(--accent-2);
}

.post-nav .next {
    text-align: right;
    margin-left: auto;
}

/* ===== comments ===== */
.comments {
    margin-top: 34px;
}

.section-title {
    font-size: 1.1rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
    margin-bottom: 14px;
}

.comment {
    border-left: 1px solid var(--line-strong);
    padding: 8px 0 10px 14px;
    margin-bottom: 4px;
}

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    font-size: .8rem;
}

.comment-author {
    color: var(--accent-2);
    font-weight: 500;
}

.comment-body {
    font-size: .9rem;
    margin-top: 4px;
}

.comment-body p:last-child {
    margin-bottom: 0;
}

.comment-body pre {
    background: var(--code-bg);
    border: 1px solid var(--code-line);
    border-radius: var(--radius);
    padding: 8px 10px;
    overflow-x: auto;
    font-size: .8rem;
}

.comment-children {
    margin-top: 8px;
    padding-left: 8px;
}

.comment-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.comment-images img {
    max-width: 180px;
    max-height: 140px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.comment-form .window-body {
    padding: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    font-size: .82rem;
    color: var(--text-dim);
}

.field input,
.field textarea,
.field select,
.inline-form input,
.inline-form select,
.form-grid input,
.form-grid select,
.toolbar input,
.toolbar select {
    font: inherit;
    font-size: .88rem;
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 5px 8px;
}

.field textarea {
    resize: vertical;
    min-height: 70px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: 1px solid var(--accent);
    border-color: var(--accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.hp-field {
    position: absolute;
    left: -5000px;
}

.comment-media {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.comment-media img {
    max-height: 80px;
    border: 1px solid var(--line);
}

.alert {
    border: 1px solid var(--line-strong);
    border-left-width: 2px;
    padding: 8px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .86rem;
}

.alert.ok {
    border-color: var(--accent);
    color: var(--accent-2);
}

.alert.error {
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== footer ===== */
.site-foot {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font-size: .78rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.foot-line {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.site-foot a {
    color: var(--text-dim);
}

.site-foot a:hover {
    color: var(--accent-2);
}

/* ===== error / auth ===== */
.error-page,
.auth-box {
    max-width: 620px;
    margin: 40px auto;
}

.error-code {
    color: var(--danger);
    font-size: .85rem;
    background: var(--code-bg);
    padding: 8px 10px;
    border: 1px solid var(--code-line);
    border-radius: var(--radius);
}

.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-box {
    width: 100%;
    margin: 20px;
}

.prompt-line {
    color: var(--text-dim);
    font-size: .82rem;
    margin-bottom: 14px;
}

/* ===== admin ===== */
body.admin {
    background-image: none;
}

.admin-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-nav {
    border-right: 1px solid var(--line);
    background: var(--bg-2);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-nav .brand {
    font-size: .9rem;
    margin-bottom: 8px;
}

.admin-nav-label {
    font-size: .7rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .12em;
}

.admin-nav nav {
    display: flex;
    flex-direction: column;
}

.admin-nav nav a {
    color: var(--text-dim);
    font-size: .86rem;
    padding: 3px 0;
    border: 0;
}

.admin-nav nav a::before {
    content: "$ ";
    color: var(--text-faint);
}

.admin-nav nav a:hover {
    color: var(--accent-2);
}

.admin-nav-foot {
    margin-top: auto;
    font-size: .78rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-main {
    padding: 24px 28px 60px;
    min-width: 0;
}

.admin-head {
    margin-bottom: 20px;
}

.admin-head h1 {
    font-size: 1.4rem;
    margin: 4px 0 0;
}

.admin-user {
    font-size: .75rem;
    color: var(--text-faint);
    margin-top: 4px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.stat-card {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-card.accent {
    border-color: var(--accent);
}

.stat-value {
    font-size: 1.5rem;
    color: var(--accent-2);
}

.stats-table-scroll {
    max-height: 55vh;
    overflow: auto;
}

.stats-row {
    cursor: pointer;
}

.stats-row:hover,
.stats-row:focus-visible {
    background: var(--panel-2);
}

.stats-row:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: -1px;
}

.stats-more {
    margin-top: 10px;
    font-size: .8rem;
}

.stats-modal .window-body {
    max-height: 78vh;
    overflow: auto;
}

.stat-label {
    font-size: .74rem;
    color: var(--text-dim);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}

.grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .84rem;
}

.grid-table th,
.grid-table td {
    text-align: left;
    padding: 5px 8px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.grid-table th {
    color: var(--text-dim);
    font-weight: 500;
    font-size: .76rem;
}

.grid-table tr:last-child td {
    border-bottom: 0;
}

.grid-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.grid-table .actions a {
    margin-right: 10px;
    font-size: .8rem;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

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

.chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
}

.form-grid .field {
    margin-bottom: 0;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .82rem;
    color: var(--text-dim);
}

.status {
    font-size: .72rem;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    padding: 0 6px;
}

.status-published,
.status-approved {
    color: var(--accent-2);
    border-color: var(--accent);
}

.status-draft,
.status-pending {
    color: var(--warn);
    border-color: var(--warn);
}

.status-rejected {
    color: var(--danger);
    border-color: var(--danger);
}

.upload-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.media-list {
    margin: 10px 0;
    font-size: .8rem;
}

.media-row {
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px dashed var(--line);
    padding: 2px 0;
    min-width: 0;
}

.media-kind {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    min-width: 3.4em;
}

.media-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-order {
    display: inline-flex;
    gap: 2px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.media-card {
    margin: 0;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: .78rem;
}

.media-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 130px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.media-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-preview.file-kind {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .1em;
}

.media-card figcaption {
    padding: 8px 10px;
}

.media-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: .72rem;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.tab {
    font: inherit;
    font-size: .74rem;
    background: none;
    border: 1px solid var(--line);
    color: var(--text-dim);
    border-radius: 2px;
    padding: 0 8px;
    cursor: pointer;
}

.tab.active {
    color: var(--accent-2);
    border-color: var(--accent);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.post-form .window-body {
    padding: 16px;
}

.danger-zone {
    margin: 26px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.admin-comment {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 2px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
}

.comment-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: .78rem;
}

.comment-foot .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.comment-foot form {
    display: inline;
}

.dl-count {
    color: var(--text-faint);
    font-size: .82em;
    white-space: nowrap;
}

.copy-code {
    position: absolute;
    top: 4px;
    right: 4px;
    font: inherit;
    font-size: .7rem;
    color: var(--text-faint);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 2px;
    padding: 0 5px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

.prose pre {
    position: relative;
}

.prose pre:hover .dl-count {
    color: var(--text-faint);
    font-size: .82em;
    white-space: nowrap;
}

.copy-code {
    opacity: 1;
}

.contact-message .window-body {
    padding: 14px 16px;
}

.contact-head {
    display: flex;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 10px;
    font-size: .9rem;
}

.contact-body {
    margin: 0 0 12px;
    padding: 10px 12px;
    background: var(--code-bg);
    border: 1px solid var(--code-line);
    border-radius: var(--radius);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .84rem;
}

/* ===== editor insert toolbar ===== */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-2);
}

.tb-btn {
    font: inherit;
    font-size: .78rem;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 2px 7px;
    cursor: pointer;
    line-height: 1.4;
}

.tb-btn:hover {
    border-color: var(--accent);
    color: var(--accent-2);
}

.tb-btn:active {
    background: var(--accent-soft);
}

.tb-sep {
    width: 1px;
    align-self: stretch;
    background: var(--line-strong);
    margin: 2px 6px;
}

/* ===== modals ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, .72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-box {
    width: min(760px, 100%);
    max-height: 92vh;
    overflow: auto;
    margin: 0;
}

.modal-box.media-modal {
    width: min(1080px, 100%);
}

.media-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.media-filters input[type="search"],
.media-filters select {
    font: inherit;
    font-size: .84rem;
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 4px 8px;
}

.media-filters input[type="search"] {
    flex: 1 1 220px;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    max-height: 56vh;
    overflow: auto;
    padding-right: 4px;
}

.picker-card {
    font: inherit;
    color: var(--text);
    text-align: left;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.picker-card:hover {
    border-color: var(--accent);
    color: var(--accent-2);
}

.picker-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 2px;
    overflow: hidden;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-dim);
}

.picker-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.picker-name {
    font-size: .78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== lightbox ===== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    cursor: zoom-out;
}

.lightbox-overlay img {
    max-width: 96vw;
    max-height: 94vh;
    border: 1px solid var(--line-strong);
}

/* ===== responsive ===== */
@media (max-width: 980px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: static;
        order: 2;
    }

    .prompt {
        display: none;
    }

    .nav-search {
        width: 100%;
        margin-left: 0;
    }

    .nav-search input {
        width: auto;
        flex: 1 1 auto;
        min-width: 0;
    }

    .nav-search .link-btn {
        white-space: nowrap;
        flex: 0 0 auto;
    }
}

@media (max-width: 760px) {
    body {
        font-size: .875rem;
    }

    .page {
        padding: 0 14px 30px;
    }

    .two-col,
    .form-grid,
    .form-row {
        grid-template-columns: 1fr;
    }

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

    .admin-nav {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .admin-nav nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .admin-nav-foot {
        margin-top: 0;
        flex-direction: row;
    }

    .admin-main {
        padding: 18px 14px 40px;
    }

    .file-row {
        flex-wrap: wrap;
    }

    .file-size,
    .file-dl {
        margin-left: 0;
    }

    .post-tags .tag {
        font-size: .74rem;
    }
}
