:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --paper-strong: #fffdf8;
  --canvas: #e9e6df;
  --ink: #20221d;
  --ink-soft: #565950;
  --muted: #8d8f86;
  --line: rgba(31, 34, 28, 0.12);
  --line-strong: rgba(31, 34, 28, 0.2);
  --moss: #5f6f52;
  --moss-dark: #43503b;
  --moss-soft: #e3e8dd;
  --gold: #d6b868;
  --warm: #f0ebe0;
  --danger: #9b4c42;
  --shadow-sm: 0 1px 2px rgba(22, 24, 20, 0.06), 0 8px 26px rgba(22, 24, 20, 0.05);
  --shadow-lg: 0 30px 80px rgba(30, 31, 28, 0.15), 0 4px 18px rgba(30, 31, 28, 0.08);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Baskerville", "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--moss);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 680px;
  overflow: hidden;
}

.global-header,
.admin-header {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 246, 240, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
}

.brand-mark::before {
  position: absolute;
  width: 21px;
  height: 21px;
  border: 1px solid rgba(52, 63, 45, 0.34);
  border-radius: 50%;
  content: "";
}

.brand-mark i {
  position: absolute;
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--moss);
}

.brand-mark i:first-child {
  transform: translate(-5px, 3px);
}

.brand-mark i:nth-child(2) {
  transform: translate(4px, -5px);
}

.brand-mark i:last-child {
  transform: translate(5px, 5px);
}

.brand-name {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.brand-tag {
  margin-left: 2px;
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.current-book {
  display: flex;
  align-items: center;
  gap: 10px;
}

.book-switcher {
  max-width: 270px;
  padding: 6px 24px 6px 8px;
  border: 0;
  border-radius: 8px;
  outline: 0;
  background-color: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}

.book-switcher:focus-visible {
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.18);
}

.book-meta {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions,
.admin-header nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.header-link,
.back-to-reader {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  transition: background 160ms ease, color 160ms ease;
}

.header-link:hover,
.back-to-reader:hover {
  background: rgba(95, 111, 82, 0.08);
  color: var(--moss-dark);
}

.header-link-icon {
  color: var(--moss);
  font-size: 16px;
  line-height: 1;
}

.icon-button,
.tool-button,
.quiet-icon,
.zoom-button,
.more-button {
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.icon-button:hover {
  background: rgba(32, 34, 29, 0.05);
}

.profile-dot {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(95, 111, 82, 0.3);
  border-radius: 50%;
  background: #dfe5d8;
  color: var(--moss-dark);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 7px minmax(360px, 440px);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.reader-pane {
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--canvas);
}

.reader-toolbar {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 13px;
  border-bottom: 1px solid rgba(32, 34, 29, 0.1);
  background: rgba(248, 247, 243, 0.92);
  backdrop-filter: blur(14px);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-end {
  justify-content: flex-end;
}

.tool-button,
.zoom-button,
.quiet-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #6e7168;
  transition: background 140ms ease, color 140ms ease;
}

.tool-button:hover,
.zoom-button:hover,
.quiet-icon:hover,
.tool-button.active {
  background: rgba(95, 111, 82, 0.1);
  color: var(--moss-dark);
}

.expand-icon,
.note-icon,
.concept-map-icon {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
}

.expand-icon::before,
.expand-icon::after {
  position: absolute;
  width: 5px;
  height: 5px;
  border-color: currentColor;
  border-style: solid;
  content: "";
}

.expand-icon::before {
  top: 1px;
  left: 1px;
  border-width: 1px 0 0 1px;
}

.expand-icon::after {
  right: 1px;
  bottom: 1px;
  border-width: 0 1px 1px 0;
}

.note-tool-button {
  position: relative;
}

.note-icon {
  width: 12px;
  height: 14px;
  border: 1px solid currentColor;
  border-radius: 2px;
}

.note-icon::after {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 4px;
  height: 4px;
  border-top: 1px solid currentColor;
  border-left: 1px solid currentColor;
  background: #f3f1eb;
  content: "";
}

.concept-map-icon::before,
.concept-map-icon::after {
  position: absolute;
  top: 6px;
  left: 1px;
  width: 12px;
  height: 1px;
  background: currentColor;
  content: "";
  transform: rotate(28deg);
  transform-origin: center;
}

.concept-map-icon::after {
  transform: rotate(-28deg);
}

.concept-map-icon i {
  position: absolute;
  z-index: 1;
  width: 4px;
  height: 4px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #f3f1eb;
}

.concept-map-icon i:first-child {
  top: 0;
  left: 5px;
}

.concept-map-icon i:nth-child(2) {
  top: 5px;
  left: 0;
}

.concept-map-icon i:nth-child(3) {
  top: 5px;
  right: 0;
}

.concept-map-icon i:last-child {
  right: 5px;
  bottom: 0;
}

.tool-count {
  position: absolute;
  top: 1px;
  right: 0;
  display: grid;
  min-width: 13px;
  height: 13px;
  place-items: center;
  padding: 0 3px;
  border: 1.5px solid #f6f4ee;
  border-radius: 99px;
  background: var(--moss);
  color: white;
  font-size: 6.5px;
  font-weight: 780;
  line-height: 1;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

.scroll-mode-icon {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid rgba(95, 111, 82, 0.2);
  border-radius: 6px;
  background: rgba(95, 111, 82, 0.07);
  color: var(--moss);
  font-size: 11px;
  font-weight: 750;
}

.scroll-mode-label {
  margin-left: 2px;
  color: #9a9c94;
  font-size: 8px;
  font-weight: 610;
  letter-spacing: 0.02em;
}

.page-input-wrap {
  display: inline-flex;
  width: 41px;
  height: 26px;
}

.page-input-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  text-align: center;
  font-size: 10px;
  font-weight: 670;
}

.page-input-wrap input:focus {
  border-color: rgba(95, 111, 82, 0.5);
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.11);
}

.page-total {
  min-width: 33px;
}

.zoom-label {
  min-width: 34px;
  color: var(--ink-soft);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.toolbar-separator {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--line);
}

.reader-body {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.reader-stage {
  position: absolute;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 36px 50px 70px;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.55), transparent 40%),
    linear-gradient(135deg, #e6e3dc 0%, #eeebe4 52%, #e4e1da 100%);
  scrollbar-color: rgba(82, 84, 77, 0.24) transparent;
  scrollbar-width: thin;
  transition: left 220ms cubic-bezier(.22,.72,.23,1),
    right 220ms cubic-bezier(.22,.72,.23,1),
    padding 220ms ease;
}

.reader-body.notes-open .reader-stage {
  left: 310px;
  padding-right: 22px;
  padding-left: 22px;
}

.reader-body.passage-tools-open .reader-stage {
  right: 340px;
  padding-right: 22px;
  padding-left: 22px;
}

.reader-body.notes-open .page-canvas,
.reader-body.passage-tools-open .page-canvas {
  width: min(calc(612px * var(--page-zoom)), calc(100% - 20px));
  min-width: 0;
}

.reader-stage:focus-visible {
  outline: 2px solid rgba(95, 111, 82, 0.35);
  outline-offset: -2px;
}

.continuous-document {
  display: flex;
  width: 100%;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  gap: 34px;
}

.document-page {
  position: relative;
  display: grid;
  width: 100%;
  justify-items: center;
  scroll-margin-top: 24px;
}

.page-canvas {
  position: relative;
  width: calc(612px * var(--page-zoom));
  min-width: 390px;
  margin: 0 auto;
  background: #fff;
  transition: width 180ms ease;
}

.page-canvas img {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1px;
  box-shadow: var(--shadow-lg);
  user-select: none;
}

.paper-shadow {
  position: absolute;
  z-index: 1;
  inset: 7px -7px -10px 8px;
  border-radius: 2px;
  background: rgba(110, 106, 96, 0.12);
  filter: blur(10px);
}

.highlight-layer {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
}

.passage-layer,
.note-layer {
  position: absolute;
  z-index: 6;
  inset: 0;
  pointer-events: none;
}

.note-layer {
  z-index: 7;
}

.passage-hit {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 2px;
  outline: 0;
  background: transparent;
  cursor: text;
  pointer-events: auto;
  touch-action: pan-y;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.passage-hit.hovered,
.passage-hit:focus-visible {
  background: rgba(95, 111, 82, 0.09);
  box-shadow: inset 0 -1px 0 rgba(95, 111, 82, 0.34);
}

.note-marker {
  position: absolute;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  border: 2px solid rgba(255, 253, 248, 0.96);
  border-radius: 50% 50% 50% 4px;
  outline: 0;
  background: #d3a93d;
  box-shadow: 0 5px 14px rgba(95, 75, 22, 0.24);
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-8%, -38%);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.note-marker span {
  width: 6px;
  height: 7px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 1px;
}

.note-marker:hover,
.note-marker:focus-visible {
  box-shadow: 0 7px 18px rgba(95, 75, 22, 0.34);
  transform: translate(-8%, -38%) scale(1.12);
}

.source-highlight {
  position: absolute;
  border-radius: 2px;
  background: rgba(233, 197, 81, 0.34);
  box-shadow: inset 0 -1px 0 rgba(176, 133, 31, 0.28);
  mix-blend-mode: multiply;
  transform-origin: center;
}

.source-highlight.pulse {
  animation: passage-pulse 1.3s ease-out;
}

@keyframes passage-pulse {
  0% {
    background: rgba(233, 197, 81, 0.12);
    transform: scaleY(0.6);
  }
  35% {
    background: rgba(233, 197, 81, 0.55);
    transform: scaleY(1.05);
  }
  100% {
    background: rgba(233, 197, 81, 0.34);
    transform: scaleY(1);
  }
}

.page-loading {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: none;
  place-items: center;
  gap: 5px;
  background: rgba(255, 253, 248, 0.78);
  backdrop-filter: blur(3px);
}

.page-loading.show {
  display: flex;
}

.page-loading span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  animation: dot-breathe 1s ease-in-out infinite;
}

.page-loading span:nth-child(2) {
  animation-delay: 120ms;
}

.page-loading span:nth-child(3) {
  animation-delay: 240ms;
}

.document-loading {
  display: flex;
  min-height: 360px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--muted);
}

.document-loading span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  animation: dot-breathe 1s ease-in-out infinite;
}

