/* Layout: narrow reading column for posts; the editor uses a full-width two-pane workspace. Shares the jhavp palette. */
:root {
  --bg: #F6F4EE; --surface: #FFFFFF; --ink: #17201C; --muted: #5F6B64; --line: #DDDAD1; --soft: #EEEBE3;
  --accent: #0B7356; --accent-soft: #D7ECE3; --accent-ink: #FFFFFF; --bad: #B83A2E; --warn: #9A6612;
  --f-display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --f-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --surface: #19201D; --ink: #E5ECE8; --muted: #95A59C; --line: #2B3631; --soft: #1F2824;
    --accent: #3BC495; --accent-soft: #163A2D; --accent-ink: #08130F; --bad: #EE6B5E; --warn: #E2A84B; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --surface: #19201D; --ink: #E5ECE8; --muted: #95A59C; --line: #2B3631; --soft: #1F2824;
  --accent: #3BC495; --accent-soft: #163A2D; --accent-ink: #08130F; --bad: #EE6B5E; --warn: #E2A84B; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--f-ui); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 720px; margin: 0 auto; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.top { display: flex; align-items: center; justify-content: space-between; padding-block: 26px; }
.word { font-family: var(--f-mono); font-weight: 500; text-decoration: none; }
.word .slash { color: var(--accent); margin-right: 2px; }
.word .sub { color: var(--muted); }
.top nav { display: flex; gap: 18px; font-size: .9rem; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: var(--ink); }

.intro { padding-block: clamp(28px, 7vw, 72px) 36px; display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font-family: var(--f-mono); font-size: .8rem; color: var(--accent); }
.intro h1 { font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 800; line-height: 1.05; letter-spacing: -0.035em; }
.sechead { font-size: .9rem; font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 10px; letter-spacing: 0; font-family: var(--f-ui); }
.postlist { list-style: none; margin: 0; padding: 0; }
.postlist li { border-bottom: 1px solid var(--line); }
.postlist a { display: flex; flex-direction: column; gap: 4px; padding-block: 22px; text-decoration: none; }
.postlist .meta { font-family: var(--f-mono); font-size: .76rem; color: var(--muted); }
.postlist .t { font-family: var(--f-display); font-weight: 800; font-size: 1.45rem; line-height: 1.2; letter-spacing: -0.02em; }
.postlist a:hover .t { color: var(--accent); }
.postlist .st { font-family: var(--f-serif); color: var(--muted); font-size: 1.05rem; }
.empty { color: var(--muted); padding-block: 28px; }
.empty h1 { color: var(--ink); font-size: 2rem; margin-bottom: 10px; }

/* post */
.post { padding-top: clamp(16px, 5vw, 48px); }
.posthead { display: flex; flex-direction: column; gap: 12px; padding-bottom: 28px; border-bottom: 1px solid var(--line); margin-bottom: 32px; }
.posthead h1 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.03em; }
.subtitle { font-family: var(--f-serif); font-size: clamp(1.1rem, 2.6vw, 1.3rem); color: var(--muted); line-height: 1.45; }
.byline { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); }
.byline span:first-child { color: var(--ink); font-weight: 600; }

