:root {
  color-scheme: light;
  --paper: #fffdf8;
  --ink: #161616;
  --muted: #5b5b5b;
  --line: #d8d0c4;
  --accent: #6c2020;
  --accent-soft: #efe5df;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font-family: ui-sans-serif, system-ui, sans-serif; }
a { color: inherit; }
button, input { font: inherit; }
body { min-height: 100vh; }
.eyebrow { margin: 0 0 0.35rem; color: var(--accent); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.lede { margin: 0.2rem 0 0; color: var(--muted); }
.shell { max-width: 72rem; margin: 0 auto; padding: 2rem; }
.gate-shell { min-height: 100vh; display: grid; place-items: center; }
.gate-card { width: min(100%, 30rem); border: 1px solid var(--line); background: white; border-radius: 1rem; padding: 2rem; box-shadow: 0 18px 60px rgba(48, 27, 18, 0.08); }
.gate-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.gate-form label { display: grid; gap: 0.4rem; }
input { width: 100%; padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: 0.65rem; background: #fff; }
button, .link-button { padding: 0.75rem 1rem; border-radius: 0.7rem; border: 1px solid transparent; background: var(--accent); color: white; text-decoration: none; cursor: pointer; }
.secondary { background: transparent; color: var(--accent); border-color: var(--line); }
.error-banner { margin: 1rem 0 0; padding: 0.85rem 1rem; border-radius: 0.75rem; background: #f8e7e7; color: #7e1111; }
.topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding: 1.5rem 2rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.9); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar h1, .pane-head h2 { margin: 0; }
.topbar-meta { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.doc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.doc-link { display: grid; gap: 0.35rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 0.9rem; background: white; text-decoration: none; }
.doc-link:hover { border-color: var(--accent); }
.doc-link span, .doc-link code, .empty-state { color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(18rem, 1fr) 6px minmax(18rem, 1fr); min-height: calc(100vh - 6rem); }
.pane { min-width: 0; display: flex; flex-direction: column; }
.pdf-pane { border-right: 1px solid var(--line); background: #faf7f1; }
.editor-pane { background: white; }
.pane-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.pdf-stack { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pdf-frame { flex: 1; width: 100%; min-height: 5rem; border: 0; background: white; }
.editor-host { flex: 1; min-height: 30rem; }
.editor-host .cm-editor { height: 100%; }
.build-output { flex: 0 0 14rem; min-height: 2.5rem; margin: 0; padding: 0.9rem 1.25rem 1.2rem; border-top: 1px solid var(--line); background: #221f1d; color: #f3eee8; font: 0.84rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: auto; white-space: pre-wrap; }
.h-resizer { cursor: col-resize; background: transparent; position: relative; }
.h-resizer::after { content: ''; position: absolute; inset: 0 2px; background: var(--line); border-radius: 2px; }
.h-resizer:hover::after, .h-resizer.dragging::after { background: var(--accent); }
.v-resizer { flex: 0 0 6px; cursor: row-resize; background: transparent; position: relative; }
.v-resizer::after { content: ''; position: absolute; inset: 2px 0; background: var(--line); border-radius: 2px; }
.v-resizer:hover::after, .v-resizer.dragging::after { background: var(--accent); }
body.resizing-h, body.resizing-h * { cursor: col-resize !important; user-select: none !important; }
body.resizing-v, body.resizing-v * { cursor: row-resize !important; user-select: none !important; }
body.resizing-h .pdf-frame, body.resizing-v .pdf-frame { pointer-events: none; }
.header-show-fab { position: fixed; top: 0.6rem; right: 0.6rem; z-index: 20; width: 2rem; height: 2rem; line-height: 1; border-radius: 999px; border: 1px solid var(--line); background: white; color: var(--accent); display: flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 4px 14px rgba(48, 27, 18, 0.14); }
body.header-hidden .topbar { display: none; }
@media (min-width: 961px) {
  body:has(.workspace) { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
  body:has(.workspace) .topbar { flex: 0 0 auto; }
  .workspace { flex: 1; min-height: 0; overflow: hidden; }
  .pane { min-height: 0; overflow: hidden; }
  .pdf-frame { min-height: 0; }
  .editor-host { min-height: 0; }
}
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .h-resizer { display: none; }
  .pdf-pane { border-right: 0; border-bottom: 1px solid var(--line); min-height: 50vh; }
}