.document-loading span:nth-child(2) {
  animation-delay: 120ms;
}

.document-loading span:nth-child(3) {
  animation-delay: 240ms;
}

.document-loading p {
  margin: 0 0 0 7px;
  font-size: 9px;
}

@keyframes dot-breathe {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

.floating-page-label {
  position: absolute;
  z-index: 10;
  bottom: 15px;
  left: 50%;
  width: max-content;
  min-width: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(50, 52, 47, 0.8);
  box-shadow: 0 8px 20px rgba(30, 31, 28, 0.16);
  color: white;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.notes-panel {
  position: absolute;
  z-index: 22;
  top: 0;
  bottom: 0;
  left: 0;
  width: 310px;
  padding: 18px 15px 16px;
  border-right: 1px solid rgba(31, 34, 28, 0.12);
  background:
    linear-gradient(rgba(250, 248, 242, 0.98), rgba(246, 243, 235, 0.98)),
    radial-gradient(circle at 0 0, rgba(214, 184, 104, 0.14), transparent 40%);
  box-shadow: 20px 0 52px rgba(34, 35, 31, 0.1);
  transform: translateX(-102%);
  transition: transform 240ms cubic-bezier(.22,.72,.23,1);
  backdrop-filter: blur(18px);
}

.notes-panel.open {
  transform: translateX(0);
}

.concept-map-panel {
  position: fixed;
  z-index: 80;
  top: 76px;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: grid;
  min-width: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(49, 53, 45, 0.13);
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 20%, rgba(214, 184, 104, 0.12), transparent 28%),
    linear-gradient(145deg, rgba(255, 254, 250, 0.99), rgba(246, 244, 237, 0.99));
  box-shadow: 0 30px 80px rgba(30, 32, 28, 0.2), 0 4px 16px rgba(30, 32, 28, 0.08);
  animation: concept-map-in 220ms cubic-bezier(.2,.78,.24,1) both;
  backdrop-filter: blur(22px);
}

@keyframes concept-map-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.concept-map-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 13px 17px 12px 22px;
  border-bottom: 1px solid rgba(49, 53, 45, 0.1);
  background: rgba(251, 249, 243, 0.9);
}

.concept-map-header .eyebrow {
  margin-bottom: 5px;
  font-size: 7px;
}

.concept-map-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1;
  letter-spacing: -0.025em;
}

