:root {
  --bg: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-elev: #eef0f3;
  --bg-editor: #ffffff;
  --border: #e2e5eb;
  --text: #3d4450;
  --text-strong: #1a1d24;
  --muted: #7a8290;
  --accent: #8a7349;
  --accent-soft: rgba(138, 115, 73, 0.1);
  --accent-text: #fffaf2;
  --active-file: #2f5f9f;
  --active-file-soft: rgba(59, 111, 184, 0.14);
  --danger: #c14b4b;
  --ok: #2f8f5b;
  --warn: #a67c2a;
  --shadow: 0 8px 24px rgba(20, 24, 32, 0.06);
  --radius: 10px;
  --font: "Fraunces", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --icon-size: 14px;
  /* Soft warm highlight — distinct from Ask Agent’s blue chip */
  --selection: rgba(138, 115, 73, 0.22);
}

* { box-sizing: border-box; }

::selection {
  background: var(--selection);
  color: inherit;
}

::-moz-selection {
  background: var(--selection);
  color: inherit;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
}

.ui-icon {
  background: currentColor;
  display: inline-block;
  flex-shrink: 0;
  height: 1em;
  width: 1em;
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
  font-size: var(--icon-size);
  vertical-align: -0.12em;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.login-screen {
  min-height: 100%;
  height: 100%;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-screen[hidden],
#app[hidden] {
  display: none !important;
}

.login-card {
  width: min(380px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 22px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: 100px;
  height: auto;
}

.brand-logo {
  display: block;
  width: 90px;
  height: auto;
  flex-shrink: 0;
}

.login-card h1 {
  margin: 0;
  font-family: "Syne", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.15;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

.brand h1 {
  margin: 0;
  font-family: "Syne", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.15;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  white-space: nowrap;
  position: relative;
  top: 1px;
}

.subtitle, .tagline, .muted {
  color: var(--muted);
  margin: 0;
  font-size: 0.84rem;
  font-weight: 400;
}

.tagline {
  font-size: 0.78rem;
  white-space: nowrap;
}

.login-card label {
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 400;
}

.login-card input {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-weight: 400;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card input:focus {
  outline: none;
  border-color: rgba(138, 115, 73, 0.45);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
  color: var(--danger);
  margin: 0;
  font-size: 0.86rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:hover:not(:disabled) { background: var(--bg-elev); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  font-weight: 500;
}

.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 0.8rem; }
.btn.btn-block { width: 100%; }
.btn.icon-only {
  padding: 6px;
  min-width: 32px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 6px 10px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
  min-width: 6.5rem;
  box-shadow: none;
  outline: none;
}

.sync-status[hidden] { display: none !important; }
.sync-status.is-saving { color: var(--accent); }
.sync-status.is-saved { color: var(--ok); }

.sync-status .sync-icon {
  transform-origin: center;
  will-change: transform;
}

.sync-status .sync-icon.is-spin {
  animation: wd-spin 0.85s linear infinite;
}

@keyframes wd-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.desklink-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.desklink-chip:hover {
  border-color: rgba(138, 115, 73, 0.45);
  color: var(--accent);
}

.desklink-sep {
  width: 1px;
  align-self: stretch;
  min-height: 1em;
  margin: 0 0.15rem;
  background: currentColor;
  opacity: 0.28;
  flex-shrink: 0;
}

.desklink-chip.is-ready {
  color: var(--ok);
  border-color: rgba(47, 143, 91, 0.28);
  cursor: default;
}

.desklink-chip.is-ready:hover {
  color: var(--ok);
}

.desklink-chip.is-missing,
.desklink-chip.is-update {
  color: var(--accent);
  border-color: rgba(138, 115, 73, 0.35);
  cursor: pointer;
}

.desklink-chip[hidden] { display: none !important; }

.app {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}

.brand-text {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  min-width: 0;
  flex-wrap: wrap;
  padding-bottom: 1px;
}

.brand-sep {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1;
  user-select: none;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

:root {
  --sidebar-width: 300px; /* default (= min); JS may override with a remembered wider width */
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-width) 6px 1fr;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 0;
  background: var(--bg-panel);
  padding: 0;
  overflow: hidden;
}

.sidebar-resizer {
  position: relative;
  z-index: 4;
  width: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
}

.sidebar-resizer:hover,
.sidebar-resizer:focus-visible,
body.is-resizing-sidebar .sidebar-resizer {
  background: rgba(138, 115, 73, 0.18);
  border-right-color: rgba(138, 115, 73, 0.45);
  outline: none;
}

body.is-resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing-sidebar * {
  cursor: col-resize !important;
}

.sidebar-head {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  padding: 12px 12px 10px 16px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.sidebar-head h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-strong);
}

.sidebar-head h2 .ui-icon {
  font-size: 18px;
  color: var(--muted);
}

.sidebar-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sidebar-head-actions .btn.icon-only {
  min-width: 28px;
  padding: 5px;
  color: var(--muted);
}

.file-tree {
  --thread: #c8ced8;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: 0.86rem;
  font-weight: 400;
  /* Top breath + modest left inset for circle-chevrons */
  padding: 24px 10px 20px 44px;
}

.ui-icon-agent {
  font-size: 16px;
  opacity: 1;
}

.tree-agent-item {
  margin-bottom: 8px;
}

.tree-dir > summary {
  cursor: pointer;
  list-style: none;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  user-select: none;
  font-weight: 400;
}

.tree-agent > summary.tree-agent-summary {
  /* Keep pill at the old left edge so tree threads do not shift */
  position: relative;
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 0;
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  outline: none;
  transition: none;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}

/* Sits to the left of the pill without affecting layout / threads */
.tree-agent-chevron-wrap {
  box-sizing: border-box;
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
}

.tree-agent-chevron {
  font-size: 18px;
  width: 1em;
  height: 1em;
  color: #7a8290;
  opacity: 1;
}

/* Expanded: same circle size — looks like the outline circle filled in */
.tree-agent[open] > .tree-agent-summary .tree-agent-chevron-wrap {
  width: 18px;
  height: 18px;
  background: #7a8290;
}

.tree-agent[open] > .tree-agent-summary .tree-agent-chevron {
  font-size: 12px; /* plain chevron inside the filled disc */
  color: #fff;
  opacity: 1;
}

.tree-agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 24px;
  color: #fff;
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.2;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  background: #7a8290;
  border: 0;
  box-shadow: none;
}

/* Keep pill appearance flat — no hover / press / focus flash */
.tree-agent > summary.tree-agent-summary:hover,
.tree-agent > summary.tree-agent-summary:active,
.tree-agent > summary.tree-agent-summary:focus,
.tree-agent > summary.tree-agent-summary:focus-visible {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  filter: none !important;
}

.tree-agent > summary.tree-agent-summary:hover .tree-agent-pill,
.tree-agent > summary.tree-agent-summary:active .tree-agent-pill,
.tree-agent > summary.tree-agent-summary:focus .tree-agent-pill,
.tree-agent > summary.tree-agent-summary:focus-visible .tree-agent-pill {
  background: #7a8290 !important;
  color: #fff !important;
}

.tree-agent > summary::-webkit-details-marker,
.tree-dir > summary::-webkit-details-marker { display: none; }

.tree-missing {
  margin: 2px 0 6px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

/* Nested guide rails + elbow connectors */
.tree-children {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
}

.tree-item {
  position: relative;
  padding-left: 16px;
}

.tree-item::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--thread);
}

.tree-item.is-last::before {
  bottom: auto;
  height: 13px;
}

.tree-item::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 13px;
  width: 9px;
  height: 1px;
  background: var(--thread);
}

