:root {
  --ink: #f6f2e7;
  --ink-muted: #ccd6ed;
  --ink-faint: #9db0da;
  --blue-950: #20386f;
  --blue-800: #2f52a0;
  --blue-700: #385db1;
  --blue-600: #486dc0;
  --cream: #f8f4e9;
  --cream-ink: #273d74;
  --line: rgba(220, 230, 255, 0.2);
  --line-strong: rgba(235, 240, 255, 0.42);
  --glass: rgba(24, 54, 122, 0.18);
  --shadow: 0 24px 70px rgba(14, 35, 86, 0.24);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.codex-panel, .codex-dialog {
  color: var(--ink);
  background: var(--blue-950);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 18px;
  overflow-wrap: anywhere;
}
.codex-panel { margin-top: 18px; }
.codex-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
.codex-dialog::backdrop { background: rgb(10 25 55 / 65%); }
.codex-panel label, .codex-dialog label { display: block; margin: 10px 0 6px; }
.codex-panel input, .codex-panel textarea, .codex-dialog input {
  width: 100%; min-width: 0; padding: 10px; border: 1px solid var(--line-strong);
  border-radius: 6px; color: var(--ink); background: var(--glass);
}
.codex-panel textarea { resize: vertical; }
.codex-settings { margin-bottom: 16px; }
.codex-settings-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: 10px; }
.codex-settings-fields > div { min-width: 0; }
.codex-panel select { width: 100%; min-width: 0; padding: 9px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--blue-950); }
.codex-settings button { padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--cream); color: var(--cream-ink); }
.codex-settings button:disabled { opacity: .6; }
.codex-settings p { margin: 8px 0 0; overflow-wrap: anywhere; }
#codex-settings-error:empty, #codex-permissions-error:empty { display: none; }
@media (max-width: 480px) { .codex-settings-fields { grid-template-columns: minmax(0, 1fr); } .codex-settings-fields > button { justify-self: start; } }
.codex-panel input[type="checkbox"] { width: auto; }
.codex-panel p, .codex-dialog p { font-size: 14px; }
.codex-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.codex-buttons button, #codex-existing-find { padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--cream); color: var(--cream-ink); }
.codex-buttons button:disabled, #codex-existing-find:disabled { opacity: .6; cursor: wait; }
.codex-request { margin: 12px 0; border: 1px solid var(--line-strong); padding: 12px; border-radius: 6px; }
.codex-request pre { overflow: auto; max-height: 240px; white-space: pre-wrap; overflow-wrap: anywhere; }
#codex-create-error { color: var(--cream); }
.codex-dialog select { width: 100%; min-width: 0; padding: 9px; color: var(--ink); background: var(--blue-950); border: 1px solid var(--line-strong); border-radius: 6px; }
#codex-existing-find { margin-top: 8px; padding: 6px 10px; }
#codex-existing-help { overflow-wrap: anywhere; }
.codex-live-reply { margin: 14px 0; padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--glass); }
.codex-live-reply .card-content { margin-top: 12px; }
.codex-update { border-left: 2px solid var(--line-strong); margin: 8px 0; padding: 6px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.codex-update.is-streaming { color: var(--ink-muted); }
.cloud-import-choice { display: flex !important; align-items: flex-start; gap: 8px; padding: 8px 0; overflow-wrap: anywhere; }
.cloud-import-choice input { width: auto !important; margin-top: 4px; }

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--blue-800);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 5%, rgba(109, 139, 210, 0.2), transparent 29rem),
    radial-gradient(circle at 8% 72%, rgba(21, 56, 132, 0.28), transparent 36rem),
    var(--blue-800);
  font-family: var(--sans);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template: 72px 1fr / 260px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.has-notifications { grid-template-rows: 72px 40px 1fr; }
