/* ── Fonts ── */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/static/fonts/newsreader-normal-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400 600;
  font-display: swap;
  src: url('/static/fonts/newsreader-italic-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/static/fonts/geist-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/static/fonts/jetbrains-mono-latin.woff2') format('woff2');
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Zen paper palette — used site-wide */
  --zen-paper:    #F6F1E7;
  --zen-paper-dp: #EFE8D8;
  --zen-ink:      #1F1A14;
  --zen-ink-2:    #4A4137;
  --zen-ink-3:    #8A7E6E;
  --zen-ink-4:    #B9AD9A;
  --zen-rule:     rgba(31,26,20,0.10);
  --zen-accent:   #5E7560;
  --zen-accent-s: rgba(94,117,96,0.14);
  --zen-selection:rgba(94,117,96,0.22);
  --zen-chrome:   rgba(246,241,231,0.72);
  --zen-shadow:   0 1px 0 rgba(255,255,255,.5) inset, 0 12px 40px rgba(0,0,0,.10);
  --zen-font:     'Newsreader', Georgia, serif;
  --zen-font-ui:  'Geist', system-ui, -apple-system, sans-serif;
  --zen-font-mono:'JetBrains Mono', 'Fira Code', monospace;
  --danger:       #b5341f;
  --radius:       6px;
  --max-w:        680px;
}

::selection { background: var(--zen-selection); }

html { font-size: 18px; }
body {
  background: var(--zen-paper);
  color: var(--zen-ink);
  font-family: var(--zen-font-ui);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--zen-font-ui); cursor: pointer; }

/* Paper grain — all pages */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(0,0,0,0.018) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  opacity: .8;
  z-index: 0;
}

/* ── Public layout ── */
.public-header {
  padding: 1.5rem 2rem;
  max-width: var(--max-w);
  margin: 0 auto;
  border-bottom: 1px solid var(--zen-rule);
}

.site-name {
  font-family: var(--zen-font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--zen-ink-3);
  text-decoration: none;
}
.site-name:hover { color: var(--zen-ink); text-decoration: none; }

.public-main {
  position: relative; z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 8rem;
}

/* ── Post list (public index) ── */
.post-list { list-style: none; }

.post-list-item {
  padding: 2rem 0;
  border-bottom: 1px solid var(--zen-rule);
}
.post-list-item:first-child { padding-top: 0; }

.post-list-title {
  display: block;
  font-family: var(--zen-font);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.4rem;
  color: var(--zen-ink);
}
.post-list-title:hover { text-decoration: underline; }

.post-list-meta {
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  color: var(--zen-ink-3);
}

.post-list-tags { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }

.tag-chip {
  display: inline-block;
  font-family: var(--zen-font-ui);
  font-size: 0.68rem;
  padding: 0.15em 0.55em;
  border-radius: 2px;
  background: var(--zen-accent-s);
  border: 1px solid var(--zen-accent);
  color: var(--zen-accent);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.tag-chip:hover { background: var(--zen-accent); color: var(--zen-paper); }

.post-tags { margin: 0.5rem 0 1.5rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }

.tag-page-heading {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 2rem;
}
.tag-page-back {
  font-family: var(--zen-font-ui);
  font-size: 0.8rem;
  color: var(--zen-ink-3);
  text-decoration: none;
}
.tag-page-back:hover { color: var(--zen-ink); }
.tag-chip-heading { font-size: 0.8rem; padding: 0.25em 0.7em; pointer-events: none; }

/* ── Single post (public) ── */
.post-body .post-title {
  font-family: var(--zen-font);
  font-size: 2rem;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.post-meta {
  font-family: var(--zen-font-ui);
  font-size: 0.75rem;
  color: var(--zen-ink-3);
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--zen-rule);
}

.post-content {
  font-family: var(--zen-font);
  font-size: 1.05rem;
  line-height: 1.78;
}
.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
  font-family: var(--zen-font);
}
.post-content h1 { font-size: 1.6rem; }
.post-content h2 { font-size: 1.3rem; }
.post-content h3 { font-size: 1.1rem; }
.post-content p { margin: 1rem 0; }
.post-content ul, .post-content ol { margin: 1rem 0 1rem 1.5rem; }
.post-content li { margin: 0.25rem 0; }
.post-content blockquote {
  border-left: 2px solid var(--zen-accent);
  padding-left: 1rem;
  color: var(--zen-ink-2);
  margin: 1.5rem 0;
  font-style: italic;
}
.post-content code {
  font-size: 0.82em;
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--zen-font-mono);
}
.post-content pre {
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
  font-family: var(--zen-font-mono);
  font-size: 0.82em;
  line-height: 1.55;
}
.post-content pre code { background: none; border: 0; padding: 0; }
.post-content a { text-decoration: underline; text-decoration-color: var(--zen-accent); }
.post-content hr { border: none; border-top: 1px solid var(--zen-rule); margin: 2rem 0; }
.post-content img { max-width: 100%; height: auto; }

/* ── Empty state ── */
.empty-state { color: var(--zen-ink-3); font-family: var(--zen-font-ui); font-size: 0.88rem; }
.empty-state a { color: var(--zen-ink); text-decoration: underline; }

/* ── Pagination ── */
.pagination { display: flex; justify-content: space-between; padding: 2rem 0 1rem; }
.pagination-link { font-family: var(--zen-font-ui); font-size: 0.88rem; color: var(--zen-ink-2); text-decoration: none; }
.pagination-link:hover { color: var(--zen-ink); }

/* ── Public theme switcher ── */
.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preview-banner {
  background: #92400e;
  color: #fff;
  text-align: center;
  font-size: 0.8rem;
  padding: 0.35rem 1rem;
}
.preview-banner a { color: #fcd34d; text-decoration: underline; }
.pub-edit-link {
  font-size: 0.78rem;
  color: var(--zen-ink-3);
  text-decoration: none;
  border: 1px solid var(--zen-rule);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius);
  transition: color .15s, border-color .15s;
  margin-left: auto;
  margin-right: 0.5rem;
}
.pub-edit-link:hover { color: var(--zen-ink); border-color: var(--zen-ink-3); }
.pub-theme-btn {
  appearance: none; border: 0; background: transparent;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--zen-ink-4);
  cursor: pointer;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.pub-theme-btn:hover { color: var(--zen-ink-3); background: var(--zen-accent-s); }

