:root {
  color-scheme: dark;
  --ink: #f5f7fb;
  --muted: #aab4c3;
  --dim: #748093;
  --panel: rgba(12, 16, 25, 0.84);
  --panel-strong: rgba(15, 20, 32, 0.96);
  --line: rgba(186, 201, 224, 0.34);
  --line-strong: rgba(126, 210, 231, 0.82);
  --accent: #7ed2e7;
  --accent-two: #f0bc6a;
  --danger: #ff918a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, rgba(126, 210, 231, 0.18), transparent 26%),
    radial-gradient(circle at 78% 72%, rgba(240, 188, 106, 0.13), transparent 28%),
    linear-gradient(135deg, #070d17 0%, #141824 44%, #1d1721 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light-theme {
  color-scheme: light;
  --ink: #15202c;
  --muted: #52616f;
  --dim: #7a8792;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(65, 82, 104, 0.28);
  --line-strong: rgba(26, 118, 144, 0.72);
  --accent: #147d96;
  --accent-two: #ad6d14;
  --danger: #b53f37;
  --shadow: 0 22px 70px rgba(68, 80, 96, 0.22);
  background:
    radial-gradient(circle at 18% 20%, rgba(20, 125, 150, 0.12), transparent 26%),
    radial-gradient(circle at 78% 72%, rgba(173, 109, 20, 0.1), transparent 28%),
    linear-gradient(135deg, #f6f2e9 0%, #f7faf9 48%, #edf2f4 100%);
}

body.light-theme .sky::before {
  background-image:
    radial-gradient(circle, rgba(48, 65, 84, 0.38) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(20, 125, 150, 0.28) 0 1px, transparent 1.4px);
  opacity: 0.34;
}

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

button {
  border: 0;
  cursor: pointer;
}

.page {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.62) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(126, 210, 231, 0.42) 0 1px, transparent 1.4px);
  background-position: 0 0, 52px 76px;
  background-size: 126px 126px, 210px 210px;
  opacity: 0.28;
}

.viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  width: 4600px;
  height: 3200px;
  transform-origin: 0 0;
  transition: transform 280ms ease;
}

.links-layer,
.cluster-layer,
.nodes-layer {
  position: absolute;
  inset: 0;
}

.links-layer {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cluster-layer {
  pointer-events: none;
}

.constellation-line {
  fill: none;
  stroke: var(--line);
  stroke-linecap: round;
  stroke-width: 1.9;
  vector-effect: non-scaling-stroke;
  opacity: 0.88;
  filter: drop-shadow(0 0 5px rgba(126, 210, 231, 0.22));
  transition: opacity 220ms ease, stroke 220ms ease, stroke-width 220ms ease, filter 220ms ease;
}

.constellation-line.is-strong {
  stroke: var(--line);
  stroke-width: 2.15;
  opacity: 0.74;
}

.constellation-line.is-manual {
  stroke: color-mix(in srgb, var(--accent-two) 68%, var(--line));
  stroke-width: 2.25;
  stroke-dasharray: 7 8;
  opacity: 0.78;
  filter: none;
}

.constellation-line.is-chrono {
  stroke: #94e3a5;
  stroke-width: 2;
}

.constellation-line.is-tag-focus {
  stroke: var(--link-color, var(--accent));
  stroke-width: 4.6;
  opacity: 1;
  filter:
    drop-shadow(0 0 7px color-mix(in srgb, var(--link-color, var(--accent)) 72%, transparent))
    drop-shadow(0 0 17px color-mix(in srgb, var(--link-color, var(--accent)) 42%, transparent));
  animation: tag-link-ignite 480ms ease-out both;
}

.constellation-line.is-tag-bridge {
  stroke: color-mix(in srgb, var(--link-color, var(--accent-two)) 68%, var(--line));
  stroke-width: 2.1;
  opacity: 0.3;
}

.constellation-line.is-filter-muted {
  opacity: 0.12;
}

.constellation-line.is-tag-muted {
  opacity: 0.045;
  filter: none;
}

.constellation-line.is-active-branch {
  stroke: var(--link-color, var(--accent));
  stroke-width: 3.45;
  opacity: 1;
  stroke-dasharray: 18 12;
  animation: branch-ignite 760ms ease both, branch-pulse 3.4s ease-in-out 760ms infinite;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--link-color, var(--accent)) 54%, transparent))
    drop-shadow(0 0 18px color-mix(in srgb, var(--link-color, var(--accent)) 34%, transparent));
}

.constellation-line.is-active-distant {
  opacity: 0.22;
}

.constellation-line.is-muted {
  opacity: 0.2;
}

.constellation-line.is-simple-muted {
  opacity: 0.18;
  stroke-width: 1.35;
}

.constellation-line.is-hidden {
  opacity: 0;
}

@keyframes branch-ignite {
  from {
    opacity: 0;
    stroke-dashoffset: 90;
  }
  to {
    opacity: 1;
    stroke-dashoffset: 0;
  }
}

@keyframes tag-link-ignite {
  from {
    opacity: 0;
    stroke-width: 1.4;
  }
  to {
    opacity: 1;
    stroke-width: 4.6;
  }
}

@keyframes branch-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 7px color-mix(in srgb, var(--link-color, var(--accent)) 48%, transparent))
      drop-shadow(0 0 15px color-mix(in srgb, var(--link-color, var(--accent)) 28%, transparent));
  }
  50% {
    filter: drop-shadow(0 0 12px color-mix(in srgb, var(--link-color, var(--accent)) 72%, transparent))
      drop-shadow(0 0 26px color-mix(in srgb, var(--link-color, var(--accent)) 46%, transparent));
  }
}

.cluster-halo {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--density-size, 320px);
  height: var(--density-size, 320px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--tag-color) 24%, transparent) 0%, transparent 68%);
  filter: blur(2px);
  opacity: var(--density-alpha, 0.12);
  pointer-events: none;
}

.cluster-label {
  position: absolute;
  width: 220px;
  border: 0;
  padding: 8px 10px;
  color: rgba(245, 247, 251, 0.24);
  background: transparent;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: translate(-50%, -50%) scale(var(--node-scale, 1));
  text-align: center;
  pointer-events: auto;
}