.concept-map-header p:not(.eyebrow) {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.concept-map-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.concept-map-zoom {
  display: flex;
  height: 31px;
  align-items: center;
  padding: 2px;
  border: 1px solid rgba(49, 53, 45, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
}

.concept-map-zoom button,
.concept-map-header-actions .concept-map-close {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.concept-map-zoom button:hover,
.concept-map-header-actions .concept-map-close:hover {
  background: rgba(32, 34, 29, 0.08);
  color: var(--ink);
}

.concept-map-zoom span {
  min-width: 42px;
  color: var(--ink-soft);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.concept-map-zoom .concept-fit-button {
  width: auto;
  min-width: 39px;
  padding: 0 8px;
  border-left: 1px solid rgba(49, 53, 45, 0.08);
  border-radius: 0 7px 7px 0;
  color: var(--moss-dark);
  font-size: 7px;
  font-weight: 740;
  text-transform: uppercase;
}

.concept-map-grounding {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 99px;
  background: rgba(95, 111, 82, 0.09);
  color: var(--moss-dark);
  font-size: 7px;
  font-weight: 740;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.concept-map-grounding::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  content: "";
}

.concept-map-header-actions .concept-map-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(32, 34, 29, 0.06);
}

.concept-map-layout {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) 330px;
}

.concept-map-canvas {
  position: relative;
  min-width: 0;
  min-height: 520px;
  overflow: hidden;
  border-right: 1px solid rgba(49, 53, 45, 0.1);
  outline: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(214, 184, 104, 0.09), transparent 27%),
    radial-gradient(rgba(95, 111, 82, 0.16) .75px, transparent .75px);
  background-size: auto, 18px 18px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.concept-map-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(95, 111, 82, 0.3);
}

.concept-map-canvas.dragging {
  cursor: grabbing;
}

.concept-map-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.concept-map-clusters,
.concept-map-edges,
.concept-map-nodes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.concept-map-clusters {
  z-index: 0;
  pointer-events: none;
}

.concept-cluster {
  position: absolute;
  border: 1px solid rgba(49, 53, 45, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.2);
}

.concept-cluster > span {
  position: absolute;
  top: 17px;
  left: 20px;
  color: rgba(63, 67, 58, 0.58);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.concept-cluster.category-foundations { background: rgba(214, 184, 104, 0.055); }
.concept-cluster.category-algorithm { background: rgba(95, 111, 82, 0.05); }
.concept-cluster.category-outputs { background: rgba(91, 112, 126, 0.05); }
.concept-cluster.category-practice { background: rgba(122, 102, 126, 0.045); }

.concept-map-edges {
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.relation-structure { --relation-color: #6d7568; }
.relation-step { --relation-color: #647c54; }
.relation-flow { --relation-color: #52758c; }
.relation-example { --relation-color: #8b6d9a; }
.relation-implementation { --relation-color: #a17439; }
.relation-constraint { --relation-color: #9b6763; }

.concept-edge-paths > path[data-source] {
  fill: none;
  stroke: var(--relation-color, #6d7568);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .68;
  transition: opacity 160ms ease, stroke 160ms ease, stroke-width 160ms ease;
}

.concept-edge-paths > path[data-source].active {
  stroke-width: 2.6;
  opacity: 1;
}

.concept-map-edges marker path {
  fill: context-stroke;
}

.concept-edge-paths [data-source].muted {
  opacity: .25;
}

.concept-edge-label.muted {
  opacity: .58;
}

.concept-edge-label rect {
  fill: rgba(250, 248, 242, 0.96);
  stroke: rgba(49, 53, 45, 0.13);
}

.concept-edge-label text {
  fill: #55594f;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 690;
  letter-spacing: .01em;
}

.concept-edge-label circle {
  fill: var(--relation-color, #6d7568);
}

.concept-label-leader {
  stroke: var(--relation-color, #6d7568);
  stroke-width: 1;
  stroke-opacity: .42;
}

.concept-edge-label.active rect {
  fill: #fffef8;
  stroke: var(--relation-color, #6d7568);
  stroke-opacity: .42;
}

.concept-edge-label.active text {
  fill: var(--moss-dark);
}

.concept-map-nodes {
  z-index: 2;
  pointer-events: none;
}

.concept-node {
  position: absolute;
  display: grid;
  width: 178px;
  height: 76px;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px 11px 12px 10px;
  border: 1px solid rgba(49, 53, 45, 0.15);
  border-top: 3px solid rgba(95, 111, 82, 0.46);
  border-radius: 16px;
  background: rgba(255, 254, 249, 0.97);
  box-shadow: 0 9px 24px rgba(43, 46, 39, 0.09);
  text-align: left;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transform: translate(-50%, -50%);
  transition: border-color 150ms ease, box-shadow 150ms ease,
    transform 150ms ease, background 150ms ease;
}

.concept-node:hover,
.concept-node.selected {
  border-color: rgba(95, 111, 82, 0.43);
  background: #fffef9;
  box-shadow: 0 10px 26px rgba(43, 46, 39, 0.12);
  transform: translate(-50%, -50%);
}

.concept-node.dragging {
  z-index: 6;
  cursor: grabbing;
  outline: 4px solid rgba(95, 111, 82, 0.16);
  box-shadow: 0 18px 40px rgba(43, 46, 39, 0.2);
  transition: none;
}

.concept-node.selected {
  z-index: 4;
  outline: 4px solid rgba(95, 111, 82, 0.11);
}

.concept-node.connected {
  border-color: rgba(95, 111, 82, 0.38);
  box-shadow: 0 9px 26px rgba(54, 64, 47, 0.13);
}

.concept-node.core {
  width: 222px;
  height: 96px;
  border-color: rgba(67, 80, 59, 0.42);
  border-top-color: rgba(255, 255, 255, 0.58);
  background: linear-gradient(145deg, #526149, #43503b);
  box-shadow: 0 14px 32px rgba(48, 58, 42, 0.21);
  color: #fffdf8;
}

.concept-node.core:hover,
.concept-node.core.selected {
  border-color: rgba(255, 255, 255, 0.72);
  background: linear-gradient(145deg, #5d6e53, #43503b);
  box-shadow: 0 16px 36px rgba(48, 58, 42, 0.28);
}

.concept-node-number {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: rgba(95, 111, 82, 0.1);
  color: var(--moss-dark);
  font-size: 8px;
  font-weight: 780;
}

.concept-node.core .concept-node-number {
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.88);
}

.concept-node-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.concept-node-copy small {
  overflow: hidden;
  color: var(--moss);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.concept-node.core .concept-node-copy small {
  color: rgba(255, 255, 255, 0.62);
}

.concept-node-copy strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.concept-node-page {
  color: var(--muted);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.concept-node.core .concept-node-page {
  color: rgba(255, 255, 255, 0.56);
}

.concept-node.category-foundations { border-top-color: rgba(181, 142, 52, 0.62); }
.concept-node.category-algorithm { border-top-color: rgba(95, 111, 82, 0.72); }
.concept-node.category-outputs { border-top-color: rgba(79, 108, 123, 0.62); }
.concept-node.category-practice { border-top-color: rgba(119, 88, 123, 0.54); }

.concept-edge-legend {
  position: absolute;
  z-index: 8;
  top: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 13px;
  max-width: calc(100% - 28px);
  padding: 9px 12px;
  border: 1px solid rgba(49, 53, 45, 0.08);
  border-radius: 12px;
  background: rgba(251, 249, 243, 0.92);
  backdrop-filter: blur(12px);
}

.concept-edge-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 8px;
}

.concept-edge-legend i {
  width: 15px;
  height: 2px;
  border-radius: 2px;
  background: var(--relation-color, #6d7568);
}

.concept-map-legend {
  position: absolute;
  z-index: 8;
  bottom: 13px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  max-width: calc(100% - 260px);
  padding: 7px 10px;
  border: 1px solid rgba(49, 53, 45, 0.09);
  border-radius: 10px;
  background: rgba(251, 249, 243, 0.9);
  backdrop-filter: blur(12px);
}

.concept-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
  font-size: 7px;
}

.concept-map-legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moss);
}

.concept-map-legend .category-foundations i { background: #b58e34; }
.concept-map-legend .category-algorithm i { background: var(--moss); }
.concept-map-legend .category-outputs i { background: #4f6c7b; }
.concept-map-legend .category-practice i { background: #77587b; }

.concept-map-hint {
  position: absolute;
  z-index: 8;
  right: 14px;
  bottom: 14px;
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(251, 249, 243, 0.88);
  color: var(--muted);
  font-size: 7px;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.concept-map-loading {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.concept-map-loading > span {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.concept-map-loading i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  animation: thinking-bounce 900ms ease-in-out infinite;
}

.concept-map-loading i:nth-child(2) { animation-delay: 120ms; }
.concept-map-loading i:nth-child(3) { animation-delay: 240ms; }

.concept-map-loading strong {
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 16px;
}

.concept-map-loading p {
  max-width: 260px;
  margin: 0;
  line-height: 1.5;
}

.concept-map-detail {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow-y: auto;
  padding: 23px 22px 20px;
  background: rgba(249, 247, 241, 0.72);
  scrollbar-width: thin;
}

.concept-map-detail > * {
  flex-shrink: 0;
}

.concept-detail-index {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  margin-bottom: 12px;
  border: 1px solid rgba(95, 111, 82, 0.22);
  border-radius: 50%;
  color: var(--moss);
  font-family: var(--serif);
  font-size: 11px;
}

.concept-detail-kind {
  margin: 0 0 6px;
  color: var(--moss);
  font-size: 7px;
  font-weight: 780;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.concept-map-detail h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.concept-detail-summary {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.58;
}

.concept-map-detail blockquote {
  position: relative;
  max-height: 110px;
  margin: 18px 0 16px;
  overflow: auto;
  padding: 0 0 0 15px;
  border-left: 2px solid rgba(214, 184, 104, 0.62);
  color: #56564f;
  font-family: var(--serif);
  font-size: 9.5px;
  line-height: 1.55;
  scrollbar-width: thin;
}

.concept-detail-relations {
  margin: 21px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(49, 53, 45, 0.1);
}

.concept-detail-relations h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 7px;
  font-weight: 760;
  letter-spacing: .09em;
  text-transform: uppercase;
}

#concept-detail-relations {
  display: grid;
  gap: 5px;
}

.concept-relation {
  display: grid;
  grid-template-columns: 15px auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(95, 111, 82, 0.065);
}

.concept-relation > span {
  color: var(--relation-color, var(--moss));
  font-size: 10px;
}

.concept-relation-copy {
  display: grid;
  gap: 2px;
}

.concept-relation-copy em {
  color: var(--muted);
  font-size: 6px;
  font-style: normal;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.concept-relation strong {
  color: var(--moss-dark);
  font-size: 8px;
}

.concept-relation small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.concept-detail-source {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(49, 53, 45, 0.1);
}

.concept-detail-source span {
  color: var(--muted);
  font-size: 7px;
  line-height: 1.4;
}

.concept-detail-source strong {
  flex: 0 0 auto;
  color: var(--moss-dark);
  font-size: 8px;
}

.concept-detail-actions {
  display: grid;
  gap: 7px;
  margin-top: 13px;
}

.concept-detail-actions button {
  min-height: 35px;
  border: 0;
  border-radius: 9px;
  font-size: 8px;
  font-weight: 720;
  cursor: pointer;
}

.concept-detail-actions button:disabled {
  opacity: .45;
  cursor: default;
}

.concept-open-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--moss-dark);
  color: #fff;
}

.concept-open-source:hover:not(:disabled) {
  background: #374331;
}

.concept-ask {
  background: rgba(95, 111, 82, 0.09);
  color: var(--moss-dark);
}

.concept-ask:hover:not(:disabled) {
  background: rgba(95, 111, 82, 0.15);
}

.notes-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2px 5px 5px;
}

.notes-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1;
}

.notes-heading .eyebrow {
  margin-bottom: 7px;
  font-size: 7.5px;
}

.notes-heading button,
.passage-tools-head button {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(32, 34, 29, 0.06);
  color: var(--muted);
  cursor: pointer;
}

.notes-heading button:hover,
.passage-tools-head button:hover {
  background: rgba(32, 34, 29, 0.1);
  color: var(--ink);
}

.notes-intro {
  margin: 10px 5px 15px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.notes-list {
  display: grid;
  max-height: calc(100% - 98px);
  gap: 9px;
  overflow-y: auto;
  padding: 1px 3px 20px;
  scrollbar-color: rgba(82, 84, 77, 0.2) transparent;
  scrollbar-width: thin;
}

.notes-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  padding: 28px;
  border: 1px dashed rgba(95, 111, 82, 0.2);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.notes-empty strong {
  margin: 12px 0 5px;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 15px;
}

.notes-empty p {
  margin: 0;
  font-size: 9px;
  line-height: 1.55;
}

.empty-note-mark {
  position: relative;
  width: 24px;
  height: 29px;
  border: 1px solid rgba(95, 111, 82, 0.46);
  border-radius: 4px;
}

.empty-note-mark::after {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-top: 1px solid rgba(95, 111, 82, 0.46);
  border-left: 1px solid rgba(95, 111, 82, 0.46);
  background: #f8f5ed;
  content: "";
}

.note-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(101, 91, 55, 0.14);
  border-radius: 14px;
  background: rgba(255, 253, 246, 0.86);
  box-shadow: 0 6px 22px rgba(57, 51, 35, 0.045);
}

.note-open {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 5px 34px 13px 13px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.note-open:hover {
  background: rgba(214, 184, 104, 0.08);
}

.note-card-meta {
  display: flex;
  min-height: 29px;
  align-items: center;
  gap: 7px;
  padding: 8px 35px 0 13px;
  color: #987a2f;
  font-size: 7px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.note-card-meta > span + span::before {
  margin-right: 7px;
  color: rgba(152, 122, 47, 0.42);
  content: "·";
}

.note-origin {
  padding: 2px 5px;
  border: 0;
  border-radius: 5px;
  background: rgba(95, 111, 82, 0.1);
  color: var(--moss-dark);
  font-size: 7px;
  font-weight: 780;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.note-origin:hover {
  background: var(--moss-soft);
}

.note-open strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-open p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.note-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #a19d91;
  cursor: pointer;
}

.note-delete:hover {
  background: rgba(155, 76, 66, 0.1);
  color: var(--danger);
}

.passage-tools {
  position: absolute;
  z-index: 28;
  top: 0 !important;
  right: 0;
  bottom: 0;
  left: auto !important;
  width: 340px;
  max-height: none;
  overflow: auto;
  border: 0;
  border-left: 1px solid rgba(49, 53, 45, 0.14);
  border-radius: 0;
  background:
    linear-gradient(145deg, rgba(255, 254, 250, 0.99), rgba(247, 244, 236, 0.99)),
    radial-gradient(circle at 100% 0, rgba(95, 111, 82, 0.12), transparent 44%);
  box-shadow: -18px 0 46px rgba(30, 32, 28, 0.1);
  animation: passage-tools-in 190ms cubic-bezier(.2,.78,.24,1) both;
  backdrop-filter: blur(22px);
  scrollbar-color: rgba(82, 84, 77, 0.2) transparent;
  scrollbar-width: thin;
}

@keyframes passage-tools-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.passage-tools-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 14px 0;
}

.passage-tools-head > div {
  display: grid;
  gap: 3px;
}

.selection-kicker,
.selection-answer-label {
  color: var(--moss);
  font-size: 7px;
  font-weight: 780;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.passage-tools-head strong {
  color: var(--ink-soft);
  font-size: 10px;
}

.selection-excerpt {
  display: -webkit-box;
  margin: 11px 14px 12px;
  overflow: hidden;
  color: #4c4e47;
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.selection-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 0 14px 13px;
}

.selection-actions button {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(95, 111, 82, 0.16);
  border-radius: 10px;
  background: rgba(95, 111, 82, 0.06);
  color: var(--moss-dark);
  font-size: 9px;
  font-weight: 720;
  cursor: pointer;
}

.selection-actions .selection-primary {
  border-color: var(--moss-dark);
  background: var(--moss-dark);
  color: white;
}

.selection-actions button:hover {
  transform: translateY(-1px);
}

.selection-actions button:disabled,
.selection-footer button:disabled {
  cursor: wait;
  opacity: 0.56;
  transform: none;
}

.selection-question-form {
  padding: 0 14px 13px;
}

.selection-question-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 670;
}

.selection-question-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 31px;
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(95, 111, 82, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
}

.selection-question-form textarea {
  width: 100%;
  min-height: 42px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 10px;
  line-height: 1.45;
}

.selection-question-form button {
  align-self: end;
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 9px;
  background: var(--moss);
  color: white;
  cursor: pointer;
}

.selection-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 13px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(95, 111, 82, 0.055);
  color: var(--muted);
  font-size: 8.5px;
}

.selection-thinking > span {
  display: inline-flex;
  gap: 3px;
}

.selection-thinking i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--moss);
  animation: dot-breathe 1s ease-in-out infinite;
}

.selection-thinking i:nth-child(2) { animation-delay: 100ms; }
.selection-thinking i:nth-child(3) { animation-delay: 200ms; }

.selection-answer {
  margin: 0 14px 13px;
  padding: 12px;
  border: 1px solid rgba(95, 111, 82, 0.13);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.66);
}

.selection-answer h4 {
  margin: 5px 0 8px;
  font-family: var(--serif);
  font-size: 15px;
}

.selection-answer p {
  margin: 0 0 9px;
  color: #42443e;
  font-size: 10px;
  line-height: 1.62;
}

.selection-answer p:last-child {
  margin-bottom: 0;
}

.selection-answer button {
  display: inline-flex;
  height: 17px;
  align-items: center;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px solid rgba(95, 111, 82, 0.2);
  border-radius: 5px;
  background: var(--moss-soft);
  color: var(--moss-dark);
  font-size: 6.5px;
  font-weight: 740;
  cursor: pointer;
}

.selection-answer mjx-container {
  max-width: 100%;
  overflow-x: auto;
}

.selection-footer {
  padding: 10px 14px 13px;
  border-top: 1px solid rgba(31, 34, 28, 0.09);
}

.saved-note-view {
  margin: 2px 14px 16px;
  padding: 14px;
  border: 1px solid rgba(101, 91, 55, 0.15);
  border-radius: 14px;
  background: rgba(255, 253, 246, 0.88);
  box-shadow: 0 8px 26px rgba(57, 51, 35, 0.05);
}

.saved-note-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.saved-note-view-head > span {
  color: #987a2f;
  font-size: 7px;
  font-weight: 780;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.saved-note-view-head button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(95, 111, 82, 0.14);
  border-radius: 50%;
  background: rgba(95, 111, 82, 0.06);
  color: var(--moss-dark);
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.saved-note-view-head button:hover {
  background: var(--moss-soft);
  transform: translateY(-1px);
}

.pencil-icon {
  position: relative;
  display: block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-42deg);
}

.pencil-icon::before {
  position: absolute;
  top: 0;
  left: -3px;
  border-top: 1.5px solid transparent;
  border-right: 3px solid currentColor;
  border-bottom: 1.5px solid transparent;
  content: "";
}

.pencil-icon::after {
  position: absolute;
  top: 0;
  right: -2px;
  width: 2px;
  height: 3px;
  border-radius: 0 1px 1px 0;
  background: rgba(95, 111, 82, 0.45);
  content: "";
}

.saved-note-view h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.25;
}

.saved-note-view-body {
  color: #42443e;
  font-size: 10px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.saved-note-view-body p {
  margin: 0 0 10px;
}

.saved-note-view-body p:last-child {
  margin-bottom: 0;
}

.saved-note-view-body mjx-container {
  max-width: 100%;
  overflow-x: auto;
}

.note-editor {
  display: grid;
  gap: 7px;
  padding: 2px 14px 16px;
}

.note-editor label {
  color: var(--muted);
  font-size: 7.5px;
  font-weight: 720;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.note-editor input,
.note-editor textarea {
  width: 100%;
  border: 1px solid rgba(95, 111, 82, 0.17);
  border-radius: 10px;
  outline: 0;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.note-editor input {
  height: 36px;
  padding: 0 10px;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
}

.note-editor textarea {
  min-height: 190px;
  padding: 10px;
  resize: vertical;
  font-size: 10px;
  line-height: 1.62;
}

.note-editor input:focus,
.note-editor textarea:focus {
  border-color: rgba(95, 111, 82, 0.52);
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.09);
}

.note-editor-actions {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.note-editor-actions span {
  color: var(--muted);
  font-size: 7.5px;
}

.note-editor-actions button {
  height: 32px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: var(--moss-dark);
  color: white;
  font-size: 8.5px;
  font-weight: 730;
  cursor: pointer;
}

.note-editor-actions > div {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.note-editor-actions .note-cancel-button {
  border: 1px solid rgba(95, 111, 82, 0.15);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink-soft);
}

.note-editor-actions .note-delete-button {
  border: 1px solid rgba(155, 76, 66, 0.18);
  background: rgba(155, 76, 66, 0.07);
  color: var(--danger);
}

.note-editor-actions .note-cancel-button:hover {
  background: white;
}

.note-editor-actions .note-delete-button:hover {
  background: rgba(155, 76, 66, 0.12);
}

.note-editor-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.note-return-focus {
  border-radius: 10px;
  animation: note-return-pulse 1.8s ease-out;
}

@keyframes note-return-pulse {
  0%, 28% {
    background: rgba(214, 184, 104, 0.25);
    box-shadow: 0 0 0 6px rgba(214, 184, 104, 0.1);
  }
  100% {
    background: transparent;
    box-shadow: 0 0 0 0 transparent;
  }
}

.selection-footer button,
.claim-note-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #89702f;
  font-size: 8px;
  font-weight: 720;
  cursor: pointer;
}

.mini-note-icon {
  position: relative;
  display: inline-block;
  width: 9px;
  height: 11px;
  border: 1px solid currentColor;
  border-radius: 1px;
}

.mini-note-icon::after {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 3px;
  height: 3px;
  border-top: 1px solid currentColor;
  border-left: 1px solid currentColor;
  background: #f8f5ed;
  content: "";
}

.panel-resizer {
  position: relative;
  z-index: 16;
  width: 7px;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(33, 35, 29, 0.08);
  border-left: 1px solid rgba(33, 35, 29, 0.08);
  background: #f0eee8;
  cursor: col-resize;
}

.panel-resizer span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 28px;
  border-radius: 99px;
  background: rgba(61, 64, 56, 0.16);
  transform: translate(-50%, -50%);
  transition: background 160ms ease, height 160ms ease;
}

.panel-resizer:hover span,
.panel-resizer.dragging span {
  height: 42px;
  background: var(--moss);
}

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 254, 250, 0.97), rgba(248, 246, 240, 0.97)),
    radial-gradient(circle at 100% 0, rgba(95, 111, 82, 0.13), transparent 36%);
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 11px;
}

.chat-header h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: -0.025em;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grounded-lockup {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--moss);
  font-size: 8.5px;
  font-weight: 720;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.grounded-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moss);
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.11);
}

.new-chat-button,
.history-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 650;
  cursor: pointer;
}

.new-chat-button:hover,
.history-button:hover,
.history-button[aria-expanded="true"] {
  border-color: rgba(95, 111, 82, 0.28);
  background: white;
}

.new-chat-button > span:first-child {
  color: var(--moss);
  font-size: 13px;
}

.history-button:disabled,
.new-chat-button:disabled {
  opacity: 0.45;
  cursor: wait;
}

.history-icon {
  position: relative;
  width: 11px;
  height: 11px;
  border: 1px solid var(--moss);
  border-radius: 50%;
}

.history-icon::before {
  position: absolute;
  top: 2px;
  left: 5px;
  width: 1px;
  height: 4px;
  background: var(--moss);
  box-shadow: 2px 3px 0 -0.2px var(--moss);
  content: "";
  transform-origin: bottom;
}

.history-count {
  display: grid;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  place-items: center;
  border-radius: 99px;
  background: var(--moss-soft);
  color: var(--moss-dark);
  font-size: 7px;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.history-scrim {
  position: absolute;
  z-index: 35;
  inset: 0;
  background: rgba(29, 31, 27, 0.16);
  backdrop-filter: blur(2px);
}

.history-panel {
  position: absolute;
  z-index: 40;
  top: 68px;
  right: 14px;
  bottom: 92px;
  left: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(48, 52, 44, 0.13);
  border-radius: 18px;
  background: rgba(255, 254, 250, 0.98);
  box-shadow: 0 24px 70px rgba(31, 34, 29, 0.22);
}

.history-panel[hidden],
.history-scrim[hidden] {
  display: none;
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.history-panel-header .eyebrow {
  margin-bottom: 4px;
  font-size: 7px;
}

.history-panel-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -0.025em;
}

.history-close {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  overscroll-behavior: contain;
}

.history-empty {
  padding: 48px 22px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.history-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(95, 111, 82, 0.055);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.history-entry:hover,
.history-entry.active {
  border-color: rgba(95, 111, 82, 0.22);
  background: var(--moss-soft);
}

.history-entry strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  font-weight: 680;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-entry small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 7.5px;
}

.history-entry time {
  color: var(--muted);
  font-size: 7.5px;
  white-space: nowrap;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin: 0 22px;
  padding: 3px;
  border: 1px solid rgba(49, 52, 44, 0.08);
  border-radius: 10px;
  background: rgba(38, 41, 35, 0.045);
}

.mode-tab {
  height: 29px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 680;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--paper-strong);
  box-shadow: 0 2px 8px rgba(38, 40, 35, 0.08);
  color: var(--moss-dark);
}

.chat-scroll {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 22px;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(82, 84, 77, 0.18) transparent;
  scrollbar-width: thin;
}

.chat-intro {
  padding: 44px 0 26px;
  text-align: center;
}

.intro-symbol {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0 auto 19px;
  place-items: center;
  border: 1px solid rgba(95, 111, 82, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(95, 111, 82, 0.09), transparent 68%);
}

.intro-symbol::before,
.intro-symbol::after,
.intro-symbol span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--moss);
  content: "";
}

.intro-symbol::before {
  transform: translate(-9px, 3px);
}

.intro-symbol::after {
  transform: translate(7px, -8px);
}

.intro-symbol span {
  transform: translate(8px, 8px);
}

.chat-intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(27px, 2.4vw, 34px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.intro-copy {
  max-width: 300px;
  margin: 17px auto 24px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.65;
}

.suggestion-list {
  display: grid;
  gap: 7px;
  width: 100%;
  max-width: 345px;
  margin: 0 auto;
  text-align: left;
}

.suggestion {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 45px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
  cursor: pointer;
  transition: border-color 170ms ease, background 170ms ease, transform 170ms ease, box-shadow 170ms ease;
}

.suggestion:hover {
  border-color: rgba(95, 111, 82, 0.3);
  background: var(--paper-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.suggestion span {
  color: var(--moss);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.suggestion strong {
  font-size: 9.5px;
  font-weight: 610;
  line-height: 1.35;
}

.suggestion i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.messages {
  display: grid;
  align-content: start;
  min-height: 0;
  gap: 16px;
  padding: 20px 0 32px;
}

.message {
  animation: message-in 250ms ease both;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  display: flex;
  justify-content: flex-end;
}

.message.user .message-bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 15px 15px 4px 15px;
  background: #30352c;
  color: #faf9f4;
  font-size: 10.5px;
  line-height: 1.5;
}

.assistant-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 10px 34px rgba(35, 37, 32, 0.055);
}

.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 0;
}

.answer-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--moss);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.answer-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--moss);
  content: "";
}

