:root {
  color-scheme: dark;
  --bg: #0a0b0e;
  --surface: #111318;
  --surface-2: #17191f;
  --line: #2b2e36;
  --line-soft: #1e2127;
  --text: #f2efe9;
  --muted: #9b9ca2;
  --accent: #c92833;
  --accent-strong: #ef3947;
  --success: #3faf78;
  --max: 1180px;
  --narrow: 820px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 4%, rgba(201, 40, 51, .08), transparent 26rem),
    var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.shell { width: min(var(--max), calc(100% - 40px)); margin-inline: auto; }
.shell-narrow { width: min(var(--narrow), calc(100% - 40px)); margin-inline: auto; }

.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 14px max(24px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 11, 14, .9);
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { color: var(--accent-strong); font-family: var(--serif); font-size: 34px; line-height: 1; }
.brand-mark.large { display: block; margin-bottom: 16px; font-size: 52px; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-family: var(--serif); font-size: 18px; letter-spacing: .015em; }
.brand-copy small { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }

.header-links { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.header-links a { color: #c9c8c5; text-decoration: none; }
.header-links a:hover { color: #fff; }
.header-links .header-button {
  padding: 9px 14px;
  border: 1px solid #4a4c53;
  color: #fff;
}
.header-links .header-button:hover { border-color: var(--accent); background: rgba(201, 40, 51, .1); }

.intro { padding: clamp(72px, 10vw, 132px) 0 clamp(60px, 8vw, 100px); border-bottom: 1px solid var(--line-soft); }
.eyebrow { color: var(--accent-strong); font: 700 12px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
.intro h1, .article-header h1, .editor-shell > h1, .admin-titlebar h1, .auth-card h1, .not-found h1 {
  margin: 16px 0 20px;
  font: 500 clamp(42px, 8vw, 92px)/.96 var(--serif);
  letter-spacing: -.045em;
}
.intro p { max-width: 610px; margin: 0; color: #b7b6b2; font-size: clamp(17px, 2vw, 21px); }

.feed { padding: 54px 0 100px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading h2 { margin: 0; font: 500 clamp(25px, 3vw, 34px)/1.2 var(--serif); }
.section-heading > span { color: var(--muted); font: 12px var(--mono); text-transform: uppercase; }

.article-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.article-card { min-height: 330px; padding: clamp(24px, 4vw, 42px); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(17, 19, 24, .5); transition: background .2s ease; }
.article-card:hover { background: var(--surface); }
.article-card-featured { grid-column: 1 / -1; min-height: 390px; }
.article-meta { display: flex; flex-wrap: wrap; gap: 12px 20px; color: var(--muted); font: 12px/1.5 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.article-meta span::before { content: "/"; margin-right: 20px; color: #4f5159; }
.article-card h3 { max-width: 780px; margin: 28px 0 18px; font: 500 clamp(28px, 4.2vw, 50px)/1.03 var(--serif); letter-spacing: -.025em; }
.article-card:not(.article-card-featured) h3 { font-size: clamp(26px, 3vw, 36px); }
.article-card h3 a { text-decoration: none; }
.article-card h3 a:hover { color: var(--accent-strong); }
.article-card > p { max-width: 740px; margin: 0; color: #adaeaf; }
.card-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-top: 42px; }
.read-link { color: #e3e1dc; font-weight: 650; text-decoration: none; }
.read-link span { margin-left: 8px; color: var(--accent-strong); }
.stat-line { display: flex; gap: 16px; color: var(--muted); font: 12px var(--mono); }

.article-page { padding: 58px 0 0; }
.back-link { display: inline-block; margin-bottom: 58px; color: var(--muted); font-size: 14px; text-decoration: none; }
.back-link:hover { color: #fff; }
.article-header { padding-bottom: 44px; border-bottom: 1px solid var(--line); }
.article-header h1 { max-width: 780px; font-size: clamp(43px, 7vw, 76px); }
.article-lead { max-width: 720px; margin: 0; color: #c2c0bb; font: 21px/1.6 var(--serif); }
.article-body { padding: 54px 0 70px; white-space: pre-wrap; font: 19px/1.85 var(--serif); color: #dedbd5; }
.article-body::first-letter { float: left; margin: 7px 10px 0 0; color: var(--accent-strong); font-size: 66px; line-height: .72; }

.reactions { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 28px; border: 1px solid var(--line); background: var(--surface); }
.reactions p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.reaction-buttons { display: flex; gap: 10px; }
.reaction-button { display: flex; align-items: center; gap: 9px; min-width: 88px; padding: 12px 17px; border: 1px solid #3c3f47; background: transparent; color: #dcdad5; cursor: pointer; }
.reaction-button:hover, .reaction-button.is-active { border-color: var(--success); background: rgba(63, 175, 120, .1); color: #74daa5; }
.reaction-button-down:hover, .reaction-button-down.is-active { border-color: var(--accent); background: rgba(201, 40, 51, .1); color: #ff6b75; }

.comments { padding: 72px 0 100px; }
.comment-form, .editor-form { display: grid; gap: 22px; padding: clamp(22px, 4vw, 36px); border: 1px solid var(--line); background: var(--surface); }
label { display: grid; gap: 8px; }
label > span { color: #d2d0ca; font-size: 14px; font-weight: 650; }
label small { color: var(--muted); font-weight: 400; }
input, textarea {
  width: 100%;
  border: 1px solid #383b43;
  border-radius: 0;
  outline: none;
  background: #0d0f13;
  color: var(--text);
  padding: 13px 14px;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 40, 51, .1); }
textarea { resize: vertical; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.form-footer p { margin: 0; color: var(--muted); font-size: 13px; }
.button-primary, .button-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.button-primary:hover { background: var(--accent-strong); }
.button-primary.full { width: 100%; }
.button-ghost { border-color: var(--line); background: transparent; color: #c5c4c0; }
.comment-list { display: grid; gap: 1px; margin-top: 26px; background: var(--line); border: 1px solid var(--line); }
.comment { padding: 24px 26px; background: var(--bg); }
.comment-topline { display: flex; justify-content: space-between; gap: 20px; }
.comment-topline strong { color: #fff; }
.comment-topline time { color: var(--muted); font: 12px var(--mono); }
.comment p { margin: 12px 0 0; white-space: pre-wrap; color: #c5c4c0; }

.flash-stack { position: fixed; z-index: 50; top: 100px; right: 20px; width: min(380px, calc(100% - 40px)); }
.flash { margin-bottom: 8px; padding: 14px 16px; border: 1px solid var(--line); background: #1b1d23; box-shadow: 0 14px 40px rgba(0,0,0,.3); }
.flash-success { border-color: var(--success); }
.flash-error { border-color: var(--accent); }

.empty-state { padding: 72px 20px; border: 1px solid var(--line); color: var(--muted); text-align: center; }
.empty-state > span { color: var(--accent); font-size: 40px; }
.empty-state h3 { margin: 12px 0 4px; color: var(--text); font: 28px var(--serif); }
.empty-state p { margin: 0; }
.empty-state.compact { padding: 32px; }

.auth-card { width: min(430px, calc(100% - 40px)); margin: clamp(60px, 10vw, 120px) auto; padding: clamp(28px, 5vw, 48px); border: 1px solid var(--line); background: var(--surface); }
.auth-card h1 { margin: 12px 0 30px; font-size: 42px; }
.auth-card form { display: grid; gap: 20px; }

.admin-shell, .editor-shell { width: min(1100px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 100px; }
.editor-shell { width: min(850px, calc(100% - 40px)); }
.admin-titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 54px; }
.admin-titlebar h1, .editor-shell > h1 { margin: 10px 0 0; font-size: 54px; }
.admin-actions, .row-actions { display: flex; align-items: center; gap: 10px; }
.admin-actions form, .row-actions form { margin: 0; }
.admin-section + .admin-section { margin-top: 66px; }
.admin-list { border-top: 1px solid var(--line); }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.admin-row-main { min-width: 0; }
.admin-row h3 { margin: 9px 0; font: 26px/1.2 var(--serif); }
.admin-row p { max-width: 740px; margin: 10px 0 0; color: #c4c2bd; white-space: pre-wrap; }
.admin-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font: 12px var(--mono); }
.admin-stats a { color: #d9d6d0; }
.status-pill { display: inline-block; padding: 3px 8px; border: 1px solid #4a4d55; color: var(--muted); font: 11px var(--mono); text-transform: uppercase; }
.status-pill.published { border-color: rgba(63, 175, 120, .5); color: #70d5a1; }
.row-actions a, .row-actions button { border: 0; background: none; color: #b9b8b4; font-size: 13px; text-decoration: underline; cursor: pointer; }
.row-actions .danger-link { color: #ef6a73; }
.comment-admin.is-hidden { opacity: .45; }
.body-editor { min-height: 400px; font: 16px/1.6 var(--serif); }
.slug-input { display: flex; align-items: center; border: 1px solid #383b43; background: #0d0f13; }
.slug-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,40,51,.1); }
.slug-input > span { padding-left: 14px; color: var(--muted); font-family: var(--mono); }
.slug-input input { border: 0; box-shadow: none; }
.publish-toggle { display: flex; grid-template-columns: auto 1fr; align-items: center; width: fit-content; cursor: pointer; }
.publish-toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

.not-found { padding: 100px 0; text-align: center; }
.not-found h1 { font-size: 58px; }
.not-found p { margin: -4px 0 30px; color: var(--muted); }

.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px max(24px, calc((100vw - var(--max)) / 2)); border-top: 1px solid var(--line-soft); color: #777980; font: 12px var(--mono); }

@media (max-width: 760px) {
  .site-header { align-items: flex-start; padding: 15px 20px; }
  .brand-copy small { display: none; }
  .header-links { gap: 12px; }
  .header-links > a:first-child { display: none; }
  .intro { padding-top: 70px; }
  .article-grid { grid-template-columns: 1fr; }
  .article-card-featured { grid-column: auto; }
  .article-card { min-height: auto; }
  .card-footer, .form-footer, .reactions, .admin-titlebar, .admin-row { align-items: stretch; flex-direction: column; }
  .stat-line { margin-top: 10px; }
  .reaction-buttons { width: 100%; }
  .reaction-button { flex: 1; justify-content: center; }
  .comment-topline { flex-direction: column; gap: 4px; }
  .admin-actions { align-items: stretch; }
  .row-actions { flex-wrap: wrap; }
  .site-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