/* Agent roots: no outer thread (they are trunks) */
.tree-agent-item {
  padding-left: 0;
}

.tree-agent-item::before,
.tree-agent-item::after {
  display: none;
}

.tree-agent > .tree-children {
  margin-left: 8px;
  padding-left: 2px;
}

.tree-dir > .tree-children {
  margin-left: 2px;
}

.tree-file {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 400;
}

.tree-file:hover,
.tree-dir > summary:hover { background: var(--bg-elev); }

.tree-agent-pill .ui-icon {
  color: #fff;
}

.tree-file.active {
  background: var(--active-file-soft);
  color: var(--active-file);
  font-weight: 500;
}

.tree-file .name,
.tree-dir .name,
.tree-agent .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.explorer-menu {
  position: fixed;
  z-index: 80;
  min-width: 180px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}
.explorer-menu[hidden] { display: none !important; }
.explorer-menu button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}
.explorer-menu button:hover { background: var(--bg-elev); }
.explorer-menu button.is-danger { color: var(--danger); }
.explorer-menu .menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

.wd-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 24, 32, 0.35);
}
.wd-modal[hidden] { display: none !important; }
.wd-modal-card {
  width: min(380px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}
.wd-modal-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-strong);
  font-weight: 600;
}
.wd-modal-field {
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
}
.wd-modal-field[hidden] { display: none !important; }
.wd-modal-field input,
.wd-modal-field select {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}
.wd-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
}

