: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;
}

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.65;
  opacity: 0.82;
  filter: drop-shadow(0 0 4px rgba(126, 210, 231, 0.18));
  transition: opacity 220ms ease, stroke 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;
  stroke-dasharray: 7 8;
  opacity: 0.62;
  filter: none;
}

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

.constellation-line.is-tag-focus {
  stroke: var(--link-color, var(--accent));
  stroke-width: 3.2;
  opacity: 1;
  filter: drop-shadow(0 0 9px color-mix(in srgb, var(--link-color, var(--accent)) 54%, transparent));
}

.constellation-line.is-tag-bridge {
  stroke: var(--accent-two);
  stroke-width: 2.35;
  opacity: 0.72;
}

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

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

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

.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);
}

.topbar,
.tag-bar,
.search-panel,
.tag-panel,
.network-panel,
.timeline-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: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

.identity,
.tools,
.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 .tools,
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 .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);
}

.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 {
  min-width: 0;
  overflow-x: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  scrollbar-width: none;
}

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

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

.type-bar {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 128px;
  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;
  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);
}

.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);
}

#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 {
  top: 174px;
  max-height: 310px;
  overflow: auto;
  padding: 8px;
}

.tag-panel {
  bottom: 82px;
  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;
  white-space: pre-wrap;
}

.project-open-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 12px;
  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: 22px;
  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;
}

.timeline-panel {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 18px;
  z-index: 10;
  max-height: 220px;
  overflow: hidden;
  padding: 15px 16px 14px;
  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);
}

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

.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-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.timeline-track {
  --timeline-count: 1;
  position: relative;
  width: max-content;
  min-width: max(100%, calc(var(--timeline-count) * 178px));
  min-height: 116px;
  display: flex;
  align-items: flex-start;
  padding: 0 24px;
}

.timeline-track::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 32px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--line), var(--accent), var(--line), transparent);
}

.timeline-item {
  position: relative;
  flex: 0 0 168px;
  margin-left: var(--timeline-gap, 12px);
  padding-top: 16px;
  width: 156px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.timeline-item:first-child {
  margin-left: 0;
}

.timeline-dot {
  position: absolute;
  left: 50%;
  top: 9px;
  width: 14px;
  height: 14px;
  transform: translateX(-50%);
  border: 2px solid var(--panel-strong);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(126, 210, 231, 0.42);
}

.timeline-item[data-type="heteronyme"] .timeline-dot {
  background: var(--accent-two);
  box-shadow: 0 0 18px rgba(240, 188, 106, 0.44);
}

.timeline-card {
  display: block;
  margin-top: 29px;
  min-height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.055);
}

.timeline-card strong,
.timeline-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-card strong {
  font-size: 0.8rem;
}

.timeline-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

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

.timeline-item.is-active .timeline-dot {
  outline: 3px solid rgba(126, 210, 231, 0.2);
}

.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-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;
  font-size: 1rem;
}

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

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);
}

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);
}

#editModeBtn {
  flex: 0 0 auto;
}

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

.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);
}

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;
}

.node.is-dimmed {
  opacity: 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;
}

.reader-panel,
.compose-popover {
  position: absolute;
  right: 28px;
  width: min(480px, calc(100% - 44px));
  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 {
  top: 96px;
  max-height: calc(100vh - 142px);
  overflow: auto;
  padding: 24px;
}

.reader-panel.is-book {
  width: min(760px, calc(100% - 56px));
  padding: 42px min(54px, 7vw);
  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 .panel-kicker {
  color: #8a5a20;
  text-align: center;
}

.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.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 {
  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 .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 .add-btn,
.full-reader-open .book-add-btn,
.full-reader-open .page-actions,
.full-reader-open .timeline-panel,
.full-reader-open .reader-panel {
  display: none;
}

.compose-popover {
  bottom: 102px;
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 20px;
}

.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;
}

.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);
}

.close-btn {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.085);
}

.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-period {
  margin-top: 14px;
  color: var(--accent-two);
  font-size: 0.84rem;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.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 {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

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

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

.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-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.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-item {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

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

.comment-body {
  color: var(--ink);
  line-height: 1.45;
  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;
}

.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;
}

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;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

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

@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: 146px;
  }

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

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

  .tag-panel {
    left: 12px;
    right: 12px;
    bottom: 78px;
    width: auto;
  }

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

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

  .timeline-track {
    min-width: max(100%, calc(var(--timeline-count) * 154px));
  }

  .timeline-item {
    flex-basis: 146px;
    width: 136px;
  }

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

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

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

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

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

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

  .tool-btn,
  .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: 62dvh;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }

  .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));
  }

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

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

  .book-add-btn {
    right: 82px;
    bottom: 21px;
    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;
  }

  .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;
  }
}