.streaming-answer .answer-status::before {
  animation: streaming-status-pulse 1.1s ease-in-out infinite;
}

.streamed-claim {
  animation: message-in 220ms ease both;
}

.streaming-typing {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 18px;
  margin-top: 2px;
  padding: 4px 8px 4px 7px;
  border: 1px solid rgba(95, 111, 82, 0.14);
  border-radius: 999px;
  background: rgba(227, 232, 221, 0.42);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.01em;
}

.streaming-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
}

.streaming-typing-dots i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--moss);
  animation: dot-breathe 1s ease-in-out infinite;
}

.streaming-typing-dots i:nth-child(2) { animation-delay: 110ms; }
.streaming-typing-dots i:nth-child(3) { animation-delay: 220ms; }

@keyframes streaming-status-pulse {
  50% {
    opacity: 0.34;
    transform: scale(0.72);
  }
}

.answer-engine {
  color: var(--muted);
  font-size: 8px;
}

.answer-body {
  padding: 11px 14px 14px;
}

.answer-body h3 {
  margin: 0 0 9px;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.18;
}

.answer-body h3::first-letter {
  text-transform: uppercase;
}

.claim {
  margin: 0 0 14px;
  color: #383a34;
  font-size: 12px;
  line-height: 1.72;
}

.claim-block {
  margin-bottom: 16px;
}