.editor-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 2;
}

.editor-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px 16px;
}

.editor-header h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-strong);
}

.editor-header .ui-icon {
  font-size: 18px;
  color: var(--muted);
}

.editor-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-md-view {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  transition: none;
}

.btn-md-view .ui-icon {
  font-size: 15px;
  color: var(--muted);
}

/* No hover flash (match explorer pills) */
.btn-md-view:hover:not(:disabled),
.btn-md-view:active:not(:disabled),
.btn-md-view:focus:not(:disabled),
.btn-md-view:focus-visible:not(:disabled) {
  background: var(--bg) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  filter: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.btn-md-view.is-active {
  background: #7a8290;
  border-color: #7a8290;
  color: #fff;
}

.btn-md-view.is-active .ui-icon {
  color: #fff;
}

.btn-md-view.is-active:hover:not(:disabled),
.btn-md-view.is-active:active:not(:disabled),
.btn-md-view.is-active:focus:not(:disabled),
.btn-md-view.is-active:focus-visible:not(:disabled) {
  background: #7a8290 !important;
  border-color: #7a8290 !important;
  color: #fff !important;
}

.btn-md-view.is-active:hover:not(:disabled) .ui-icon,
.btn-md-view.is-active:focus:not(:disabled) .ui-icon {
  color: #fff !important;
}

.md-source {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 320px;
  height: auto;
  margin: 0;
  padding: 28px 36px 48px;
  border: 0;
  border-radius: inherit;
  resize: none;
  outline: none;
  background: var(--bg-editor);
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: hidden; /* grow with content; editor-body scrolls the paper */
  tab-size: 2;
}

.md-source[hidden] {
  display: none !important;
}

.workspace.is-md-view .doc-editor {
  display: none;
}

.btn-drive-sync {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.btn-drive-sync:hover:not(:disabled) {
  border-color: rgba(66, 133, 244, 0.45);
  color: #1a73e8;
}

.btn-drive-sync:disabled {
  opacity: 0.72;
  cursor: default;
}

.btn-drive-sync.is-syncing {
  color: var(--accent);
  border-color: rgba(138, 115, 73, 0.35);
}

.btn-drive-sync.is-synced {
  color: var(--ok);
  border-color: rgba(47, 143, 91, 0.28);
}

.btn-drive-sync.is-error {
  color: var(--danger);
  border-color: rgba(193, 75, 75, 0.35);
}

.drive-sync-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.disk-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: rgba(166, 124, 42, 0.08);
  border: 1px solid rgba(166, 124, 42, 0.28);
  color: var(--warn);
  padding: 8px 11px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.84rem;
  font-weight: 400;
}

.disk-banner[hidden] { display: none !important; }

.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; /* keep rounded canvas corners */
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.format-bubble {
  position: fixed;
  z-index: 40;
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  box-shadow: 0 8px 24px rgba(20, 24, 32, 0.12);
  transform: translate(-50%, -100%);
  pointer-events: auto;
}

.format-bubble[hidden] {
  display: none !important;
}

.format-bubble .btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.format-bubble .btn.icon-only {
  min-width: 32px;
  padding: 6px;
}

.format-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 4px;
  background: var(--border);
}