.notification-queue {
  --notification-width: 160px;
  position: sticky;
  top: var(--notification-top, 72px);
  z-index: 19;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 4px 28px;
  overflow-x: hidden;
  overflow-y: hidden;
  scrollbar-width: none;
  background: var(--blue-800);
  border-bottom: 1px solid var(--line);
}
.notification-square {
  flex: 0 0 var(--notification-width);
  width: var(--notification-width);
  height: 30px;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  border: 1px solid #f8f4e9;
  border-radius: 4px;
  background: #f8f4e9;
  color: #20386f;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.notification-square.is-seen { background: transparent; color: #c7d0e4; border-color: #9caac6; }
.notification-square:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.app-shell.has-notifications .block-sidebar {
  top: calc(var(--notification-top, 72px) + 40px);
  height: calc(100vh - var(--notification-top, 72px) - 40px);
}
.app-shell.has-notifications .header-command .block-line-popup {
  top: calc(100% + 62px);
  max-height: calc(100dvh - var(--notification-top, 72px) - 60px);
}
@media (max-width: 650px) {
  .notification-queue { top: var(--notification-top, 64px); padding-inline: 16px; }
  .app-shell.has-notifications .block-sidebar { top: calc(var(--notification-top, 64px) + 40px); height: auto; }
  .app-shell.has-notifications .header-command .block-line-popup {
    top: calc(var(--notification-top, 64px) + 46px);
    max-height: calc(100dvh - var(--notification-top, 64px) - 66px);
  }
}


.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 20px;
  align-items: center;
  min-height: 72px;
  padding: 0 28px;
  background: rgba(32, 56, 111, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
}


.topbar-navigation {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--sans);
  font-size: 18px;
}

.topbar-message {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-self: center;
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.02em;
}


.status-dot {
  width: 6px;
  height: 6px;
  background: #a8c7bd;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(168, 199, 189, 0.08);
}

.block-sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  padding: 34px 18px 24px;
  overflow: hidden;
  background: rgba(31, 65, 139, 0.23);
  border-right: 1px solid var(--line);
}

.block-navigation {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.block-navigation-button {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  overflow: hidden;
  color: var(--ink-muted);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
}

.block-navigation-button:hover,
.block-navigation-button[aria-current="location"] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

.document-outline-heading {
  padding: 0 13px 14px;
}

.document-outline-heading .eyebrow {
  margin: 0;
}

.document-outline-navigation {
  display: grid;
  gap: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.document-outline-button {
  width: 100%;
  min-height: 38px;
  padding: 7px 11px;
  overflow: hidden;
  color: var(--ink-muted);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
}

.document-outline-button.depth-2 {
  padding-left: 24px;
  font-size: 11px;
}

.document-outline-button.depth-3 {
  padding-left: 36px;
  color: var(--ink-faint);
  font-size: 10px;
}

.document-outline-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
}

.document-outline-button[aria-current="location"] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--cream);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.workspace {
  position: relative;
  min-width: 0;
  padding: 0 clamp(24px, 4vw, 64px) 28px;
}

.document-workspace {
  min-width: 0;
  height: auto;
  overflow: visible;
}


.document-content-editor {
  display: block;
  width: 100%;
  min-height: 200px;
  padding: 0;
  overflow: hidden;
  resize: none;
  color: var(--ink);
  caret-color: var(--cream);
  background: transparent;
  border: 0;
  outline: 0;
  font: 15px/1.5 var(--sans);
  tab-size: 2;
}

.document-content-editor:focus-visible {
  outline: 0;
  box-shadow: inset 3px 0 0 rgba(248, 244, 233, 0.42);
}

.document-content-editor::placeholder {
  color: var(--ink-faint);
  opacity: 0.72;
}

.document-view-controls button,
#block-full-edit-button {
  padding: 5px 9px;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
  cursor: pointer;
}


.document-view-controls {
  position: absolute;
  z-index: 10;
  top: 24px;
  left: -14px;
  display: flex;
  flex-direction: column;
  width: 28px;
  padding: 2px;
  gap: 2px;
  color: var(--ink-muted);
  cursor: pointer;
  background: var(--blue-950);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
}

.document-view-controls > span {
  min-height: 46px;
  padding: 5px 4px;
  border-radius: 5px;
  writing-mode: vertical-rl;
  font-size: 10px;
}

.document-view-controls[aria-pressed="false"] #page-preview-mode,
.document-view-controls[aria-pressed="true"] .document-edit-label {
  color: var(--ink);
  background: rgba(248, 244, 233, 0.12);
}


.document-preview-list {
  margin: 0;
  padding-left: 1.35em;
}

.document-preview-list li {
  margin: 0;
  padding-left: 0.15em;
}

.document-preview-list li::marker {
  color: var(--ink-muted);
}

.document-preview-spacer {
  height: 1.6em;
}

