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

:root {
    --noir: #191919;
    --noir-elevated: #222222;
    --paper: #f5f0eb;
    --white: #ffffff;
    --red: #c8102e;
    --red-dark: #9b0a20;
    --red-glow: rgba(200, 16, 46, 0.2);
    --gray-dark: #2a2a2a;
    --gray-mid: #888;
    --gray-line: #333;
    --danger: #ff3b30;
    --danger-hover: #d63027;
    --code-bg: #111;
    --transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    color-scheme: dark;
}

[data-theme="light"] {
    --noir: #f5f0eb;
    --noir-elevated: #ece6df;
    --paper: #1a1a1a;
    --white: #0f0f0f;
    --gray-dark: #e8e2db;
    --gray-mid: #777;
    --gray-line: #d4cdc5;
    --code-bg: #1a1a1a;
    --red-glow: rgba(200, 16, 46, 0.12);
    color-scheme: light;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --noir: #f5f0eb;
        --noir-elevated: #ece6df;
        --paper: #1a1a1a;
        --white: #0f0f0f;
        --gray-dark: #e8e2db;
        --gray-mid: #777;
        --gray-line: #d4cdc5;
        --code-bg: #1a1a1a;
        --red-glow: rgba(200, 16, 46, 0.12);
        color-scheme: light;
    }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--paper);
    background: var(--noir);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

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

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--noir); }
::-webkit-scrollbar-thumb { background: var(--gray-line); }
::-webkit-scrollbar-thumb:hover { background: var(--red); }

a {
    color: var(--paper);
    text-decoration: none;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* ── Nav ── */

.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--noir);
    border-bottom: 2px solid var(--red);
    padding: 0;
}

.nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 2rem;
    border-left: 2px solid var(--red);
    padding-left: 12px;
}

.nav-brand,
.nav-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    color: var(--gray-mid);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: color var(--transition);
}

.nav-brand {
    font-weight: 700;
}

.nav-brand.active,
.nav-link.active {
    color: var(--paper);
}

.nav-brand:hover,
.nav-link:hover {
    color: var(--paper);
}

/* ── Theme toggle ── */

.theme-toggle {
    background: none;
    border: 1px solid var(--gray-line);
    color: var(--paper);
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    line-height: 1;
    transition: border-color var(--transition);
}

.theme-toggle:hover {
    border-color: var(--paper);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }

[data-theme="light"] .theme-toggle .icon-sun { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: inline; }
    :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
}

/* ── Footer ── */

.footer {
    margin-top: auto;
    padding: 3rem 0;
    border-top: 1px solid var(--gray-line);
    font-size: 0.75rem;
}


.footer-links {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.footer-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    color: var(--gray-mid);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color var(--transition);
}

.footer-link:hover {
    color: var(--paper);
}

.footer p {
    color: var(--gray-mid);
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* ── About ── */

.about-page {
    max-width: 600px;
    margin: 3rem auto;
}

.about-page h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 2rem;
    color: var(--white);
}

.about-content {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1rem;
    line-height: 1.85;
    color: var(--paper);
    margin-bottom: 2.5rem;
}

.about-links {
    display: flex;
    gap: 1.5rem;
}

.about-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    color: var(--gray-mid);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}

.about-link:hover {
    color: var(--red);
    border-bottom-color: var(--red);
}

.about-articles {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--gray-line);
}

.about-articles h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gray-mid);
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.about-articles-grid {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
}

.about-article-card {
    min-width: 220px;
    flex-shrink: 0;
}

.about-article-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    border: 1px solid var(--gray-line);
    overflow: hidden;
    transition: border-color var(--transition);
}

.about-article-card:hover {
    border-color: var(--red);
}

.about-article-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.about-article-info {
    padding: 1rem;
}