/* ── Admin settings ── */
.settings-section { margin-bottom: 2rem; }
.settings-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--zen-ink-3);
  margin-bottom: 0.5rem;
}
.settings-hint {
  font-size: 0.78rem;
  color: var(--zen-ink-3);
  margin-bottom: 1rem;
}
.settings-input {
  display: block;
  width: 100%;
  max-width: 22rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--zen-rule);
  border-radius: 0;
  outline: none;
  padding: 0.3rem 0;
  font-size: 1rem;
  font-family: var(--zen-font-ui);
  color: var(--zen-ink);
  transition: border-color .15s;
}
.settings-input:focus { border-bottom-color: var(--zen-ink-3); }
.settings-input::placeholder { color: var(--zen-ink-4); }
.theme-swatches { display: flex; gap: 1rem; flex-wrap: wrap; }
.theme-swatch-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--zen-ink-2);
  padding: 6px 10px 6px 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.theme-swatch-label:has(input:checked) {
  border-color: var(--zen-rule);
  background: var(--zen-paper-dp);
}
.theme-swatch-label input[type="radio"] { display: none; }
.theme-swatch-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--zen-rule);
  flex-shrink: 0;
}

/* Font picker */
.font-options { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.font-option-label {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
  min-width: 90px;
}
.font-option-label:has(input:checked) {
  border-color: var(--zen-rule);
  background: var(--zen-paper-dp);
}
.font-option-label input[type="radio"] { display: none; }
.font-option-preview {
  font-size: 1.05rem;
  color: var(--zen-ink);
  line-height: 1.2;
}
.font-option-name {
  font-size: 0.7rem;
  font-family: var(--zen-font-ui);
  color: var(--zen-ink-3);
}

/* Custom font list */
.custom-font-list { list-style: none; margin: 0.75rem 0 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.custom-font-item { display: flex; align-items: center; gap: 1rem; font-size: 0.88rem; }
.custom-font-name { font-size: 1rem; color: var(--zen-ink); }
.btn-danger-sm {
  background: none; border: 1px solid rgba(181,52,31,0.3);
  color: var(--danger); border-radius: var(--radius);
  padding: 2px 8px; font-size: 0.72rem; font-family: var(--zen-font-ui);
  cursor: pointer; transition: background .15s, color .15s;
}
.btn-danger-sm:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.font-upload-form { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.font-file-input { font-size: 0.82rem; font-family: var(--zen-font-ui); color: var(--zen-ink-2); }
.settings-error { font-size: 0.82rem; color: var(--danger); margin-top: 0.5rem; }
.settings-success { font-size: 0.82rem; color: #3a7d44; margin-top: 0.5rem; }

/* ── Admin layout ── */
.admin-page { font-family: var(--zen-font-ui); }

.admin-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 52px;
  background: var(--zen-chrome);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--zen-rule);
  z-index: 20;
}

.admin-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-size: 0.8rem;
  color: var(--zen-ink-3);
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--zen-ink); background: var(--zen-accent-s); text-decoration: none; }
.nav-link--btn { background: none; border: none; cursor: pointer; font-family: inherit; }

.admin-main {
  position: relative; z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-block;
  background: var(--zen-ink);
  color: var(--zen-paper);
  border: none;
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--zen-font-ui);
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: 0.82; text-decoration: none; }

.btn-secondary {
  background: transparent;
  color: var(--zen-ink-2);
  border: 1px solid var(--zen-rule);
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-family: var(--zen-font-ui);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-secondary:hover { border-color: var(--zen-ink-3); color: var(--zen-ink); }

.btn-new {
  display: inline-flex;
  align-items: center;
  background: var(--zen-ink);
  color: var(--zen-paper);
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--zen-font-ui);
  transition: opacity .15s;
}
.btn-new:hover { opacity: 0.82; text-decoration: none; }

.btn-cancel {
  font-size: 0.82rem;
  color: var(--zen-ink-3);
  text-decoration: none;
  padding: 0.4rem 0.5rem;
}
.btn-cancel:hover { color: var(--zen-ink); }

.btn-action {
  background: none;
  border: 1px solid var(--zen-rule);
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-family: var(--zen-font-ui);
  color: var(--zen-ink-2);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-action:hover { border-color: var(--zen-ink-3); color: var(--zen-ink); }
.btn-danger { color: var(--danger); border-color: rgba(181,52,31,0.25); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-view { display: inline-flex; align-items: center; padding: 0.2rem 0.45rem; text-decoration: none; }

/* ── Post table (admin) ── */
.post-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.post-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--zen-rule);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--zen-ink-3);
  font-weight: 600;
}
.post-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--zen-rule);
  vertical-align: middle;
}
.post-title-cell a { font-weight: 500; color: var(--zen-ink); }
.post-title-cell a:hover { text-decoration: underline; }
.untitled { color: var(--zen-ink-4); font-style: italic; }
.date-cell { color: var(--zen-ink-3); font-size: 0.78rem; white-space: nowrap; }
.actions-cell { white-space: nowrap; display: flex; gap: 0.5rem; align-items: center; height: 3.5rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.18em 0.6em;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-published { background: var(--zen-accent-s); color: var(--zen-accent); }
.badge-draft     { background: rgba(31,26,20,0.06); color: var(--zen-ink-3); }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--zen-ink-2);
}

.you-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--zen-accent-s);
  color: var(--zen-accent);
  padding: 0.1em 0.5em;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.setup-hint {
  font-size: 0.85rem;
  color: var(--zen-ink-3);
  margin-bottom: 1.75rem;
}

.user-form { max-width: 400px; }
.form-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }

/* ── Login / Setup ── */
.login-page {
  position: relative; z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  width: 100%;
  max-width: 360px;
  padding: 0 1.5rem;
}

.login-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--zen-ink-2);
  margin-bottom: 2rem;
}

.field { margin-bottom: 1.25rem; }
.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--zen-ink-3);
  margin-bottom: 0.35rem;
}
.field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--zen-font-ui);
  border: 1px solid var(--zen-rule);
  border-radius: var(--radius);
  background: var(--zen-paper-dp);
  color: var(--zen-ink);
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--zen-ink-3); }

.error {
  background: rgba(181,52,31,0.07);
  color: var(--danger);
  border: 1px solid rgba(181,52,31,0.15);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
}

.login-box .btn-primary {
  width: 100%;
  padding: 0.6rem;
  font-size: 0.88rem;
  margin-top: 0.5rem;
  text-align: center;
}

/* ── Zen editor ── */

.zen-page {
  --zen-page-top: 152px;
}
.zen-page-content { transition: padding-top .3s ease; }

