:root {
  --bg: #E7EAEF;
  --shell: #FFFFFF;
  --main: #F5F6F8;
  --panel: #FFFFFF;
  --ink: #16181D;
  --muted: #636A76;
  --line: #E6E8EC;
  --soft: #FCEBE8;
  --chip: #EEF0F3;
  --red: #C8392A;
  --red-text: #B8321F;
  --good: #1E8A4A;
  --good-bg: #E3F4EA;
  --warn: #9A6700;
  --warn-bg: #FFF4D6;
  --nav: #16181D;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --head: 'Oswald', 'Arial Narrow', sans-serif;
  --body: Futura, 'Jost', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060708; --shell: #111317; --main: #0B0C0F; --panel: #181A20; --ink: #F3F4F6; --muted: #A1A7B3;
    --line: #262A33; --soft: #2B1513; --chip: #23262E; --red-text: #FF7A6B; --good: #4ADE80; --good-bg: #12301E;
    --warn: #FBBF24; --warn-bg: #33280D; --nav: #1F2229; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #060708; --shell: #111317; --main: #0B0C0F; --panel: #181A20; --ink: #F3F4F6; --muted: #A1A7B3;
  --line: #262A33; --soft: #2B1513; --chip: #23262E; --red-text: #FF7A6B; --good: #4ADE80; --good-bg: #12301E;
  --warn: #FBBF24; --warn-bg: #33280D; --nav: #1F2229; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.h { font-family: var(--head); font-weight: 600; text-transform: uppercase; letter-spacing: 0.2px; line-height: 1.05; margin: 0; }
.muted { color: var(--muted); }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: block; }
}

/* ---------- Shell ---------- */
.app { min-height: 100vh; }
@media (min-width: 900px) {
  .app { padding: 20px; }
  .frame { max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 40px); display: flex; background: var(--shell); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; }
}
.side { display: none; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 24px; width: 248px; flex-shrink: 0; padding: 28px 20px; }
  .side .logo img { width: 190px; height: auto; }
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; letter-spacing: 1.5px; color: var(--muted); padding: 0 12px 6px; }
.nav a, .nav button { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; font-size: 15px; border: 0; background: transparent; text-align: left; width: 100%; }
.nav a:hover, .nav button:hover { background: var(--main); }
.nav a.on { background: var(--soft); color: var(--red-text); font-weight: 600; }
.nav .soon { margin-left: auto; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--chip); color: var(--muted); }
.nav svg, .bnav svg, .icon { width: 20px; height: 20px; flex-shrink: 0; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--main); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.main { flex: 1; min-width: 0; min-height: 100vh; background: var(--main); display: flex; flex-direction: column; }
@media (min-width: 900px) { .main { min-height: 0; } }
.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 16px 0; }
.topbar .logo img { height: 34px; width: auto; }
@media (min-width: 900px) { .topbar { padding: 24px 32px 0; } .topbar .logo { display: none; } }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.view { padding: 16px 16px 120px; display: flex; flex-direction: column; gap: 18px; flex: 1; }
@media (min-width: 900px) { .view { padding: 20px 32px 40px; gap: 22px; } }

/* bottom nav (phone) */
.bnav { position: fixed; left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); height: 64px; border-radius: 999px; background: var(--nav); display: flex; align-items: center; justify-content: space-around; padding: 0 8px; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.bnav a { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px; border-radius: 999px; color: #C9CDD4; font-size: 14px; font-weight: 600; }
.bnav a.on { background: var(--red); color: #fff; padding: 0 16px; }
.bnav a .lbl { display: none; }
.bnav a.on .lbl { display: inline; }
@media (min-width: 900px) { .bnav { display: none; } }

/* ---------- Pieces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn { height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; font-family: var(--head); font-size: 16px; letter-spacing: 0.6px; text-transform: uppercase; }
.btn.red:hover { filter: brightness(1.06); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.btn[disabled] { background: var(--chip); border-color: var(--chip); color: var(--muted); cursor: not-allowed; filter: none; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.live { background: var(--good-bg); color: var(--good); }
.chip.pending { background: var(--warn-bg); color: var(--warn); }
.chip.red { background: var(--soft); color: var(--red-text); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-family: var(--body); }
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 4px 0 12px; border-bottom: 3px solid transparent; margin-bottom: -1px; font-family: var(--head); font-weight: 600; font-size: 17px; text-transform: uppercase; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--red); }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span, .label { font-size: 14px; font-weight: 600; }
.input, .select, textarea.input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--main); outline: 0; font-size: 15px; }
.input:focus, .select:focus { border-color: var(--red); }
.hint { font-size: 12px; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.req { color: var(--red-text); font-weight: 600; font-size: 12px; }

/* hero */
.hero { position: relative; isolation: isolate; overflow: hidden; border-radius: 26px; color: #fff; padding: 28px 24px; min-height: 190px; display: flex; flex-direction: column; justify-content: flex-end; gap: 16px; }
.hero::before { content: ''; position: absolute; inset: 0; z-index: -2; background: url(assets/hero.jpg) 50% 28% / cover; filter: grayscale(1); }
.hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--red); mix-blend-mode: multiply; opacity: 0.9; }
.hero h2 { font-size: 34px; }
@media (min-width: 900px) { .hero { padding: 36px; min-height: 230px; } .hero h2 { font-size: 52px; } }
.pill-white { align-self: flex-start; display: inline-flex; align-items: center; gap: 12px; height: 52px; padding: 0 8px 0 22px; border-radius: 999px; background: #fff; color: var(--red); font-family: var(--head); font-weight: 600; font-size: 17px; letter-spacing: 0.6px; text-transform: uppercase; }
.pill-white .plus { width: 36px; height: 36px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; }

/* post rows */
.list { display: flex; flex-direction: column; }
.post-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-top: 1px solid var(--line); }
.post-row:first-child { border-top: 0; }
.post-row:hover .post-title { color: var(--red-text); }
.thumb { width: 72px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--chip); flex-shrink: 0; }
.post-meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.post-title { font-size: 16px; font-weight: 400; line-height: 1.3; margin-top: 3px; }
.search { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 15px; }