.document-preview-spacer + h2,
.document-preview-spacer + h3,
.document-preview-spacer + h4 {
  margin-top: 0;
}

.markdown-link {
  color: var(--ink);
  text-decoration-color: rgba(248, 244, 233, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.markdown-link:hover {
  text-decoration-color: currentColor;
}

.card-content :is(strong, b),
.page-text-line :is(strong, b),
.block-line-preview strong { color: var(--ink); font-weight: 700; }

.card-content code,
.page-text-line code,
.block-line-preview code {
  padding: 0.08em 0.3em;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.88em;
  overflow-wrap: anywhere;
}

.markdown-code {
  max-width: 100%;
  margin: 8px 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  tab-size: 2;
}

.markdown-code > code {
  padding: 0;
  border: 0;
  font-size: inherit;
  overflow-wrap: normal;
}

.markdown-file-reference { border-bottom: 1px dotted var(--line-strong); }
.markdown-file-reference code { font-size: 0.8em; color: var(--ink-faint); }

.markdown-table-scroll, .markdown-diagram {
  max-width: 100%;
  min-width: 0;
  margin: 10px 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.markdown-table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.5;
}

.markdown-table th, .markdown-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.markdown-table th { color: var(--ink); font-weight: 700; }
.markdown-align-left { text-align: left; }
.markdown-align-center { text-align: center; }
.markdown-align-right { text-align: right; }

.markdown-diagram svg {
  display: block;
  width: 100%;
  min-width: 640px;
  max-height: 500px;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 14px;
}

.markdown-diagram :is(path, rect, ellipse) { fill: none; stroke: currentColor; stroke-width: 1.4; }
.markdown-diagram .markdown-node { fill: var(--blue-800); }
.markdown-diagram text { fill: var(--ink); stroke: none; }
.markdown-diagram .markdown-edge-label { font-size: 11px; }

.card-content .markdown-link {
  color: inherit;
}

.title-page-link {
  display: inline-block;
  margin-left: 5px;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.85em;
  text-decoration: none;
}

.title-page-link:hover { color: var(--ink); text-decoration: underline; }

.block-tab-with-links {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.block-tab-link-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.block-tab-with-links .markdown-link { color: inherit; }
.block-tab-with-links .title-page-link { margin: 0; color: inherit; }
.block-tab-select {
  flex: 0 0 auto;
  padding: 0 3px;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 3px;
  font: inherit;
}

.collection {
  padding: 18px 0 26px;
}

.page-context {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 0;
}

.page-context-heading {
  flex: 1;
  min-width: 0;
  font-size: 15px;
}

.page-context-heading h2 {
  margin: 3px 0 0;
  font-family: var(--sans);
  font-size: 1em;
  font-weight: 400;
  line-height: 1.5;
}

#page-title[data-heading-depth="1"] { font-size: 1.5em; font-weight: 700; }
#page-title[data-heading-depth="2"] { font-size: 1.17em; font-weight: 700; }
#page-title[data-heading-depth="3"] { font-weight: 700; }

.title-edit-row {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.title-edit-row > :is(h1, h2) {
  min-width: 0;
  overflow-wrap: anywhere;
}


.title-edit-button {
  display: inline-grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 19px;
  line-height: 1;
}

.title-edit-button:hover,
.title-edit-button[aria-pressed="true"] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

.page-back-button {
  padding: 8px 11px;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.page-back-button {
  white-space: nowrap;
}

.back-history-button {
  align-self: stretch;
  margin-left: -14px;
  padding: 0 7px;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
}

.topbar-navigation:has(.back-history-button:not([hidden])) .page-back-button {
  border-radius: 8px 0 0 8px;
}

.back-history-menu {
  position: fixed;
  z-index: 65;
  width: min(320px, calc(100vw - 24px));
  max-height: min(60vh, 420px);
  padding: 5px;
  overflow-y: auto;
  color: var(--ink);
  background: var(--blue-950);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(13, 32, 82, 0.4);
}

.back-history-item {
  display: block;
  width: 100%;
  padding: 9px 11px;
  color: inherit;
  text-align: left;
  overflow-wrap: anywhere;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
}

.back-history-item:hover,
.back-history-item:focus-visible { background: var(--glass); border-color: var(--line); }

.page-text-line,
.inline-text-line {
  grid-column: 1 / -1;
  min-width: 0;
  min-height: 1.5em;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  position: relative;
  padding-left: 14px;
}

.inline-text-line.is-card-text { font-size: 13px; }

.text-line-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 12px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: grab;
}

.text-line-handle::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
}

:is(.page-text-line, .inline-text-line):hover > .text-line-handle::before,
.text-line-handle:focus-visible::before { background: var(--ink); }
.text-line-handle:active { cursor: grabbing; }
:is(.page-text-line, .inline-text-line).is-dragging { opacity: 0.45; }
:is(.page-text-line, .inline-text-line, .block-card, .embedded-block).is-drop-before { box-shadow: 0 -2px 0 var(--cream); }
:is(.page-text-line, .inline-text-line, .block-card, .embedded-block).is-drop-after { box-shadow: 0 2px 0 var(--cream); }

:is(.page-text-line, .inline-text-line) :is(h2, h3, h4, p, ul) { margin: 0; }
:is(.page-text-line, .inline-text-line) ul { padding-left: 1.3em; }

/* Long equations scroll inside their line instead of widening the page. */
.math-display,
.math-source {
  display: block;
  max-width: 100%;
  margin: 0.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.math-display math {
  display: block;
  width: max-content;
  margin-inline: auto;
  color: inherit;
  font-size: 1em;
}

.math-inline {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: -0.12em;
}

.math-inline math {
  color: inherit;
  font-size: 1em;
  white-space: nowrap;
}

.math-source {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.page-command-line {
  display: block;
  margin-bottom: 22px;
}

.page-line-area {
  position: relative;
}

.header-command {
  min-width: 0;
}

.page-command-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.is-quick-edit .page-command-fields {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.quick-edit-search {
  min-width: 0;
  border-left: 1px solid var(--line-strong);
}

.page-command-fields > label { min-width: 0; }

.header-command .page-command-line {
  margin: 0;
}

.header-command .page-command-line input {
  min-height: 40px;
  padding: 8px;
  font-size: 14px;
}

.block-line-popup {
  position: absolute;
  z-index: 15;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  min-height: min(60vh, 480px);
  max-height: min(calc(100dvh - 100px), 760px);
  overflow: hidden;
  color: var(--ink);
  background: rgba(20, 36, 76, 0.97);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 22px 60px rgba(13, 32, 82, 0.38);
  backdrop-filter: blur(10px);
}

.block-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.block-tab-button,
.block-tab-add {
  flex: 0 0 auto;
  max-width: 190px;
  min-height: 27px;
  padding: 4px 9px;
  overflow: hidden;
  color: var(--ink-muted);
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
  background: rgba(14, 36, 94, 0.22);
  border: 1px solid var(--line);
  border-radius: 11px 11px 6px 6px;
  font-size: 11px;
}

.block-tab-button:hover,
.block-tab-add:hover,
.block-tab-button[aria-pressed="true"],
.block-tab-button.is-active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--line-strong);
}

.block-tab-button[aria-pressed="true"],
.block-tab-button.is-active {
  color: var(--cream-ink);
  background: var(--cream);
  border-color: var(--cream);
}

.block-tab-add { font-size: 17px; line-height: 1; }
.quick-edit-tabs { flex: 0 0 auto; margin: 0 12px 6px; }
.page-tabs { flex: 1; min-width: 0; }

.block-line-popup-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 6px;
  font-size: 12px;
}

.block-line-popup-heading strong {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
}

.block-line-popup-heading [role="status"] {
  color: var(--ink-muted);
  font-size: 11px;
}

.block-line-list {
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
}

.block-line-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 20px;
  gap: 10px;
  min-height: 28px;
  align-items: start;
  padding: 3px 18px;
  cursor: pointer;
}

.block-line-insert {
  width: 20px;
  height: 20px;
  padding: 0;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  opacity: 0;
  cursor: pointer;
}

.block-line-row:hover .block-line-insert,
.block-line-row:focus-within .block-line-insert,
.block-line-insert:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .block-line-insert { opacity: 1; }
}

.block-line-row:first-child {
  padding-top: 8px;
  padding-bottom: 7px;
}

.block-line-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.block-line-row[aria-current="true"] {
  background: rgba(248, 244, 233, 0.11);
  box-shadow: inset 3px 0 0 var(--cream);
}

.block-line-number {
  padding-top: 2px;
  color: var(--ink-faint);
  font-size: 10px;
  text-align: right;
}

.block-line-preview {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.35;
}

.block-line-title {
  display: block;
  color: var(--ink);
  font-size: 1em;
  font-weight: 400;
  line-height: 1.35;
}

.block-line-block {
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 7px 9px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 400;
}

.block-line-block-icon {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.7;
}

.block-line-block-main { min-width: 0; flex: 1; }

.block-line-block-title { font-weight: 400; }
.block-line-block-title[data-heading-depth="1"] { font-size: 1.2em; font-weight: 700; }
.block-line-block-title[data-heading-depth="2"] { font-size: 1.1em; font-weight: 700; }
.block-line-block-title[data-heading-depth="3"] { font-weight: 700; }

.block-line-block-content {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.35;
}

.block-line-block-title + .block-line-block-content { margin-top: 3px; }
.block-line-child-reference { padding-left: 7px; border-left: 1px solid var(--line-strong); }
.block-line-child-missing { color: var(--ink-faint); font-size: 12px; }

.block-line-title[data-heading-depth="1"] { font-size: 1.5em; font-weight: 700; }
.block-line-title[data-heading-depth="2"] { font-size: 1.17em; font-weight: 700; }
.block-line-title[data-heading-depth="3"] { font-weight: 700; }

.block-line-preview :is(h2, h3, h4, p, ul) {
  margin: 0;
}

.block-line-preview h2 { font-size: 1.2em; }
.block-line-preview h3 { font-size: 1.1em; }
.block-line-preview h4 { font-size: 1em; }
.block-line-preview ul { padding-left: 1.3em; }

.block-line-blank {
  display: block;
  min-height: 1em;
}

.block-line-empty,
.block-line-help {
  color: var(--ink-muted);
  font-size: 11px;
}

.block-line-help {
  margin: 0;
  padding: 11px 18px;
}

.page-command-line input {
  width: 100%;
  min-height: 48px;
  padding: 8px 0;
  color: var(--ink);
  caret-color: var(--cream);
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: 0;
  font-family: var(--sans);
  font-size: 16px;
}

.page-command-line input::placeholder {
  color: var(--ink-muted);
}

.page-command-line input:focus {
  background: rgba(255, 255, 255, 0.035);
}

kbd {
  min-width: 21px;
  padding: 2px 6px;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: var(--sans);
  font-size: 10px;
  text-align: center;
}

.block-grid,
.inline-page-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.block-card,
.embedded-block {
  scroll-margin-top: 88px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  min-height: 40px;
  padding: 10px 14px;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 35px rgba(18, 41, 98, 0.1);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.block-card {
  min-width: 0;
  overflow: visible;
}

.block-card:hover {
  background: rgba(29, 65, 145, 0.27);
  border-color: var(--line-strong);
}

.block-card.is-selected {
  background: rgba(52, 94, 182, 0.42);
  border-color: var(--cream);
  box-shadow: 0 0 0 2px rgba(248, 244, 233, 0.24),
    0 12px 38px rgba(18, 41, 98, 0.2);
}

.block-card:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 3px;
}

.block-card.is-selected:focus-visible {
  outline: none;
}

.block-card.is-complete {
  opacity: 0.62;
}

.block-card.is-complete.is-selected {
  opacity: 0.9;
}

.block-card.is-complete .card-title-button {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.block-card.is-complete .block-tab-button.is-active,
.block-card.is-complete .block-tab-button[aria-pressed="true"] {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.card-delete-button {
  position: absolute;
  z-index: 2;
  top: -12px;
  left: -12px;
  display: grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  color: var(--ink-muted);
  background: var(--blue-950);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 140ms ease, color 140ms ease, background 140ms ease;
}

.block-card.is-selected > .card-delete-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.card-delete-button:hover,
.card-delete-button:focus-visible {
  color: var(--ink);
  background: var(--blue-800);
}

.card-title-row {
  margin: 0;
  padding-right: 28px;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.5;
}

.card-title-row.is-tabbed {
  display: flex;
  gap: 6px;
  align-items: center;
}

.card-title-row.is-tabbed .block-tabs { min-width: 0; }
.card-title-row.is-tabbed .block-tab-button { font-size: 13px; }
.page-tabs .block-tab-button { font-size: 15px; }

.card-title-row[data-heading-depth="1"] { color: var(--ink); font-size: 14px; font-weight: 650; }
.card-title-row[data-heading-depth="2"] { color: var(--ink); font-size: 13px; font-weight: 650; }
.card-title-row[data-heading-depth="3"] { font-size: 12px; font-weight: 650; }

.card-title-button {
  display: inline;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-decoration: none;
}

a.card-title-button:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.card-title-external-link {
  color: var(--ink-muted);
  white-space: nowrap;
  text-decoration: none;
}

.card-title-external-link:hover {
  color: var(--ink);
}

.card-title-arrow {
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.68em;
}

.markdown-todo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
  font-weight: inherit;
}

.markdown-todo input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--cream);
  cursor: pointer;
}

