:root {
  color-scheme: dark;
  --bg: #181818;
  --chrome: #111111;
  --panel: #1f1f1f;
  --panel-soft: #232323;
  --panel-strong: #2a2a2a;
  --ink: #e4e4e4;
  --ink-strong: #f4f4f4;
  --muted: #a6a6a6;
  --faint: #6f6f6f;
  --line: #353535;
  --line-soft: #2a2a2a;
  --accent: #8b5cf6;
  --accent-2: #22c55e;
  --accent-3: #d9b566;
  --danger: #ef6868;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 290px minmax(520px, 1fr) minmax(330px, 0.72fr);
  height: 100vh;
  min-height: 0;
  background: var(--bg);
}

.sidebar,
.editor-pane,
.insight-pane {
  min-height: 0;
  background: var(--panel);
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.insight-pane {
  display: grid;
  grid-template-rows: minmax(240px, 0.88fr) minmax(170px, 0.62fr) minmax(210px, 0.7fr);
  border-left: 1px solid var(--line);
}

.brand,
.editor-toolbar,
.panel-head,
.settings-form header,
.settings-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  padding: 20px 18px 14px;
}

.brand h1 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 25px;
  line-height: 1.1;
}

.settings-form h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button,
.ghost-button,
.primary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.ghost-button,
.primary-button {
  padding: 0 13px;
  white-space: nowrap;
}

.primary-button {
  border-color: #1d6f46;
  background: #1f7a4d;
  color: #fff;
}

.primary-button:hover {
  background: #26965d;
}

.text-button {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 0;
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--accent);
  color: var(--ink-strong);
}

.search-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 0 14px 12px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #181818;
  color: var(--ink);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
textarea:focus {
  border-color: #7c5bd5;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.18);
}

input {
  height: 40px;
  padding: 0 12px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin: 0 14px 12px;
  padding: 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  background: #1a1a1a;
}

.search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px 10px;
  color: var(--faint);
  font-size: 12px;
}

.search-heading strong {
  color: var(--ink);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-3);
}

.dot.connected {
  background: var(--accent-2);
}

.dot.error {
  background: var(--danger);
}

.note-list {
  overflow: auto;
  padding: 0 8px 16px;
}

.note-list::-webkit-scrollbar,
.suggestion-list::-webkit-scrollbar,
.attachment-list::-webkit-scrollbar,
.panel::-webkit-scrollbar {
  width: 8px;
}

.note-list::-webkit-scrollbar-thumb,
.suggestion-list::-webkit-scrollbar-thumb,
.attachment-list::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb {
  background: #4a4a4a;
  border-radius: 999px;
}

.note-item {
  display: block;
  width: 100%;
  margin: 0 0 5px;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.note-item:hover,
.note-item.active {
  border-color: var(--line);
  background: #242424;
}

.note-title {
  display: block;
  overflow: hidden;
  color: var(--ink-strong);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-meta {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.editor-toolbar {
  align-items: flex-start;
  padding: 22px 28px 12px;
}

.title-stack {
  min-width: 0;
  flex: 1;
}

.title-input {
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink-strong);
  font-size: 34px;
  font-weight: 850;
  line-height: 1.12;
}

.title-input:focus {
  box-shadow: none;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  color: var(--faint);
  font-size: 12px;
}

.top-attachments {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  max-width: 100%;
}

.top-attachment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  flex: 0 0 auto;
}

.top-attachment-head strong {
  color: var(--ink-strong);
  font-size: 13px;
  line-height: 1.15;
}

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

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(300px, 1fr) minmax(220px, 0.72fr);
  gap: 12px;
  min-height: 0;
  padding: 0 28px 24px;
}

.body-card {
  grid-column: 1 / -1;
}

.composer-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1b1b1b;
  overflow: hidden;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.field-head h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 14px;
}

textarea {
  min-height: 0;
  flex: 1;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 18px;
  background: transparent;
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 15px;
  line-height: 1.74;
}

textarea:focus {
  box-shadow: none;
}