.claim-block:last-child {
  margin-bottom: 0;
}

.claim-block .claim {
  margin-bottom: 5px;
}

.claim-note-action {
  color: #8b7843;
  opacity: 0.66;
  transition: color 130ms ease, opacity 130ms ease;
}

.claim-block:hover .claim-note-action,
.claim-note-action:hover,
.claim-note-action:focus-visible {
  color: #80651f;
  opacity: 1;
}

.claim-note-action:disabled {
  cursor: default;
  opacity: 0.78;
}

.answer-body mjx-container {
  color: #262923;
  font-size: 108% !important;
}

.answer-body mjx-container[display="true"] {
  max-width: 100%;
  margin: 14px 0 !important;
  padding: 12px 10px;
  overflow-x: auto;
  border: 1px solid rgba(95, 111, 82, 0.12);
  border-radius: 10px;
  background: rgba(95, 111, 82, 0.045);
}

.answer-body mjx-container svg {
  max-width: none;
}

.inline-citation {
  display: inline-flex;
  align-items: center;
  height: 19px;
  margin: 0 1px 0 4px;
  padding: 0 6px;
  border: 1px solid rgba(95, 111, 82, 0.22);
  border-radius: 6px;
  background: var(--moss-soft);
  color: var(--moss-dark);
  font-size: 7.5px;
  font-weight: 740;
  vertical-align: 1px;
  cursor: pointer;
}