.markdown-todo > .markdown-todo-text {
  min-width: 0;
  overflow-wrap: anywhere;
  color: inherit;
  text-decoration: none;
}

.markdown-todo.is-checked > .markdown-todo-text {
  text-decoration: line-through;
  opacity: 0.7;
}

.card-content {
  display: block;
  flex: 1 1 auto;
  max-height: none;
  margin: 0;
  overflow: visible;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: unset;
}

.card-content:empty {
  display: none;
}

/* A paper's abstract must expand fully instead of being clipped as a card excerpt. */
.card-content:has(.paper-abstract),
.block-line-block-content:has(.paper-abstract) {
  display: block;
  max-height: none;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.block-card.is-shrunk > .card-content {
  display: -webkit-box;
  max-height: 9em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}

.block-size-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 4px;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10px;
}

/* Match inline titles that share the same 26px size control. */
.block-card:has(> .block-size-button) > .card-title-row { padding-right: 34px; min-height: 26px; }

.block-size-button:hover { color: var(--ink); border-color: var(--line-strong); }

.paper-abstract { margin-top: 5px; min-width: 0; }
.paper-abstract > summary { cursor: pointer; color: var(--ink-muted); }
.paper-abstract-content { padding: 6px 0 3px 16px; overflow-wrap: anywhere; }
.paper-abstract-content p { margin: 0 0 6px; }