.about-article-title {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--paper);
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.about-article-card time {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    color: var(--gray-mid);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Articles list ── */

.articles {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 3rem;
}

.article-card {
    background: var(--noir-elevated);
    overflow: hidden;
    border-bottom: 1px solid var(--gray-line);
    border-left: 4px solid transparent;
    transition: transform var(--transition), border-color var(--transition);
}

.article-card:first-child {
    border-top: 1px solid var(--gray-line);
}

.article-card:hover {
    border-left-color: var(--red);
}

@media (hover: hover) {
    .article-card:hover {
        transform: translateX(4px);
    }
}

.article-cover {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
    filter: grayscale(100%);
    transition: filter 0.6s ease;
}

.article-card:hover .article-cover {
    filter: grayscale(0%);
}

.article-card-body {
    padding: 1.5rem 1.75rem;
}

.article-card-body h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 0.625rem;
    letter-spacing: -0.01em;
}

.article-card-body h2 a {
    color: var(--paper);
    text-decoration: none;
    transition: color var(--transition);
}

.article-card-body h2 a:hover {
    color: var(--red);
}

.article-card-body time {
    color: var(--gray-mid);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* ── Single article ── */

.article-header {
    margin-bottom: 2.5rem;
}

.article-header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2.75rem, 5vw, 4rem);
    line-height: 1.05;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
    font-weight: 900;
    color: var(--white);
}

.article-header time {
    color: var(--gray-mid);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.article-header time::before {
    content: '— ';
    color: var(--red);
}

.editorial-rule {
    width: 40px;
    height: 1px;
    background: var(--red);
    border: none;
    margin: 1rem 0 0 0;
    opacity: 0.6;
}

/* ── Article Layout ── */

.article-layout {
    position: relative;
}

.article-layout .sidebar {
    position: fixed;
    left: calc(50% + 900px / 2 + 3rem);
    top: 5rem;
    width: 240px;
}

.article-hero {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    margin-bottom: 3rem;
    filter: contrast(1.1) brightness(0.95);
}

/* ── Table of Contents ── */

.toc {
    position: fixed;
    left: calc(50% - 900px / 2 - 200px - 3rem);
    top: 5rem;
    width: 200px;
    text-align: right;
}

.toc-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gray-mid);
    margin-bottom: 1rem;
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-item.toc-sub {
    margin-bottom: 0.4rem;
}

.toc-link {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    color: var(--gray-mid);
    text-decoration: none;
    transition: color 0.2s;
}

.toc-item.toc-sub .toc-link {
    font-size: 0.75rem;
    opacity: 0.7;
}

.toc-link:hover {
    color: var(--paper);
}

.toc-link.active {
    color: var(--red);
}

@media (max-width: 1200px) {
    .toc {
        display: none;
    }
}

/* ── Sidebar ── */

.sidebar {
    top: 2rem;
    border-left: 1px solid var(--gray-line);
    padding-left: 1.5rem;
}

.sidebar-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gray-mid);
    margin-bottom: 1.25rem;
}

.sidebar-card {
    display: block;
    text-decoration: none;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--gray-line);
    transition: opacity 0.2s;
}

.sidebar-card:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sidebar-card:hover {
    opacity: 0.7;
}

.sidebar-card-img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    margin-bottom: 0.5rem;
}

.sidebar-card-title {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--paper);
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.sidebar-card-date {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    color: var(--gray-mid);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.article-content {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.1875rem;
    line-height: 1.85;
    color: var(--paper);
    max-width: 680px;
    margin: 0 auto;
}

.article-content > p:first-of-type::first-letter {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: 4em;
    float: left;
    line-height: 0.8;
    margin-right: 0.1em;
    margin-top: 0.05em;
    color: var(--red);
}

.article-content h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.625rem;
    font-weight: 700;
    margin-top: 3rem;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
    border-left: 3px solid var(--red);
    padding-left: 0.75rem;
    color: var(--white);
}

.article-content h3 {
    font-family: 'Lora', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
    font-style: italic;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: var(--paper);
}

.article-content p {
    margin-bottom: 1.25rem;
}

.article-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
}

.article-content figure {
    margin: 1.5rem auto;
    text-align: center;
}

.article-content figure img {
    margin-top: 0;
    margin-bottom: 0;
}

.article-content figcaption:empty {
    display: none;
}

