:root {
  color-scheme: light;
  --bg: #eef4f8;
  --wall-a: #e5f2ff;
  --wall-b: #f7edf6;
  --wall-c: #eaf8ef;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.76);
  --glass-soft: rgba(255, 255, 255, 0.34);
  --line: rgba(255, 255, 255, 0.58);
  --line-strong: rgba(108, 124, 148, 0.22);
  --hairline: rgba(24, 36, 56, 0.1);
  --text: #162033;
  --muted: #6b7382;
  --blue: #0a84ff;
  --blue-dark: #0067d7;
  --green: #30d158;
  --amber: #ff9f0a;
  --purple: #8e8cf6;
  --red: #ff453a;
  --shadow: 0 18px 52px rgba(35, 52, 78, 0.15);
  --shadow-soft: 0 10px 28px rgba(35, 52, 78, 0.1);
  --blur: blur(26px) saturate(1.55);
  --radius: 18px;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #090c13;
  --wall-a: #10243a;
  --wall-b: #251630;
  --wall-c: #10281f;
  --glass: rgba(24, 29, 42, 0.58);
  --glass-strong: rgba(35, 40, 56, 0.78);
  --glass-soft: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.18);
  --hairline: rgba(255, 255, 255, 0.1);
  --text: #f5f7fb;
  --muted: #a6afbf;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family:
    Inter, "SF Pro Display", "SF Pro Text", "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 10%, var(--wall-a) 0 24%, transparent 42%),
    radial-gradient(circle at 86% 12%, var(--wall-b) 0 20%, transparent 38%),
    radial-gradient(circle at 78% 88%, var(--wall-c) 0 24%, transparent 44%),
    linear-gradient(135deg, #fbfdff, var(--bg));
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 50%, #000 0 58%, transparent 86%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

p,
h1,
h2 {
  margin: 0;
}

.app {
  display: grid;
  grid-template-columns: 70px 310px minmax(520px, 1fr) 360px;
  gap: 12px;
  height: 100vh;
  min-width: 1180px;
  padding: 12px;
}

.rail,
.sidebar,
.main-pane,
.insight-pane,
.editor-shell,
.insight-card,
.network-card,
.review-card {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px;
  border-radius: 24px;
}

.brand {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 14px;
  color: #fff;
  font-weight: 850;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.36), transparent 38%),
    linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.62),
    0 12px 28px rgba(10, 132, 255, 0.28);
}

.rail-btn,
.icon-btn,
.soft-btn,
.primary-btn,
.plain-btn,
.nav-item,
.note-item,
.tag-pill,
.mini-note,
.suggestion,
.library-card,
.cluster-card,
.connection-row {
  position: relative;
  overflow: hidden;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.rail-btn::before,
.icon-btn::before,
.soft-btn::before,
.primary-btn::before,
.nav-item::before,
.note-item::before,
.tag-pill::before,
.mini-note::before,
.suggestion::before,
.library-card::before,
.cluster-card::before,
.connection-row::before {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  content: "";
  background: radial-gradient(
    circle at var(--spot-x, 50%) var(--spot-y, 50%),
    rgba(255, 255, 255, 0.58),
    rgba(255, 255, 255, 0.18) 24%,
    transparent 55%
  );
  opacity: 0;
  transition: opacity 160ms ease;
}

.rail-btn:hover::before,
.icon-btn:hover::before,
.soft-btn:hover::before,
.primary-btn:hover::before,
.nav-item:hover::before,
.note-item:hover::before,
.tag-pill:hover::before,
.mini-note:hover::before,
.suggestion:hover::before,
.library-card:hover::before,
.cluster-card:hover::before,
.connection-row:hover::before {
  opacity: 1;
}

.rail-btn,
.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: 15px;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
}

.rail-btn.active,
.rail-btn:hover,
.icon-btn:hover {
  color: var(--blue);
  border-color: var(--line);
  background: var(--glass-strong);
  box-shadow: 0 12px 24px rgba(10, 132, 255, 0.14);
  transform: translateY(-1px);
}

.rail-btn.bottom {
  margin-top: auto;
}

.sidebar,
.main-pane,
.insight-pane {
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-head,
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.18);
}

