:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --sidebar: #1f3a38;
  --sidebar-text: #e9efed;
  --sidebar-muted: #a9bcb8;
  --ink: #1d2729;
  --ink-2: #44514f;
  --muted: #6b7774;
  --rule: #e2ddd2;
  --accent: #1f5c57;
  --accent-soft: #e6efed;
  --gold: #a37b2c;
  --draft: #b4532a;
  --draft-soft: #fbeee6;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 288px;
  --measure: 760px;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #143f3c; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; color: var(--ink); margin: 0; line-height: 1.2; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }
li + li { margin-top: .3em; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); }
.sidebar-inner { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 40px 28px 28px; display: flex; flex-direction: column; gap: 32px; }
body.admin .sidebar-inner { top: 56px; height: calc(100vh - 56px); }

.identity { display: flex; flex-direction: column; gap: 16px; }
.portrait { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.18); }
.monogram { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); font: 500 32px/1 var(--serif); color: var(--sidebar-text); letter-spacing: .02em; }
.identity-name { font: 500 26px/1.15 var(--serif); color: #fff; }
.identity-cred { display: block; font: 500 12px/1.4 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-muted); margin-top: 6px; }
.identity-role { font-size: 14px; color: var(--sidebar-muted); line-height: 1.5; }

.nav-toggle { display: none; }
.nav ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid rgba(255,255,255,.12); }
.nav li { margin: 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.nav a { display: grid; grid-template-columns: 28px 1fr; gap: 6px; padding: 11px 0; color: var(--sidebar-text); text-decoration: none; font-size: 15px; }
.nav a:hover { color: #fff; }
.nav a .num { font: 500 12px/1.9 var(--sans); color: var(--sidebar-muted); letter-spacing: .04em; }
.nav a[aria-current="true"] { color: #fff; font-weight: 600; }
.nav a[aria-current="true"] .num { color: #d9b46a; }
.nav .hidden-section { opacity: .55; font-style: italic; }

.contact { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.contact a { color: var(--sidebar-text); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; word-break: break-all; }
.contact a:hover { color: #fff; text-decoration: underline; }
.contact svg { width: 16px; height: 16px; flex: none; fill: currentColor; opacity: .8; }

.main { padding: 72px clamp(20px, 6vw, 88px) 48px; min-width: 0; }
body.admin .main { padding-top: 120px; }
.main > * { max-width: var(--measure); }

/* ---------- Hero ---------- */
.hero { padding-bottom: 56px; border-bottom: 1px solid var(--rule); margin-bottom: 8px; }
.kicker { font: 600 12px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 14px; }
.hero h1 { font-size: clamp(40px, 6vw, 60px); letter-spacing: -.01em; margin-bottom: 12px; }
.hero-role { font-size: 18px; color: var(--ink-2); margin-bottom: 28px; }
.hero-summary { font-size: 18px; color: var(--ink-2); line-height: 1.7; }
.theme { margin-top: 36px; padding: 28px 32px; background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent); }
.theme-label { font: 600 12px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.theme-title { font-size: 26px; margin-bottom: 12px; }
.theme-body { color: var(--ink-2); }

/* ---------- Sections ---------- */
.section { padding: 64px 0 24px; border-bottom: 1px solid var(--rule); scroll-margin-top: 16px; }
body.admin .section { scroll-margin-top: 72px; }
.section:last-child { border-bottom: 0; }
.eyebrow { font: 600 12px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.section h2 { font-size: clamp(30px, 4vw, 40px); margin-bottom: 18px; letter-spacing: -.005em; }
.section-intro { font-size: 17px; color: var(--ink-2); margin-bottom: 32px; }

.standard { background: var(--surface); border: 1px solid var(--rule); padding: 28px 32px; margin: 8px 0 40px; }
.standard-label { font: 600 12px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.standard-statement { color: var(--ink-2); margin-bottom: 18px; }
.standard ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.standard li { display: grid; grid-template-columns: 40px 1fr; gap: 8px; margin: 0; font-size: 15px; color: var(--ink-2); }
.standard li .n { font: 600 13px/1.65 var(--sans); color: var(--accent); }

.block { margin: 0 0 40px; position: relative; }
.block > h3 { font-size: 24px; margin-bottom: 14px; }
.block-body { color: var(--ink-2); }
.block-body h3, .block-body h4 { margin: 1.2em 0 .5em; font-size: 20px; }
.block-body blockquote { margin: 1em 0; padding-left: 18px; border-left: 2px solid var(--rule); font-style: italic; }

.callout { background: var(--accent-soft); padding: 28px 32px; }
.callout > h3 { font-size: 20px; }

.artifact { background: var(--surface); border: 1px solid var(--rule); padding: 28px 32px; }
.artifact-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 12px/1 var(--sans); letter-spacing: .04em; color: var(--accent); background: var(--accent-soft); padding: 7px 10px; border-radius: 3px; }
.artifact > h3 { font-size: 22px; margin-bottom: 6px; }
.artifact-meta { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.artifact .demonstrates-text { color: var(--muted); font-size: 13px; margin: -6px 0 16px; }
.files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--rule); }
.file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 4px; font-size: 14px; color: var(--ink); text-decoration: none; background: var(--bg); }
.file:hover { border-color: var(--accent); color: var(--accent); }
.file svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.file-image { display: block; margin-top: 18px; border: 1px solid var(--rule); }
.file-image img { width: 100%; }

/* TOC block */
.toc ol { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.toc li { margin: 0; border-bottom: 1px solid var(--rule); }
.toc a { display: grid; grid-template-columns: 48px 1fr auto; align-items: baseline; gap: 8px; padding: 14px 0; text-decoration: none; color: var(--ink); }
.toc a:hover .toc-title { color: var(--accent); text-decoration: underline; }
.toc .num { font: 500 13px/1 var(--sans); color: var(--gold); }
.toc .toc-title { font: 500 19px/1.3 var(--serif); }
.toc .toc-sub { font-size: 13px; color: var(--muted); }

/* Resume block */
.resume-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.resume-head h3 { font-size: 24px; }
.resume { background: var(--surface); border: 1px solid var(--rule); padding: 8px 32px 24px; }
.resume-group { padding-top: 22px; }
.resume-group + .resume-group { border-top: 1px solid var(--rule); margin-top: 18px; }
.resume-group > h4 { font: 600 12px/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.ritem { display: grid; grid-template-columns: 1fr auto; gap: 2px 20px; margin-bottom: 16px; }
.ritem:last-child { margin-bottom: 0; }
.ritem-title { font-weight: 600; font-size: 16px; }
.ritem-dates { font-size: 14px; color: var(--muted); text-align: right; white-space: nowrap; }
.ritem-org { grid-column: 1 / -1; font-size: 15px; color: var(--ink-2); }
.ritem-body { grid-column: 1 / -1; font-size: 15px; color: var(--ink-2); margin-top: 6px; }
.ritem-body ul { margin-bottom: 0; }

.footer { padding: 48px 0 0; margin-top: 24px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.footer button.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Buttons & dialogs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 500 14px/1 var(--sans); padding: 10px 14px; border-radius: 4px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #174744; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.danger:hover { border-color: #a33; color: #a33; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 15px; height: 15px; fill: currentColor; }

.dialog { border: 1px solid var(--rule); border-radius: 6px; padding: 28px; width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.dialog.wide { width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 30, 30, .45); }
.dialog h2 { font-size: 24px; margin-bottom: 8px; }
.dialog label { display: block; font-size: 14px; font-weight: 500; margin: 16px 0 6px; }
.dialog input { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cfc9bc; border-radius: 4px; background: #fff; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.form-error { color: #a33; font-size: 14px; min-height: 1.2em; margin: 10px 0 0; }
.history-list { list-style: none; padding: 0; margin: 16px 0 0; max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--rule); }
.history-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); margin: 0; font-size: 14px; }

/* ---------- Admin bar & edit mode ---------- */
.adminbar { position: fixed; inset: 0 0 auto 0; height: 56px; z-index: 40; background: #14211f; color: #e9efed; display: flex; align-items: center; gap: 8px; padding: 0 16px; font-size: 14px; border-bottom: 1px solid #000; }
.adminbar .btn { background: transparent; color: #e9efed; border-color: rgba(255,255,255,.22); }
.adminbar .btn:hover { border-color: #fff; color: #fff; }
.adminbar .btn.primary { background: #d9b46a; border-color: #d9b46a; color: #1b1b1b; }
.adminbar .btn.primary:hover { background: #e6c47f; color: #000; }
.adminbar .btn[aria-pressed="true"] { background: rgba(255,255,255,.14); }
.adminbar .label { font-weight: 600; letter-spacing: .02em; margin-right: 6px; }
.adminbar .status { color: #a9bcb8; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adminbar .status.dirty { color: #f0c987; }
.adminbar .sep { width: 1px; height: 24px; background: rgba(255,255,255,.18); margin: 0 4px; }
.adminbar .fmt { display: flex; gap: 4px; }
.adminbar .fmt .btn { width: 34px; padding: 7px 0; font-weight: 600; }
.adminbar .more { position: relative; }
.adminbar .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 6px; min-width: 220px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.adminbar .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; font: inherit; color: var(--ink); border-radius: 4px; cursor: pointer; }
.adminbar .menu button:hover { background: var(--accent-soft); }

body.editing [data-path] { outline: 1px dashed transparent; outline-offset: 4px; border-radius: 2px; cursor: text; min-height: 1.2em; }
body.editing [data-path]:hover { outline-color: #c9c2b2; }
body.editing [data-path]:focus { outline: 2px solid var(--gold); background: #fffdf6; }
body.editing .sidebar [data-path]:focus { background: rgba(255,255,255,.06); }
body.editing [data-path]:empty::before { content: attr(data-placeholder); color: #a29c8f; font-style: italic; }
body.editing .sidebar [data-path]:empty::before { color: #7f948f; }
body.editing [data-path].plain-block { display: block; }

.guidance { font-size: 14px; background: #fff8e8; border: 1px solid #ecdcb3; color: #6b5420; padding: 14px 16px; margin: 0 0 28px; border-radius: 4px; }
.guidance strong { display: block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }

.controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; }
.controls .spacer { flex: 1; }
.block-type { font: 600 11px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.draft-badge { font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--draft); background: var(--draft-soft); padding: 6px 8px; border-radius: 3px; }
body.editing .block.is-draft { outline: 1px dashed #e3b9a3; outline-offset: 10px; }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px; border: 1px dashed #cfc9bc; border-radius: 4px; margin: 0 0 32px; align-items: center; }
.add-row .muted { font-size: 14px; margin-right: 4px; }
.file-edit { display: inline-flex; align-items: center; gap: 4px; }
.file-edit .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; }
.file-edit .x:hover { color: #a33; }
.inline-field { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.inline-field [data-path] { color: var(--ink); min-width: 80px; }
.photo-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-controls .btn { background: transparent; color: var(--sidebar-text); border-color: rgba(255,255,255,.25); }
.section-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.section.is-hidden > :not(.section-controls) { opacity: .55; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #14211f; color: #fff; padding: 12px 18px; border-radius: 6px; font-size: 14px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.toast.error { background: #7a2020; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .adminbar .fmt-label { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar-inner { position: static; height: auto; padding: 20px 16px; gap: 16px; }
  body.admin .sidebar-inner { height: auto; }
  body.admin .layout { padding-top: 56px; }
  .identity { flex-direction: row; align-items: center; gap: 14px; }
  .portrait, .monogram { width: 56px; height: 56px; font-size: 20px; }
  .identity-name { font-size: 21px; }
  .identity-role { display: none; }
  .nav-toggle { display: inline-flex; align-self: flex-start; background: transparent; color: var(--sidebar-text); border: 1px solid rgba(255,255,255,.3); border-radius: 4px; padding: 8px 12px; font: 500 14px/1 var(--sans); cursor: pointer; }
  .nav { display: none; }
  .nav.open { display: block; }
  .contact { display: none; }
  .main { padding: 40px 16px 32px; }
  body.admin .main { padding-top: 40px; }
  .standard, .artifact, .callout, .theme { padding: 22px 20px; }
  .resume { padding: 4px 20px 20px; }
  .ritem { grid-template-columns: 1fr; }
  .ritem-dates { text-align: left; grid-row: 2; }
  .adminbar { overflow-x: auto; }
  .adminbar .fmt, .adminbar .sep { display: none; }
  .toc a { grid-template-columns: 36px 1fr; }
  .toc .toc-sub { display: none; }
}

@media print {
  .sidebar, .adminbar, .footer button, .add-row, .controls, .guidance { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  .section { break-inside: avoid-page; }
}