/* Theme variants — apply to any page via body[data-theme] */
body[data-theme="slate"] {
  --zen-paper:    #F2F2F2;
  --zen-paper-dp: #E8E8E8;
  --zen-ink:      #1A1A1A;
  --zen-ink-2:    #4A4A4A;
  --zen-ink-3:    #8A8A8A;
  --zen-ink-4:    #BBBBBB;
  --zen-rule:     rgba(0,0,0,.09);
  --zen-accent:   #4A7FA5;
  --zen-accent-s: rgba(74,127,165,.11);
  --zen-selection:rgba(74,127,165,.20);
  --zen-chrome:   rgba(242,242,242,.74);
}
body[data-theme="ember"] {
  --zen-paper:    #1A1714;
  --zen-paper-dp: #221E1A;
  --zen-ink:      #ECE4D3;
  --zen-ink-2:    #B9AE97;
  --zen-ink-3:    #7A7060;
  --zen-ink-4:    #4B4338;
  --zen-rule:     rgba(236,228,211,.10);
  --zen-accent:   #D4956A;
  --zen-accent-s: rgba(212,149,106,.12);
  --zen-selection:rgba(212,149,106,.20);
  --zen-chrome:   rgba(26,23,20,.72);
  --zen-shadow:   0 1px 0 rgba(255,255,255,.04) inset, 0 12px 40px rgba(0,0,0,.50);
}
body[data-theme="carbon"] {
  --zen-paper:    #111111;
  --zen-paper-dp: #1A1A1A;
  --zen-ink:      #D4D4D4;
  --zen-ink-2:    #909090;
  --zen-ink-3:    #505050;
  --zen-ink-4:    #333333;
  --zen-rule:     rgba(255,255,255,.07);
  --zen-accent:   #58A6FF;
  --zen-accent-s: rgba(88,166,255,.10);
  --zen-selection:rgba(88,166,255,.18);
  --zen-chrome:   rgba(17,17,17,.72);
  --zen-shadow:   0 1px 0 rgba(255,255,255,.04) inset, 0 12px 40px rgba(0,0,0,.50);
}

/* Dark theme grain override */
body[data-theme="ember"]::before,
body[data-theme="carbon"]::before {
  background-image: radial-gradient(rgba(255,255,255,0.022) 1px, transparent 1px);
  mix-blend-mode: screen;
}

/* Font themes — body[data-font] */
/* literary is the default (:root), no override needed */
body[data-font="sans"] {
  --zen-font: 'Geist', system-ui, -apple-system, sans-serif;
}
body[data-font="mono"] {
  --zen-font:    'JetBrains Mono', 'Fira Code', monospace;
  --zen-font-ui: 'JetBrains Mono', 'Fira Code', monospace;
}

/* zen-page body overrides */
.zen-page { background: var(--zen-paper); color: var(--zen-ink); }

/* Chrome auto-hide */
.zen-page .chrome { transition: opacity .5s ease; }
.zen-page.chrome-hidden .chrome:not(:hover):not(:focus-within) { opacity: 0; }
.zen-page.chrome-hidden .chrome:not(:hover):not(:focus-within) * { pointer-events: none; }

/* ── Top bar ── */
.zen-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex; flex-direction: column;
  padding: 14px 28px 10px;
  z-index: 20;
  background: linear-gradient(to bottom, var(--zen-chrome) 0%, var(--zen-chrome) 70%, transparent 100%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.zen-topbar-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.zen-topbar-left, .zen-topbar-right {
  display: flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
}
.zen-topbar-center { display: flex; align-items: center; flex: 1 1 auto; justify-content: center; }

/* Back link */
.zen-back {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--zen-font);
  font-weight: 500;
  font-size: 0.92rem;
  letter-spacing: .005em;
  color: var(--zen-ink-2);
  text-decoration: none;
  padding: 4px 14px 4px 6px;
  margin-right: 4px;
  border-right: 1px solid var(--zen-rule);
  transition: color .15s;
}
.zen-back:hover { color: var(--zen-ink); text-decoration: none; }
.zen-back::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--zen-accent);
  box-shadow: 0 0 0 3px var(--zen-accent-s);
  flex-shrink: 0;
}

/* Mode buttons */
.zen-modes {
  display: inline-flex;
  padding: 3px;
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  border-radius: 999px;
}
.mode-btn {
  appearance: none; border: 0; background: transparent;
  padding: 6px 14px;
  font: 500 12px/1 var(--zen-font-ui);
  letter-spacing: .01em;
  color: var(--zen-ink-3);
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease;
}
.mode-btn[aria-pressed="true"] {
  background: var(--zen-paper);
  color: var(--zen-ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px var(--zen-rule);
}
.mode-btn:hover:not([aria-pressed="true"]) { color: var(--zen-ink-2); }

/* Icon buttons */
.zen-icon-btn {
  appearance: none; border: 0; background: transparent;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--zen-ink-3);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}
.zen-icon-btn:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.zen-icon-btn.is-active { color: var(--zen-accent); }

/* Editor action buttons */
.zen-btn-primary {
  background: var(--zen-ink);
  color: var(--zen-paper);
  border: none;
  padding: 0.3rem 0.9rem;
  border-radius: 6px;
  font: 600 0.78rem var(--zen-font-ui);
  cursor: pointer;
  transition: opacity .15s;
}
.zen-btn-primary:hover { opacity: 0.82; }

.zen-btn-secondary {
  background: transparent;
  color: var(--zen-ink-2);
  border: 1px solid var(--zen-rule);
  padding: 0.3rem 0.9rem;
  border-radius: 6px;
  font: 0.78rem var(--zen-font-ui);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.zen-btn-secondary:hover { border-color: var(--zen-ink-3); color: var(--zen-ink); }

/* Save status */
.save-status { font-family: var(--zen-font-ui); font-size: 0.72rem; color: var(--zen-ink-3); }

/* ── Persistent formatting toolbar ── */
#toolbar-row {
  border-top: 1px solid var(--zen-rule);
  margin-top: 6px;
  padding: 8px 0 2px;
  display: flex; justify-content: center;
  overflow-x: auto;
}
.zen-toolbar { display: contents; }
.zen-tb-inner {
  display: inline-flex; align-items: center;
  gap: 6px; padding: 4px;
  flex-shrink: 0; flex-wrap: nowrap;
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset;
}
.zen-tb-group { display: inline-flex; align-items: center; gap: 1px; flex-shrink: 0; }
.zen-tb-sep { width: 1px; height: 18px; background: var(--zen-rule); margin: 0 2px; }
.zen-tb-btn {
  appearance: none; border: 0; background: transparent;
  width: 30px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--zen-ink-2);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.zen-tb-btn:hover { background: var(--zen-paper); color: var(--zen-ink); }
.zen-tb-btn.is-active { background: var(--zen-paper); color: var(--zen-accent); box-shadow: 0 0 0 1px var(--zen-rule); }

/* ── Writing area ── */
.zen-page-content {
  position: relative; z-index: 1;
  min-height: 100vh;
  padding: var(--zen-page-top, 148px) 24px 160px;
  display: flex; justify-content: center;
}
.zen-column { width: 100%; max-width: 720px; }

/* Title */
.zen-title {
  display: block; width: 100%;
  font-family: var(--zen-font);
  font-size: 2.2rem; font-weight: 600; line-height: 1.2;
  border: none; outline: none; background: transparent;
  color: var(--zen-ink);
  padding: 1.25rem 0 0.75rem;
  margin-bottom: 0.5rem;
}
.zen-title::placeholder { color: var(--zen-ink-4); font-style: italic; }

