/* Last War Codex — military / wasteland theme. Mobile-first. */

:root {
  --bg: #14160f;
  --bg-2: #191c13;
  --panel: #1e2218;
  --panel-2: #262b1f;
  --line: #3a4130;
  --line-2: #4c5540;
  --bone: #ebe5d3;
  --text: #d9d4c3;
  --muted: #9b9c86;
  --sand: #c8b27a;
  --olive: #6f7d3c;
  --olive-2: #8a9a4c;
  --accent: #f08a24;
  --accent-ink: #1a1206;
  --danger: #d4553f;
  --ok: #8fb35a;
  --info: #6fa3b8;
  --radius: 3px;
  --chamfer: 10px;
  --wrap: 1180px;
  --font-display: 'Black Ops One', Impact, 'Arial Black', sans-serif;
  --font-head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(240, 138, 36, 0.08), transparent 55%),
    radial-gradient(ellipse at 100% 30%, rgba(111, 125, 60, 0.10), transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
  color: var(--text);
  font: 400 17px/1.6 var(--font-body);
}

a { color: var(--sand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { color: var(--bone); font-family: var(--font-head); font-weight: 700; line-height: 1.15; letter-spacing: 0.01em; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 56px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(20, 22, 15, 0.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.header-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.logo-mark { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-display); font-size: 1.35rem; color: var(--bone); letter-spacing: 0.04em; line-height: 1; white-space: nowrap; }
.brand-tag { font-family: var(--font-head); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--accent); margin-top: 4px; white-space: nowrap; }
.hazard { height: 6px; background: repeating-linear-gradient(-45deg, var(--accent) 0 12px, #15120c 12px 24px); opacity: 0.9; }

.search { display: flex; flex: 1 1 100%; order: 3; min-width: 0; }
.search input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px;
  background: var(--panel); color: var(--bone);
  border: 1px solid var(--line-2); border-right: 0; border-radius: var(--radius) 0 0 var(--radius);
  font: 500 16px var(--font-body);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--accent); }
.search button {
  width: 48px; height: 44px; display: grid; place-items: center;
  background: var(--panel-2); color: var(--sand); border: 1px solid var(--line-2); border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer;
}
.search button svg { width: 20px; height: 20px; }
.search button:hover { color: var(--accent); }
.search-lg input { height: 52px; font-size: 17px; }
.search-lg button.btn { width: auto; height: 52px; padding: 0 22px; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); border-radius: 0 var(--radius) var(--radius) 0; clip-path: none; }
.search-lg button.btn:hover { background: #ffa04a; color: var(--accent-ink); }

.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; order: 4; flex: 1 1 100%; font-family: var(--font-head); font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; }
.admin-nav a:not(.btn) { color: var(--text); text-decoration: none; padding: 6px 0; }
.admin-nav a:not(.btn):hover { color: var(--accent); }
.admin-nav .who { color: var(--muted); font-family: var(--font-mono); font-size: 0.75rem; text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.rank { color: var(--accent-ink); background: var(--sand); padding: 1px 5px; font-family: var(--font-head); font-size: 0.7rem; letter-spacing: 0.1em; }

@media (min-width: 760px) {
  .search { flex: 0 1 360px; order: 0; margin-left: auto; }
  .is-admin .search { flex-basis: 260px; }
  .admin-nav { flex: 0 1 auto; order: 0; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 20px;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: var(--radius);
  font: 700 1rem var(--font-head); text-transform: uppercase; letter-spacing: 0.08em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.btn:hover { background: #ffa04a; color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--sand); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--bone); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.linkish { background: none; border: 0; padding: 0; color: var(--sand); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--accent); }

/* ---------- Common bits ---------- */
.stamp {
  display: inline-block; margin: 0 0 12px; padding: 3px 10px;
  border: 1.5px solid var(--accent); color: var(--accent);
  font: 700 0.75rem var(--font-head); text-transform: uppercase; letter-spacing: 0.22em;
  transform: rotate(-1.5deg);
}
.lead { font-size: 1.1rem; color: var(--text); max-width: 68ch; }
.meta { color: var(--muted); font: 500 0.82rem var(--font-mono); letter-spacing: 0.02em; }
.kicker { display: inline-flex; align-items: center; gap: 6px; color: var(--olive-2); font: 700 0.8rem var(--font-head); text-transform: uppercase; letter-spacing: 0.14em; text-decoration: none; }
a.kicker:hover { color: var(--accent); }
.icon { width: 28px; height: 28px; }
.icon-xs { width: 16px; height: 16px; }
.empty { padding: 28px; border: 1px dashed var(--line-2); color: var(--muted); text-align: center; }
.tag {
  display: inline-block; padding: 3px 9px; margin: 2px 4px 2px 0;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--sand);
  font: 500 0.78rem var(--font-mono); text-decoration: none; border-radius: 2px;
}
.tag::before { content: '#'; color: var(--muted); }
.tag:hover { border-color: var(--accent); color: var(--accent); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; font: 600 0.82rem var(--font-head); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs span:last-child { color: var(--sand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.section { margin-top: 48px; }
.section-title { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.2em; color: var(--sand); }
.section-title::before { content: ''; width: 10px; height: 10px; background: var(--accent); transform: rotate(45deg); flex: none; }
.section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }

/* ---------- Grid + cards ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2, .grid-3, .grid-cats { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid-3, .grid-cats { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative; display: block;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%);
  transition: border-color 0.15s, transform 0.15s;
}
.card::after { content: ''; position: absolute; top: 0; right: 0; width: calc(var(--chamfer) * 1.42); height: 1px; background: var(--line); transform-origin: right top; transform: rotate(45deg); }
.card:hover { border-color: var(--olive); }
.card:hover::after { background: var(--accent); }

.article-card .card-link { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px 18px 16px; text-decoration: none; color: var(--text); }
.article-card h3 { margin: 0; font-size: 1.35rem; }
.article-card p { margin: 0; color: var(--text); font-size: 0.97rem; flex: 1; }
.article-card .card-link:hover h3 { color: var(--accent); }

.cat-card { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: var(--text); min-height: 92px; }
.cat-icon { display: grid; place-items: center; width: 52px; height: 52px; flex: none; color: var(--sand); background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line-2); }
.cat-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cat-name { color: var(--bone); font: 700 1.25rem var(--font-head); text-transform: uppercase; letter-spacing: 0.04em; }
.cat-desc { font-size: 0.9rem; color: var(--muted); line-height: 1.4; }
.count { align-self: flex-start; font: 600 0.8rem var(--font-mono); color: var(--olive-2); }
.cat-card:hover .cat-icon { color: var(--accent); border-color: var(--accent); }
.cat-card:hover .cat-name { color: var(--accent); }

.related-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; text-decoration: none; color: var(--text); }
.related-card strong { color: var(--bone); font: 700 1.1rem var(--font-head); }
.related-card span { font-size: 0.9rem; color: var(--muted); }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; padding: 12px 0 8px; }
.hero h1 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 400; font-size: clamp(2.2rem, 9vw, 4.2rem); line-height: 1.02; letter-spacing: 0.02em; text-transform: uppercase; }
.hero h1 span { color: var(--accent); }
.hero .lead { margin: 0 0 22px; }
.hero-radar { display: none; }
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); padding: 32px 0 16px; }
  .hero-radar {
    display: block; position: relative; justify-self: center; width: 300px; aspect-ratio: 1; border-radius: 50%;
    background:
      radial-gradient(circle, transparent 0 24%, rgba(143, 179, 90, 0.25) 24.3% 24.8%, transparent 25% 49%, rgba(143, 179, 90, 0.25) 49.3% 49.8%, transparent 50% 74%, rgba(143, 179, 90, 0.25) 74.3% 74.8%, transparent 75%),
      linear-gradient(transparent 49.7%, rgba(143, 179, 90, 0.25) 49.7% 50.3%, transparent 50.3%),
      linear-gradient(90deg, transparent 49.7%, rgba(143, 179, 90, 0.25) 49.7% 50.3%, transparent 50.3%),
      radial-gradient(circle, #1d2416, #12160d);
    border: 2px solid var(--olive); box-shadow: 0 0 40px rgba(111, 125, 60, 0.25), inset 0 0 30px rgba(0, 0, 0, 0.6); overflow: hidden;
  }
  .sweep { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, rgba(143, 179, 90, 0.45), transparent 22%); animation: sweep 4s linear infinite; }
  .blip { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: blip 4s ease-out infinite; }
  .b1 { top: 28%; left: 62%; } .b2 { top: 64%; left: 30%; animation-delay: 1.6s; } .b3 { top: 70%; left: 72%; animation-delay: 2.7s; }
}
@keyframes sweep { to { transform: rotate(360deg); } }
@keyframes blip { 0%, 100% { opacity: 0.15; } 10% { opacity: 1; } 60% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .sweep, .blip { animation: none; } }

/* ---------- Page heads ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 26px; }
.page-head h1 { margin: 0 0 6px; font-size: clamp(2rem, 7vw, 2.8rem); text-transform: uppercase; }
.page-head .lead { margin: 0; }
.page-icon { display: grid; place-items: center; width: 60px; height: 60px; flex: none; color: var(--accent); border: 1px solid var(--accent); background: rgba(240, 138, 36, 0.06); }
.page-icon .icon { width: 32px; height: 32px; }

/* ---------- Article ---------- */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.article-head { margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.article-head h1 { margin: 8px 0 10px; font-size: clamp(2rem, 7.5vw, 3rem); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 14px 0 0; }
.toc { order: -1; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); }
.toc-title { margin: 0 0 6px; font: 700 0.8rem var(--font-head); text-transform: uppercase; letter-spacing: 0.18em; color: var(--sand); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc li.lvl-3 { padding-left: 14px; }
.toc a { display: block; padding: 5px 0; color: var(--text); text-decoration: none; font-size: 0.95rem; line-height: 1.35; }
.toc a:hover { color: var(--accent); }
@media (min-width: 1000px) {
  .article-layout.has-toc { grid-template-columns: minmax(0, 1fr) 250px; }
  .toc { order: 0; position: sticky; top: 96px; align-self: start; max-height: calc(100vh - 120px); overflow: auto; }
}

/* ---------- Prose (article body) ---------- */
.prose { max-width: 74ch; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 2em 0 0.6em; font-size: 1.75rem; text-transform: uppercase; letter-spacing: 0.03em; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.prose h3 { margin: 1.6em 0 0.5em; font-size: 1.35rem; color: var(--sand); }
.prose h4, .prose h5, .prose h6 { margin: 1.4em 0 0.4em; font-size: 1.1rem; }
.prose h2 .anchor, .prose h3 .anchor, .prose h4 .anchor { float: left; margin-left: -0.9em; width: 0.9em; color: var(--line-2); text-decoration: none; opacity: 0; }
.prose :is(h2, h3, h4):hover .anchor { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.25em 0; }
.prose ul li::marker { color: var(--accent); }
.prose ol li::marker { color: var(--sand); font-family: var(--font-mono); font-size: 0.9em; }
.prose strong { color: var(--bone); }
.prose img { display: block; margin: 1.2em 0; border: 1px solid var(--line-2); }
.prose hr { border: 0; height: 6px; margin: 2em 0; background: repeating-linear-gradient(-45deg, var(--line-2) 0 8px, transparent 8px 16px); }
.prose code { padding: 0.1em 0.35em; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); color: var(--sand); font: 0.85em var(--font-mono); border-radius: 2px; }
.prose pre { margin: 0 0 1.2em; padding: 14px 16px; overflow-x: auto; background: #0e100a; border: 1px solid var(--line); }
.prose pre code { padding: 0; border: 0; background: none; color: var(--text); }
.prose blockquote { margin: 0 0 1.2em; padding: 4px 16px; border-left: 3px solid var(--line-2); color: var(--muted); }
.prose .task.done { color: var(--ok); }
.table-wrap { width: 100%; overflow-x: auto; margin: 0 0 1.2em; -webkit-overflow-scrolling: touch; }
.prose table, .admin-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.prose th, .prose td, .admin-table th, .admin-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th, .admin-table th { background: var(--panel-2); color: var(--sand); font: 700 0.85rem var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.prose tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.al-center { text-align: center !important; } .al-right { text-align: right !important; }

.callout { margin: 0 0 1.2em; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--info); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { margin: 0 0 4px !important; font: 700 0.85rem var(--font-head); text-transform: uppercase; letter-spacing: 0.16em; color: var(--info); }
.callout-tip { border-left-color: var(--ok); } .callout-tip .callout-title { color: var(--ok); }
.callout-warning, .callout-caution { border-left-color: var(--accent); background: linear-gradient(90deg, rgba(240, 138, 36, 0.08), var(--panel) 40%); }
.callout-warning .callout-title, .callout-caution .callout-title { color: var(--accent); }
.callout-important { border-left-color: var(--danger); } .callout-important .callout-title { color: var(--danger); }

/* ---------- 404 ---------- */
.notfound { padding: 60px 0; text-align: center; }
.notfound h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(2.4rem, 10vw, 4rem); text-transform: uppercase; margin: 0 0 10px; }
.notfound .lead { margin: 0 auto 26px; }
.notfound p:last-child { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); padding: 22px 0 28px; font-size: 0.85rem; color: var(--muted); }
.footer-row { display: flex; flex-direction: column; gap: 8px; }
.footer-row p { margin: 0; }
.footer-row strong { color: var(--sand); }
.footer-links a { color: var(--muted); }
@media (min-width: 760px) { .footer-row { flex-direction: row; justify-content: space-between; gap: 32px; } .footer-links { white-space: nowrap; } }

/* ======================= Admin ======================= */
.wrap.wide { max-width: 1400px; }
.admin-head { flex-wrap: wrap; justify-content: space-between; align-items: flex-end; }
.flash { margin-bottom: 18px; padding: 12px 16px; border: 1px solid var(--ok); border-left-width: 4px; background: rgba(143, 179, 90, 0.08); color: var(--bone); }
.flash-error { border-color: var(--danger); background: rgba(212, 85, 63, 0.1); }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--muted); text-decoration: none; font: 700 0.95rem var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab span { font-family: var(--font-mono); font-size: 0.75rem; color: var(--line-2); }
.tab.active { color: var(--bone); border-bottom-color: var(--accent); }
.tab.active span { color: var(--accent); }
.admin-table td a strong { color: var(--bone); }
.admin-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.row-actions { white-space: nowrap; text-align: right !important; }
.row-actions > * { margin-left: 12px; }
.row-actions form { display: inline; }
.badge { display: inline-block; padding: 2px 8px; font: 700 0.72rem var(--font-head); text-transform: uppercase; letter-spacing: 0.12em; border: 1px solid var(--line-2); color: var(--muted); }
.badge-published { border-color: var(--ok); color: var(--ok); }
.badge-draft { border-color: var(--sand); color: var(--sand); border-style: dashed; }
.badge-featured { border: 0; color: var(--accent); padding: 0; }

/* Admin table becomes stacked cards on phones */
@media (max-width: 720px) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .admin-table td { padding: 2px 0; border: 0; }
  .row-actions { text-align: left !important; padding-top: 8px !important; }
  .row-actions > * { margin: 0 16px 0 0; }
}

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font: 700 0.8rem var(--font-head); text-transform: uppercase; letter-spacing: 0.12em; color: var(--sand); }
.field > span em { font: italic 400 0.8rem var(--font-body); text-transform: none; letter-spacing: 0; color: var(--muted); }
.field input, .field select, .md-editor textarea, .slug-input {
  width: 100%; min-height: 44px; padding: 9px 12px;
  background: #101209; color: var(--bone); border: 1px solid var(--line-2); border-radius: var(--radius);
  font: 400 16px var(--font-body);
}
.field input:focus, .field select:focus, .md-editor textarea:focus, .slug-input:focus-within { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field-title input { font: 700 1.3rem var(--font-head); letter-spacing: 0.02em; }
.slug-input { display: flex; align-items: center; padding: 0 0 0 12px; }
.slug-input .prefix { color: var(--muted); font: 0.85rem var(--font-mono); }
.slug-input input { border: 0; background: transparent; box-shadow: none !important; padding-left: 2px; font-family: var(--font-mono); font-size: 15px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.editor-meta { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }
@media (min-width: 760px) {
  .editor-meta { grid-template-columns: 2fr 1fr; }
  .editor-meta .field-wide { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  .editor-meta { grid-template-columns: 2fr 1fr 1fr; }
  .editor-meta .field-title { grid-column: span 2; }
  .editor-meta .field-wide { grid-column: span 2; }
}

.md-editor { border: 1px solid var(--line-2); background: var(--panel); }
.md-toolbar { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line-2); overflow-x: auto; -webkit-overflow-scrolling: touch; position: sticky; top: 0; background: var(--panel-2); z-index: 2; }
.md-toolbar button { flex: none; min-width: 40px; min-height: 40px; padding: 0 10px; background: transparent; color: var(--text); border: 1px solid transparent; border-radius: var(--radius); font: 600 0.9rem var(--font-head); letter-spacing: 0.04em; cursor: pointer; }
.md-toolbar button:hover { border-color: var(--line-2); color: var(--bone); background: rgba(0, 0, 0, 0.2); }
.md-toolbar .tb-tip { color: var(--ok); } .md-toolbar .tb-warn { color: var(--accent); }
.tb-spacer { flex: 1; }
.tb-toggle[aria-pressed='true'] { background: var(--accent) !important; color: var(--accent-ink) !important; }
.md-panes { display: grid; grid-template-columns: 1fr; }
.md-editor textarea { display: block; min-height: 60vh; border: 0; border-radius: 0; resize: vertical; font: 15px/1.65 var(--font-mono); background: #101209; }
.md-preview { display: none; padding: 18px 20px; min-height: 60vh; max-width: none; background: var(--bg); overflow: auto; }
.md-editor.show-preview textarea { display: none; }
.md-editor.show-preview .md-preview { display: block; }
@media (min-width: 1100px) {
  .md-panes { grid-template-columns: 1fr 1fr; }
  .md-preview { display: block; border-left: 1px solid var(--line-2); max-height: 75vh; }
  .md-editor textarea { min-height: 75vh; }
  .md-editor.show-preview textarea { display: block; }
  .tb-toggle { display: none; }
}
.hint { color: var(--muted); font-size: 0.85rem; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 18px; border-top: 1px dashed var(--line-2); }

/* Categories admin */
.cat-list { display: grid; gap: 12px; margin-bottom: 36px; }
.cat-row { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px; align-items: end; }
.cat-row .cat-icon { width: 44px; height: 44px; }
.cat-actions { display: flex; gap: 8px; }
.cat-count { align-self: center; }
@media (min-width: 900px) {
  .cat-row { grid-template-columns: 44px 1.2fr 1fr 2.4fr 130px 80px auto; }
  .cat-count { grid-column: 2 / -1; }
}

.revision-body { padding: 20px; border: 1px dashed var(--line-2); background: var(--panel); }

/* ---------- Phone refinements ---------- */
@media (max-width: 639px) {
  /* Compact two-up briefing room tiles */
  .grid-cats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card { flex-direction: column; align-items: flex-start; gap: 10px; min-height: 0; padding: 14px 12px; }
  .cat-card .cat-icon { width: 42px; height: 42px; }
  .cat-card .cat-icon .icon { width: 24px; height: 24px; }
  .cat-name { font-size: 1.02rem; line-height: 1.15; }
  .cat-desc { display: none; }
  .cat-card .count { position: absolute; top: 12px; right: 14px; }
  /* The home page has its own big search box */
  .page-home .site-header .search { display: none; }
}

@media (max-width: 759px) {
  /* Editors: keep the header out of the way and the main buttons always in reach */
  .is-admin .site-header { position: static; }
  .is-admin .admin-nav .who { display: none; }
  .is-admin .admin-nav { gap: 4px 16px; }
  .editor-actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--panel); box-shadow: 0 -8px 20px rgba(0,0,0,.45); border-top: 1px solid var(--line-2);
  }
  .editor-actions .btn { padding: 0 10px; font-size: 0.92rem; }
  .editor-actions a.btn { display: none; }
  .is-admin:has(.editor-actions) main { padding-bottom: 96px; }
  .md-editor textarea, .md-preview { min-height: 55vh; }
}

/* Editor access requests */
.request-form { display: grid; gap: 18px; max-width: 640px; padding: 22px; }
.request-form textarea, .field textarea {
  width: 100%; padding: 9px 12px; resize: vertical;
  background: #101209; color: var(--bone); border: 1px solid var(--line-2); border-radius: var(--radius);
  font: 400 16px var(--font-body);
}
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.request-form p { margin: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.flash-notice { border-color: var(--accent); background: rgba(240, 138, 36, 0.08); }
.flash-notice a { color: var(--bone); font-weight: 600; }
.next-step code, .admin-table code { font: 0.85em var(--font-mono); color: var(--sand); word-break: break-all; }
.request-reason { max-width: 36ch; white-space: pre-wrap; }

/* Image uploads */
.upload-status { min-height: 1.4em; margin: 6px 0 0; font-size: 0.9rem; color: var(--ok); }
.upload-status.is-error { color: var(--danger); }
.md-editor textarea.is-drop { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: #15180d; }
.img-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.img-card { display: flex; flex-direction: column; overflow: hidden; }
.img-thumb { display: block; aspect-ratio: 4 / 3; background: #0d0f08; border-bottom: 1px solid var(--line); }
.img-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.img-meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 4px; min-width: 0; }
.img-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 12px; margin-top: auto; }
.img-actions form { display: inline; }