.article-content pre {
    background: var(--code-bg);
    color: #e2e8f0;
    padding: 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.7;
    border: 1px solid var(--gray-line);
    border-left: 3px solid var(--red);
}

.article-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
}

.article-content p code {
    background: var(--gray-dark);
    color: var(--red);
    padding: 0.15em 0.4em;
    border: 1px solid var(--gray-line);
}

.article-content blockquote {
    border-left: 3px solid var(--red);
    padding-left: 1.5rem;
    color: var(--paper);
    margin-bottom: 1.25rem;
    font-style: italic;
}

.article-content a {
    color: var(--red);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: text-decoration-thickness var(--transition);
}

.article-content a:hover {
    text-decoration-thickness: 2px;
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.article-content li {
    margin-bottom: 0.375rem;
}

.article-content li::marker {
    color: var(--red);
}

.article-content hr {
    border: none;
    height: 1px;
    background: var(--gray-line);
    margin: 3rem auto;
    width: 40%;
}

/* ── Auth form ── */

.auth-form {
    max-width: 420px;
    margin: 6rem auto;
    background: var(--noir-elevated);
    padding: 2.5rem;
    border: 1px solid var(--gray-line);
}

.auth-form h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.75rem;
    text-align: center;
    letter-spacing: -0.02em;
    position: relative;
    padding-bottom: 1.25rem;
}

.auth-form h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: var(--red);
}

/* ── Forms ── */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
    font-size: 0.75rem;
    color: var(--gray-mid);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: 'Space Grotesk', sans-serif;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    padding: 0.7rem 0.875rem;
    border: 1px solid var(--gray-line);
    background: var(--noir);
    color: var(--paper);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

.form-group input::placeholder {
    color: var(--gray-mid);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    border: 1px solid var(--gray-line);
    background: transparent;
    color: var(--paper);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all var(--transition);
    gap: 0.5rem;
}

.btn:hover {
    border-color: var(--paper);
    color: var(--white);
}

.btn-primary {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}

.btn-secondary {
    background: transparent;
    border-color: var(--gray-line);
    color: var(--gray-mid);
}

.btn-secondary:hover {
    border-color: var(--paper);
    color: var(--paper);
}

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

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-small {
    padding: 0.4rem 0.875rem;
    font-size: 0.7rem;
}

/* ── Cover Upload ── */

.cover-upload {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cover-preview {
    border: 2px dashed var(--gray-dark);
    padding: 1rem;
}

.cover-preview:not(.has-image)::after {
    content: "No cover image";
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 0.85rem;
}

.cover-preview.has-image {
    border-style: solid;
    display: inline-block;
}

.cover-preview img {
    max-height: 300px;
    display: block;
}

.cover-upload-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cover-upload-btn {
    cursor: pointer;
}

.cover-upload-status {
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--muted);
}

/* ── Admin ── */

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ── Table ── */

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 2rem;
    background: var(--noir-elevated);
    overflow: hidden;
    border: 1px solid var(--gray-line);
}

.table th,
.table td {
    text-align: left;
    padding: 0.875rem 1rem;
}

.table th {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-mid);
    background: var(--noir);
    border-bottom: 2px solid var(--red);
}

.table td {
    border-bottom: 1px solid var(--gray-line);
    font-size: 0.9rem;
    color: var(--paper);
    font-family: 'Space Grotesk', sans-serif;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: rgba(200, 16, 46, 0.05);
}

.table td a {
    color: var(--red);
    text-decoration: none;
    font-weight: 500;
}

.table td a:hover {
    text-decoration: underline;
}

.actions {
    display: flex;
    gap: 0.375rem;
}

/* ── Alert ── */

.alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-error {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* ── Analytics ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--noir-elevated);
    border: 1px solid var(--gray-line);
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
    transition: background var(--transition);
}

.stat-card + .stat-card {
    border-left: 1px solid var(--gray-line);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--red);
}

.stat-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-mid);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-number {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--white);
    transition: color var(--transition);
}

.stat-card:hover .stat-number {
    color: var(--red);
}

.analytics-section {
    margin-bottom: 2.5rem;
}

.analytics-section h2 {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-mid);
    margin-bottom: 1rem;
}