.chip-box {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 50px;
  padding: 12px 12px 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 30px;
  border: 1px solid #3a3152;
  border-radius: 999px;
  padding: 0 9px 0 11px;
  background: rgba(139, 92, 246, 0.16);
  color: #ded3ff;
  font-size: 12px;
  font-weight: 700;
}

.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #b5a7e3;
  line-height: 1;
  padding: 0;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 6px 12px 10px;
}

.composer-card > input {
  width: calc(100% - 24px);
  margin: 6px 12px 10px;
}

.suggestion-list {
  display: grid;
  gap: 6px;
  overflow: auto;
  padding: 0 12px 12px;
}

.suggestion-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 9px 10px;
  background: #202020;
  color: var(--ink);
  text-align: left;
}

.suggestion-item:hover {
  border-color: #6f55bd;
  background: #25222e;
}

.suggestion-item strong {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-item span {
  overflow: hidden;
  color: var(--faint);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-item.create {
  border-color: rgba(34, 197, 94, 0.36);
  color: #9ee8b9;
}

.file-picker {
  position: relative;
  overflow: hidden;
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.attachment-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
  padding: 0 0 2px;
}

.attachment-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 8px;
  background: #202020;
  min-width: 220px;
  max-width: 280px;
}

.attachment-thumb {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 5px;
  overflow: hidden;
  background: #151515;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-info {
  min-width: 0;
}

.attachment-info strong,
.attachment-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-info strong {
  color: var(--ink-strong);
  font-size: 13px;
}

.attachment-info span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 12px;
}

.attachment-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.attachment-remove:hover {
  background: #292929;
  color: var(--ink-strong);
}

.panel {
  min-height: 0;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  padding: 18px;
  background: #1b1b1b;
}

.panel:last-child {
  border-bottom: 0;
}

.panel h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 16px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.graph-view {
  position: relative;
  min-height: 170px;
  height: calc(100% - 30px);
  margin-top: 12px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 55%, rgba(139, 92, 246, 0.1), transparent 34%),
    #1b1b1b;
  overflow: hidden;
}

.graph-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 0;
  background: #f3f3f3;
  color: transparent;
  font-size: 0;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.08);
}

.graph-node::after {
  content: attr(data-label);
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 120px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: normal;
}

.graph-node.secondary {
  width: 10px;
  height: 10px;
  background: #b8b8b8;
  box-shadow: none;
}

.graph-node.secondary::after {
  display: none;
}

.graph-line {
  position: absolute;
  height: 1px;
  transform-origin: left center;
  background: rgba(170, 170, 170, 0.28);
}

.related-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.related-card {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 10px;
  background: #202020;
  color: var(--ink);
  text-align: left;
}

.related-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-strong);
  font-size: 13px;
}

.related-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.preview {
  margin-top: 10px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.72;
}

.preview h1,
.preview h2,
.preview h3 {
  margin: 14px 0 8px;
  color: var(--ink-strong);
  line-height: 1.25;
}

.preview p {
  margin: 0 0 10px;
}

.preview code {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.18);
  color: #d9ceff;
}

dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.56);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-form label input {
  color: var(--ink);
  font-weight: 500;
}

.check-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.empty {
  margin: 0;
  padding: 18px 10px;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.5;
}

.top-attachments .empty {
  width: 100%;
  max-width: 100%;
  padding: 9px 0 0;
  overflow: visible;
  color: var(--muted);
  white-space: normal;
}

.attachment-list.empty-state {
  display: block;
  overflow: visible;
  padding-bottom: 0;
}

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

  .shell {
    grid-template-columns: 270px minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .insight-pane {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .panel {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .panel:last-child {
    border-right: 0;
  }
}

@media (max-width: 780px) {
  .shell {
    display: block;
  }

  .sidebar,
  .editor-pane,
  .insight-pane {
    min-height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .note-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
  }

  .note-item {
    min-width: 210px;
  }

  .editor-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 20px 16px 12px;
  }

  .top-attachments {
    flex-direction: column;
  }

  .toolbar-actions {
    flex-direction: column;
  }

  .title-input {
    font-size: 27px;
  }

  .memory-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    padding: 0 16px 16px;
  }

  .body-card {
    min-height: 420px;
  }

  .insight-pane {
    display: block;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