.prose { font-family: var(--f-serif); font-size: 1.16rem; line-height: 1.72; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: 1.6rem; margin-top: 2em; line-height: 1.2; }
.prose h3 { font-size: 1.25rem; margin-top: 1.6em; }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose blockquote { margin-left: 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose code { font-family: var(--f-mono); font-size: .85em; background: var(--soft); padding: 2px 5px; border-radius: 4px; }
.prose pre { background: var(--soft); padding: 16px; border-radius: 10px; overflow-x: auto; font-size: .9rem; }
.prose pre code { background: none; padding: 0; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2.2em; }
.prose strong { font-weight: 600; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.prose table { border-collapse: collapse; width: 100%; font-family: var(--f-ui); font-size: .88rem; font-variant-numeric: tabular-nums; line-height: 1.45; }
.prose th, .prose td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--soft); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.prose tr:last-child td { border-bottom: 0; }
.al-right { text-align: right !important; } .al-center { text-align: center !important; }

.subscribe { margin-block: 56px 24px; padding: 26px; border-radius: 16px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 10px; }
.subscribe h2 { font-size: 1.3rem; }
.subscribe > p { color: var(--muted); font-size: .95rem; }
.subform { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.subform input[type=email] { flex: 1 1 220px; min-width: 0; font: 1rem var(--f-ui); padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.subform button, .btn { font: 600 .92rem var(--f-ui); padding: 11px 18px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.hp { position: absolute; left: -9999px; }
.note.ok { color: var(--accent); font-weight: 500; }
.note.err { color: var(--bad); font-weight: 500; }
.back { margin-bottom: 40px; font-size: .95rem; }
.back a { color: var(--muted); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-block: 28px 44px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); margin-top: 40px; }

/* ---------------- editor ---------------- */
body.editor { height: 100dvh; overflow: hidden; }
.ed { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100%; }
.ed-side { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.ed-side header { padding: 18px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
.ed-tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.ed-tabs button { all: unset; cursor: pointer; padding: 8px 10px; font-size: .85rem; color: var(--muted); border-bottom: 2px solid transparent; }
.ed-tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
.ed-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.ed-list button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 10px; border-radius: 8px; }
.ed-list button:hover { background: var(--soft); }
.ed-list button[aria-current="true"] { background: var(--accent-soft); }
.ed-list .t { font-weight: 600; font-size: .92rem; line-height: 1.3; }
.ed-list .m { font-size: .74rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.pill { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 99px; }
.pill.draft { background: var(--soft); color: var(--muted); }
.pill.published { background: var(--accent-soft); color: var(--accent); }
.ed-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ed-bar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.ed-bar .status { font-size: .82rem; color: var(--muted); margin-right: auto; }
.ed-bar .status.dirty { color: var(--warn); }
.ed-bar .status.err { color: var(--bad); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--bad); border-color: transparent; }
.btn.danger.armed { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.ed-meta { padding: 22px 28px 10px; display: flex; flex-direction: column; gap: 6px; }
.ed-meta input { all: unset; width: 100%; color: var(--ink); }
.ed-meta .ed-title { font: 800 clamp(1.6rem, 3vw, 2.3rem)/1.15 var(--f-display); letter-spacing: -0.03em; }
.ed-meta .ed-sub { font: 1.1rem/1.4 var(--f-serif); color: var(--muted) !important; }
.ed-slug { display: flex; align-items: center; gap: 2px; font: .8rem var(--f-mono); color: var(--muted); }
.ed-slug input { width: auto; flex: 1; min-width: 0; color: var(--ink); border-bottom: 1px dashed var(--line); }
.ed-tools { display: flex; gap: 2px; padding: 6px 22px; border-block: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.ed-tools button { all: unset; cursor: pointer; font: 600 .82rem var(--f-ui); padding: 6px 9px; border-radius: 6px; color: var(--muted); }
.ed-tools button:hover { background: var(--soft); color: var(--ink); }
.ed-tools .sep { width: 1px; height: 18px; background: var(--line); margin-inline: 6px; }
.ed-tools .view { margin-left: auto; display: none; }
.ed-panes { display: grid; grid-template-columns: 1fr 1fr; flex: 1; min-height: 0; }
.ed-panes textarea { border: 0; resize: none; padding: 22px 28px; font: .95rem/1.7 var(--f-mono); background: var(--bg); color: var(--ink); outline: none; min-height: 0; }
.ed-preview { overflow-y: auto; padding: 22px 32px 60px; border-left: 1px solid var(--line); background: var(--surface); min-width: 0; }
.ed-empty { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 40px; }
.subs { padding: 24px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.subs table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.subs th, .subs td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.subs th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
@media (max-width: 860px) {
  body.editor { height: auto; overflow: auto; }
  .ed { grid-template-columns: minmax(0, 1fr); height: auto; }
  .ed-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .ed-panes { grid-template-columns: minmax(0, 1fr); min-height: 60vh; }
  .ed-panes textarea { min-height: 60vh; }
  .ed-preview { border-left: 0; }
  .ed-tools .view { display: inline-block; }
  .ed-panes[data-view="write"] .ed-preview, .ed-panes[data-view="preview"] textarea { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.contents { display: contents; }
.ed-none { padding: 10px; color: var(--muted); font-size: .9rem; }
.pv-title { font-family: var(--f-display); font-size: 2rem; font-weight: 800; line-height: 1.1; margin-bottom: .6em; }