.inline-citation:hover {
  border-color: rgba(95, 111, 82, 0.5);
  background: #d8e0d1;
}

.source-strip {
  border-top: 1px solid var(--line);
  background: rgba(241, 239, 232, 0.58);
}

.source-strip summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  color: var(--ink-soft);
  font-size: 8.5px;
  font-weight: 670;
  list-style: none;
  cursor: pointer;
}

.source-strip summary::-webkit-details-marker {
  display: none;
}

.source-count {
  color: var(--moss);
}

.source-list {
  display: grid;
  gap: 7px;
  padding: 0 10px 10px;
}

.source-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  padding: 9px;
  border: 1px solid rgba(39, 42, 35, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.source-card:hover {
  border-color: rgba(95, 111, 82, 0.25);
}

.source-page {
  display: grid;
  width: 30px;
  height: 37px;
  place-items: center;
  border: 1px solid rgba(95, 111, 82, 0.18);
  border-radius: 4px;
  background: #f6f1e7;
  color: var(--moss-dark);
  font-family: var(--serif);
  font-size: 9px;
  font-weight: 700;
}

.source-copy strong {
  display: block;
  margin: 0 0 3px;
  overflow: hidden;
  font-size: 8.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-copy p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.locate-results {
  display: grid;
  gap: 8px;
}

.locate-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.66);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

.locate-card:hover {
  border-color: rgba(95, 111, 82, 0.35);
  transform: translateY(-1px);
}

.locate-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.locate-card header strong {
  font-family: var(--serif);
  font-size: 12px;
}

.locate-card header span {
  color: var(--moss);
  font-size: 8px;
  font-weight: 730;
}

.locate-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.thinking-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  font-size: 9px;
}

