:root {
  --accent: #FF6B4A;
  --accent-ink: #B93A1E;      /* accent text on white: 5.3:1 */
  --ink: #111827;
  --ink-2: #4B5563;            /* 7.6:1 on white */
  --line: #E5E7EB;
  --bg: #F9FAFB;
  --surface: #FFFFFF;
  --danger: #B91C1C;
  --warn-bg: #FFFBEB;
  --warn-line: #F59E0B;
  --warn-ink: #78350F;
  --ok-bg: #ECFDF5;
  --ok-ink: #065F46;
  --radius: 10px;
  --focus: 0 0 0 3px rgba(255, 107, 74, .45);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; z-index: 100; }
.muted { color: var(--ink-2); font-weight: 400; }
a { color: var(--accent-ink); }
:focus-visible { outline: none; box-shadow: var(--focus); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover { background: #F3F4F6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111827; }
.btn.primary:hover { background: #F25A38; }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: #FCA5A5; }
.btn.danger-ghost:hover { background: #FEF2F2; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.busy { opacity: .6; cursor: progress; }

label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink);
  border: 1px solid #D1D5DB; border-radius: 8px; background: var(--surface);
}
input[readonly], select[disabled] { background: #F3F4F6; color: var(--ink-2); }
textarea { resize: vertical; }
textarea.body { font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.help { font-size: 14px; color: var(--ink-2); margin: 6px 0 0; }
.field-error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 12px 0 0; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card .btn { width: 100%; margin-top: 16px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent-ink); }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  min-height: 44px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.count { font-weight: 500; color: var(--ink-2); }

.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.post-list a {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; transition: border-color .15s ease;
}
.post-list a:hover { border-color: #D1D5DB; }
.post-title { font-weight: 600; }
.post-meta { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.empty { color: var(--ink-2); text-align: center; padding: 48px 0; }

.badge { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; align-self: start; }
.badge.review { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.badge.live { background: var(--ok-bg); border-color: #6EE7B7; color: var(--ok-ink); }
.badge.archived { color: var(--ink-2); }

.back { margin-bottom: 12px; }
.banner { border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor-head h2 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.editor-head-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.cover-row { display: flex; gap: 8px; }
.cover-row input { flex: 1; }
.upload { margin: 0; flex: none; }
.cover { display: block; max-width: 320px; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); margin-top: 8px; }
.actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.actions-left, .actions-right { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