/* ── Tag chips (editor) ── */
.tag-chips-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  margin-bottom: 0.6rem;
}
.tag-chip-editor {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font: 500 11px/1 var(--zen-font-ui);
  letter-spacing: .02em;
  padding: 3px 5px 3px 8px;
  border-radius: 999px;
  background: var(--zen-accent-s);
  color: var(--zen-accent);
  user-select: none;
  transition: background-color .15s ease, color .15s ease;
}
.tag-chip-editor:hover { background: var(--zen-accent); color: var(--zen-paper); }
.tag-chip-editor:hover .tag-chip-editor-hash { color: var(--zen-paper); opacity: .8; }
.tag-chip-editor-hash { opacity: .55; margin-right: 1px; }
.tag-chip-editor-name { line-height: 1; }
.tag-chip-editor-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border: none;
  background: none;
  color: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  opacity: 0.55;
  border-radius: 50%;
  transition: opacity .15s, background .15s;
}
.tag-chip-editor-remove:hover { opacity: 1; background: rgba(0,0,0,.12); }
.tag-chips-input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  color: var(--zen-ink-3);
  min-width: 70px;
  padding: 3px 6px;
  caret-color: var(--zen-accent);
}
.tag-chips-input::placeholder { color: var(--zen-ink-4); }
.tag-chips-input:focus { color: var(--zen-ink-2); }

/* ── WYSIWYG editor ── */
.zen-editor {
  outline: none;
  font-family: var(--zen-font);
  font-size: 1.15rem; line-height: 1.7;
  color: var(--zen-ink);
  caret-color: var(--zen-accent);
  min-height: calc(100vh - 300px);
  padding-bottom: 4rem;
}
.zen-editor.is-empty::before {
  content: attr(data-placeholder);
  color: var(--zen-ink-4); font-style: italic;
  pointer-events: none;
}
.zen-editor > * { margin: 0 0 1.1em; }
.zen-editor > *:last-child { margin-bottom: 0; }
.zen-editor h1, .zen-editor h2, .zen-editor h3 {
  font-family: var(--zen-font); color: var(--zen-ink);
  line-height: 1.2; letter-spacing: -.01em;
}
.zen-editor h1 { font-size: 2em; font-weight: 600; margin: 1.4em 0 .5em; }
.zen-editor h2 { font-size: 1.45em; font-weight: 600; margin: 1.3em 0 .4em; }
.zen-editor h3 { font-size: 1.18em; font-weight: 600; margin: 1.2em 0 .3em; font-style: italic; }
.zen-editor blockquote {
  margin: 1.2em 0; padding: 2px 0 2px 22px;
  border-left: 2px solid var(--zen-accent);
  color: var(--zen-ink-2); font-style: italic;
}
.zen-editor ul, .zen-editor ol { padding-left: 1.4em; margin: .75em 0; }
.zen-editor li { margin-bottom: .35em; }
.zen-editor a {
  color: var(--zen-ink); text-decoration: underline;
  text-decoration-color: var(--zen-accent);
  text-decoration-thickness: 1.5px; text-underline-offset: 4px;
}
.zen-editor code {
  font-family: var(--zen-font-mono); font-size: .82em;
  padding: 2px 6px;
  background: var(--zen-paper-dp); border: 1px solid var(--zen-rule);
  border-radius: 4px;
}
.zen-editor pre {
  font-family: var(--zen-font-mono); font-size: .82em;
  padding: 14px 18px;
  background: var(--zen-paper-dp); border: 1px solid var(--zen-rule);
  border-radius: 8px; overflow-x: auto; line-height: 1.55;
  margin: 1.2em 0;
}
.zen-editor pre code { background: transparent; border: 0; padding: 0; }
.zen-editor hr { border: 0; height: 1px; background: var(--zen-rule); margin: 2em auto; width: 40%; }
.zen-editor strong { font-weight: 600; }
.zen-editor table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: .9em; }
.zen-editor th, .zen-editor td { border: 1px solid var(--zen-rule); padding: 8px 12px; text-align: left; vertical-align: top; }
.zen-editor th { background: var(--zen-paper-dp); font-weight: 600; }

/* ── Markdown textarea ── */
.zen-md-editor {
  display: block; width: 100%;
  min-height: calc(100vh - 300px);
  appearance: none; border: 0; outline: 0;
  background: transparent; resize: none;
  overflow: hidden;
  font-family: var(--zen-font-ui);
  font-size: 0.95rem; line-height: 1.75;
  color: var(--zen-ink); caret-color: var(--zen-accent);
  padding: 0 0 4rem;
}
.zen-md-editor::placeholder { color: var(--zen-ink-4); }