.format-bubble .btn.ask-agent {
  gap: 0.35rem;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: #dff0ff;
  color: #1a6fad;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.format-bubble .btn.ask-agent:hover:not(:disabled) {
  filter: none;
  background: #cce7ff;
}

.doc-editor {
  min-height: 320px;
  overflow: visible;
  background: var(--bg-editor);
  border-radius: inherit;
}

.doc-editor .tiptap,
.doc-editor .ProseMirror,
.doc-surface {
  outline: none;
  min-height: 100%;
  padding: 28px 36px 48px;
  line-height: 1.7;
  font-family: var(--sans);
  font-size: 1.02rem;
  font-weight: 300;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  border-radius: inherit;
}

.doc-editor.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.workspace-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  pointer-events: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 400;
  background: transparent;
}

.workspace-hint[hidden] { display: none !important; }

.doc-surface p.is-editor-empty:first-child::before,
.doc-surface .is-empty::before {
  color: var(--muted);
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
  font-weight: 400;
}

/* Headings: serif + weight/size — clearly distinct from body even in grayscale */
.doc-surface h1,
.doc-surface h2,
.doc-surface h3 {
  font-family: var(--font);
  font-weight: 600;
  color: var(--text-strong);
  margin: 1.4em 0 0.4em;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.doc-surface h1:first-child,
.doc-surface h2:first-child,
.doc-surface h3:first-child { margin-top: 0; }

.doc-surface h1 { font-size: 1.55rem; font-weight: 600; }
.doc-surface h2 { font-size: 1.28rem; font-weight: 600; }
.doc-surface h3 { font-size: 1.1rem; font-weight: 500; }

.doc-surface p {
  margin: 0.7em 0;
  font-weight: 300;
}

.doc-surface ul,
.doc-surface ol {
  margin: 0.6em 0;
  padding-left: 1.3em;
  font-weight: 300;
}

.doc-surface li { margin: 0.25em 0; }

.doc-surface hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.4em 0;
}

.doc-surface blockquote {
  margin: 0.85em 0;
  padding-left: 14px;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-weight: 400;
}

.doc-surface code {
  font-family: var(--mono);
  font-size: 0.88em;
  font-weight: 400;
  background: var(--bg-elev);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.doc-surface strong {
  font-weight: 600;
  color: var(--text-strong);
}

@media (max-width: 900px) {
  /* Stacked view: whole page scrolls. Only section headers stick.
     Important: one scroll root (html) — sticky breaks if body also scrolls. */
  html {
    height: auto;
    overflow-x: hidden;
    overflow-y: scroll;
  }

  body {
    height: auto;
    overflow: visible;
  }

  .app {
    height: auto;
    max-height: none;
    min-height: 100vh;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 6;
  }

  .layout {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .sidebar-resizer {
    display: none;
  }

  .sidebar {
    display: block;
    flex: 0 0 auto;
    width: auto !important;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }

  .sidebar-head {
    position: sticky;
    top: var(--wd-sticky-top, 0px);
    z-index: 5;
  }

  .file-tree {
    flex: none;
    max-height: none;
    overflow: visible;
    padding-bottom: 12px;
  }

  .editor-pane {
    display: block;
    flex: 1 0 auto;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .editor-header {
    position: sticky;
    top: var(--wd-sticky-top, 0px);
    z-index: 5;
  }

  .editor-body {
    display: block;
    flex: none;
    min-height: auto;
    overflow: visible;
  }

  .workspace {
    min-height: 60vh;
  }

  .doc-surface {
    padding: 20px 18px 36px;
    font-size: 0.98rem;
  }

  .brand-text { gap: 0.3rem; }
}