.thinking-dots {
  display: flex;
  gap: 3px;
}

.thinking-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--moss);
  animation: dot-breathe 1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: 100ms; }
.thinking-dots i:nth-child(3) { animation-delay: 200ms; }

.empty-answer {
  padding: 15px;
  border: 1px dashed rgba(95, 111, 82, 0.32);
  border-radius: 13px;
  background: rgba(227, 232, 221, 0.38);
}

.empty-answer strong {
  display: block;
  margin-bottom: 6px;
  font-family: var(--serif);
  font-size: 15px;
}

.empty-answer p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.55;
}

.composer {
  position: relative;
  z-index: 8;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: rgba(249, 247, 241, 0.92);
  backdrop-filter: blur(18px);
}

.composer-context {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 5px 7px;
  color: var(--muted);
  font-size: 7.5px;
}

.composer-context strong {
  color: var(--ink-soft);
  font-weight: 650;
}

.tiny-book {
  position: relative;
  width: 10px;
  height: 9px;
  border: 1px solid var(--moss);
  border-radius: 1px;
}

.tiny-book::after {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 1px;
  height: 9px;
  background: var(--moss);
  content: "";
}

.context-check {
  margin-left: auto;
  color: var(--moss);
  font-weight: 800;
}

.composer-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: end;
  gap: 8px;
  padding: 9px 9px 9px 12px;
  border: 1px solid rgba(45, 48, 40, 0.14);
  border-radius: 14px;
  background: var(--paper-strong);
  box-shadow: 0 8px 30px rgba(37, 39, 34, 0.06);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer-input-row:focus-within {
  border-color: rgba(95, 111, 82, 0.46);
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.08), 0 10px 32px rgba(37, 39, 34, 0.07);
}

.composer textarea {
  width: 100%;
  max-height: 108px;
  min-height: 29px;
  padding: 6px 0 3px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 10.5px;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #9b9d95;
}

.send-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--moss-dark);
  box-shadow: 0 7px 16px rgba(67, 80, 59, 0.2);
  color: white;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.send-button:hover {
  background: #35422f;
  transform: translateY(-1px);
}

.send-button:disabled {
  opacity: 0.45;
  cursor: wait;
  transform: none;
}

.send-button span {
  font-size: 16px;
  line-height: 1;
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  margin: 6px 4px 0;
  color: #9a9c94;
  font-size: 7px;
}

kbd {
  font: inherit;
}

.empty-library {
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 60px;
  text-align: center;
}

.empty-library h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 56px;
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.empty-library > p:not(.eyebrow) {
  max-width: 430px;
  margin: 22px 0 26px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.6;
}

.empty-orbit {
  position: relative;
  width: 70px;
  height: 70px;
  margin-bottom: 22px;
  border: 1px solid rgba(95, 111, 82, 0.28);
  border-radius: 50%;
}

.empty-orbit::before,
.empty-orbit::after,
.empty-orbit span {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--moss);
  content: "";
}

.empty-orbit::before { top: 13px; right: 13px; }
.empty-orbit::after { bottom: 15px; right: 15px; }
.empty-orbit span { top: 33px; left: 9px; }

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 10px;
  font-weight: 720;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--moss-dark);
  background: var(--moss-dark);
  box-shadow: 0 10px 24px rgba(67, 80, 59, 0.18);
  color: white;
}

.primary-button:hover {
  background: #35422f;
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-soft);
}

.toast-stack {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(42, 45, 38, 0.94);
  box-shadow: 0 18px 50px rgba(27, 29, 25, 0.18);
  color: #fbfaf7;
  font-size: 9px;
  line-height: 1.45;
  animation: toast-in 220ms ease both;
  backdrop-filter: blur(18px);
}

.toast.error {
  background: rgba(119, 56, 48, 0.95);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Admin */

.admin-screen {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0, rgba(95, 111, 82, 0.1), transparent 30%),
    linear-gradient(180deg, #f7f5ef 0, #efece4 100%);
}

.admin-shell {
  min-height: 100vh;
}

.admin-header {
  position: sticky;
  top: 0;
  grid-template-columns: 1fr auto;
  padding-right: 30px;
  padding-left: 30px;
}

.admin-main {
  width: min(1180px, calc(100% - 56px));
  margin: 0 auto;
  padding: 54px 0 90px;
}

.admin-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
}

.admin-title-row h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 52px;
  letter-spacing: -0.052em;
  line-height: 0.95;
}

.admin-title-row p:not(.eyebrow) {
  max-width: 560px;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.65;
}

.library-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 40px 0 18px;
}

.library-stats article {
  position: relative;
  min-height: 118px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow-sm);
}

.library-stats article > span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.library-stats article > strong {
  display: block;
  margin-top: 13px;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
}

.library-stats article small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
}

.stat-line {
  position: absolute;
  right: 18px;
  bottom: 20px;
  width: 84px;
  height: 30px;
  border-bottom: 2px solid rgba(95, 111, 82, 0.22);
  border-radius: 50%;
  transform: rotate(-8deg);
}

.stat-line::before {
  position: absolute;
  right: 9px;
  bottom: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.stat-line.green::before {
  background: var(--moss);
}

.scope-stat {
  color: var(--moss-dark);
  font-size: 26px !important;
}

.engine-stat {
  color: var(--ink-soft);
  font-size: 20px !important;
}

.engine-stat.connected {
  color: var(--moss-dark);
}

.book-table-card {
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 21px 22px 17px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 20px;
}

.table-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 8.5px;
}

.library-search {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 220px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
}

.library-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 9px;
}

.book-list {
  padding: 6px;
}

.book-row {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(200px, 1.9fr) 100px 70px 100px 96px;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 10px 11px;
  border-bottom: 1px solid rgba(37, 39, 33, 0.07);
  border-radius: 11px;
}

.book-row:last-child {
  border-bottom: 0;
}

.book-row:hover {
  background: rgba(95, 111, 82, 0.045);
}

.book-cover-mini {
  position: relative;
  display: grid;
  width: 38px;
  height: 50px;
  place-items: center;
  overflow: hidden;
  border-radius: 3px 6px 6px 3px;
  background: linear-gradient(145deg, #46523f, #78866b);
  box-shadow: 0 6px 12px rgba(46, 53, 41, 0.18);
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--serif);
  font-size: 18px;
}

.book-cover-mini::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.2);
  content: "";
}

.book-cover-mini i {
  position: absolute;
  right: -6px;
  bottom: -5px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.book-title-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

.book-row-main h3 {
  margin: 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-row-main p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 8.5px;
}

.active-pill,
.demo-pill,
.ai-pill {
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 6.5px;
  font-weight: 760;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.active-pill {
  background: var(--moss-soft);
  color: var(--moss-dark);
}

.demo-pill {
  background: #eee8d9;
  color: #877241;
}

.ai-pill {
  background: rgba(74, 105, 69, 0.12);
  color: var(--moss-dark);
}

.book-status,
.book-pages,
.book-date {
  color: var(--ink-soft);
  font-size: 8.5px;
}

.book-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

.status-dot.ready {
  background: var(--moss);
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.1);
}

.book-pages strong,
.book-date strong {
  display: block;
  font-size: 9px;
}

.book-pages span,
.book-date span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 7px;
}

.row-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.row-button {
  display: inline-grid;
  min-width: 46px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 700;
  cursor: pointer;
}

.row-button:hover {
  border-color: rgba(95, 111, 82, 0.28);
  color: var(--moss-dark);
}