/* ── Side panels (outline + scratchpad) ── */
.side-panel {
  position: fixed;
  top: var(--zen-page-top, 152px);
  bottom: 56px;
  width: 260px;
  display: flex; flex-direction: column;
  background: var(--zen-paper);
  border: 1px solid var(--zen-rule);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 12px 30px rgba(0,0,0,.06);
  z-index: 18;
  overflow: hidden;
  animation: panelIn .25s ease-out;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.side-panel.outline    { left: 16px; }
.side-panel.scratchpad { right: 16px; width: 280px; }
.side-panel[hidden] { display: none; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--zen-rule);
}
.side-title {
  font-family: var(--zen-font);
  font-size: 14px; font-weight: 500;
  color: var(--zen-ink-2);
  letter-spacing: .005em;
}
.side-head-actions { display: inline-flex; align-items: center; gap: 4px; }
.side-action {
  appearance: none; border: 0; background: var(--zen-paper-dp);
  color: var(--zen-ink-2);
  font: 500 11px/1 var(--zen-font-ui);
  letter-spacing: .02em;
  padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--zen-rule);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.side-action:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.side-x {
  appearance: none; border: 0; background: transparent;
  width: 24px; height: 24px; border-radius: 6px;
  color: var(--zen-ink-3);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.side-x:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.side-sub {
  padding: 8px 14px 6px;
  font-size: 11px; line-height: 1.5;
  color: var(--zen-ink-3);
  border-bottom: 1px solid var(--zen-rule);
}
.side-empty {
  padding: 22px 16px;
  text-align: center;
  font-family: var(--zen-font);
  color: var(--zen-ink-3);
  font-size: 13px; font-style: italic;
}
.side-empty p { margin: 0 0 .4em; }
.side-empty-sub {
  font-size: 11.5px; font-style: normal;
  font-family: var(--zen-font-ui); color: var(--zen-ink-4);
}
.side-kbd {
  font-family: var(--zen-font-mono);
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  border-radius: 4px;
  padding: 0 4px; font-size: 10px; color: var(--zen-ink-2);
}
.side-link {
  color: var(--zen-accent); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* Outline list */
.outline-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 8px 16px;
  display: flex; flex-direction: column; gap: 1px;
}
.outline-item {
  appearance: none; border: 0; background: transparent;
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  color: var(--zen-ink-2);
  font-family: var(--zen-font);
  font-size: 13.5px; line-height: 1.4;
  transition: background-color .15s ease, color .15s ease;
}
.outline-item:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.outline-item.is-active { color: var(--zen-accent); }
.outline-item.is-active .outline-dot { background: var(--zen-accent); transform: scale(1.4); }
.outline-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--zen-ink-4);
  flex: 0 0 auto;
  transition: background-color .15s ease, transform .15s ease;
}
.outline-item.lv-1 { font-weight: 600; font-size: 14px; }
.outline-item.lv-2 { padding-left: 22px; }
.outline-item.lv-3 { padding-left: 34px; font-style: italic; color: var(--zen-ink-3); font-size: 12.5px; }
.outline-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Post-it notes */
.postit-stack {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 14px 22px;
  display: flex; flex-direction: column;
  gap: 14px;
}
.postit {
  position: relative;
  background: var(--note-bg, #f5d97a);
  color: var(--note-ink, #3a2a08);
  padding: 18px 14px 12px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.4) inset,
    0 4px 10px rgba(0,0,0,.10),
    0 12px 22px rgba(0,0,0,.06);
  border-radius: 2px;
  cursor: grab;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.postit:active { cursor: grabbing; }
.postit.is-dragging {
  opacity: .35;
  transform: rotate(0deg) !important;
}
.postit.is-drop-target        { box-shadow: 0 -3px 0 var(--zen-accent), 0 4px 10px rgba(0,0,0,.10), 0 12px 22px rgba(0,0,0,.06); }
.postit.is-drop-target-after  { box-shadow:  0  3px 0 var(--zen-accent), 0 4px 10px rgba(0,0,0,.10), 0 12px 22px rgba(0,0,0,.06); }

/* Small grip dots at top of each note — a visible drag handle */
.postit-grip {
  position: absolute;
  top: 5px; left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 6px;
  background-image: radial-gradient(currentColor 1px, transparent 1.2px);
  background-size: 5px 6px;
  background-position: 0 2px;
  background-repeat: repeat-x;
  opacity: .25;
  pointer-events: none;
  z-index: 1;
}
.postit:hover .postit-grip { opacity: .45; }
.postit::before {
  content: "";
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%) rotate(-1deg);
  width: 48px; height: 14px;
  background: rgba(255,255,255,.45);
  border: 1px solid rgba(255,255,255,.55);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  border-radius: 1px;
}
.postit:hover {
  transform: rotate(0deg) translateY(-1px) !important;
  box-shadow: 0 6px 14px rgba(0,0,0,.14), 0 14px 28px rgba(0,0,0,.08);
}
.postit-input {
  appearance: none; border: 0; outline: 0; background: transparent;
  width: 100%;
  resize: none;
  color: inherit;
  font-family: var(--zen-font);
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.5;
  padding: 0;
  overflow: hidden;
}
.postit-input::placeholder { color: currentColor; opacity: .4; }
.postit-x {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,.06);
  color: inherit;
  font-size: 12px; line-height: 1;
  cursor: pointer;
  opacity: 0; transition: opacity .15s ease, background-color .15s ease;
}
.postit:hover .postit-x { opacity: .8; }
.postit-x:hover { background: rgba(0,0,0,.16); opacity: 1; }

/* Color picker button (upper-left corner) */
.postit-color-btn {
  position: absolute;
  top: 5px; left: 5px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.18);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 2;
}
.postit:hover .postit-color-btn { opacity: .85; }
.postit-color-btn:hover, .postit-color-btn[aria-expanded="true"] {
  opacity: 1;
  transform: scale(1.15);
}
.postit-color-pop {
  position: absolute;
  top: 24px; left: 4px;
  display: inline-flex;
  gap: 4px;
  padding: 5px 6px;
  background: var(--zen-paper);
  border: 1px solid var(--zen-rule);
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,.15), 0 1px 0 rgba(255,255,255,.6) inset;
  z-index: 3;
  animation: panelIn .14s ease-out;
}
.postit-color-pop[hidden] { display: none; }
.postit-color-swatch {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.18);
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset;
  padding: 0;
  cursor: pointer;
  transition: transform .15s ease;
}
.postit-color-swatch:hover { transform: scale(1.18); }
.postit-color-swatch.is-active {
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 0 0 2px var(--zen-paper), 0 0 0 3px var(--zen-accent);
}
.postit-clear {
  margin: 6px auto 0; display: block;
  appearance: none; border: 0; background: transparent;
  color: var(--zen-ink-4);
  font: 11px/1 var(--zen-font-ui);
  padding: 6px 10px; border-radius: 6px;
  cursor: pointer;
}
.postit-clear:hover { color: var(--zen-ink-2); background: var(--zen-paper-dp); }

/* Focus mode shouldn't dim the side panels — they're outside the editor */
body.focus-mode .side-panel { opacity: 1; }

/* ── Margin notes (pinned scratchpad notes in the editor's right gutter) ── */
.margin-notes-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 0;
  pointer-events: none;
  z-index: 15;
}
.margin-note {
  position: absolute;
  background: var(--note-bg, #f5d97a);
  color: var(--note-ink, #3a2a08);
  padding: 10px 12px 12px;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.4) inset,
    0 4px 10px rgba(0,0,0,.10),
    0 10px 18px rgba(0,0,0,.05);
  pointer-events: auto;
  cursor: pointer;
  transform: rotate(-0.4deg);
  transition: transform .15s ease, box-shadow .15s ease, max-height .2s ease;
  max-height: 120px;
  overflow: hidden;
  font-family: var(--zen-font);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.45;
}
.margin-note::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22px;
  background: linear-gradient(to bottom, transparent, var(--note-bg, #f5d97a));
  pointer-events: none;
  transition: opacity .15s ease;
}
.margin-note:hover {
  transform: rotate(0deg) translateY(-1px);
  box-shadow: 0 6px 14px rgba(0,0,0,.14), 0 14px 28px rgba(0,0,0,.08);
  max-height: 360px;
}
.margin-note:hover::after { opacity: 0; }
.margin-note-body {
  white-space: pre-wrap;
  word-wrap: break-word;
}
.margin-note-unpin {
  position: absolute;
  top: 3px; right: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,.06);
  color: inherit;
  font-size: 11px; line-height: 1;
  cursor: pointer;
  opacity: 0; transition: opacity .15s ease, background-color .15s ease;
}
.margin-note:hover .margin-note-unpin { opacity: .8; }
.margin-note-unpin:hover { opacity: 1; background: rgba(0,0,0,.16); }

/* Narrow-viewport fallback: small coloured dot on the block's right edge */
.margin-note-dot {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.18);
  background: var(--note-bg, #f5d97a);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease;
}
.margin-note-dot:hover { transform: scale(1.25); }

/* Pin button on scratchpad notes */
.postit-pin {
  position: absolute;
  top: 4px; right: 26px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,.06);
  color: inherit;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s ease, background-color .15s ease, color .15s ease;
}
.postit:hover .postit-pin { opacity: .7; }
.postit-pin:hover { opacity: 1; background: rgba(0,0,0,.16); }
.postit.is-pinned .postit-pin {
  opacity: 1;
  background: rgba(0,0,0,.14);
}
.postit-pin[disabled] {
  cursor: not-allowed;
  opacity: .25 !important;
}