.analytics-section h2::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-line);
}

/* ── Editor ── */

.editor-page {
    max-width: 820px;
    padding-bottom: 3rem;
}

.editor-page h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.75rem;
    letter-spacing: -0.02em;
}

trix-editor {
    min-height: 420px;
    border: 1px solid var(--gray-line);
    padding: 1.25rem;
    font-family: 'Lora', Georgia, serif;
    font-size: 1.0625rem;
    line-height: 1.8;
    background: var(--noir-elevated);
    color: var(--paper);
    transition: border-color var(--transition), box-shadow var(--transition);
}

trix-editor:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

trix-toolbar {
    border: 1px solid var(--gray-line);
    border-bottom: none;
    background: var(--gray-dark);
    padding: 0.5rem;
}

trix-toolbar .trix-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

trix-toolbar .trix-button-group {
    display: flex;
    border: none;
    gap: 1px;
    margin-right: 0.5rem;
    margin-bottom: 0;
}

trix-toolbar .trix-button {
    border: none;
    background: var(--noir);
    color: var(--paper);
    padding: 0.375rem 0.5rem;
    min-width: 2rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

trix-toolbar .trix-button:hover {
    background: var(--gray-line);
    color: #fff;
}

trix-toolbar .trix-button.trix-active {
    background: var(--red);
    color: #fff;
}

trix-toolbar .trix-button--icon::before {
    opacity: 0.9;
}

trix-toolbar .trix-button--icon:hover::before {
    opacity: 1;
}

trix-toolbar .trix-dialogs {
    background: var(--gray-dark);
    border: 1px solid var(--gray-line);
}

trix-toolbar .trix-dialog {
    background: var(--gray-dark);
    border: none;
    color: var(--paper);
    padding: 0.75rem;
}

trix-toolbar .trix-dialog input[type="text"],
trix-toolbar .trix-dialog input[type="url"] {
    background: var(--noir);
    border: 1px solid var(--gray-line);
    color: var(--paper);
    padding: 0.375rem 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
}

trix-toolbar .trix-dialog input:focus {
    border-color: var(--red);
    outline: none;
}

trix-toolbar .trix-dialog .trix-button-group {
    margin-right: 0;
}

trix-toolbar .trix-dialog .trix-button-group .trix-button {
    background: var(--red);
    color: #fff;
}

/* ── Focus states ── */

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

/* ── Image resize (editor) ── */

.editor-wrapper {
    position: relative;
}

trix-editor figure {
    display: block;
    max-width: 100%;
    margin: 1rem auto;
    text-align: center;
}

trix-editor figure img {
    max-width: 100%;
    height: auto;
    display: block;
}


.img-resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--red);
    cursor: nwse-resize;
    z-index: 20;
    opacity: 0.9;
    pointer-events: auto;
}

.img-resize-handle::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
}

.img-resize-handle:hover {
    opacity: 1;
}

.img-resize-outline {
    position: absolute;
    border: 2px solid var(--red);
    pointer-events: none;
    z-index: 19;
    background: rgba(200, 16, 46, 0.05);
}

.img-resize-outline .resize-width-label {
    position: absolute;
    bottom: -24px;
    right: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    color: var(--red);
    background: var(--noir);
    padding: 2px 6px;
    border: 1px solid var(--red);
}

/* ── Misc ── */

.empty-state {
    color: var(--gray-mid);
    text-align: center;
    padding: 4rem 1rem;
    font-size: 0.9rem;
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Responsive ── */

@media (max-width: 1200px) {
    .article-layout .sidebar {
        display: none;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 1rem;
    }

    .nav .container {
        height: 56px;
    }

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

    .table th:nth-child(3),
    .table td:nth-child(3) {
        display: none;
    }

    .article-header h1 {
        font-size: 2.25rem;
    }

    .article-cover {
        height: 220px;
    }

    .auth-form {
        margin: 3rem auto;
        padding: 1.75rem;
    }

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

    .stat-number {
        font-size: 2.25rem;
    }

    .article-content > p:first-of-type::first-letter {
        font-size: 3em;
    }
}