.more-button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.more-button:hover {
  background: rgba(32, 34, 29, 0.06);
}

.action-menu {
  position: absolute;
  z-index: 20;
  top: 35px;
  right: 0;
  display: none;
  min-width: 128px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-strong);
  box-shadow: var(--shadow-lg);
}

.action-menu.open {
  display: grid;
}

.action-menu a,
.action-menu button {
  padding: 8px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 8px;
  text-align: left;
  cursor: pointer;
}

.action-menu a:hover,
.action-menu button:hover {
  background: rgba(32, 34, 29, 0.05);
}

.action-menu .delete-book {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  padding: 28px;
  overflow-y: auto;
  place-items: center;
  background: rgba(30, 32, 28, 0.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  backdrop-filter: blur(7px);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.upload-modal {
  position: relative;
  width: min(590px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 20px;
  background: #f9f7f1;
  box-shadow: 0 40px 120px rgba(23, 25, 21, 0.28);
  transform: translateY(10px) scale(0.985);
  transition: transform 180ms ease;
}

.modal-backdrop.open .upload-modal {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  cursor: pointer;
}

.upload-modal h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  letter-spacing: -0.035em;
}

.modal-intro {
  max-width: 490px;
  margin: 11px 0 20px;
  color: var(--ink-soft);
  font-size: 9.5px;
  line-height: 1.55;
}

.upload-dropzone {
  display: grid;
  min-height: 138px;
  margin-bottom: 18px;
  place-content: center;
  justify-items: center;
  border: 1px dashed rgba(95, 111, 82, 0.4);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(227, 232, 221, 0.5), rgba(255, 255, 255, 0.34));
  cursor: pointer;
}

.upload-dropzone.dragging {
  border-color: var(--moss);
  background: rgba(227, 232, 221, 0.8);
}

.upload-dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-symbol {
  display: grid;
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--moss-dark);
  color: white;
  font-size: 16px;
}

.upload-dropzone strong {
  font-family: var(--serif);
  font-size: 14px;
}

.upload-dropzone small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 7.5px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field.wide {
  grid-column: 1 / -1;
}

.form-field span {
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 690;
}

.form-field input,
.form-field select {
  width: 100%;
  height: 39px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-size: 9px;
}

.form-field input:focus,
.form-field select:focus {
  border-color: rgba(95, 111, 82, 0.5);
  box-shadow: 0 0 0 3px rgba(95, 111, 82, 0.09);
}

.activate-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 17px 0;
  cursor: pointer;
}

.activate-toggle > input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 99px;
  background: #c9cac4;
  transition: background 150ms ease;
}

.toggle-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.14);
  transition: transform 150ms ease;
}

.activate-toggle input:checked + .toggle-track {
  background: var(--moss);
}

.activate-toggle input:checked + .toggle-track i {
  transform: translateX(14px);
}

.activate-toggle strong,
.activate-toggle small {
  display: block;
}

.activate-toggle strong {
  font-size: 8.5px;
}

.activate-toggle small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 7.5px;
}

.upload-progress {
  display: none;
  margin: 17px 0;
}

.upload-progress.show {
  display: block;
}

.upload-progress > div {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(95, 111, 82, 0.12);
}

.upload-progress > div span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--moss);
  animation: progress-travel 1.5s ease-in-out infinite;
}

@keyframes progress-travel {
  from { transform: translateX(-110%); }
  to { transform: translateX(250%); }
}

.upload-progress p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(420px, 1fr) 6px 365px;
  }

  .current-book .book-meta,
  .brand-tag {
    display: none;
  }

  .reader-stage {
    padding-right: 25px;
    padding-left: 25px;
  }

  .passage-tools {
    width: 310px;
  }

  .concept-map-panel {
    top: 72px;
    right: 8px;
    bottom: 8px;
    left: 8px;
  }

  .concept-map-layout {
    grid-template-columns: minmax(0, 1fr) 285px;
  }

  .concept-map-detail {
    padding-right: 15px;
    padding-left: 15px;
  }

  .reader-body.passage-tools-open .reader-stage {
    right: 310px;
  }

  .scroll-mode-label {
    display: none;
  }

  .library-stats {
    grid-template-columns: 1fr 1fr;
  }

  .book-row {
    grid-template-columns: 42px minmax(180px, 1fr) 90px 65px 80px;
  }

  .book-date {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    height: auto;
    max-height: none;
    min-height: 100vh;
    overflow: visible;
  }

  .global-header {
    position: sticky;
    top: 0;
    grid-template-columns: auto 1fr auto;
  }

  .current-book {
    justify-self: center;
  }

  .book-meta,
  .header-link,
  .icon-button {
    display: none;
  }

  .workspace {
    display: block;
  }

  .reader-pane {
    height: 56vh;
  }

  .page-canvas {
    width: calc(612px * var(--page-zoom));
    min-width: 0;
    max-width: 100%;
  }

  .reader-body.notes-open .reader-stage,
  .reader-body.passage-tools-open .reader-stage {
    right: 0;
    left: 0;
  }

  .notes-panel {
    width: min(310px, 88%);
  }

  .passage-tools {
    top: auto !important;
    right: 10px;
    bottom: 10px;
    left: 10px !important;
    width: auto;
    max-height: 86%;
    border: 1px solid rgba(49, 53, 45, 0.14);
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(30, 32, 28, 0.22);
  }

  .concept-map-panel {
    top: 68px;
    right: 4px;
    bottom: 4px;
    left: 4px;
    overflow: hidden;
    border-radius: 15px;
  }

  .concept-map-header {
    position: sticky;
    z-index: 8;
    top: 0;
    min-height: 68px;
    padding: 11px 12px 10px 14px;
    background: rgba(251, 249, 243, 0.96);
    backdrop-filter: blur(16px);
  }

  .concept-map-header h2 {
    font-size: 20px;
  }

  .concept-map-header p:not(.eyebrow),
  .concept-map-grounding {
    display: none;
  }

  .concept-map-header-actions {
    gap: 5px;
  }

  .concept-map-zoom .concept-fit-button,
  .concept-map-hint {
    display: none;
  }

  .concept-map-layout {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 1fr) 255px;
  }

  .concept-map-canvas {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid rgba(49, 53, 45, 0.1);
  }

  .concept-map-legend {
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-width: none;
  }

  .concept-map-detail {
    min-height: 0;
    padding: 15px 17px;
  }

  .concept-detail-index,
  .concept-map-detail blockquote,
  .concept-detail-relations {
    display: none;
  }

  .concept-detail-summary {
    margin-top: 7px;
  }

  .panel-resizer {
    display: none;
  }

  .chat-panel {
    height: 74vh;
    min-height: 620px;
    border-top: 1px solid var(--line);
  }

  .chat-scroll {
    min-height: 0;
  }

  .reader-toolbar {
    grid-template-columns: auto 1fr auto;
  }

  .page-control-label {
    display: none;
  }

  .scroll-mode-icon {
    display: none;
  }

  .admin-main {
    width: min(100% - 28px, 720px);
    padding-top: 35px;
  }

  .admin-title-row {
    align-items: flex-start;
  }

  .admin-title-row h1 {
    font-size: 40px;
  }

  .library-stats {
    grid-template-columns: 1fr;
  }

  .book-row {
    grid-template-columns: 42px 1fr auto;
    gap: 10px;
  }

  .book-status,
  .book-pages,
  .book-date {
    display: none;
  }

  .table-toolbar {
    align-items: flex-start;
  }

  .library-search {
    width: 160px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