/* Orphaned (anchor lost) state */
.postit.is-orphaned { opacity: .7; }
.postit-orphan-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,.10);
  color: inherit;
  font-family: var(--zen-font-ui);
  font-size: 10px;
  font-style: normal;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .7;
}

/* Drop target highlight when dragging a note over an editor block */
.zen-editor > .is-pin-target {
  outline: 2px dashed var(--zen-accent);
  outline-offset: 4px;
  border-radius: 4px;
  background: var(--zen-accent-s);
}

/* ── Selection bubble ── */
#zen-bubble {
  position: fixed;
  z-index: 200;
  display: inline-flex; align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--zen-paper);
  border: 1px solid var(--zen-rule);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15), 0 1px 0 rgba(255,255,255,.6) inset;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 8px)) scale(.96);
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
  white-space: nowrap;
}
.zen-bubble-buttons {
  display: inline-flex; align-items: center; gap: 2px; flex-wrap: nowrap;
}
#zen-bubble.is-visible {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 8px)) scale(1);
  pointer-events: auto;
}
.zen-bubble-btn {
  appearance: none; border: 0; background: transparent;
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--zen-ink-2);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.zen-bubble-btn:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.zen-bubble-btn.is-active { background: var(--zen-accent-s); color: var(--zen-accent); }
.zen-bubble-sep { width: 1px; height: 16px; background: var(--zen-rule); margin: 0 2px; }
.zen-bubble-link {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px;
}
.zen-bubble-link input {
  appearance: none; border: 0; outline: 0; background: transparent;
  font: 12px/1 var(--zen-font-ui);
  color: var(--zen-ink); width: 200px;
}
.zen-bubble-link input::placeholder { color: var(--zen-ink-4); }

/* ── Status bar ── */
.statusbar {
  position: fixed; bottom: 0; right: 0; left: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  z-index: 20;
  font-family: var(--zen-font-ui);
  font-size: 11.5px; letter-spacing: .04em;
  color: var(--zen-ink-3);
  background: linear-gradient(to top, var(--zen-chrome) 0%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, #000 60%, transparent);
  mask-image: linear-gradient(to top, #000 60%, transparent);
  pointer-events: none;
}
.statusbar > * { pointer-events: auto; }
.status-group { display: inline-flex; align-items: center; gap: 18px; }
.status-item { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.status-item b { color: var(--zen-ink-2); font-weight: 500; }
.save-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--zen-accent);
  transition: background-color .3s ease, transform .3s ease;
}
.save-dot.saving { background: var(--zen-ink-4); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%,100% { opacity: .4; transform: scale(.85); }
  50%      { opacity: 1; transform: scale(1.1); }
}

/* ── Focus mode ── */
.focus-mode .zen-title,
.focus-mode .zen-editor > * { transition: opacity .25s ease, filter .25s ease; }
.focus-mode .zen-title:not(.is-focused),
.focus-mode .zen-editor > *:not(.is-focused) { opacity: .25; filter: blur(0.2px); }
.focus-mode .zen-title.is-focused,
.focus-mode .zen-editor > .is-focused { opacity: 1; }
.focus-mode .tag-chips-row { opacity: .2; transition: opacity .25s ease; }
.focus-mode .tag-chips-row:focus-within { opacity: 1; }

/* ── Theme / overflow menu ── */
#zen-menu {
  position: fixed;
  right: 24px; top: 56px;
  width: 200px;
  background: var(--zen-paper);
  border: 1px solid var(--zen-rule);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.16);
  padding: 6px;
  z-index: 100;
  display: none;
  animation: menuIn .14s ease-out;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.zen-menu-section {
  padding: 8px 10px 4px;
  font: 10px/1 var(--zen-font-ui); letter-spacing: .08em; text-transform: uppercase;
  color: var(--zen-ink-4);
}
.zen-menu-swatches { display: flex; gap: 6px; padding: 4px 10px 8px; }
.zen-swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--zen-rule);
  cursor: pointer; position: relative;
}
.zen-swatch.is-active { border-color: var(--zen-accent); }
.zen-swatch .ring {
  position: absolute; inset: -4px;
  border: 1.5px dashed var(--zen-accent);
  border-radius: 50%; opacity: 0;
}
.zen-swatch.is-active .ring { opacity: 1; }
.zen-menu-sep { height: 1px; background: var(--zen-rule); margin: 4px 6px; }
.zen-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  color: var(--zen-ink-2);
  font: 13px var(--zen-font-ui);
  border: none; background: transparent; width: 100%; text-align: left;
}
.zen-menu-item:hover { background: var(--zen-accent-s); color: var(--zen-ink); }