.cluster-label:hover,
.cluster-label.is-selected,
.cluster-label.is-related {
  color: color-mix(in srgb, var(--tag-color, #f5f7fb) 72%, white);
  text-shadow: 0 0 14px color-mix(in srgb, var(--tag-color, #f5f7fb) 48%, transparent);
}

body.light-theme .cluster-label {
  color: rgba(21, 32, 44, 0.38);
}

body.light-theme .cluster-label:hover,
body.light-theme .cluster-label.is-selected,
body.light-theme .cluster-label.is-related {
  color: color-mix(in srgb, var(--tag-color, #15202c) 68%, #15202c);
}

body.density-simple .cluster-halo,
body.density-simple .cluster-label,
body.density-simple .node-tags {
  display: none;
}

body.density-simple .constellation-line.is-tag-link {
  opacity: 0.18;
}

body.density-dense .constellation-line {
  opacity: 0.9;
}

body.density-dense .constellation-line.is-tag-link {
  stroke-width: 2;
}

body.density-dense .node-tags {
  max-height: 56px;
}

.topbar,
.tag-bar,
.view-controls,
.search-panel,
.tag-panel,
.network-panel,
.timeline-panel,
.library-panel,
.bibliography-panel,
.project-panel,
.reader-panel,
.compose-popover,
.page-actions {
  z-index: 8;
}

.topbar {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 18px;
  z-index: 12;
  display: grid;
  grid-template-columns: auto auto minmax(260px, 1fr);
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

.identity,
.workspace-switcher,
.tools,
.view-controls,
.page-actions {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

body.light-theme .identity,
body.light-theme .workspace-switcher,
body.light-theme .tools,
body.light-theme .view-controls,
body.light-theme .page-actions,
body.light-theme .search-panel,
body.light-theme .tag-panel,
body.light-theme .network-panel,
body.light-theme .side-panel,
body.light-theme .timeline-panel,
body.light-theme .library-panel,
body.light-theme .bibliography-panel,
body.light-theme .project-panel,
body.light-theme .reader-panel,
body.light-theme .compose-popover {
  border-color: rgba(30, 45, 60, 0.12);
}

.identity {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
}

.project-toggle {
  min-height: 34px;
  margin-left: 2px;
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.project-toggle:hover,
.project-toggle.is-selected {
  color: #07101a;
  background: var(--accent);
}

.visualisations-shortcut {
  display: none;
  align-items: center;
  text-decoration: none;
}

.star-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  padding: 0;
  background:
    radial-gradient(circle, #ffffff 0 9%, transparent 10%),
    conic-gradient(from 30deg, var(--accent), var(--accent-two), #d989c9, #94e3a5, var(--accent));
  box-shadow: 0 0 24px rgba(126, 210, 231, 0.42);
}

.star-mark:hover,
.star-mark.is-selected {
  box-shadow: 0 0 0 3px rgba(126, 210, 231, 0.18), 0 0 30px rgba(240, 188, 106, 0.62);
  transform: scale(1.05);
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 1.1rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.identity p,
.reader-panel time {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tools {
  position: relative;
  justify-self: end;
  min-width: 0;
  overflow: visible;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  scrollbar-width: none;
}

.workspace-switcher {
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
  gap: 4px;
  padding: 5px;
  border-radius: 8px;
}

.workspace-switcher button,
.workspace-switcher a {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 850;
  display: grid;
  place-items: center;
  text-decoration: none;
}

.workspace-switcher button:hover,
.workspace-switcher a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
}

.workspace-switcher button.is-selected {
  color: #07101a;
  background: var(--accent);
}

.workspace-switcher button.has-new-comments:not(.is-selected) {
  color: #07101a;
  background: var(--accent-two);
}

.desktop-more-btn {
  min-width: 92px;
}

.desktop-more-btn.is-selected {
  color: #07101a;
  background: var(--accent-two);
}

.desktop-tools-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 24;
  width: min(620px, calc(100vw - 44px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.desktop-tools-menu[hidden] {
  display: none;
}

.desktop-tools-menu .mode-select,
.desktop-tools-menu .tool-btn {
  width: 100%;
}

.tool-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.desktop-tools-menu .link-toggles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.desktop-tools-menu .mini-toggle {
  min-width: 0;
}

.tools::-webkit-scrollbar {
  display: none;
}

.view-controls {
  position: absolute;
  right: 22px;
  top: 92px;
  z-index: 6;
  display: flex;
  gap: 7px;
  padding: 8px;
  border-radius: 8px;
}

.quiet-toggle {
  width: auto;
  min-width: 64px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.welcome-panel {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(126, 210, 231, 0.16), transparent 32%),
    rgba(4, 7, 13, 0.56);
  backdrop-filter: blur(8px);
}

.welcome-panel[hidden] {
  display: none;
}

.welcome-copy {
  width: min(680px, 100%);
  display: grid;
  gap: 14px;
  padding: 0 0 88px;
  text-align: center;
}

.welcome-copy h2 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.welcome-copy p:not(.panel-kicker) {
  max-width: 58ch;
  margin: 0 auto;
  color: rgba(245, 247, 251, 0.8);
  font-size: 1.02rem;
  line-height: 1.55;
}

.welcome-actions {
  position: absolute;
  left: 50%;
  bottom: min(12vh, 92px);
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}

.welcome-open .topbar,
.welcome-open .view-controls,
.welcome-open .tag-bar,
.welcome-open .type-bar,
.welcome-open .density-control,
.welcome-open .link-legend,
.welcome-open .mini-map,
.welcome-open .page-actions,
.welcome-open .mobile-dock,
.welcome-open .add-btn,
.welcome-open .book-add-btn {
  opacity: 0;
  pointer-events: none;
}

.has-active-entry .tag-bar,
.has-active-entry .type-bar,
.has-active-entry .density-control,
.has-active-entry .view-controls,
.has-active-entry .link-legend,
.has-active-entry .mini-map,
.has-active-entry .mobile-dock {
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.quiet-mode .topbar,
.quiet-mode .tag-bar,
.quiet-mode .type-bar,
.quiet-mode .density-control,
.quiet-mode .link-legend,
.quiet-mode .mini-map,
.quiet-mode .mobile-dock,
.quiet-mode .page-actions,
.quiet-mode .search-panel,
.quiet-mode .tag-panel,
.quiet-mode .network-panel {
  opacity: 0;
  pointer-events: none;
}

.quiet-mode .view-controls {
  z-index: 16;
  opacity: 1;
  pointer-events: auto;
}

.quiet-mode .view-controls button:not(.quiet-toggle) {
  display: none;
}

.quiet-mode .quiet-toggle {
  color: #07101a;
  background: var(--accent);
}

.compose-open .view-controls,
.compose-open .mobile-dock,
.compose-open .add-btn,
.compose-open .book-add-btn,
.compose-open .page-actions,
.compose-open .mini-map {
  opacity: 0;
  pointer-events: none;
}

.tag-bar {
  position: absolute;
  left: 22px;
  right: auto;
  top: 136px;
  bottom: 92px;
  width: min(220px, 24vw);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 8px 8px 0;
  pointer-events: auto;
}

.type-bar {
  position: absolute;
  left: 320px;
  right: 22px;
  top: 84px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  pointer-events: auto;
  z-index: 8;
}

.type-bar button {
  min-height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(12, 16, 25, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.type-bar button.is-selected,
.type-bar button:hover {
  color: #07101a;
  background: var(--accent-two);
}

.tag-bar button {
  min-height: 34px;
  max-width: 100%;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0 13px;
  color: color-mix(in srgb, var(--tag-color, var(--muted)) 78%, white);
  background: color-mix(in srgb, var(--tag-color, #0c1019) 16%, rgba(12, 16, 25, 0.62));
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-bar button:hover,
.tag-bar button.is-selected {
  color: #07101a;
  border-color: color-mix(in srgb, var(--tag-color, var(--accent)) 58%, white);
  background: var(--tag-color, var(--accent));
}

.search {
  width: min(24vw, 230px);
  height: 38px;
  min-width: 118px;
}

.mode-select {
  width: 150px;
}

.link-toggles {
  display: flex;
  gap: 5px;
  align-items: center;
}

.mini-toggle {
  min-height: 32px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.76rem;
  font-weight: 800;
}

.mini-toggle.is-selected {
  color: #07101a;
  background: var(--accent);
}

.link-legend {
  position: absolute;
  left: 22px;
  bottom: 18px;
  z-index: 8;
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(9, 13, 22, 0.48);
  font-size: 0.74rem;
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.link-legend span {
  display: flex;
  gap: 8px;
  align-items: center;
}

.legend-line {
  width: 34px;
  height: 0;
  border-top: 2px solid var(--line);
}

.legend-line.manual {
  border-top-color: var(--accent-two);
  border-top-style: dashed;
}

.legend-line.chrono {
  border-top-color: #94e3a5;
}

body.light-theme .link-legend {
  border-color: rgba(30, 45, 60, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.density-control {
  position: absolute;
  left: 22px;
  top: 84px;
  z-index: 9;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(9, 13, 22, 0.52);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.density-control span {
  padding: 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.density-control button {
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.74rem;
  font-weight: 850;
}

.density-control button.is-selected {
  color: #07101a;
  background: var(--accent);
}

body.light-theme .density-control {
  border-color: rgba(30, 45, 60, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

#modeBadge {
  color: var(--accent-two);
  font-weight: 850;
}

.is-admin #modeBadge {
  color: var(--accent);
}

.is-admin .identity {
  border-color: rgba(126, 210, 231, 0.34);
}

.search-panel,
.tag-panel {
  position: absolute;
  left: 22px;
  width: min(360px, calc(100% - 44px));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.search-panel {
  left: 254px;
  top: 128px;
  max-height: 310px;
  overflow: auto;
  padding: 8px;
}

.tag-panel {
  left: 254px;
  top: 142px;
  bottom: auto;
  width: min(420px, calc(100% - 300px));
  max-height: calc(100dvh - 164px);
  overflow: auto;
  padding: 16px;
}

.project-panel {
  position: absolute;
  left: 22px;
  top: 186px;
  width: min(680px, calc(100% - 44px));
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.project-panel h2 {
  margin: 0 42px 18px 0;
  font-size: 1.36rem;
  line-height: 1.18;
}

.project-text {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.62;
}

.project-text p + p {
  margin-top: 0.95em;
}

.project-open-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 16px;
  border-radius: 8px;
  padding: 0 11px;
  color: #07101a;
  background: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.project-pdf {
  width: 100%;
  height: min(760px, calc(100vh - 270px));
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.network-panel {
  position: absolute;
  left: 254px;
  bottom: 82px;
  width: min(300px, calc(100% - 44px));
  max-height: min(560px, calc(100vh - 190px));
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.side-panel {
  position: absolute;
  top: 186px;
  right: 22px;
  z-index: 9;
  width: min(310px, calc(100% - 44px));
  max-height: calc(100vh - 224px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.side-panel .search {
  width: 100%;
  margin-bottom: 12px;
}

.side-panel h2 {
  margin: 0 46px 14px 0;
  font-size: 1.42rem;
  line-height: 1.15;
}

.side-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.side-stats span {
  min-width: 0;
  border-radius: 8px;
  padding: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.78rem;
}

.side-stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.08rem;
}

.side-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.side-actions button {
  min-width: 0;
  min-height: 34px;
  white-space: normal;
}

.atelier-primary-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.atelier-primary-actions button {
  min-width: 0;
  min-height: 42px;
  color: #07101a;
  background: var(--accent);
  font-weight: 850;
  text-align: center;
  white-space: normal;
}

.atelier-primary-actions button:nth-child(2) {
  background: var(--accent-two);
}

@media (min-width: 761px) {
  .workspace-reading .timeline-panel {
    left: 22px;
    right: 22px;
    top: 94px;
    bottom: 22px;
  }

  .workspace-reading .tag-bar,
  .workspace-reading .type-bar,
  .workspace-reading .density-control,
  .workspace-reading .view-controls,
  .workspace-reading .link-legend,
  .workspace-reading .mini-map {
    opacity: 0;
    pointer-events: none;
  }

  .side-panel {
    top: 94px;
    bottom: 22px;
    width: min(560px, calc(100% - 310px));
    max-height: none;
    padding: 22px;
    background: color-mix(in srgb, var(--panel-strong) 96%, transparent);
  }

  .side-content {
    gap: 12px;
  }

  .side-overview {
    padding: 14px;
    border: 1px solid rgba(126, 210, 231, 0.14);
    border-radius: 8px;
    background: rgba(126, 210, 231, 0.045);
  }

  .side-overview:first-child {
    border-top: 1px solid rgba(126, 210, 231, 0.14);
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .topbar {
    gap: 8px;
  }

  .identity {
    gap: 8px;
    padding: 9px 10px;
  }

  .identity p {
    display: none;
  }

  .workspace-switcher {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
  }

  .workspace-switcher button,
  .workspace-switcher a {
    padding: 0 9px;
  }

  .tools .search {
    width: 170px;
  }
}

.mobile-dock {
  display: none;
}

.mobile-more-panel {
  display: none;
}

.mobile-graph-controls,
.mobile-neighbor-controls {
  display: none;
}

#detailMood {
  display: grid;
  gap: 7px;
  letter-spacing: 0;
  text-transform: none;
}

.detail-type {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-title {
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1.15;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.detail-tags span {
  border-radius: 999px;
  padding: 3px 7px;
  color: color-mix(in srgb, var(--tag-color) 82%, white);
  background: color-mix(in srgb, var(--tag-color) 18%, transparent);
  font-size: 0.72rem;
  font-weight: 750;
}

.mobile-dock button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.085);
  font-size: 0.78rem;
  font-weight: 820;
}

.timeline-panel {
  position: absolute;
  left: min(290px, 27vw);
  right: 22px;
  top: 128px;
  bottom: 22px;
  z-index: 14;
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-strong) 92%, transparent);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.timeline-panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.library-panel {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 94px;
  bottom: 22px;
  z-index: 14;
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(240, 188, 106, 0.055), transparent 34%),
    color-mix(in srgb, var(--panel-strong) 97%, #111822);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
}

.library-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 22px;
  padding: 0 48px 18px 0;
  border-bottom: 1px solid rgba(240, 188, 106, 0.16);
}

.library-heading h2 {
  margin: 3px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.85rem;
  font-weight: 500;
}

.library-summary {
  color: var(--muted);
  font-size: 0.84rem;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 280px) minmax(150px, 190px);
  gap: 7px 10px;
}

.library-toolbar label {
  grid-row: 1;
  color: var(--dim);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.library-toolbar .search,
.library-toolbar .mode-select {
  grid-row: 2;
  width: 100%;
  min-height: 40px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.library-book {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--book-color, var(--accent-two)) 24%, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.library-book-edit,
.library-book-delete {
  position: absolute;
  right: 10px;
  z-index: 2;
  min-height: 36px;
  padding: 0 11px;
  color: #211b14;
  background: rgba(248, 242, 231, 0.94);
  border-color: rgba(95, 63, 31, 0.22);
  box-shadow: 0 6px 18px rgba(5, 8, 12, 0.24);
}

.library-book-edit {
  top: 10px;
}

.library-book-delete {
  top: 52px;
  color: #8f2929;
  background: rgba(255, 242, 238, 0.95);
  border-color: rgba(151, 46, 46, 0.25);
}

.library-book:hover {
  border-color: color-mix(in srgb, var(--book-color, var(--accent-two)) 56%, white);
  background: color-mix(in srgb, var(--book-color, var(--accent-two)) 9%, transparent);
  transform: translateY(-2px);
}

.library-book-open {
  width: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.library-book-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(240, 188, 106, 0.14);
  color: #f7e7cb;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--book-color, var(--accent-two)) 36%, transparent), transparent 52%),
    #151c25;
}

.library-book-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.library-book-cover > span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 4rem;
  opacity: 0.78;
}

.library-book-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 210px;
  padding: 15px;
}

.library-book-author,
.library-book-excerpt {
  margin: 0;
}

.library-book-author {
  overflow: hidden;
  color: color-mix(in srgb, var(--book-color, var(--accent-two)) 78%, white);
  font-size: 0.72rem;
  font-weight: 850;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.library-book-copy h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  font-weight: 500;
  line-height: 1.2;
}

.library-book-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.84rem;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.library-book-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  color: var(--dim);
  font-size: 0.72rem;
}

.library-book-footer strong {
  color: var(--accent-two);
  font-size: 0.72rem;
}

.library-book-progress {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.library-book-progress span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--book-color, var(--accent-two));
}

.library-empty {
  max-width: 520px;
  margin: 12vh auto 0;
  color: var(--muted);
  text-align: center;
}

.library-empty h3 {
  color: var(--ink);
}

.mini-map {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  width: 180px;
  height: 126px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  padding: 8px;
  background: rgba(9, 13, 22, 0.58);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  cursor: crosshair;
}

.mini-map svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mini-map-viewport {
  fill: rgba(126, 210, 231, 0.08);
  stroke: rgba(126, 210, 231, 0.86);
  stroke-width: 1.6;
}

body.light-theme .mini-map {
  border-color: rgba(30, 45, 60, 0.14);
  background: rgba(255, 255, 255, 0.68);
}

.bibliography-panel {
  position: absolute;
  top: 186px;
  right: 22px;
  z-index: 10;
  width: min(560px, calc(100% - 44px));
  max-height: calc(100vh - 224px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.bibliography-return-btn {
  min-height: 36px;
  margin: 0 48px 12px 0;
}

.bibliography-panel h2,
.bibliography-form h3 {
  margin: 0;
}

.bibliography-panel .search {
  width: 100%;
  margin: 12px 0;
}

.bibliography-list {
  display: grid;
  gap: 10px;
}

.bibliography-item {
  display: grid;
  gap: 7px;
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.055);
}

.bibliography-item.is-active {
  border: 1px solid rgba(240, 188, 106, 0.34);
  background: rgba(240, 188, 106, 0.12);
}

.bibliography-item h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.28;
}

.bibliography-item p {
  color: var(--muted);
  line-height: 1.45;
}

.bibliography-meta,
.bibliography-empty {
  color: var(--dim);
  font-size: 0.78rem;
}

.bibliography-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.bibliography-tags span {
  border-radius: 999px;
  padding: 2px 7px;
  color: color-mix(in srgb, var(--tag-color, var(--accent)) 78%, white);
  background: color-mix(in srgb, var(--tag-color, var(--accent)) 15%, transparent);
  font-size: 0.72rem;
  font-weight: 750;
}

.bibliography-item a {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.bibliography-quote-bank {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.bibliography-quote-bank h4 {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bibliography-quote-list {
  display: grid;
  gap: 7px;
}

.bibliography-quote-item {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.bibliography-quote-item:hover {
  border-color: rgba(240, 188, 106, 0.28);
  background: rgba(240, 188, 106, 0.09);
}

.bibliography-quote-item blockquote {
  margin: 0;
  color: rgba(245, 247, 251, 0.86);
  font-size: 0.86rem;
  line-height: 1.45;
}

.bibliography-quote-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.bibliography-focus-btn {
  width: max-content;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 9px;
  color: #07101a;
  background: var(--accent-two);
  font-size: 0.72rem;
  font-weight: 850;
}

.bibliography-actions {
  display: flex;
  justify-content: flex-end;
}

.bibliography-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.bibliography-form[hidden] {
  display: none;
}

.bibliography-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 10px;
  align-items: center;
}

.bibliography-grid label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bibliography-grid input,
.bibliography-grid textarea {
  width: 100%;
}

.timeline-summary,
.timeline-empty {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.timeline-summary {
  margin-top: 3px;
}

.timeline-rail {
  margin-top: 14px;
  overflow: visible;
}

.timeline-reader-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.timeline-reader-list {
  max-height: calc(100vh - 260px);
  display: grid;
  gap: 7px;
  overflow: auto;
  padding-right: 4px;
}

.timeline-reader-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.timeline-reader-row:hover,
.timeline-reader-row.is-active {
  border-color: color-mix(in srgb, var(--accent) 40%, rgba(255, 255, 255, 0.12));
  background: rgba(126, 210, 231, 0.13);
}

.timeline-reader-row[data-type="heteronyme"] {
  border-color: rgba(240, 188, 106, 0.22);
  background:
    linear-gradient(90deg, rgba(240, 188, 106, 0.13), rgba(255, 255, 255, 0.045));
}

.timeline-reader-row[data-type="heteronyme"]:hover,
.timeline-reader-row[data-type="heteronyme"].is-active {
  border-color: rgba(240, 188, 106, 0.48);
  background:
    linear-gradient(90deg, rgba(240, 188, 106, 0.24), rgba(255, 255, 255, 0.075));
}

.timeline-reader-row span {
  grid-row: span 2;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
}

.timeline-reader-row strong,
.timeline-reader-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-reader-row small {
  color: var(--muted);
}

.timeline-reader-row[data-type="heteronyme"] span {
  color: var(--accent-two);
}

.timeline-reader-preview {
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.055);
}

.timeline-reader-preview[data-type="heteronyme"] {
  border-color: rgba(240, 188, 106, 0.24);
  background:
    linear-gradient(90deg, rgba(240, 188, 106, 0.08), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.045);
}

.timeline-reader-preview h3 {
  margin: 0;
  font-size: 1.25rem;
}

.timeline-preview-meta,
.timeline-book-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.timeline-book-note {
  border-left: 2px solid rgba(240, 188, 106, 0.42);
  padding-left: 10px;
}

.timeline-preview-image {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  margin-top: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.timeline-reader-body {
  max-width: 72ch;
  max-height: calc(100vh - 430px);
  margin-top: 12px;
  overflow: auto;
  padding-right: 10px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
  line-height: 1.62;
}

.timeline-reader-body h1,
.timeline-reader-body h2,
.timeline-reader-body h3 {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
}

.timeline-reader-body .book-title {
  margin-bottom: 1.2em;
}

.timeline-reader-body .book-title h1 {
  font-size: 1.35rem;
}

.timeline-reader-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.timeline-reader-tags span {
  border-radius: 999px;
  padding: 2px 7px;
  color: color-mix(in srgb, var(--tag-color) 78%, white);
  background: color-mix(in srgb, var(--tag-color) 16%, transparent);
  font-size: 0.72rem;
}

.timeline-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.side-content,
.side-section {
  display: grid;
  gap: 8px;
}

.side-section {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.side-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.side-section button {
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
}

.side-section button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.side-comments button.has-new-comment {
  border: 1px solid rgba(240, 188, 106, 0.32);
  background: rgba(240, 188, 106, 0.13);
}

.side-section small,
.side-empty {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
}

.network-panel h2,
.network-panel h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.network-panel h3 {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.network-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.network-legend,
.network-top-list,
.network-groups,
.network-actions {
  display: grid;
  gap: 7px;
}

.network-actions {
  grid-template-columns: repeat(3, 1fr);
  margin: 12px 0 14px;
}

.network-actions button,
.network-groups button {
  min-height: 34px;
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
  font-weight: 750;
}

.network-actions button:disabled {
  cursor: default;
  opacity: 0.42;
}

.network-actions button.is-selected {
  color: #07101a;
  background: var(--accent);
}

.network-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.network-legend i {
  width: 28px;
  height: 0;
  display: inline-block;
  border-top: 2px solid var(--line-strong);
}

.network-legend .legend-manual {
  border-top-color: var(--accent-two);
  border-top-style: dashed;
}

.network-legend .legend-chrono {
  border-top-color: #94e3a5;
}

.network-top-list button {
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
}

.network-top-list small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.network-groups button {
  width: 100%;
  display: block;
  text-align: left;
}

.network-groups small,
.network-empty {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.search-result,
.tag-panel button {
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.search-result:hover,
.tag-panel button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.search-result small,
.tag-panel small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.tag-panel h2 {
  margin: 0 0 8px;
  color: color-mix(in srgb, var(--tag-color, var(--accent)) 78%, white);
  font-size: 1.08rem;
}

.tag-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.tag-panel h3 {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag-panel-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.tag-panel-actions button,
.tag-panel-pills button {
  min-height: 34px;
  border-radius: 8px;
  padding: 8px 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.tag-panel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag-panel-pills button {
  width: auto;
  border-radius: 999px;
  color: color-mix(in srgb, var(--tag-color) 78%, white);
  background: color-mix(in srgb, var(--tag-color) 15%, rgba(255, 255, 255, 0.04));
}

.tag-panel-pills small {
  display: inline;
  margin-left: 4px;
  color: inherit;
  opacity: 0.68;
}

.tag-panel-list {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.075);
  color: var(--ink);
}

body.light-theme input,
body.light-theme select,
body.light-theme textarea,
body.light-theme .tool-btn,
body.light-theme .icon-btn,
body.light-theme .ghost-btn,
body.light-theme .project-toggle,
body.light-theme .comment-actions button,
body.light-theme .form-actions button,
body.light-theme .close-btn,
body.light-theme .tag-bar button,
body.light-theme .type-bar button,
body.light-theme .search-result,
body.light-theme .tag-panel button,
body.light-theme .network-actions button,
body.light-theme .network-groups button,
body.light-theme .network-top-list button {
  border-color: rgba(30, 45, 60, 0.12);
  background-color: rgba(255, 255, 255, 0.68);
}

body.light-theme .tag-panel-pills button {
  color: color-mix(in srgb, var(--tag-color) 62%, #15202c);
  background: color-mix(in srgb, var(--tag-color) 18%, rgba(255, 255, 255, 0.72));
}

body.light-theme .reader-panel:not(.is-book) {
  background:
    linear-gradient(180deg, rgba(21, 125, 150, 0.055), transparent 170px),
    rgba(250, 252, 255, 0.98);
  border-color: rgba(30, 45, 60, 0.16);
}

body.light-theme .reader-panel:not(.is-book) .panel-kicker {
  border-bottom-color: rgba(30, 45, 60, 0.1);
  color: #126579;
}

body.light-theme .reader-panel:not(.is-book) .reader-text,
body.light-theme .comment-body {
  color: #24303c;
}

body.light-theme .reader-panel:not(.is-book) .reader-text blockquote,
body.light-theme .timeline-reader-body blockquote {
  color: #3b4a58;
  background: rgba(21, 125, 150, 0.075);
}

body.light-theme .sourced-quote-panel {
  border-color: rgba(160, 94, 24, 0.18);
  background: rgba(160, 94, 24, 0.065);
}

body.light-theme .inline-image-panel {
  border-color: rgba(21, 125, 150, 0.18);
  background: rgba(21, 125, 150, 0.06);
}

body.light-theme .sourced-quote figcaption {
  color: #5a6673;
}

body.light-theme .bibliography-quote-bank {
  border-top-color: rgba(30, 45, 60, 0.1);
}

body.light-theme .bibliography-quote-item {
  border-color: rgba(30, 45, 60, 0.1);
  background: rgba(30, 45, 60, 0.035);
}

body.light-theme .bibliography-quote-item blockquote {
  color: #384454;
}

body.light-theme .reader-period,
body.light-theme .reader-actions,
body.light-theme .manual-link-editor,
body.light-theme .entry-bibliography-panel,
body.light-theme .entry-visualisations-panel,
body.light-theme .comments-panel,
body.light-theme .comment-form,
body.light-theme .comment-item {
  border-color: rgba(30, 45, 60, 0.1);
  background: rgba(30, 45, 60, 0.035);
}

input {
  padding: 0 12px;
}

select {
  min-height: 40px;
  padding: 0 12px;
}

input[type="file"] {
  height: auto;
  padding: 10px 12px;
}

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  padding: 13px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(126, 210, 231, 0.76);
  box-shadow: 0 0 0 3px rgba(126, 210, 231, 0.16);
}

.tool-btn,
.icon-btn,
.ghost-btn,
.form-actions button {
  min-height: 38px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.085);
}

.tool-btn,
.ghost-btn,
.form-actions button {
  padding: 0 13px;
  font-weight: 750;
}

.tool-btn.is-selected,
.ghost-btn.is-selected {
  color: #07101a;
  background: var(--accent);
}

.tool-btn.has-new-comments {
  color: #07101a;
  background: var(--accent-two);
}

#editModeBtn {
  flex: 0 0 auto;
}

.icon-btn {
  width: 38px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.icon-btn[disabled] {
  opacity: 0.38;
  cursor: not-allowed;
}

.add-btn {
  position: absolute;
  z-index: 9;
  right: 28px;
  bottom: 28px;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #07101a;
  background: var(--accent);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34), 0 0 28px rgba(126, 210, 231, 0.42);
  font-size: 2rem;
  font-weight: 700;
}

.book-add-btn {
  position: absolute;
  z-index: 9;
  right: 102px;
  bottom: 32px;
  min-width: 82px;
  height: 46px;
  border-radius: 999px;
  color: #211b14;
  background: var(--accent-two);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.28), 0 0 24px rgba(240, 188, 106, 0.28);
  font-size: 0.9rem;
  font-weight: 850;
}

.page-actions {
  position: absolute;
  left: 22px;
  bottom: 22px;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
}

.danger {
  color: var(--danger);
}

.delete-entry-btn {
  width: 100%;
  min-height: 40px;
  margin-top: 18px;
  border-radius: 8px;
  color: var(--danger);
  background: rgba(255, 145, 138, 0.1);
  border: 1px solid rgba(255, 145, 138, 0.24);
  font-weight: 750;
}

.node {
  position: absolute;
  width: 154px;
  min-height: 74px;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 12px 12px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.028)),
    rgba(12, 17, 28, 0.82);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  transform: translate(-50%, -50%) scale(var(--node-scale, 1));
  user-select: none;
  touch-action: none;
  cursor: grab;
  backdrop-filter: blur(10px);
  will-change: left, top;
  overflow: hidden;
  transition: opacity 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.node[data-type="heteronyme"] {
  width: 220px;
  min-height: 220px;
  aspect-ratio: 1;
  align-content: center;
  justify-items: center;
  padding: 28px;
  border-radius: 50%;
  border-color: rgba(240, 188, 106, 0.48);
  text-align: center;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.2), transparent 18%),
    radial-gradient(circle at 50% 58%, rgba(240, 188, 106, 0.3), rgba(77, 47, 38, 0.5) 46%, rgba(18, 17, 27, 0.9) 100%);
  box-shadow: 0 0 0 1px rgba(240, 188, 106, 0.24), 0 0 44px rgba(240, 188, 106, 0.22), 0 18px 46px rgba(0, 0, 0, 0.38);
}

.node::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--node-color, var(--accent));
  box-shadow: 0 0 17px var(--node-color, var(--accent));
}

.node[data-type="heteronyme"]::before {
  left: 50%;
  top: 22px;
  width: 12px;
  height: 12px;
  transform: translateX(-50%);
  background: #fff5ca;
  box-shadow: 0 0 24px rgba(240, 188, 106, 0.9);
}

.node:hover,
.node.is-active,
.node.is-dragging {
  border-color: rgba(255, 255, 255, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.042)),
    rgba(21, 28, 43, 0.94);
}

.node.is-active {
  z-index: 7;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--node-color, var(--accent)) 34%, transparent),
    0 0 42px color-mix(in srgb, var(--node-color, var(--accent)) 28%, transparent),
    0 18px 46px rgba(0, 0, 0, 0.38);
}

.node.is-active-neighbor {
  z-index: 4;
  opacity: 1;
  border-color: color-mix(in srgb, var(--node-color, var(--accent)) 46%, white);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--node-color, var(--accent)) 22%, transparent),
    0 0 30px color-mix(in srgb, var(--node-color, var(--accent)) 18%, transparent),
    0 12px 34px rgba(0, 0, 0, 0.32);
}

.node.is-active-distant {
  opacity: 0.46;
}

.has-active-entry .node.is-active-distant {
  opacity: 0.18;
  filter: saturate(0.62);
}

.has-active-entry .node.is-active-neighbor {
  transform: translate(-50%, -50%) scale(calc(var(--node-scale, 1) * 1.04));
}

.has-active-entry .node.is-active {
  transform: translate(-50%, -50%) scale(calc(var(--node-scale, 1) * 1.08));
}

.has-active-entry .constellation-line.is-active-distant {
  opacity: 0.16;
}

.has-active-entry .constellation-line.is-active-branch {
  stroke-width: 4.2;
}

body.light-theme .node {
  color: #f5f7fb;
  border-color: rgba(12, 18, 28, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(14, 19, 29, 0.92);
  box-shadow: 0 13px 34px rgba(70, 84, 99, 0.24);
}

body.light-theme .node:hover,
body.light-theme .node.is-active,
body.light-theme .node.is-dragging {
  border-color: rgba(20, 125, 150, 0.62);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.04)),
    rgba(20, 27, 40, 0.96);
}

body.light-theme .node[data-type="heteronyme"] {
  border-color: rgba(110, 68, 28, 0.72);
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.24), transparent 18%),
    radial-gradient(circle at 50% 58%, rgba(196, 126, 42, 0.38), rgba(79, 48, 32, 0.72) 54%, rgba(15, 18, 26, 0.94) 100%);
}

.node.is-dragging {
  cursor: grabbing;
  z-index: 5;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  transition: opacity 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.is-visitor .node {
  cursor: grab;
}

.is-visitor .add-btn,
.is-visitor .book-add-btn,
.is-visitor .page-actions {
  display: none;
}

.is-visitor .manual-link-editor {
  display: none;
}

.is-visitor .entry-bibliography-editor {
  display: none;
}

.node.is-dimmed {
  opacity: 0.34;
}

.node.is-bibliography-muted {
  opacity: 0.18;
}

.node.is-bibliography-focus {
  opacity: 1;
  border-color: rgba(240, 188, 106, 0.82);
  box-shadow: 0 0 0 1px rgba(240, 188, 106, 0.28), 0 0 38px rgba(240, 188, 106, 0.26), 0 14px 38px rgba(0, 0, 0, 0.34);
}

.network-mode .node {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 38px rgba(0, 0, 0, 0.34);
}

.network-mode .node.is-network-muted {
  opacity: 0.18;
}

.network-mode .node.is-network-hidden {
  pointer-events: none;
  opacity: 0;
}

.network-mode .node.is-network-focus,
.network-mode .node.is-active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.48);
}

.node-mood {
  padding-left: 16px;
  color: var(--node-color, var(--accent));
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-type {
  justify-self: start;
  border-radius: 999px;
  padding: 2px 7px;
  color: #07101a;
  background: var(--node-color, var(--accent));
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
}

.node[data-type="heteronyme"] .node-type {
  justify-self: center;
  max-width: 150px;
  background: rgba(255, 242, 204, 0.9);
  color: #2a1a0e;
}

.node-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.28;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.node[data-type="heteronyme"] .node-mood {
  padding-left: 0;
  color: #ffe3a6;
  font-size: 0.82rem;
  white-space: normal;
}

.node[data-type="heteronyme"] .node-text {
  color: #fff8e8;
  font-size: 0.9rem;
  -webkit-line-clamp: 4;
}

.node-content {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.node-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.node.has-image {
  width: 172px;
}

.node[data-type="heteronyme"].has-image {
  width: 240px;
  min-height: 240px;
  padding: 34px 36px 26px;
}

.node[data-type="heteronyme"] .node-content {
  width: 100%;
  max-width: 154px;
  justify-items: center;
}

.node[data-type="heteronyme"] .node-image {
  width: min(126px, 64%);
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 245, 202, 0.22), 0 0 18px rgba(240, 188, 106, 0.18);
}

.node[data-type="heteronyme"].has-image .node-text {
  max-width: 142px;
  -webkit-line-clamp: 2;
}

.node-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.25;
  max-height: 34px;
}

.node-tags span {
  min-width: 0;
  max-width: 100%;
  border-radius: 999px;
  padding: 2px 6px;
  color: color-mix(in srgb, var(--tag-color) 78%, white);
  background: color-mix(in srgb, var(--tag-color) 17%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.light-theme .node-text {
  color: #f5f7fb;
}

body.light-theme .node-tags span {
  color: color-mix(in srgb, var(--tag-color) 72%, white);
  background: color-mix(in srgb, var(--tag-color) 23%, rgba(255, 255, 255, 0.06));
}

body.light-theme .node-date {
  color: #9aa6b6;
}

.node-date {
  color: var(--dim);
  font-size: 0.68rem;
}

.node-degree {
  display: none;
  color: var(--accent-two);
  font-size: 0.68rem;
  font-weight: 800;
}

.network-mode .node-degree {
  display: block;
}

.node-comment-badge {
  justify-self: start;
  max-width: 100%;
  border-radius: 999px;
  padding: 2px 7px;
  color: #07101a;
  background: color-mix(in srgb, var(--accent-two) 82%, white);
  font-size: 0.62rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-comment-badge[hidden] {
  display: none;
}

.node.has-new-comments {
  border-color: rgba(240, 188, 106, 0.72);
  box-shadow: 0 0 0 1px rgba(240, 188, 106, 0.26), 0 0 30px rgba(240, 188, 106, 0.18), 0 10px 30px rgba(0, 0, 0, 0.32);
}

.node[data-type="heteronyme"] .node-comment-badge {
  justify-self: center;
  max-width: 145px;
}

.reader-panel,
.compose-popover {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.reader-panel {
  left: auto;
  top: 96px;
  right: 24px;
  width: min(680px, calc(100% - 56px));
  max-height: calc(100vh - 142px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 48px 30px 28px;
  transform: none;
  animation: reader-rise 220ms ease both;
}

.reader-panel:not(.is-book) {
  background:
    linear-gradient(180deg, rgba(126, 210, 231, 0.055), transparent 170px),
    rgba(12, 17, 28, 0.96);
  border-color: rgba(255, 255, 255, 0.18);
}

.reader-panel.is-dragging {
  cursor: grabbing;
  user-select: none;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
}

.reader-drag-handle {
  position: absolute;
  left: 16px;
  top: 10px;
  width: 76px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: grab;
  touch-action: none;
}

.reader-drag-handle span {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 66%, white);
  box-shadow: 0 0 14px rgba(126, 210, 231, 0.3);
}

.reader-drag-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.reader-panel.is-dragging .reader-drag-handle {
  cursor: grabbing;
}

@keyframes reader-rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.reader-panel.is-book {
  width: min(820px, calc(100% - 56px));
  padding: 48px min(54px, 7vw) 42px;
  color: #1f1a13;
  background:
    linear-gradient(90deg, rgba(67, 45, 25, 0.08), transparent 8%, transparent 92%, rgba(67, 45, 25, 0.08)),
    #f7f1e6;
  border-color: rgba(95, 63, 31, 0.22);
}

.reader-panel.is-book .reader-drag-handle {
  border-color: rgba(80, 54, 31, 0.16);
  background: rgba(80, 54, 31, 0.08);
}

.reader-panel.is-book .reader-drag-handle span {
  background: #8a5a20;
  box-shadow: none;
}

.reader-panel.is-book .panel-kicker {
  color: #8a5a20;
  text-align: center;
}

.book-reader-launch {
  width: min(58ch, 100%);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 auto 18px;
  border: 1px solid rgba(138, 90, 32, 0.3);
  border-radius: 6px;
  padding: 0 16px;
  color: #f9f1e4;
  background: #6f461b;
  box-shadow: 0 10px 24px rgba(80, 54, 31, 0.15);
  font-weight: 850;
  text-align: left;
}

.book-reader-launch[hidden] {
  display: none;
}

.book-reader-launch:hover {
  background: #815421;
}

.reader-panel.is-book #fullReaderBtn {
  display: none;
}

.reader-panel.is-book .reader-text {
  max-width: 58ch;
  margin: 0 auto;
  color: #211b14;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.78;
}

.reader-panel:not(.is-book) .panel-kicker {
  margin: 0 46px 18px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  color: color-mix(in srgb, var(--accent) 72%, white);
  font-size: 0.82rem;
  line-height: 1.45;
}

.reader-panel:not(.is-book) .reader-text {
  max-width: 64ch;
  color: rgba(245, 247, 251, 0.92);
  font-size: 1.02rem;
  line-height: 1.74;
  word-break: break-word;
}

.reader-panel:not(.is-book) .reader-text em {
  color: color-mix(in srgb, var(--accent-two) 78%, white);
}

.reader-panel:not(.is-book) .reader-text blockquote,
.timeline-reader-body blockquote {
  margin: 1.15em 0;
  padding: 0.9em 1em;
  border-left: 3px solid color-mix(in srgb, var(--accent) 74%, white);
  border-radius: 0 8px 8px 0;
  color: rgba(245, 247, 251, 0.82);
  background: rgba(126, 210, 231, 0.075);
}

.sourced-quote {
  margin: 1em 0;
  white-space: normal;
}

.inline-note-image {
  display: grid;
  justify-items: center;
  gap: 9px;
  max-width: 100%;
  margin: 1.45em auto;
  text-indent: 0;
}

.inline-note-image img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(68vh, 720px);
  border-radius: 6px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.12);
}

.inline-note-image figcaption {
  max-width: 62ch;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
}

.reader-panel.is-book .inline-note-image,
.full-reader-panel .inline-note-image {
  margin-top: 2em;
  margin-bottom: 2em;
}

.reader-panel.is-book .inline-note-image figcaption,
.full-reader-panel .inline-note-image figcaption {
  color: #6f5a43;
}

.sourced-quote blockquote {
  margin: 0 0 0.4em !important;
  white-space: pre-wrap;
}

.sourced-quote figcaption {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.sourced-quote figcaption a {
  color: var(--accent-two);
  font-weight: 850;
  text-decoration: none;
}

.sourced-quote figcaption a:hover {
  text-decoration: underline;
}

.reader-panel:not(.is-book) .reader-text blockquote p,
.timeline-reader-body blockquote p {
  margin-bottom: 0;
}

.reader-panel:not(.is-book) .reader-image {
  margin-bottom: 18px;
}

.reader-panel.is-book .reader-text h1 {
  margin: 2.1em 0 0.9em;
  color: #3a2414;
  font-size: 1.72rem;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
}

.reader-text p {
  margin: 0 0 1em;
}

.reader-text h2 {
  margin: 1.7em 0 0.85em;
  font-size: 1.22rem;
  line-height: 1.25;
}

.reader-text hr {
  width: 34%;
  height: 1px;
  margin: 2.2em auto;
  border: 0;
  background: currentColor;
  opacity: 0.24;
}

.reader-panel.is-book .book-title {
  max-width: 58ch;
  margin: 0 auto 2.2em;
  text-align: center;
}

.reader-panel.is-book .book-title h1 {
  color: #211b14;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.1rem;
  font-weight: 500;
  line-height: 1.1;
}

.reader-panel.is-book .book-title p {
  margin-top: 0.8em;
  color: #7a6041;
  font-size: 1rem;
}

.reader-panel.is-book .reader-text h2 {
  color: #5d3718;
  font-size: 1.28rem;
  font-weight: 600;
  text-align: center;
}

.reader-panel.is-book .reader-text h3 {
  margin: 1.35em 0 0.65em;
  color: #6d4a2d;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
}

.reader-panel.is-book .reader-text p {
  text-indent: 1.4em;
}

.reader-panel.is-book .book-title + p,
.reader-panel.is-book .reader-text h2 + p,
.reader-panel.is-book .reader-text h3 + p,
.reader-panel.is-book .reader-text hr + p {
  text-indent: 0;
}

.reader-panel.is-book .reader-text blockquote {
  margin: 1.6em auto;
  padding: 0 0 0 1.2em;
  border-left: 2px solid rgba(93, 55, 24, 0.28);
  color: #5f4d3a;
  font-size: 1.02rem;
  line-height: 1.7;
}

.reader-panel.is-book .reader-text .book-center {
  text-align: center;
  text-indent: 0;
}

.reader-panel.is-book .reader-text .book-indent-left {
  margin-left: 2.8em;
  text-indent: 0;
}

.reader-panel.is-book .reader-text .book-indent-right {
  margin-right: 2.8em;
  text-align: right;
  text-indent: 0;
}

.reader-panel.is-book .reader-text .book-page-break {
  width: 100%;
  height: 10px;
  margin: 3em auto;
  background:
    linear-gradient(90deg, transparent, rgba(93, 55, 24, 0.18), transparent);
}

.book-footnotes {
  max-width: 58ch;
  margin: 2.4em auto 0;
  padding-top: 1.2em;
  border-top: 1px solid rgba(93, 55, 24, 0.22);
  color: #5f4d3a;
  font-size: 0.9rem;
}

.book-footnotes h3 {
  margin: 0 0 0.8em;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.book-footnotes ol {
  margin: 0;
  padding-left: 1.2em;
}

.book-toc {
  max-width: 58ch;
  display: grid;
  gap: 5px;
  margin: 0 auto 22px;
  padding: 12px;
  border: 1px solid rgba(93, 55, 24, 0.16);
  border-radius: 8px;
  background: rgba(80, 54, 31, 0.05);
}

.book-toc span {
  color: #7a6041;
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.book-toc button {
  min-height: 28px;
  border-radius: 6px;
  padding: 4px 6px;
  color: #3a2414;
  background: transparent;
  text-align: left;
}

.book-toc button:hover {
  background: rgba(80, 54, 31, 0.08);
}

.book-toc .toc-level-2 {
  padding-left: 14px;
}

.book-toc .toc-level-3 {
  padding-left: 28px;
  color: #6d4a2d;
}

.reader-panel.is-book .reader-period,
.reader-panel.is-book time,
.reader-panel.is-book .comments-panel h3,
.reader-panel.is-book .comment-meta,
.reader-panel.is-book .comments-empty {
  color: #7a6041;
}

.reader-panel.is-book .reader-actions,
.reader-panel.is-book .journey-controls,
.reader-panel.is-book .comments-panel,
.reader-panel.is-book .manual-link-editor,
.reader-panel.is-book .entry-bibliography-panel,
.reader-panel.is-book .entry-visualisations-panel {
  max-width: 58ch;
  margin-right: auto;
  margin-left: auto;
}

.reader-panel.is-book .close-btn,
.reader-panel.is-book .ghost-btn,
.reader-panel.is-book .comment-actions button,
.reader-panel.is-book .form-actions button {
  color: #211b14;
  background: rgba(80, 54, 31, 0.08);
}

.full-reader-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: auto;
  padding: 54px min(9vw, 110px);
  color: #211b14;
  background: #f7f1e6;
}

.full-reader-panel .panel-kicker,
.full-reader-panel .book-toc,
.full-reader-panel .reader-text {
  max-width: 72ch;
  margin-right: auto;
  margin-left: auto;
}

.full-reader-panel .reader-text {
  color: #211b14;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  line-height: 1.86;
}

.full-reader-panel .reader-text blockquote {
  margin: 1.4em 0;
  padding: 0.9em 1.1em;
  border-left: 3px solid rgba(93, 55, 24, 0.34);
  border-radius: 0 8px 8px 0;
  color: #5f4d3a;
  background: rgba(80, 54, 31, 0.06);
}

.full-reader-panel .close-btn {
  position: fixed;
  color: #211b14;
  background: rgba(80, 54, 31, 0.08);
}

.full-reader-open .topbar,
.full-reader-open .tag-bar,
.full-reader-open .type-bar,
.full-reader-open .density-control,
.full-reader-open .view-controls,
.full-reader-open .add-btn,
.full-reader-open .book-add-btn,
.full-reader-open .page-actions,
.full-reader-open .link-legend,
.full-reader-open .mini-map,
.full-reader-open .mobile-dock,
.full-reader-open .timeline-panel,
.full-reader-open .library-panel,
.full-reader-open .bibliography-panel,
.full-reader-open .reader-panel {
  display: none;
}

.compose-popover {
  left: 50%;
  right: auto;
  bottom: 102px;
  z-index: 32;
  width: min(680px, calc(100% - 56px));
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 22px 20px 20px;
  transform: translateX(-50%);
}

.compose-close-btn {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: -10px -8px 4px auto;
  display: grid;
}

.compose-popover.is-book-compose {
  width: min(1180px, calc(100% - 56px));
  background:
    linear-gradient(90deg, rgba(240, 188, 106, 0.05), transparent 16%),
    var(--panel-strong);
}

.compose-popover.is-book-compose textarea {
  min-height: 46vh;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.62;
}

.book-editor-grid {
  display: grid;
  gap: 12px;
}

.text-editor-frame {
  display: grid;
  gap: 0;
  min-width: 0;
}

.text-editor-frame textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.compose-popover.is-book-compose .book-editor-grid {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.82fr);
}

.book-preview-panel {
  min-height: 46vh;
  max-height: 58vh;
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(240, 188, 106, 0.18);
  border-radius: 8px;
  color: #211b14;
  background: #f7f1e6;
}

.book-preview-panel .reader-text {
  color: #211b14;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  line-height: 1.65;
}

.book-preview-empty {
  color: #7a6041;
  text-indent: 0;
}

.draft-notice {
  color: var(--accent-two);
  font-size: 0.82rem;
  line-height: 1.4;
}

.book-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 7px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.book-tools[hidden] {
  display: none;
}

.book-tools button {
  min-height: 32px;
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  font-weight: 760;
}

.book-tools button:hover {
  color: #07101a;
  background: var(--accent-two);
}

.text-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 8px;
  width: 100%;
  max-width: 100%;
  flex-wrap: wrap;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.078);
}

.text-tools[hidden] {
  display: none;
}

.compose-popover .text-tools {
  z-index: 5;
  display: flex !important;
  backdrop-filter: blur(12px);
}

.text-tools-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.text-tools button {
  min-height: 32px;
  border-radius: 8px;
  padding: 0 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  font-weight: 760;
}

.text-tools button strong {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 5px;
  border-radius: 6px;
  color: #07101a;
  background: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
}

.text-tools button:hover {
  color: #07101a;
  background: var(--accent);
}

.text-tools button:hover strong {
  background: rgba(255, 255, 255, 0.84);
}

.sourced-quote-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(120px, 0.7fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(240, 188, 106, 0.18);
  border-bottom: 0;
  background: rgba(240, 188, 106, 0.075);
}

.inline-image-panel {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(126, 210, 231, 0.2);
  border-bottom: 0;
  background: rgba(126, 210, 231, 0.07);
}

.inline-image-panel[hidden] {
  display: none;
}

.inline-image-panel label {
  align-self: end;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.inline-image-panel input {
  min-width: 0;
  min-height: 38px;
}

.inline-image-actions {
  display: flex;
  gap: 8px;
}

.inline-image-panel .form-note {
  align-self: center;
  margin: 0;
}

.sourced-quote-panel[hidden] {
  display: none;
}

.sourced-quote-panel label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sourced-quote-panel select,
.sourced-quote-panel input {
  min-height: 34px;
}

.sourced-quote-actions {
  display: flex;
  gap: 8px;
}

.sourced-quote-panel .form-note {
  grid-column: 1 / -1;
  margin: 0;
}

.close-btn {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 70;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.085);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  font-weight: 900;
}

.panel-kicker {
  margin-right: 42px;
  margin-bottom: 13px;
  color: var(--accent-two);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-text {
  line-height: 1.58;
  white-space: pre-wrap;
}

.reader-loading {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.reader-period {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--accent-two);
  font-size: 0.84rem;
  line-height: 1.45;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.reader-actions .primary,
.full-reader-map-btn {
  color: #07101a;
  background: var(--accent);
}

.full-reader-map-btn {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 41;
}

.full-reader-edit-btn {
  position: fixed;
  top: 18px;
  right: 68px;
  z-index: 42;
  color: #211b14;
  background: rgba(248, 242, 231, 0.92);
  border-color: rgba(95, 63, 31, 0.2);
}

.full-reader-edit-btn[hidden] {
  display: none;
}

.full-reader-delete-btn {
  position: fixed;
  top: 18px;
  right: 152px;
  z-index: 42;
  color: #9d3434;
  background: rgba(255, 242, 238, 0.94);
  border-color: rgba(151, 46, 46, 0.25);
}

.full-reader-delete-btn[hidden] {
  display: none;
}

.journey-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.journey-controls span {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.manual-link-editor,
.entry-bibliography-panel,
.entry-visualisations-panel {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.entry-bibliography-panel h3,
.entry-visualisations-panel h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.entry-bibliography-list,
.entry-bibliography-editor,
.entry-visualisations-list {
  display: grid;
  gap: 9px;
}

.entry-bibliography-editor[hidden] {
  display: none;
}

.entry-bibliography-item {
  display: grid;
  gap: 6px;
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.055);
}

.entry-bibliography-item h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.entry-bibliography-item p {
  color: var(--muted);
  line-height: 1.45;
}

.entry-bibliography-item a {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.entry-bibliography-suggestions {
  display: grid;
  gap: 7px;
}

.entry-bibliography-suggestion {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
}

.entry-bibliography-suggestion:hover {
  background: rgba(240, 188, 106, 0.13);
}

.entry-bibliography-suggestion small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.manual-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.compose-bibliography-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.compose-visualisation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.compose-bibliography-suggestions {
  display: grid;
  gap: 7px;
  max-height: 210px;
  overflow: auto;
}

.compose-visualisation-suggestions {
  display: grid;
  gap: 7px;
  max-height: 210px;
  overflow: auto;
}

.compose-bibliography-suggestion {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.compose-visualisation-suggestion {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(126, 210, 231, 0.14);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(126, 210, 231, 0.055);
  text-align: left;
}

.compose-bibliography-suggestion:hover {
  border-color: rgba(240, 188, 106, 0.35);
  background: rgba(240, 188, 106, 0.12);
}

.compose-visualisation-suggestion:hover {
  border-color: rgba(126, 210, 231, 0.38);
  background: rgba(126, 210, 231, 0.13);
}

.compose-bibliography-suggestion span,
.compose-bibliography-suggestion small,
.compose-visualisation-suggestion span,
.compose-visualisation-suggestion small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-bibliography-suggestion span {
  font-weight: 800;
}

.compose-visualisation-suggestion span {
  font-weight: 800;
}

.compose-bibliography-suggestion small {
  margin-top: 3px;
  color: var(--muted);
}

.compose-visualisation-suggestion small {
  margin-top: 3px;
  color: var(--muted);
}

.entry-visualisation-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(126, 210, 231, 0.12);
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  background: rgba(126, 210, 231, 0.055);
  text-decoration: none;
}

.entry-visualisation-item:hover {
  border-color: rgba(126, 210, 231, 0.36);
  background: rgba(126, 210, 231, 0.11);
}

.entry-visualisation-item img,
.entry-visualisation-placeholder {
  width: 72px;
  height: 52px;
  display: block;
  border-radius: 5px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.entry-visualisation-placeholder {
  background:
    linear-gradient(135deg, rgba(126, 210, 231, 0.2), transparent),
    rgba(255, 255, 255, 0.06);
}

.entry-visualisation-placeholder.is-animation {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1rem;
}

.entry-visualisation-item > span:last-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.entry-visualisation-item strong,
.entry-visualisation-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-visualisation-item small {
  color: var(--muted);
  font-size: 0.76rem;
}

.manual-link-pill {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
}

button.manual-link-pill {
  cursor: pointer;
}

button.manual-link-pill:hover {
  color: var(--danger);
  background: rgba(255, 145, 138, 0.1);
}

.comments-panel {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.032);
}

.comments-panel h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.comments-list,
.comment-form,
.comment-item {
  display: grid;
  gap: 9px;
}

.comment-form {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.comment-form-intro {
  display: grid;
  gap: 3px;
}

.comment-form-intro strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.comment-form-intro span,
.comment-form label span,
.comment-counter,
.comment-status {
  color: var(--muted);
  font-size: 0.76rem;
}

.comment-form label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.comment-item {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.comment-item.is-new {
  border: 1px solid rgba(240, 188, 106, 0.32);
  background: rgba(240, 188, 106, 0.1);
}

.comment-meta,
.comments-empty {
  color: var(--dim);
  font-size: 0.78rem;
}

.comment-meta strong {
  margin-left: 6px;
  color: var(--accent-two);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.comment-status-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  border: 1px solid rgba(240, 188, 106, 0.28);
  border-radius: 999px;
  padding: 2px 6px;
  color: #f0bc6a;
  background: rgba(240, 188, 106, 0.1);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.comment-status-pill.is-rejected {
  border-color: rgba(255, 128, 128, 0.25);
  color: #ff9a9a;
  background: rgba(255, 128, 128, 0.08);
}

.comment-body {
  color: rgba(245, 247, 251, 0.88);
  line-height: 1.58;
  white-space: pre-wrap;
}

.comment-reply {
  margin-top: 2px;
  padding: 10px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(126, 210, 231, 0.1);
}

.comment-reply strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.comment-reply p {
  line-height: 1.45;
  white-space: pre-wrap;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.comment-form textarea {
  min-height: 96px;
  resize: vertical;
}

.comment-form .form-actions {
  align-items: center;
  justify-content: space-between;
}

.comment-counter.is-near-limit {
  color: var(--danger);
}

.reader-image {
  width: 100%;
  max-height: 48vh;
  display: block;
  object-fit: contain;
  margin-bottom: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.entry-form {
  display: grid;
  gap: 10px;
}

.field-group {
  display: grid;
  gap: 10px;
}

.reference-field {
  display: grid;
  gap: 8px;
  margin: 4px 0;
  border: 1px solid rgba(240, 188, 106, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(240, 188, 106, 0.075);
}

.reference-field .panel-kicker {
  margin: 0;
}

.reference-field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reference-field-heading .ghost-btn {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  text-decoration: none;
}

.reference-field label {
  color: var(--ink);
}

label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.entry-form input {
  width: 100%;
  min-height: 42px;
}

.form-note {
  color: var(--dim);
  font-size: 0.82rem;
  line-height: 1.4;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.form-actions .compose-delete-btn {
  margin-right: auto;
  color: #ff9a9a;
  border-color: rgba(255, 116, 116, 0.3);
  background: rgba(146, 35, 35, 0.16);
}

.form-actions .compose-delete-btn:hover {
  color: #ffd3d3;
  border-color: rgba(255, 116, 116, 0.55);
  background: rgba(146, 35, 35, 0.28);
}

.form-actions button[type="submit"] {
  color: #07101a;
  background: var(--accent);
}

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

.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  padding: 22px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(126, 210, 231, 0.035), transparent 190px),
    #0b1018;
}

.admin-panel[hidden] {
  display: none;
}

body.light-theme .admin-panel {
  color: #15202c;
  background:
    linear-gradient(180deg, rgba(20, 125, 150, 0.055), transparent 190px),
    #f4f7f9;
}

.admin-header {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-theme .admin-header {
  border-color: rgba(21, 32, 44, 0.14);
}

.admin-header h2 {
  margin: 3px 0 5px;
  font-size: 1.65rem;
}

.admin-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-header-actions .close-btn {
  position: static;
  flex: 0 0 auto;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) repeat(3, minmax(150px, 190px));
  gap: 10px;
  align-items: end;
}

.admin-toolbar label {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.admin-toolbar label > span {
  color: var(--muted);
}

.admin-toolbar .search,
.admin-toolbar .mode-select {
  width: 100%;
  min-width: 0;
  height: 42px;
}

.admin-table-wrap {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(10, 14, 23, 0.62);
}

body.light-theme .admin-table-wrap {
  border-color: rgba(21, 32, 44, 0.14);
  background: rgba(255, 255, 255, 0.78);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.admin-table th,
.admin-table td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  text-align: left;
  vertical-align: middle;
}

body.light-theme .admin-table th,
body.light-theme .admin-table td {
  border-color: rgba(21, 32, 44, 0.1);
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #111722;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

body.light-theme .admin-table th {
  background: #edf2f5;
}

.admin-table th:nth-child(1) {
  width: 104px;
}

.admin-table th:nth-child(2) {
  width: auto;
}

.admin-table th:nth-child(3) {
  width: 140px;
}

.admin-table th:nth-child(4) {
  width: 104px;
}

.admin-table th:nth-child(5) {
  width: 140px;
}

.admin-table th:nth-child(6) {
  width: 330px;
}

.admin-table tbody tr {
  transition: background 150ms ease;
}

.admin-table tbody tr:hover {
  background: rgba(126, 210, 231, 0.045);
}

.admin-table tbody tr[data-status="draft"] {
  background: rgba(240, 188, 106, 0.035);
}

.admin-table tbody tr[data-status="archived"] {
  opacity: 0.68;
}

.admin-type-badge {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  color: #07101a;
  background: var(--accent);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

tr[data-type="heteronyme"] .admin-type-badge {
  background: var(--accent-two);
}

.admin-title-button {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.admin-title-button strong,
.admin-title-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-title-button strong {
  font-size: 0.94rem;
}

.admin-title-button small {
  color: var(--muted);
  font-size: 0.78rem;
}

.admin-row-tags {
  display: flex;
  gap: 4px;
  margin-top: 7px;
  overflow: hidden;
}

.admin-row-tags span {
  flex: 0 1 auto;
  min-width: 0;
  border-radius: 999px;
  padding: 2px 6px;
  color: color-mix(in srgb, var(--tag-color) 78%, white);
  background: color-mix(in srgb, var(--tag-color) 16%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.67rem;
}

.admin-reference-count {
  display: inline-grid;
  min-width: 30px;
  min-height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  font-weight: 800;
}

.admin-status-select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
}

.admin-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.admin-row-actions .ghost-btn {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.75rem;
}

.admin-row-actions .admin-archive {
  color: var(--accent-two);
}

.admin-empty {
  padding: 70px 24px;
  color: var(--muted);
  text-align: center;
}

.admin-empty h3 {
  margin-bottom: 6px;
  color: var(--ink);
}

.admin-open .mobile-dock,
.admin-open .topbar,
.admin-open .view-controls,
.admin-open .page-actions,
.admin-open .add-btn,
.admin-open .book-add-btn {
  visibility: hidden;
}

.admin-open .compose-popover {
  z-index: 46;
}

@media (max-width: 760px) {
  body {
    min-height: 100dvh;
  }

  .topbar {
    left: 12px;
    right: 12px;
    top: 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .tag-bar {
    left: 12px;
    right: 12px;
    top: 190px;
    bottom: auto;
    width: auto;
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0 8px;
  }

  .type-bar {
    left: 12px;
    right: 12px;
    top: 234px;
  }

  .density-control {
    left: 12px;
    right: 12px;
    top: 146px;
    overflow-x: auto;
    border-radius: 8px;
  }

  .search-panel {
    left: 12px;
    top: 280px;
    max-height: 34dvh;
  }

  .tag-panel {
    left: 12px;
    right: 12px;
    top: 280px;
    bottom: 72px;
    width: auto;
    max-height: none;
    overflow: auto;
  }

  .network-panel {
    left: 12px;
    right: 12px;
    bottom: 72px;
    width: auto;
    max-height: 42dvh;
    overflow: auto;
  }

  .timeline-panel {
    left: 12px;
    right: 12px;
    top: 280px;
    bottom: 72px;
    max-height: none;
    padding: 14px;
  }

  .timeline-reader-layout {
    grid-template-columns: 1fr;
  }

  .timeline-reader-list {
    max-height: 180px;
  }

  .timeline-reader-preview {
    max-height: none;
  }

  .timeline-reader-body {
    max-height: 42dvh;
  }

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

  .mini-map {
    display: none;
  }

  .link-legend {
    display: none;
  }

  .side-panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 72px;
    width: auto;
    max-height: 48dvh;
  }

  .bibliography-panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 72px;
    width: auto;
    max-height: 62dvh;
  }

  .bibliography-grid {
    grid-template-columns: 1fr;
  }

  .tools {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .tools::-webkit-scrollbar {
    display: none;
  }

  .view-controls {
    right: 12px;
    top: auto;
    bottom: 72px;
    z-index: 6;
    flex-direction: column;
  }

  .mobile-dock {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 13;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
  }

  body.light-theme .mobile-dock {
    border-color: rgba(30, 45, 60, 0.12);
  }

  .manual-link-row {
    grid-template-columns: 1fr;
  }

  .search {
    flex: 0 0 156px;
    width: 156px;
  }

  .mode-select {
    flex: 0 0 148px;
    width: 148px;
  }

  .tool-btn,
  .tools .icon-btn {
    flex: 0 0 auto;
  }

  .identity {
    width: max-content;
    max-width: 100%;
    flex-wrap: wrap;
  }

  .node {
    width: 138px;
  }

  .reader-panel,
  .project-panel,
  .compose-popover {
    left: 0;
    right: 0;
    width: 100%;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 10px 10px 0 0;
  }

  .reader-panel {
    top: auto;
    bottom: 0;
    max-height: 72dvh;
    padding: 46px 18px calc(22px + env(safe-area-inset-bottom));
    transform: none;
  }

  .reader-panel:not(.is-book) .reader-text {
    max-width: none;
    font-size: 1rem;
    line-height: 1.68;
  }

  .reader-drag-handle {
    display: none;
  }

  .project-panel {
    top: auto;
    bottom: 0;
    max-height: 72dvh;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .project-pdf {
    height: 54dvh;
  }

  .compose-popover {
    bottom: 0;
    max-height: 78dvh;
    overflow: auto;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    transform: none;
  }

  .page-actions {
    left: 12px;
    bottom: 68px;
  }

  .add-btn {
    right: 16px;
    bottom: 142px;
    width: 56px;
    height: 56px;
  }

  .book-add-btn {
    right: 82px;
    bottom: 147px;
    min-width: 70px;
    height: 42px;
    font-size: 0.82rem;
  }

  .compose-popover.is-book-compose {
    width: 100%;
  }

  .compose-popover.is-book-compose textarea {
    min-height: 42dvh;
  }

  .compose-popover.is-book-compose .book-editor-grid {
    grid-template-columns: 1fr;
  }

  .sourced-quote-panel {
    grid-template-columns: 1fr;
  }

  .inline-image-panel {
    grid-template-columns: 1fr;
  }

  .inline-note-image img {
    max-height: 58vh;
  }

  .book-preview-panel {
    min-height: 280px;
    max-height: 42dvh;
  }

  .network-actions {
    grid-template-columns: 1fr;
  }

  .reader-panel:not([hidden]) ~ .compose-popover {
    display: none;
  }
}

@media (max-width: 430px) {
  .identity {
    padding: 9px 11px;
  }

  .star-mark {
    width: 28px;
    height: 28px;
  }

  h1 {
    font-size: 1rem;
  }

  .identity p {
    font-size: 0.76rem;
  }

  .node {
    width: 126px;
    padding: 10px;
  }

  .node.has-image {
    width: 146px;
  }

  .node-text {
    font-size: 0.78rem;
  }
}

/* Mobile workspace: keep the constellation primary and open tools as sheets. */
@media (max-width: 760px) {
  :root {
    --mobile-edge: max(10px, env(safe-area-inset-left));
    --mobile-dock-height: calc(58px + env(safe-area-inset-bottom));
  }

  body {
    background:
      linear-gradient(145deg, #08101a 0%, #121722 58%, #1c1820 100%);
  }

  .world {
    transition: none;
  }

  .constellation-line,
  .constellation-line.is-active-branch,
  .constellation-line.is-tag-focus {
    filter: none;
    transition: none;
  }

  .constellation-line.is-active-branch {
    animation: none;
  }

  .constellation-line.is-tag-focus {
    stroke-width: 5.2;
    animation: none;
  }

  .constellation-line.is-tag-muted {
    opacity: 0.035;
  }

  .cluster-halo {
    display: none;
  }

  button,
  input,
  select {
    min-height: 44px;
  }

  .topbar {
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: max(8px, env(safe-area-inset-top));
    display: block;
  }

  .identity {
    width: 100%;
    min-height: 52px;
    max-width: none;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(10, 14, 23, 0.92);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: none;
  }

  .node.is-active,
  .node.is-active-neighbor,
  .node.has-new-comments,
  .node.is-bibliography-focus,
  .network-mode .node {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--node-color, var(--accent)) 28%, transparent),
      0 8px 24px rgba(0, 0, 0, 0.3);
  }

  body.light-theme .identity {
    background: rgba(255, 255, 255, 0.94);
  }

  .identity > div {
    min-width: 0;
    flex: 1 1 auto;
  }

  .identity h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .identity p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .project-toggle {
    min-width: 44px;
    min-height: 40px;
    padding: 0 10px;
  }

  .visualisations-shortcut {
    display: flex;
  }

  .tools {
    display: none;
  }

  .mobile-search-open .tools {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: calc(max(8px, env(safe-area-inset-top)) + 60px);
    z-index: 22;
    width: auto;
    display: flex;
    justify-self: stretch;
    padding: 8px;
    overflow: visible;
    background: var(--panel-strong);
    backdrop-filter: none;
  }

  .mobile-search-open .tools > :not(.search) {
    display: none;
  }

  .mobile-search-open .tools .search {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1 1 auto;
  }

  .density-control,
  .workspace-switcher,
  .tag-bar,
  .type-bar,
  .view-controls,
  .link-legend,
  .mini-map {
    display: none;
  }

  .search-panel {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: calc(max(8px, env(safe-area-inset-top)) + 120px);
    bottom: calc(var(--mobile-dock-height) + 12px);
    z-index: 21;
    width: auto;
    max-height: none;
    padding: 8px;
    overflow: auto;
    background: var(--panel-strong);
  }

  .search-result {
    min-height: 56px;
    padding: 10px 12px;
  }

  .tag-panel,
  .network-panel,
  .side-panel,
  .timeline-panel,
  .bibliography-panel,
  .project-panel {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: calc(max(8px, env(safe-area-inset-top)) + 60px);
    bottom: calc(var(--mobile-dock-height) + 10px);
    z-index: 18;
    width: auto;
    max-height: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 18px 16px;
    overflow: auto;
    overscroll-behavior: contain;
    background: var(--panel-strong);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
    backdrop-filter: none;
  }

  .tag-panel h2,
  .timeline-panel h2,
  .bibliography-panel h2,
  .project-panel h2 {
    margin-right: 48px;
  }

  .side-panel .close-btn,
  .timeline-panel .close-btn,
  .bibliography-panel .close-btn,
  .project-panel .close-btn {
    position: sticky;
    top: 0;
    float: right;
    margin: -6px -4px 4px 10px;
  }

  .timeline-reader-list {
    max-height: 31dvh;
  }

  .timeline-reader-body {
    max-height: none;
    padding-right: 2px;
    font-size: 1rem;
    line-height: 1.72;
  }

  .bibliography-list {
    max-height: none;
  }

  .atelier-primary-actions {
    grid-template-columns: 1fr;
  }

  .mobile-dock {
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    bottom: max(8px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    min-height: 54px;
    padding: 6px;
    overflow: hidden;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    background: rgba(10, 14, 23, 0.94);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.42);
    backdrop-filter: none;
  }

  .mobile-dock::-webkit-scrollbar {
    display: none;
  }

  body.light-theme .mobile-dock {
    background: rgba(255, 255, 255, 0.94);
  }

  .mobile-dock button {
    min-width: 0;
    min-height: 42px;
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
  }

  .mobile-more-panel:not([hidden]) {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    bottom: calc(var(--mobile-dock-height) + 14px);
    z-index: 58;
    display: grid;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 16px;
    background: rgba(10, 14, 23, 0.97);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.48);
    animation: mobile-sheet-enter 160ms ease both;
  }

  body.light-theme .mobile-more-panel:not([hidden]) {
    border-color: rgba(21, 32, 44, 0.14);
    background: rgba(255, 255, 255, 0.98);
  }

  .mobile-more-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .mobile-more-header h2 {
    margin: 2px 0 0;
    font-size: 1.2rem;
  }

  .mobile-more-header .close-btn {
    position: static;
    flex: 0 0 auto;
  }

  .mobile-more-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-more-actions button,
  .mobile-more-actions a {
    min-height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.07);
    font-size: 0.82rem;
    font-weight: 820;
    text-align: center;
    text-decoration: none;
  }

  .mobile-dock button.is-selected {
    color: #07101a;
    background: var(--accent);
  }

  .library-panel {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: max(8px, env(safe-area-inset-top));
    bottom: calc(var(--mobile-dock-height) + 12px);
    z-index: 20;
    padding: 16px 12px 20px;
    border-radius: 8px;
    backdrop-filter: none;
  }

  .library-heading {
    display: block;
    margin-bottom: 14px;
    padding: 0 42px 14px 0;
  }

  .library-heading h2 {
    font-size: 1.5rem;
  }

  .library-toolbar {
    grid-template-columns: minmax(0, 1fr) 118px;
    margin-top: 12px;
  }

  .library-toolbar .search,
  .library-toolbar .mode-select {
    min-width: 0;
    min-height: 42px;
    font-size: 0.78rem;
  }

  .library-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .library-book-open {
    grid-template-columns: 108px minmax(0, 1fr);
    grid-template-rows: 1fr;
  }

  .library-book-cover {
    height: 100%;
    min-height: 164px;
    aspect-ratio: auto;
    border-right: 1px solid rgba(240, 188, 106, 0.14);
    border-bottom: 0;
  }

  .library-book-copy {
    min-height: 164px;
    padding: 12px;
  }

  .library-book-copy h3 {
    font-size: 1.08rem;
  }

  .library-book-excerpt {
    font-size: 0.8rem;
    -webkit-line-clamp: 3;
  }

  .reader-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 30;
    width: 100%;
    max-height: 82dvh;
    padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: auto;
    overscroll-behavior: contain;
    transform: none;
    backdrop-filter: none;
  }

  .reader-panel:not([hidden]),
  .tag-panel:not([hidden]),
  .network-panel:not([hidden]),
  .side-panel:not([hidden]),
  .timeline-panel:not([hidden]),
  .library-panel:not([hidden]),
  .bibliography-panel:not([hidden]),
  .project-panel:not([hidden]),
  .compose-popover:not([hidden]) {
    animation: mobile-sheet-enter 180ms ease-out both;
  }

  .reader-panel::before {
    content: "";
    position: sticky;
    top: 0;
    z-index: 2;
    width: 42px;
    height: 4px;
    display: block;
    margin: -5px auto 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 58%, transparent);
  }

  .reader-panel > .close-btn {
    position: sticky;
    top: 0;
    float: right;
    margin: -10px -6px 6px 10px;
  }

  .reader-panel:not(.is-book) .panel-kicker {
    margin-right: 42px;
  }

  .reader-panel:not(.is-book) .reader-text,
  .reader-panel.is-book .reader-text {
    max-width: none;
    font-size: 1rem;
    line-height: 1.72;
  }

  .reader-panel.is-book {
    width: 100%;
    padding: 16px 20px calc(26px + env(safe-area-inset-bottom));
  }

  .reader-panel.is-book .book-title h1 {
    font-size: 1.72rem;
  }

  .reader-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px;
  }

  .reader-actions button {
    min-width: 0;
    min-height: 44px;
    padding: 0 8px;
  }

  .comments-panel,
  .manual-link-editor,
  .entry-bibliography-panel,
  .entry-visualisations-panel {
    padding: 12px;
  }

  .comment-form {
    padding: 10px;
  }

  .compose-popover,
  .compose-popover.is-book-compose {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: max(8px, env(safe-area-inset-top));
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 32;
    width: auto;
    max-height: none;
    padding: 10px 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    overflow: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 64px 150px;
    transform: none;
    backdrop-filter: none;
  }

  .compose-close-btn {
    top: 0;
    margin: 0 -4px -34px auto;
  }

  .entry-form {
    gap: 11px;
    padding-top: 38px;
  }

  .text-tools {
    flex-wrap: nowrap;
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .text-tools::-webkit-scrollbar {
    display: none;
  }

  .text-tools-label {
    display: none;
  }

  .text-tools button {
    flex: 0 0 auto;
    min-height: 40px;
  }

  .book-tools {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .book-tools[hidden] {
    display: none;
  }

  .book-tools button {
    flex: 0 0 auto;
    min-height: 40px;
  }

  .compose-popover textarea,
  .compose-popover.is-book-compose textarea {
    min-height: 34dvh;
  }

  .book-preview-panel {
    min-height: 220px;
    max-height: 36dvh;
    padding: 16px;
  }

  .form-actions {
    position: sticky;
    bottom: -18px;
    z-index: 4;
    margin: 4px -14px -18px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--panel-strong);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.2);
  }

  .comment-form .form-actions,
  .bibliography-form .form-actions {
    position: static;
    margin: 4px 0 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  .full-reader-panel {
    padding: calc(70px + env(safe-area-inset-top)) 20px calc(34px + env(safe-area-inset-bottom));
  }

  .full-reader-panel .reader-text {
    font-size: 1.05rem;
    line-height: 1.78;
  }

  .full-reader-map-btn {
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
  }

  .full-reader-edit-btn {
    top: max(12px, env(safe-area-inset-top));
    right: 58px;
    min-height: 38px;
    padding: 0 10px;
  }

  .full-reader-delete-btn {
    top: auto;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    min-height: 36px;
    padding: 0 9px;
  }

  .full-reader-panel .close-btn {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
  }

  .page-actions {
    display: none;
  }

  .add-btn {
    right: 14px;
    bottom: calc(var(--mobile-dock-height) + 24px);
  }

  .book-add-btn {
    right: 82px;
    bottom: calc(var(--mobile-dock-height) + 31px);
  }

  .node {
    width: 140px;
    min-height: 82px;
    padding: 12px;
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(12, 17, 28, 0.92);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.26);
    backdrop-filter: none;
    will-change: auto;
    contain: layout style;
  }

  .node.is-dragging {
    will-change: left, top;
  }

  .node.has-image {
    width: 154px;
  }

  .node[data-type="heteronyme"] {
    width: 200px;
    min-height: 200px;
    padding: 26px;
    box-shadow: 0 0 0 1px rgba(240, 188, 106, 0.2), 0 10px 28px rgba(0, 0, 0, 0.3);
  }

  .node[data-type="heteronyme"].has-image {
    width: 214px;
    min-height: 214px;
  }

  .node-text {
    font-size: 0.82rem;
    line-height: 1.34;
  }

  .node-tags {
    display: none;
  }

  .welcome-panel {
    padding: 22px 18px calc(90px + env(safe-area-inset-bottom));
  }

  .welcome-copy {
    padding-bottom: 64px;
  }

  .welcome-copy h2 {
    font-size: clamp(2.25rem, 15vw, 4.2rem);
  }

  .welcome-actions {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

@keyframes mobile-sheet-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.full-reader-panel:not(.is-book-reader) .book-page-arrow {
  display: none;
}

.full-reader-panel:not(.is-book-reader) .full-reader-book-stage {
  display: block;
}

.full-reader-panel:not(.is-book-reader) .full-reader-page-viewport {
  display: contents;
}

.full-reader-panel.is-book-reader {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
  padding: 58px 24px 18px;
  background:
    radial-gradient(circle at 50% 12%, rgba(240, 188, 106, 0.08), transparent 34%),
    #171511;
}

.full-reader-panel.is-book-reader > .panel-kicker {
  width: min(900px, calc(100% - 130px));
  max-width: none;
  margin: 0 auto;
  overflow: hidden;
  color: #d9b67d;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-reader-panel.is-book-reader .book-toc {
  width: min(900px, calc(100% - 130px));
  max-width: none;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  padding: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  border-color: rgba(240, 188, 106, 0.2);
  background: rgba(255, 255, 255, 0.045);
  scrollbar-width: thin;
}

.full-reader-panel.is-book-reader .book-toc span,
.full-reader-panel.is-book-reader .book-toc button {
  flex: 0 0 auto;
}

.full-reader-panel.is-book-reader .book-toc span {
  padding: 0 7px;
  color: #d9b67d;
}

.full-reader-panel.is-book-reader .book-toc button {
  min-height: 30px;
  padding: 4px 10px;
  color: #eee2d1;
  background: rgba(255, 255, 255, 0.055);
}

.full-reader-panel.is-book-reader .book-toc button:hover {
  background: rgba(240, 188, 106, 0.14);
}

.full-reader-book-stage {
  min-width: 0;
  min-height: 0;
}

.full-reader-panel.is-book-reader .full-reader-book-stage {
  display: grid;
  grid-template-columns: 54px minmax(0, 780px) 54px;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.full-reader-page-viewport {
  min-width: 0;
  min-height: 0;
}

.full-reader-panel.is-book-reader .full-reader-page-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(95, 63, 31, 0.22);
  border-radius: 3px;
  padding: clamp(34px, 5.5vh, 60px) clamp(44px, 6vw, 78px);
  background:
    linear-gradient(90deg, rgba(67, 45, 25, 0.045), transparent 9%, transparent 91%, rgba(67, 45, 25, 0.04)),
    #f8f2e7;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.full-reader-panel.is-book-reader .reader-text {
  width: calc(100% - 16px);
  max-width: none;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  color: #211b14;
  column-fill: auto;
  column-gap: 112px;
  column-width: var(--book-page-width, 680px);
  font-size: 1.06rem;
  font-kerning: normal;
  hyphens: auto;
  line-height: 1.76;
  orphans: 3;
  overflow-wrap: break-word;
  scroll-behavior: smooth;
  scrollbar-width: none;
  text-rendering: optimizeLegibility;
  widows: 3;
}

.full-reader-panel.is-book-reader .reader-text::-webkit-scrollbar {
  display: none;
}

.full-reader-panel.is-book-reader .reader-text > :first-child {
  margin-top: 0;
}

.full-reader-panel.is-book-reader .book-title {
  margin: 0 auto 2em;
  break-inside: avoid;
  text-align: center;
}

.full-reader-panel.is-book-reader .book-title h1 {
  margin: 0 0 0.55em;
  color: #2e2115;
  font-size: clamp(1.75rem, 4vh, 2.4rem);
  font-weight: 500;
  line-height: 1.1;
}

.full-reader-panel.is-book-reader .book-title p {
  color: #7a6041;
  text-indent: 0;
}

.full-reader-panel.is-book-reader .reader-text h2 {
  margin: 1.5em 0 0.75em;
  color: #5d3718;
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.full-reader-panel.is-book-reader .reader-text h3 {
  margin: 1.35em 0 0.65em;
  color: #6d4a2d;
  font-size: 1.04rem;
  font-weight: 600;
  text-align: center;
}

.full-reader-panel.is-book-reader .reader-text p {
  margin: 0 0 0.95em;
  text-indent: 1.35em;
  text-wrap: pretty;
}

.full-reader-panel.is-book-reader .book-title + p,
.full-reader-panel.is-book-reader .reader-text h2 + p,
.full-reader-panel.is-book-reader .reader-text h3 + p,
.full-reader-panel.is-book-reader .reader-text hr + p {
  text-indent: 0;
}

.full-reader-panel.is-book-reader .reader-text h1,
.full-reader-panel.is-book-reader .reader-text h2,
.full-reader-panel.is-book-reader .reader-text h3,
.full-reader-panel.is-book-reader .reader-text figure,
.full-reader-panel.is-book-reader .reader-text blockquote {
  break-inside: avoid;
}

.full-reader-panel.is-book-reader .reader-text h1,
.full-reader-panel.is-book-reader .reader-text h2,
.full-reader-panel.is-book-reader .reader-text h3 {
  break-after: avoid;
}

.full-reader-panel.is-book-reader .reader-text .book-page-break {
  height: 0;
  margin: 0;
  break-after: column;
  border: 0;
  background: transparent;
  opacity: 0;
}

.full-reader-panel.is-book-reader .inline-note-image img {
  max-height: calc(100dvh - 320px);
}

.book-page-arrow {
  width: 48px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(240, 188, 106, 0.22);
  border-radius: 8px;
  color: #f5e8d4;
  background: rgba(255, 255, 255, 0.055);
  font-size: 1.5rem;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.book-page-arrow:hover:not(:disabled) {
  border-color: rgba(240, 188, 106, 0.55);
  background: rgba(240, 188, 106, 0.13);
  transform: translateY(-1px);
}

.book-page-arrow:disabled {
  cursor: default;
  opacity: 0.24;
}

.book-page-controls {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d9b67d;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .full-reader-panel.is-book-reader {
    gap: 7px;
    padding: calc(112px + env(safe-area-inset-top)) 8px calc(10px + env(safe-area-inset-bottom));
  }

  .full-reader-panel.is-book-reader > .panel-kicker,
  .full-reader-panel.is-book-reader .book-toc {
    width: calc(100% - 96px);
  }

  .full-reader-panel.is-book-reader .book-toc {
    min-height: 38px;
    padding: 4px;
  }

  .full-reader-panel.is-book-reader .book-toc button {
    min-height: 30px;
    padding: 3px 8px;
    font-size: 0.76rem;
  }

  .full-reader-panel.is-book-reader .full-reader-book-stage {
    position: relative;
    display: block;
  }

  .full-reader-panel.is-book-reader .full-reader-page-viewport {
    padding: clamp(26px, 4.5vh, 40px) clamp(30px, 9vw, 42px);
  }

  .full-reader-panel.is-book-reader .reader-text {
    width: calc(100% - 8px);
    column-gap: 72px;
    font-size: clamp(0.94rem, 4vw, 1.02rem);
    line-height: 1.7;
  }

  .full-reader-panel.is-book-reader .inline-note-image img {
    max-height: calc(100dvh - 290px);
  }

  .book-page-arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 32px;
    height: 50px;
    border-color: rgba(95, 63, 31, 0.24);
    color: #3a2414;
    background: rgba(248, 242, 231, 0.9);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.16);
    transform: translateY(-50%);
  }

  .book-page-arrow:hover:not(:disabled) {
    background: #f8f2e7;
    transform: translateY(-50%);
  }

  .book-page-arrow-previous {
    left: 4px;
  }

  .book-page-arrow-next {
    right: 4px;
  }

  .book-page-controls {
    min-height: 24px;
  }
}

@media (max-width: 760px) {
  .admin-panel {
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 12px;
    padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  }

  .admin-header {
    position: relative;
    display: grid;
    gap: 12px;
    padding: 0 48px 12px 2px;
  }

  .admin-header h2 {
    font-size: 1.35rem;
  }

  .admin-summary {
    font-size: 0.78rem;
    line-height: 1.45;
  }

  .admin-header-actions {
    width: calc(100vw - 70px);
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }

  .admin-header-actions::-webkit-scrollbar {
    display: none;
  }

  .admin-header-actions .ghost-btn {
    flex: 0 0 auto;
    min-height: 42px;
  }

  .admin-header-actions .close-btn {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: 10px;
    z-index: 2;
  }

  .reference-field-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .reference-field-heading .ghost-btn {
    width: 100%;
    min-height: 42px;
  }

  #composeVisualisationSearch {
    scroll-margin-block: 100px 170px;
  }

  .bibliography-return-btn {
    max-width: calc(100% - 48px);
    min-height: 42px;
  }

  .admin-toolbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .admin-toolbar .admin-search-field {
    grid-column: 1 / -1;
  }

  .admin-toolbar label > span {
    font-size: 0.67rem;
  }

  .admin-toolbar .search,
  .admin-toolbar .mode-select {
    min-height: 42px;
    font-size: 0.78rem;
  }

  .admin-table-wrap,
  body.light-theme .admin-table-wrap {
    border: 0;
    background: transparent;
  }

  .admin-table,
  .admin-table tbody {
    display: block;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tbody {
    display: grid;
    gap: 9px;
  }

  .admin-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(16, 22, 33, 0.86);
  }

  body.light-theme .admin-table tbody tr {
    border-color: rgba(21, 32, 44, 0.13);
    background: rgba(255, 255, 255, 0.88);
  }

  .admin-table th,
  .admin-table td {
    width: auto;
  }

  .admin-table td {
    min-width: 0;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 11px;
  }

  .admin-table td::before {
    content: attr(data-label);
    display: inline;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .admin-table td:nth-child(2) {
    display: block;
    grid-column: 1 / -1;
    order: -1;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .admin-table td:nth-child(2)::before {
    display: none;
  }

  .admin-title-button strong {
    font-size: 1rem;
  }

  .admin-title-button small {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
  }

  .admin-row-tags {
    display: none;
  }

  .admin-table td:nth-child(6) {
    display: block;
    grid-column: 1 / -1;
  }

  .admin-reference-count {
    min-width: 26px;
    min-height: 26px;
  }

  .admin-status-select {
    max-width: 118px;
  }

  .admin-row-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-row-actions .ghost-btn {
    min-width: 0;
    min-height: 40px;
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 760px) {
  .has-active-entry .mobile-dock {
    z-index: 45;
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-overview .tag-bar {
    position: fixed;
    left: var(--mobile-edge);
    top: calc(max(8px, env(safe-area-inset-top)) + 66px);
    bottom: calc(var(--mobile-dock-height) + 20px);
    z-index: 11;
    width: min(116px, 31vw);
    max-width: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 0;
    overflow: auto;
    opacity: 1;
    pointer-events: none;
    scrollbar-width: none;
  }

  .mobile-overview .tag-bar::-webkit-scrollbar {
    display: none;
  }

  .mobile-overview .tag-bar button {
    min-height: 36px;
    flex: 0 0 auto;
    justify-content: flex-start;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    background: rgba(10, 14, 23, 0.9);
    backdrop-filter: none;
    pointer-events: auto;
  }

  .mobile-overview .tag-bar button:first-child.is-selected {
    color: #07101a;
    border-color: color-mix(in srgb, var(--accent) 64%, white);
    background: var(--accent);
  }

  .welcome-open.mobile-overview .tag-bar {
    opacity: 0;
    pointer-events: none;
  }

  .mobile-overview .tag-bar button:nth-child(n + 8) {
    display: none;
  }

  .mobile-local-view .tag-bar,
  .mobile-local-view .type-bar,
  .mobile-local-view .cluster-layer {
    display: none;
  }

  .mobile-graph-controls:not([hidden]) {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: calc(max(8px, env(safe-area-inset-top)) + 66px);
    z-index: 17;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    pointer-events: none;
  }

  .mobile-graph-controls button {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--ink);
    background: rgba(10, 14, 23, 0.92);
    font-size: 0.72rem;
    font-weight: 800;
    pointer-events: auto;
  }

  .mobile-graph-controls span {
    border-radius: 999px;
    padding: 6px 9px;
    color: var(--muted);
    background: rgba(10, 14, 23, 0.82);
    font-size: 0.68rem;
  }

  .mobile-overview .node {
    width: 64px;
    min-height: 64px;
    aspect-ratio: 1;
    display: block;
    padding: 0;
    border-radius: 50%;
    overflow: visible;
    background: color-mix(in srgb, var(--node-color, var(--accent)) 13%, rgba(10, 14, 23, 0.96));
    transform: translate(-50%, -50%) scale(var(--mobile-overview-compensation, 1));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--node-color, var(--accent)) 36%, transparent),
      0 0 24px color-mix(in srgb, var(--node-color, var(--accent)) 20%, transparent);
    transition: none;
  }

  .mobile-overview .node[data-type="heteronyme"],
  .mobile-overview .node[data-type="heteronyme"].has-image {
    width: 78px;
    min-height: 78px;
    padding: 0;
  }

  .mobile-overview .node > * {
    display: none;
  }

  .mobile-overview .node::before,
  .mobile-overview .node[data-type="heteronyme"]::before {
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    background: var(--node-color, var(--accent));
    box-shadow: 0 0 20px var(--node-color, var(--accent));
  }

  .mobile-overview .node[data-type="heteronyme"]::before {
    width: 22px;
    height: 22px;
    background: #fff0bb;
  }

  .mobile-overview .node.is-mobile-landmark::after {
    content: attr(data-label);
    position: absolute;
    left: 50%;
    top: calc(100% + 9px);
    width: 124px;
    transform: translateX(-50%);
    color: rgba(245, 247, 251, 0.94);
    font-size: 0.76rem;
    font-weight: 760;
    line-height: 1.18;
    text-align: center;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.96);
  }

  .mobile-overview .constellation-line {
    stroke: color-mix(in srgb, var(--link-color, var(--line)) 48%, var(--line));
    opacity: 0.28;
  }

  .mobile-local-view .node {
    width: 112px;
    min-height: 88px;
    padding: 12px;
    border-radius: 12px;
    transform: translate(-50%, -50%) scale(1);
    transition: left 220ms ease, top 220ms ease, opacity 160ms ease, border-color 160ms ease;
  }

  .mobile-local-view .node .node-content,
  .mobile-local-view .node .node-tags,
  .mobile-local-view .node .node-comment-badge,
  .mobile-local-view .node .node-degree {
    display: none;
  }

  .mobile-local-view .node .node-mood {
    padding-left: 13px;
    font-size: 0.9rem;
    line-height: 1.18;
    white-space: normal;
  }

  .mobile-local-view .node .node-date {
    font-size: 0.72rem;
  }

  .mobile-local-view .node.is-active {
    z-index: 8;
    width: 176px;
    min-height: 126px;
    align-content: center;
    padding: 20px;
    border-radius: 50%;
    text-align: center;
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--node-color, var(--accent)) 54%, transparent),
      0 0 48px color-mix(in srgb, var(--node-color, var(--accent)) 32%, transparent);
  }

  .mobile-local-view .node.is-active .node-type,
  .mobile-local-view .node.is-active .node-date {
    justify-self: center;
  }

  .mobile-local-view .node.is-active .node-mood {
    padding-left: 0;
    font-size: 1.08rem;
  }

  .mobile-local-view .node[data-type="heteronyme"],
  .mobile-local-view .node[data-type="heteronyme"].has-image {
    width: 132px;
    min-height: 132px;
    padding: 18px;
  }

  .mobile-local-view .node[data-type="heteronyme"].is-active {
    width: 184px;
    min-height: 184px;
  }

  .mobile-local-view .constellation-line {
    opacity: 0.82;
    stroke-width: 2.2;
  }

  .mobile-local-view .constellation-line.is-active-branch {
    opacity: 1;
    stroke-width: 3.2;
  }

  .mobile-local-view .reader-panel {
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    bottom: calc(var(--mobile-dock-height) + 14px);
    z-index: 40;
    width: auto;
    max-height: 42dvh;
    padding: 12px 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    box-shadow: 0 -14px 42px rgba(0, 0, 0, 0.46);
    transition: transform 150ms ease;
  }

  .mobile-local-view .reader-panel.is-swiping {
    transition: none;
  }

  .mobile-local-view .reader-panel::before {
    display: none;
  }

  .mobile-local-view .reader-drag-handle {
    position: sticky;
    left: auto;
    top: 0;
    z-index: 3;
    width: 72px;
    height: 22px;
    display: grid;
    margin: -7px auto 2px;
    border: 0;
    background: transparent;
  }

  .mobile-local-view .reader-panel > .close-btn {
    top: 2px;
    z-index: 4;
  }

  .mobile-local-view #detailMood {
    margin: 0 46px 10px 0;
    padding: 0;
    border: 0;
  }

  .mobile-local-view .detail-title {
    font-size: 1.45rem;
  }

  .mobile-neighbor-controls:not([hidden]) {
    min-height: 42px;
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 8px;
    margin: 8px 0 12px;
  }

  .mobile-neighbor-controls button {
    min-width: 44px;
    min-height: 42px;
    border-radius: 8px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.35rem;
  }

  .mobile-neighbor-controls span {
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
  }

  .mobile-local-view .reader-text {
    max-height: none;
    padding-right: 4px;
  }
}

@media (max-width: 380px) {
  .identity p {
    display: none;
  }

  .project-toggle {
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .mobile-dock button {
    font-size: 0.64rem;
  }

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

@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;
  }
}

.reader-video,
.youtube-embed {
  width: 100%;
  margin: 14px 0 18px;
}

.youtube-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #05070a;
  break-inside: avoid;
}

.youtube-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.node.has-video .node-content {
  position: relative;
}

.node.has-video .node-content::after {
  content: "\25B6";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  color: #07101a;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.42);
  font-size: 0.9rem;
}

.node-video-thumbnail {
  aspect-ratio: 16 / 9;
}

.full-reader-pin-btn {
  position: fixed;
  top: 18px;
  left: 178px;
  z-index: 42;
}

.full-reader-share-btn {
  position: fixed;
  top: 18px;
  left: 276px;
  z-index: 42;
}

.full-reader-pin-btn.is-selected,
.reader-actions button.is-selected {
  color: #07101a;
  border-color: color-mix(in srgb, var(--accent-two) 65%, white);
  background: var(--accent-two);
}

.manual-link-row {
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 0.72fr) auto;
}

.constellation-line.is-manual.is-relation-prolonge {
  stroke: #77d8ef;
  stroke-dasharray: none;
}

.constellation-line.is-manual.is-relation-contredit {
  stroke: #ff8f85;
  stroke-dasharray: 3 7;
}

.constellation-line.is-manual.is-relation-illustre {
  stroke: #f3c86d;
  stroke-dasharray: 1 8;
  stroke-linecap: round;
}

.constellation-line.is-manual.is-relation-source {
  stroke: #8fe0a1;
  stroke-width: 3;
  stroke-dasharray: none;
}

.constellation-line.is-manual.is-relation-repond {
  stroke: #d89ee9;
  stroke-dasharray: 13 5 3 5;
}

.tag-manager-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 70;
  width: min(920px, calc(100vw - 32px));
  max-height: min(82vh, 820px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  transform: translate(-50%, -50%);
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(10, 15, 24, 0.98);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}

.tag-manager-open::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(3, 6, 11, 0.64);
  backdrop-filter: blur(4px);
}

.tag-manager-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-right: 48px;
}

.tag-manager-header h2,
.tag-manager-header p {
  margin: 0;
}

.tag-manager-header .panel-kicker {
  margin-bottom: 5px;
}

.tag-manager-header > .close-btn {
  right: 0;
  top: 0;
}

.tag-manager-panel > .search {
  width: 100%;
  max-width: none;
}

.tag-manager-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.tag-manager-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) minmax(150px, 1fr) 92px 130px auto;
  align-items: end;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.tag-manager-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tag-manager-row input,
.tag-manager-row select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
}

.tag-manager-save {
  min-height: 38px;
}

.tag-manager-color {
  padding: 4px;
}

.tag-manager-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
  padding-bottom: 8px;
}

.tag-manager-identity strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-manager-identity small {
  grid-column: 2;
  color: var(--muted);
}

.tag-manager-swatch {
  grid-row: span 2;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tag-color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--tag-color) 48%, transparent);
}

.tag-manager-empty {
  color: var(--muted);
  text-align: center;
}

body.light-theme .tag-manager-panel {
  color: #15202c;
  border-color: rgba(30, 45, 60, 0.16);
  background: rgba(247, 249, 251, 0.99);
}

body.light-theme .tag-manager-row {
  border-color: rgba(30, 45, 60, 0.11);
  background: rgba(30, 45, 60, 0.035);
}

.field-optional {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: none;
}

@media (max-width: 760px) {
  .heatmap-enabled.mobile-overview .cluster-halo {
    display: block;
  }

  .full-reader-panel {
    padding-top: calc(116px + env(safe-area-inset-top));
  }

  .mobile-local-view .reader-video {
    margin-top: 8px;
  }

  .full-reader-pin-btn {
    top: calc(max(12px, env(safe-area-inset-top)) + 48px);
    left: 12px;
    min-height: 38px;
    padding: 0 10px;
  }

  .full-reader-share-btn {
    top: calc(max(12px, env(safe-area-inset-top)) + 48px);
    left: 112px;
    min-height: 38px;
    padding: 0 10px;
  }

  .manual-link-row {
    grid-template-columns: 1fr;
  }

  .tag-manager-panel {
    inset: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
    transform: none;
    padding: 14px;
  }

  .tag-manager-row {
    grid-template-columns: minmax(0, 1fr) 84px;
    align-items: end;
  }

  .tag-manager-identity,
  .tag-manager-row label:first-of-type {
    grid-column: 1 / -1;
  }

  .tag-manager-row label:nth-of-type(3) {
    grid-column: 1 / -1;
  }

  .tag-manager-save {
    grid-column: 1 / -1;
  }
}

/* Mobile reading-first layout: the map and the reader no longer compete for space. */
@media (max-width: 760px) {
  .mobile-overview .tag-bar,
  .mobile-local-view .tag-bar,
  .mobile-local-view .type-bar,
  .mobile-local-view .mobile-graph-controls {
    display: none !important;
  }

  .mobile-overview .viewport {
    inset: calc(max(8px, env(safe-area-inset-top)) + 64px) 0 calc(var(--mobile-dock-height) + 8px);
  }

  .mobile-overview .node {
    width: 58px;
    min-height: 58px;
  }

  .mobile-overview .node[data-type="heteronyme"],
  .mobile-overview .node[data-type="heteronyme"].has-image {
    width: 70px;
    min-height: 70px;
  }

  .mobile-overview .node::before,
  .mobile-overview .node[data-type="heteronyme"]::before {
    width: 16px;
    height: 16px;
  }

  .mobile-overview .node[data-type="heteronyme"]::before {
    width: 20px;
    height: 20px;
  }

  .mobile-overview .node.is-mobile-landmark::after {
    top: calc(100% + 7px);
    width: 112px;
    font-size: 0.7rem;
    line-height: 1.2;
  }

  .mobile-overview .constellation-line {
    opacity: 0.36;
  }

  .mobile-local-view .viewport {
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-local-view .reader-panel {
    position: fixed;
    left: var(--mobile-edge);
    right: var(--mobile-edge);
    top: calc(max(8px, env(safe-area-inset-top)) + 64px);
    bottom: calc(var(--mobile-dock-height) + 10px);
    z-index: 40;
    width: auto;
    max-height: none;
    display: block;
    padding: 14px 16px 28px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 62px 24px;
    border-radius: 10px;
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.48);
    transform: none !important;
  }

  body.light-theme.mobile-local-view .reader-panel {
    border-color: rgba(21, 32, 44, 0.16);
    background: rgba(248, 250, 252, 0.99);
  }

  .mobile-local-view .reader-drag-handle {
    display: none;
  }

  .mobile-local-view .reader-panel > .close-btn {
    position: sticky;
    top: 0;
    float: right;
    z-index: 6;
    margin: 0 0 -44px 10px;
  }

  .mobile-local-view #detailMood {
    min-height: 44px;
    margin: 0 50px 10px 0;
    padding: 4px 0 10px;
  }

  .mobile-local-view .detail-title {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
    line-height: 1.08;
  }

  .mobile-local-view .mobile-neighbor-controls:not([hidden]) {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 0 16px;
    padding: 6px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel-strong) 94%, transparent);
  }

  .mobile-local-view .reader-video {
    margin: 4px 0 18px;
    border-radius: 6px;
  }

  .mobile-local-view .reader-text {
    max-height: none;
    padding: 0;
    overflow: visible;
    font-size: 1.02rem;
    line-height: 1.72;
  }

  .mobile-local-view .reader-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-local-view .comments-panel {
    margin-top: 22px;
  }
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