/* ---------- Editor ---------- */
.ed-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ed-grid { display: flex; gap: 24px; align-items: flex-start; }
.ed-paper { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.ed-side { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.ed-title { width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-family: var(--head); font-weight: 600; font-size: 34px; line-height: 1.12; text-transform: none; padding: 0; overflow: hidden; }
.ed-title::placeholder { color: var(--muted); opacity: 0.6; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; border-radius: 14px; background: var(--main); position: sticky; top: 0; z-index: 5; }
.toolbar button { min-width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; }
.toolbar button:hover { background: var(--panel); }
.toolbar .sep { width: 1px; background: var(--line); margin: 6px 4px; }
.ed-body { min-height: 360px; outline: 0; font-family: Georgia, 'Times New Roman', serif; font-size: 18px; line-height: 1.7; }
.ed-body:empty::before { content: attr(data-placeholder); color: var(--muted); }
.ed-body h2, .ed-body h3 { font-family: var(--head); text-transform: none; line-height: 1.2; }
.ed-body blockquote { margin: 1em 0; padding: 4px 0 4px 18px; border-left: 4px solid var(--red); color: var(--muted); }
.ed-body img { max-width: 100%; height: auto; border-radius: 10px; }
.ed-body a { color: var(--red-text); text-decoration: underline; }
.ed-body p { margin: 0 0 1em; }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--soft); font-size: 14px; }
.banner.warn { background: var(--warn-bg); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--main); min-height: 46px; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 500; }
.tag.new { background: var(--red); border-color: var(--red); color: #fff; }
.tag button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.tags input { flex: 1; min-width: 90px; border: 0; outline: 0; background: transparent; font-size: 14px; padding: 4px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px dashed var(--line); background: var(--panel); font-size: 13px; }
.feat { aspect-ratio: 16 / 9; border-radius: 14px; background: var(--chip); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; position: relative; }
.feat img { width: 100%; height: 100%; object-fit: cover; }
.checklist { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.checklist .ok { color: var(--good); }
.checklist .no { color: var(--muted); }

@media (max-width: 899px) {
  .ed-grid { display: block; }
  .ed-title { font-size: 28px; }
  .ed-side { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 82vh; overflow: auto; background: var(--shell); border-radius: 26px 26px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); z-index: 60; transform: translateY(105%); transition: transform 0.25s ease; box-shadow: 0 -10px 40px rgba(0,0,0,0.25); }
  .ed-side.open { transform: none; }
  .ed-side .card { box-shadow: none; padding: 16px; }
  .sheet-grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 6px; }
  .ed-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--shell); border-top: 1px solid var(--line); display: flex; gap: 10px; z-index: 40; }
  .ed-bar .btn { flex: 1; padding: 0 12px; font-size: 14px; }
  .ed-bar .btn.red { font-size: 15px; }
  .ed-bar #openSide { flex: 0 0 48px; padding: 0; }
  .ed-bar #openSide span { display: none; }
  .posts-head .search { flex-basis: 100%; max-width: none !important; margin-left: 0 !important; order: 3; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 55; }
  .desk-only { display: none !important; }
}
@media (min-width: 900px) {
  .ed-bar, .sheet-grab, .phone-only, .scrim { display: none !important; }
}

/* toast */
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.25); max-width: calc(100vw - 32px); }
.toast.err { background: var(--red); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 32px; } }

/* full-page messages */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate .card { max-width: 520px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.gate code { background: var(--chip); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--red); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } .ed-side { transition: none; } }