/* ── Settings panel ── */
#settings-panel {
  position: fixed;
  right: 28px; top: 60px;
  width: 260px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--zen-paper);
  border: 1px solid var(--zen-rule);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.16), 0 1px 0 rgba(255,255,255,.6) inset;
  padding: 6px;
  z-index: 100;
  display: none;
  transform-origin: top right;
  animation: menuIn .14s ease-out;
}
.sp-label {
  padding: 8px 10px 4px;
  font: 10px/1 var(--zen-font-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--zen-ink-4);
}
.sp-swatches {
  display: flex; gap: 6px;
  padding: 4px 10px 8px;
}
.sp-swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--zen-rule);
  cursor: pointer;
  position: relative;
  appearance: none;
  padding: 0;
  transition: border-color .15s;
  outline: none;
}
.sp-swatch.is-active { border-color: var(--zen-accent); }
.sp-swatch.is-active::after {
  content: '';
  position: absolute; inset: -4px;
  border: 1px dashed var(--zen-accent);
  border-radius: 50%;
  pointer-events: none;
}
.sp-sep {
  height: 1px;
  background: var(--zen-rule);
  margin: 4px 6px;
}
.sp-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: default;
  color: var(--zen-ink-2);
  font-size: 13px;
}
.sp-row:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.sp-row-label {
  display: flex; align-items: center; gap: 6px;
  font: 13px/1.2 var(--zen-font-ui);
  color: inherit;
}
.sp-row-label kbd {
  font-family: var(--zen-font-mono);
  font-size: 10px;
  color: var(--zen-ink-4);
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  border-radius: 4px;
  padding: 2px 5px;
  letter-spacing: 0;
}
/* Pill toggle — matches design's menu-switch */
.sp-toggle {
  position: relative;
  width: 26px; height: 14px;
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color .2s ease, border-color .2s ease;
}
.sp-toggle[aria-pressed="true"] {
  background: var(--zen-accent-s);
  border-color: var(--zen-accent);
}
.sp-toggle span {
  position: absolute;
  top: 1px; left: 1px;
  width: 10px; height: 10px;
  background: var(--zen-ink-4);
  border-radius: 50%;
  transition: transform .2s cubic-bezier(.4,.2,.2,1), background-color .2s ease;
  pointer-events: none;
}
.sp-toggle[aria-pressed="true"] span {
  background: var(--zen-accent);
  transform: translateX(12px);
}
/* Sliders */
.sp-slider-label {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 4px 10px 4px;
  font: 12px/1.2 var(--zen-font-ui);
  color: var(--zen-ink-2);
}
.sp-slider-num {
  font-family: var(--zen-font-mono);
  font-size: 10.5px;
  color: var(--zen-ink-4);
  font-variant-numeric: tabular-nums;
}
.sp-slider {
  display: block;
  width: calc(100% - 20px);
  margin: 0 10px 8px;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--zen-paper-dp);
  border: 1px solid var(--zen-rule);
  outline: none;
  cursor: pointer;
}
.sp-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--zen-paper);
  border: 2px solid var(--zen-accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  cursor: pointer;
  transition: transform .15s;
}
.sp-slider::-webkit-slider-thumb:hover { transform: scale(1.1); }
.sp-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--zen-paper);
  border: 2px solid var(--zen-accent);
  cursor: pointer;
}
/* Action buttons */
.sp-action {
  display: flex; align-items: center;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  border: none; background: transparent; cursor: pointer;
  font: 13px var(--zen-font-ui);
  color: var(--zen-ink-2);
  text-align: left;
  transition: background .15s, color .15s;
}
.sp-action:hover { background: var(--zen-accent-s); color: var(--zen-ink); }
.sp-action-danger { color: var(--zen-ink-3); }
.sp-action-danger:hover { background: rgba(181,52,31,.08); color: var(--danger); }

/* ════════════════════════════════════════════════════════════════════════
   READER — public site chrome, home feed, and About page
   Translated from the Bloggy reader design, mapped onto existing zen-* tokens.
   ════════════════════════════════════════════════════════════════════════ */

.r-shell { position: relative; z-index: 1; }

/* ── Sticky reader header ── */
.r-head {
  position: sticky; top: 0; z-index: 20;
  background: var(--zen-chrome);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
          backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--zen-rule);
}
.r-head-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex; align-items: center; gap: 18px;
}
.r-brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--zen-font);
  font-weight: 500;
  color: var(--zen-ink);
  flex: 0 0 auto;
  text-decoration: none;
}
.r-brand:hover { text-decoration: none; }
.r-brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--zen-accent);
  box-shadow: 0 0 0 3px var(--zen-accent-s);
}
.r-brand-word {
  font-size: 1.05rem;
  letter-spacing: .005em;
}

.r-nav {
  flex: 1 1 auto;
  display: flex; align-items: center; gap: 4px;
  margin-left: 6px;
}
.r-nav-link {
  display: inline-flex; align-items: center;
  font-family: var(--zen-font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--zen-ink-3);
  padding: 8px 12px;
  border-radius: 8px;
  letter-spacing: .01em;
  text-decoration: none;
  transition: color .15s, background-color .15s;
}
.r-nav-link:hover { color: var(--zen-ink); background: var(--zen-accent-s); text-decoration: none; }
.r-nav-link.is-active {
  color: var(--zen-ink);
  background: var(--zen-paper-dp);
  box-shadow: 0 0 0 1px var(--zen-rule);
}

.r-head-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.r-icon-btn {
  appearance: none; border: 0; background: transparent;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--zen-ink-3);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.r-icon-btn:hover { background: var(--zen-accent-s); color: var(--zen-ink); text-decoration: none; }

.r-nav-toggle { display: none; flex-direction: column; gap: 3px; }
.r-nav-toggle span {
  width: 16px; height: 1.5px; border-radius: 999px;
  background: currentColor;
  transition: transform .2s, opacity .2s;
}
.r-nav-toggle.is-open span:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
.r-nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.r-nav-toggle.is-open span:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