.sidebar-head p,
.pane-head p {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-head h1,
.pane-head h2 {
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.search-box {
  padding: 12px;
}

.search-box input,
.title-input,
.note-editor {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.44);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

body.theme-dark .search-box input,
body.theme-dark .title-input,
body.theme-dark .note-editor {
  background: rgba(255, 255, 255, 0.08);
}

.search-box input {
  height: 40px;
  padding: 0 12px;
}

.search-box input:focus,
.title-input:focus,
.note-editor:focus {
  border-color: rgba(10, 132, 255, 0.68);
  box-shadow:
    0 0 0 4px rgba(10, 132, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.nav-list,
.note-list,
.tag-list,
.mini-list,
.connection-list,
.theme-review {
  display: grid;
  gap: 8px;
}

.nav-list {
  padding: 0 12px 12px;
}

.nav-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: var(--line);
  background: var(--glass-strong);
  box-shadow: 0 10px 22px rgba(35, 52, 78, 0.1);
}

.nav-count {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.34);
  font-size: 12px;
  text-align: center;
}

.side-section {
  padding: 0 12px 12px;
  border-top: 1px solid var(--hairline);
}

.side-section.grow {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 8px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.section-title.flat {
  padding: 0 0 10px;
}

.plain-btn {
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
  font-weight: 820;
}

.tag-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tag-pill {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  font-size: 12px;
}

.tag-pill.active,
.tag-pill:hover {
  color: var(--blue);
  background: var(--glass-strong);
}

.note-list {
  padding-bottom: 12px;
}

.note-item,
.library-card {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 15px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.note-item:hover,
.note-item.active,
.library-card:hover {
  border-color: var(--line);
  background: var(--glass-strong);
  box-shadow: 0 12px 24px rgba(35, 52, 78, 0.1);
}

.note-item strong,
.library-card strong,
.mini-note strong,
.suggestion strong,
.connection-row strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item span,
.note-item small,
.library-card p,
.library-card span,
.mini-note span,
.suggestion span,
.connection-row span,
.insight-card p,
.review-card p,
.cluster-card p,
.cluster-card span,
.theme-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.main-pane {
  display: flex;
  flex-direction: column;
}

.head-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
}

.soft-btn,
.primary-btn {
  min-height: 38px;
  padding: 0 15px;
  border-radius: 13px;
  font-weight: 780;
  white-space: nowrap;
}

.soft-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--glass-soft);
}

.soft-btn:hover {
  background: var(--glass-strong);
  transform: translateY(-1px);
}

.primary-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 46%),
    linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 12px 26px rgba(10, 132, 255, 0.24);
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.write-view,
.library-view,
.network-view,
.review-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.editor-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 560px;
  padding: 26px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.52);
}

.title-input {
  min-height: 58px;
  padding: 0 4px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 34px;
  font-weight: 820;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
}

.meta-chip {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.36);
  font-size: 12px;
  font-weight: 800;
}

.note-editor {
  min-height: 0;
  padding: 16px 4px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 16px;
  line-height: 1.75;
  resize: none;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.library-card {
  min-height: 170px;
  padding: 18px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.42);
}

.network-grid,
.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.network-card,
.review-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 220px;
  padding: 18px;
  border-radius: 18px;
  background: var(--glass-strong);
}

.network-card.wide,
.hero-review {
  grid-column: 1 / -1;
}

.cluster-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.cluster-card,
.connection-row,
.mini-note,
.suggestion {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.28);
  text-align: left;
}

.cluster-card {
  min-height: 124px;
}

.cluster-card strong {
  color: var(--blue);
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.28);
}

.hero-review {
  min-height: 240px;
  padding: 26px;
}

.hero-review > span,
.ownership > span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.hero-review strong,
.ownership strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.2;
}

.hero-review p {
  max-width: 720px;
  margin: 8px 0 6px;
  font-size: 14px;
}

.insight-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow: auto;
}

.insight-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
}

.ownership {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.24)),
    linear-gradient(135deg, rgba(10, 132, 255, 0.12), rgba(142, 140, 246, 0.1));
}

.empty-mini {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 66px 300px minmax(480px, 1fr);
    min-width: 0;
    min-height: 100vh;
  }

  .insight-pane {
    grid-column: 2 / 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .ownership {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
    height: auto;
    padding: 10px;
  }

  .rail {
    position: sticky;
    top: 10px;
    height: calc(100vh - 20px);
    padding: 10px 6px;
  }

  .brand,
  .rail-btn,
  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .sidebar {
    grid-column: 2;
    max-height: 48vh;
  }

  .main-pane,
  .insight-pane {
    grid-column: 2;
  }

  .pane-head {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
  }

  .head-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .head-actions button {
    flex: 1 1 auto;
  }

  .write-view,
  .library-view,
  .network-view,
  .review-view {
    padding: 12px;
  }

  .editor-shell {
    min-height: 520px;
    padding: 18px;
  }

  .title-input {
    min-height: 50px;
    font-size: 26px;
  }

  .library-grid,
  .network-grid,
  .review-grid,
  .cluster-board,
  .insight-pane {
    grid-template-columns: 1fr;
  }

  .network-card.wide,
  .hero-review,
  .ownership {
    grid-column: auto;
  }
}