.card-title-button:not(a) {
  display: inline;
}

.block-title-list {
  margin: 0;
  padding-left: 1.3em;
  text-align: left;
}

.card-preview-line,
.card-preview-heading,
.card-preview-empty {
  display: block;
  min-height: 1.5em;
}

.embedded-block {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  background: transparent;
  border: 0;
  border-left: 1px solid transparent;
  border-radius: 0;
  box-shadow: none;
  font-size: 16px;
  line-height: normal;
  overflow-wrap: anywhere;
}

.embedded-block-title {
  display: block;
  padding-right: 0;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-muted);
  text-decoration: none;
}

/* Only the first nested level gets a full outline. */
.embedded-block:not(.embedded-block .embedded-block) {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.embedded-block-title[data-heading-depth="1"] { color: var(--ink); font-size: 14px; font-weight: 650; }
.embedded-block-title[data-heading-depth="2"] { color: var(--ink); font-size: 13px; font-weight: 650; }
.embedded-block-title[data-heading-depth="3"] { font-size: 12px; font-weight: 650; }

a.embedded-block-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.embedded-block-content {
  min-width: 0;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
}

.embedded-block > .block-tabs .block-tab-button { font-size: 13px; line-height: 1.5; }

.embedded-block-missing {
  display: block;
  color: var(--ink-faint);
  font-style: italic;
}

.card-preview-heading {
  color: var(--ink);
  font-weight: 650;
}

.card-preview-heading.depth-1 {
  font-size: 14px;
}

.card-preview-heading.depth-2 {
  font-size: 13px;
}

.card-preview-heading.depth-3 {
  color: var(--ink-muted);
  font-size: 12px;
}

.card-preview-list {
  margin: 0;
  padding-left: 1.25em;
}

.card-preview-list li {
  min-height: 1.5em;
  padding-left: 0.1em;
}

.card-preview-list li::marker {
  color: var(--ink-faint);
}


.card-footer {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.topic-label {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.empty-state {
  padding: 66px 24px;
  color: var(--ink-muted);
  text-align: center;
  background: rgba(24, 54, 122, 0.13);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

.empty-state h3 {
  margin: 10px 0 7px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 28px;
  font-weight: 500;
}

.empty-state p {
  margin: 0 0 21px;
  font-family: var(--sans);
}

.empty-orbit {
  display: block;
  color: var(--ink-faint);
  font-size: 37px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 18px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(340px, calc(100vw - 48px));
  padding: 12px 16px;
  color: var(--cream-ink);
  background: var(--cream);
  border-radius: 10px;
  box-shadow: 0 14px 42px rgba(9, 27, 70, 0.38);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }


  .topbar-message {
    display: none;
  }


}

@media (max-width: 650px) {
  .app-shell {
    display: block;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    min-height: 64px;
    padding: 0 16px;
  }

  .brand {
    font-size: 19px;
  }

  .brand > span:last-child {
    display: inline;
  }


  .topbar-navigation {
    gap: 8px;
  }

  .back-history-button { margin-left: -6px; }

  .header-command .block-line-popup {
    position: fixed;
    top: 70px;
    right: 16px;
    left: 16px;
  }

  .topbar.is-quick-edit {
    padding-top: 8px;
    padding-bottom: 8px;
    row-gap: 4px;
  }

  .header-command.is-quick-edit { grid-column: 1 / -1; }
  .is-quick-edit .page-command-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .header-command.is-quick-edit .block-line-popup {
    top: 96px;
    max-height: calc(100dvh - 116px);
  }

  .brand {
    font-size: 16px;
  }

  .brand-mark {
    display: none;
  }


  .block-sidebar {
    position: sticky;
    z-index: 9;
    top: 64px;
    display: block;
    height: 54px;
    padding: 8px 16px;
    overflow: hidden;
    background: var(--blue-800);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .block-navigation {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .block-navigation::-webkit-scrollbar {
    display: none;
  }

  .block-navigation-button {
    flex: 0 0 auto;
    width: auto;
    max-width: 190px;
    min-height: 37px;
    padding: 0 11px;
    font-size: 11px;
  }

  .block-card {
    scroll-margin-top: 126px;
  }

  .document-outline-heading {
    display: none;
  }

  .document-outline-navigation {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .document-outline-navigation::-webkit-scrollbar {
    display: none;
  }

  .document-outline-button,
  .document-outline-button.depth-2,
  .document-outline-button.depth-3 {
    flex: 0 0 auto;
    width: auto;
    min-height: 37px;
    padding: 0 11px;
    font-size: 10px;
  }

  .document-outline-button[aria-current="location"] {
    box-shadow: inset 0 -2px 0 var(--cream);
  }


  .workspace {
    padding: 0 16px 24px;
  }

  .collection {
    padding-top: 18px;
  }

  .page-context {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .page-context-heading {
    flex-basis: calc(100% - 100px);
  }

  .block-line-popup {
    min-height: min(65vh, 520px);
    max-height: calc(100dvh - 90px);
  }

  .block-grid {
    grid-template-columns: 1fr;
  }

  .app-footer {
    gap: 8px;
    align-items: flex-start;
    flex-direction: column;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* One page shell in both modes: only the body changes from rendered rows to raw source. */
.block-sidebar {
  overflow-y: auto;
}

.block-navigation { flex: 0 0 auto; }

.block-sidebar .document-outline {
  position: static;
  height: auto;
  min-height: 0;
  padding: 18px 0 0;
  overflow: visible;
  background: transparent;
  border: 0;
}


.page-edit-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  color: var(--ink-muted);
  font-size: 11px;
}

.page-text-line { scroll-margin-top: 150px; }

@media (max-width: 650px) {
  .block-sidebar { height: auto; min-height: 54px; }
  .block-sidebar .document-outline { padding-top: 6px; }
  .page-context-heading { flex-basis: 0; }
  .workspace { padding-left: 64px; }
  .document-view-controls { left: 12px; top: 14px; }
}

.block-card[draggable="true"] { cursor: grab; }
.block-card.is-dragging { opacity: 0.45; }
.is-drop-target {
  outline: 2px dashed var(--cream) !important;
  outline-offset: 4px;
  background-color: rgba(248, 244, 233, 0.1);
}

.embedded-block { position: relative; overflow: visible; }
:is(.block-card, .embedded-block) > .block-size-button {
  top: 0;
  bottom: 0;
  left: -6.5px;
  right: auto;
  width: 12px;
  height: auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

/* Center both the invisible hit area and hover stroke on the 1px left border. */
:is(.block-card, .embedded-block) > .block-size-button::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  transform: translateX(-50%);
  width: 1px;
  background: transparent;
  transition: background 140ms ease;
}

:is(.block-card, .embedded-block) > .block-size-button:hover::before,
:is(.block-card, .embedded-block) > .block-size-button:focus-visible::before {
  width: 3px;
  background: var(--ink);
}

:is(.block-card, .embedded-block) > .block-size-button > svg { display: none; }

.block-card > .block-size-button {
  top: 12px;
  bottom: 12px;
}

.embedded-block:not(.embedded-block .embedded-block) > .block-size-button {
  top: 10px;
  bottom: 10px;
}

.embedded-block.is-shrunk > .embedded-block-content {
  display: -webkit-box;
  max-height: 9em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}

.quick-block-open {
  align-self: flex-start;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
}
.quick-block-open:hover { color: var(--ink); border-color: var(--line-strong); }

.embedded-block[draggable="true"],
.block-navigation-button[draggable="true"] { cursor: grab; }
.embedded-block.is-dragging,
.block-navigation-button.is-dragging { opacity: 0.45; }
.block-navigation-button.is-drop-before { box-shadow: inset 0 3px 0 var(--cream); }
.block-navigation-button.is-drop-after { box-shadow: inset 0 -3px 0 var(--cream); }
@media (max-width: 650px) {
  .block-navigation-button.is-drop-before { box-shadow: inset 3px 0 0 var(--cream); }
  .block-navigation-button.is-drop-after { box-shadow: inset -3px 0 0 var(--cream); }
}

.workspace-page-button {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  margin: 0 0 12px;
  padding: 7px 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 650 13px/1.4 var(--sans);
  text-align: left;
  cursor: pointer;
}
#workspace-page-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-page-button:hover,
.workspace-page-button[aria-expanded="true"] { background: rgba(255, 255, 255, 0.1); }

#workspace-page-menu { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.workspace-menu-panel {
  position: fixed;
  width: min(248px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 5px;
  color: var(--ink);
  background: var(--blue-950);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(10, 25, 60, 0.4);
  pointer-events: auto;
}
.workspace-menu-item,
.workspace-menu-back {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 3px 6px 3px 10px;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font: 12px/1.5 var(--sans);
  text-align: left;
  cursor: pointer;
}
.workspace-menu-item:hover,
.workspace-menu-item:focus-visible,
.workspace-menu-item[aria-expanded="true"],
.workspace-menu-back:hover,
.workspace-menu-back:focus-visible {
  outline: 0;
  color: var(--cream);
  background: rgba(248, 244, 233, 0.12);
  border-color: var(--line);
}
.workspace-menu-item[aria-current="page"] .workspace-menu-name { font-weight: 700; }
.workspace-menu-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-menu-arrow { display: grid; place-items: center; flex: 0 0 28px; height: 28px; font-size: 20px; }
.workspace-menu-back { color: var(--ink-muted); border-bottom-color: var(--line); margin-bottom: 4px; }
@media (max-width: 650px) {
  .workspace-page-button { margin-bottom: 6px; }
  .block-card, .page-text-line { scroll-margin-top: 224px; }
}

.workspace-menu-search {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 4px 8px;
  margin-bottom: 4px;
  background: var(--blue-950);
  border-bottom: 1px solid var(--line);
}
.workspace-menu-search input {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font: 12px/1.5 var(--sans);
}
.workspace-menu-search input::placeholder { color: var(--ink-faint); }
.workspace-menu-search-status { display: block; padding-top: 7px; color: var(--ink-muted); font-size: 11px; }
.workspace-menu-name > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-menu-page-path { color: var(--ink-faint); font-size: 10px; font-weight: 400; }

/* Prose supports native selection even inside a movable card. */
:is(.block-card, .embedded-block) :is(.page-text-line, .inline-text-line) { cursor: text; }

:is(.card-title-button, .embedded-block-title, .block-tab-button) {
  -webkit-user-select: text;
  user-select: text;
}

/* Blank space after a title belongs to its selectable text line. */
.card-title-row { cursor: text; }