/* ── Main column ── */
.r-main {
  position: relative; z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* ── Tag filter chips ── */
.r-filter { margin-bottom: 2.25rem; }
.r-filter-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center;
}
.r-chip {
  appearance: none;
  border: 1px solid var(--zen-rule);
  background: var(--zen-paper);
  color: var(--zen-ink-2);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color .15s, color .15s, border-color .15s;
}
.r-chip:hover { background: var(--zen-accent-s); color: var(--zen-ink); border-color: var(--zen-accent-s); text-decoration: none; }
.r-chip.is-active {
  background: var(--zen-accent); color: var(--zen-paper);
  border-color: var(--zen-accent);
}
.r-chip.is-active .r-chip-count { color: var(--zen-paper); opacity: .8; }
.r-chip-hash { opacity: .55; }
.r-chip-count {
  font-family: var(--zen-font-mono);
  font-size: 0.62rem;
  color: var(--zen-ink-4);
  margin-left: 1px;
}
.r-filter-status {
  margin-top: 0.75rem;
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  color: var(--zen-ink-3);
}
.r-link {
  color: var(--zen-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
  background: none; border: 0; padding: 0;
  font: inherit;
}
.r-link:hover { color: var(--zen-ink); }

/* ── Meta line shared by cards and single posts ── */
.r-meta {
  font-family: var(--zen-font-ui);
  font-size: 0.66rem;
  color: var(--zen-ink-3);
  letter-spacing: .04em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums;
}
.r-meta time { font-variant-numeric: tabular-nums; }
.r-meta-sep { opacity: .6; margin: 0 0.15rem; }

.r-post-tags {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
}
.r-tag-inline {
  color: var(--zen-accent);
  font-family: var(--zen-font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 4px 0;
  letter-spacing: .02em;
  text-decoration: none;
}
.r-tag-inline:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ── Cards layout (home feed) ── */
.r-cards { list-style: none; padding: 0; margin: 0; }
.r-card {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--zen-rule);
}
.r-card:first-child { padding-top: 0.25rem; }
.r-card:last-child { border-bottom: 0; }
.r-card-link { display: block; text-decoration: none; color: inherit; }
.r-card-link:hover { text-decoration: none; }
.r-card-title {
  font-family: var(--zen-font);
  font-size: clamp(1.4rem, 3.6vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.18;
  margin: 0 0 0.75rem;
  color: var(--zen-ink);
  text-wrap: balance;
}
.r-card-link:hover .r-card-title { color: var(--zen-accent); }
.r-card-excerpt {
  font-family: var(--zen-font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--zen-ink-2);
  margin: 0 0 0.85rem;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.r-card-meta {
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.1rem;
  align-items: center;
}

/* ── Pagination on reader ── */
.r-pagination {
  display: flex; justify-content: space-between;
  padding: 2rem 0 0;
  font-family: var(--zen-font-ui);
  font-size: 0.85rem;
}

/* ── Reader footer ── */
.r-foot {
  border-top: 1px solid var(--zen-rule);
  margin-top: 4rem;
}
.r-foot-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.4rem 1.25rem 2rem;
  display: flex; gap: 0.6rem; align-items: center;
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  color: var(--zen-ink-4);
}
.r-foot-inner a { color: inherit; text-decoration: none; }
.r-foot-inner a:hover { color: var(--zen-ink); text-decoration: underline; }
.r-foot-sep { opacity: .6; }

/* ── Empty state ── */
.r-empty {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--zen-ink-3);
  font-family: var(--zen-font);
  font-style: italic;
}
.r-empty p { margin: 0 0 0.6rem; font-size: 1rem; }

/* ── About page ── */
.r-about { padding-top: 0.4rem; }
.r-about-head {
  display: flex; gap: 1.25rem;
  align-items: center;
  margin-bottom: 2.25rem;
}
.r-about-portrait {
  display: block;
  width: 104px; height: 104px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--zen-rule);
  background: var(--zen-paper-dp);
  object-fit: cover;
}
.r-about-portrait-empty {
  background: var(--zen-paper-dp);
}
.r-about-name {
  font-family: var(--zen-font);
  font-size: clamp(1.55rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0 0 0.35rem;
  color: var(--zen-ink);
}
.r-about-handle {
  font-family: var(--zen-font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--zen-accent);
  margin-bottom: 0.25rem;
}
.r-about-since {
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  color: var(--zen-ink-3);
  font-style: italic;
}
.r-about-bio { margin-bottom: 0.5rem; }
.r-about-bio p {
  font-family: var(--zen-font);
  font-size: 1.06rem;
  line-height: 1.65;
  color: var(--zen-ink-2);
  margin: 0 0 1em;
  text-wrap: pretty;
}
.r-about-bio p:first-of-type::first-letter {
  font-family: var(--zen-font);
  font-size: 3.4em;
  font-weight: 500;
  float: left;
  line-height: .9;
  margin: 6px 10px 0 0;
  color: var(--zen-ink);
}
.r-about-bio h1, .r-about-bio h2, .r-about-bio h3 {
  font-family: var(--zen-font);
  font-weight: 600;
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}
.r-about-bio h1 { font-size: 1.4rem; }
.r-about-bio h2 { font-size: 1.2rem; }
.r-about-bio h3 { font-size: 1.05rem; }
.r-about-bio a { color: var(--zen-accent); text-decoration: underline; text-underline-offset: 3px; }
.r-about-bio ul, .r-about-bio ol { margin: 1rem 0 1rem 1.4rem; }
.r-about-bio blockquote {
  border-left: 2px solid var(--zen-accent);
  padding-left: 1rem;
  color: var(--zen-ink-2);
  margin: 1.25rem 0;
  font-style: italic;
}
.r-about-bio code {
  font-family: var(--zen-font-mono);
  font-size: 0.85em;
  background: var(--zen-paper-dp);
  padding: 1px 4px; border-radius: 3px;
}

.r-about-block { margin-top: 3rem; }
.r-about-h2 {
  font-family: var(--zen-font-ui);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--zen-ink-4);
  margin: 0 0 0.9rem;
}
.r-about-cloud {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.65rem;
  align-items: baseline;
}
.r-cloud-chip {
  color: var(--zen-ink);
  font-family: var(--zen-font);
  font-size: calc(1.05rem * var(--cloud-scale, 1));
  font-weight: 500;
  padding: 4px 0;
  text-decoration: none;
  transition: color .15s;
  display: inline-flex; align-items: baseline; gap: 4px;
}
.r-cloud-chip:hover { color: var(--zen-accent); text-decoration: none; }
.r-cloud-chip .r-chip-hash { opacity: .35; }
.r-cloud-chip .r-chip-count {
  font-family: var(--zen-font-mono);
  font-size: 0.62rem;
  color: var(--zen-ink-4);
}
.r-about-list { list-style: none; padding: 0; margin: 0; }
.r-about-list li { border-top: 1px solid var(--zen-rule); }
.r-about-list li:last-child { border-bottom: 1px solid var(--zen-rule); }
.r-about-link {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0.85rem 0.25rem;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color .15s;
}
.r-about-link:hover { background: var(--zen-accent-s); text-decoration: none; }
.r-about-link-label {
  font-family: var(--zen-font);
  font-size: 1rem;
  color: var(--zen-ink);
}
.r-about-link-sub {
  font-family: var(--zen-font-mono);
  font-size: 0.7rem;
  color: var(--zen-ink-4);
}
.r-about-foot {
  margin-top: 4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--zen-rule);
  font-family: var(--zen-font-ui);
  font-size: 0.72rem;
  color: var(--zen-ink-3);
  font-style: italic;
  text-align: center;
}

/* ── Single post body keeps original styling but inherits reader chrome.
       Override the legacy .post-meta to thread reading time naturally. ── */
.post-body .post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

/* ── Mobile (≤640px) ── */
@media (max-width: 640px) {
  .r-head-inner { gap: 6px; padding: 14px 16px; }
  .r-brand-word { font-size: 0.95rem; }
  .r-nav {
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--zen-paper);
    border-bottom: 1px solid var(--zen-rule);
    padding: 6px 12px 14px;
    margin: 0;
    opacity: 0; pointer-events: none;
    transform: translateY(-4px);
    transition: opacity .2s, transform .2s;
  }
  .r-nav.is-open { opacity: 1; pointer-events: auto; transform: none; }
  .r-nav-link {
    padding: 10px 6px;
    font-size: 0.86rem;
    border-radius: 0;
    border-bottom: 1px dashed var(--zen-rule);
  }
  .r-nav-link:last-child { border-bottom: 0; }
  .r-nav-toggle { display: inline-flex; }
  .r-main { padding: 1.75rem 1rem 3.5rem; }
  .r-card { padding: 1.4rem 0; }
  .r-card-title { font-size: 1.25rem; }
  .r-card-excerpt { font-size: 0.95rem; -webkit-line-clamp: 3; }
  .r-card-meta { gap: 0.45rem 0.85rem; }
  .r-about-head { gap: 0.9rem; flex-direction: column; align-items: flex-start; }
  .r-about-portrait { width: 88px; height: 88px; }
  .r-about-bio p { font-size: 1rem; }
  .r-about-bio p:first-of-type::first-letter { font-size: 3em; margin-top: 4px; }
  .r-filter-row { gap: 5px; }
  .r-chip { padding: 5px 10px; font-size: 0.68rem; }
}
