:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-soft: #eef4ff;
  --green: #14b8a6;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111827;
  --panel: #1f2937;
  --text: #f9fafb;
  --muted: #a7b0bf;
  --line: #374151;
  --blue-soft: rgba(37, 99, 235, 0.18);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.web-login-view {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}

.web-login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  padding-bottom: 4px;
}

.web-login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.web-login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.web-login-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.web-login-status.bad {
  color: var(--red);
}

.web-login-status.ok {
  color: var(--green);
}

.app-shell {
  display: grid;
  grid-template-columns: 48px 220px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

:root[data-sidebar="collapsed"] .app-shell {
  grid-template-columns: 48px 0 minmax(0, 1fr);
}

.app-rail {
  position: sticky;
  top: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  height: 100vh;
  padding: 10px 6px;
  border-right: 1px solid #2f343c;
  background: #1f2937;
}

.rail-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  padding: 0;
  font-size: 13px;
  font-weight: 900;
}

:root[data-rail-mode="icon"] .rail-btn {
  font-size: 18px;
  font-weight: 800;
}

:root[data-rail-mode="letter"] .rail-btn {
  font-size: 13px;
  font-weight: 900;
}

.rail-btn:hover,
.rail-btn.active {
  border-color: #4b5563;
  background: #111827;
  color: #fff;
}

.hidden-file-input {
  display: none;
}

:root[data-sidebar="collapsed"] #railSidebarBtn {
  border-color: #4b5563;
  background: #111827;
  color: #fff;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  transition: padding 160ms ease, border-color 160ms ease;
}

:root[data-sidebar="collapsed"] .sidebar {
  padding: 0;
  border-right-color: transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.brand p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input,
.title-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.search-box input {
  height: 38px;
  padding: 0 10px;
}

.search-box input:focus,
.title-input:focus,
.memo-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.today-chip {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 42px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  text-align: left;
}

.today-chip span {
  font-size: 12px;
  font-weight: 800;
}

.today-chip strong {
  color: var(--text);
  font-size: 13px;
}

.nav-tab,
.ghost-btn,
.primary-btn,
.secondary-btn,
.danger-btn,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  min-height: 40px;
  padding: 0 12px;
  font-weight: 700;
}

.nav-tab {
  justify-content: flex-start;
  text-align: left;
}

.nav-tab.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.side-section {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

:root[data-sidebar-assist="hide"] .side-knowledge-section {
  display: none;
}

.side-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.side-section-head h2 {
  margin: 0;
  font-size: 13px;
}

.side-section-head span {
  font-size: 12px;
  font-weight: 800;
}

.side-list,
.side-tag-list {
  display: grid;
  gap: 6px;
}

.side-link,
.side-tag {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.side-link {
  display: grid;
  gap: 2px;
}

.side-link strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.side-link span,
.side-empty {
  color: var(--muted);
  font-size: 12px;
}

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

.side-tag {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.side-actions {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.side-action-group {
  display: grid;
  gap: 6px;
}

.side-action-group h2 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.sidebar .nav-tab,
.sidebar .ghost-btn,
.sidebar .file-btn {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
  justify-content: flex-start;
  text-align: left;
}

.count-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.count-btn strong {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: var(--blue);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.count-btn:not(.has-items) strong {
  color: var(--muted);
  background: transparent;
}

.file-btn {
  display: flex;
  align-items: center;
}

.file-btn input {
  display: none;
}

.workspace {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 18px 20px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.view-header h2 {
  margin: 6px 0 0;
  font-size: 28px;
  letter-spacing: 0;
}

.header-actions,
.editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.header-icon-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
}

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

.primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.secondary-btn {
  color: var(--blue);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.danger-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

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

.daily-layout,
.tree-layout {
  display: grid;
  grid-template-columns: minmax(180px, var(--tree-list-width, 280px)) 8px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-height: 0;
}

.daily-layout {
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
}

.resize-handle {
  align-self: stretch;
  border-radius: 8px;
  cursor: col-resize;
}

.resize-handle:hover,
body.resizing .resize-handle {
  background: var(--blue-soft);
}

body.resizing {
  user-select: none;
  cursor: col-resize;
}

.daily-popover {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  justify-items: end;
  background: rgba(15, 23, 42, 0.18);
  padding: 18px;
}

.settings-popover {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.28);
  padding: 18px;
}

.settings-popover.hidden {
  display: none;
}

.settings-card {
  width: min(880px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  padding: 22px;
}

.settings-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-row > div:first-child {
  min-width: 0;
}

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

.settings-row h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.settings-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.settings-select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-actions .secondary-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.help-link {
  text-decoration: none;
  justify-content: center;
}

.accent-choices {
  display: flex;
  gap: 10px;
}

.accent-btn {
  width: 34px;
  height: 34px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--accent-preview);
}

.accent-btn.active {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.switch input {
  display: none;
}

.switch span {
  position: relative;
  display: block;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #cbd5e1;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--blue);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

.feature-row {
  align-items: flex-start;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 300px;
}

.feature-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.shortcuts-row {
  align-items: flex-start;
}

.shortcut-groups {
  display: grid;
  gap: 14px;
  width: min(620px, 100%);
}

.shortcut-group {
  display: grid;
  gap: 8px;
}

.shortcut-group strong {
  color: var(--text);
  font-size: 13px;
}

.shortcut-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px;
}

.shortcut-list span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.shortcut-edit-row,
.feature-toggle-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.shortcut-capture-btn,
.shortcut-reset-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}

.shortcut-capture-btn {
  min-width: 120px;
  color: var(--blue);
}

.shortcut-reset-btn {
  padding: 0 8px;
  color: var(--muted);
}

.feature-toggle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  width: min(620px, 100%);
}

.feature-toggle-row {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feature-toggle-row span {
  display: grid;
  gap: 3px;
}

.feature-toggle-row small {
  color: var(--muted);
  font-size: 12px;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

[data-feature-search="hide"] #railSearchBtn,
[data-feature-search="hide"] #searchPopoverView,
[data-feature-daily="hide"] #railDailyBtn,
[data-feature-daily="hide"] #dailyToggleBtn,
[data-feature-daily="hide"] #dailyView,
[data-feature-quick-switch="hide"] #railQuickBtn,
[data-feature-quick-switch="hide"] #quickSwitchBtn,
[data-feature-quick-switch="hide"] #quickSwitchView,
[data-feature-graph="hide"] #railGraphBtn,
[data-feature-graph="hide"] #graphBtn,
[data-feature-graph="hide"] #graphView,
[data-feature-favorites="hide"] .side-section[aria-labelledby="favoriteTitle"],
[data-feature-favorites="hide"] #favoriteBtn {
  display: none !important;
}

.daily-popover.hidden {
  display: none;
}

.daily-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  padding: 18px;
}

.daily-layout.compact {
  grid-template-columns: 260px minmax(0, 1fr);
}

.daily-layout.compact .memo-editor {
  min-height: 360px;
}

.archive-panel {
  margin-top: 14px;
  padding: 16px;
}

.archive-head,
.archive-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.archive-head {
  margin-bottom: 12px;
}

.archive-head h3 {
  margin: 4px 0 0;
  font-size: 20px;
}

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

.deleted-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 14px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.deleted-toolbar strong {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.deleted-toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.deleted-toolbar .secondary-btn,
.deleted-toolbar .danger-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.archive-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

#deletedTreeList .archive-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: flex-start;
}

#deletedTreeList .archive-item.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.24);
}

.archive-check {
  display: inline-flex;
  align-items: center;
  padding-top: 3px;
}

.archive-check input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--blue);
}

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

.archive-item strong {
  display: block;
  margin-bottom: 4px;
}

.archive-item span,
.archive-item p,
.empty-compact {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.archive-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calendar-panel,
.tree-panel,
.editor-panel {
  padding: 18px;
}

.tree-panel,
.editor-panel {
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.tree-panel {
  padding: 8px;
}

.month-bar {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  text-align: center;
}

.icon-btn {
  padding: 0;
  font-size: 26px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.day-btn {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.day-btn.muted {
  color: #c0c6d0;
}

.day-btn.selected {
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.day-btn.has-note::after {
  content: "";
  position: absolute;
  bottom: 6px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--green);
}

.open-tabs-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: -4px 0 14px;
  border-bottom: 1px solid var(--line);
  padding-left: 4px;
}

.open-tabs {
  display: flex;
  gap: 0;
  min-width: 0;
  overflow-x: auto;
}

.open-tab-actions {
  display: flex;
  gap: 6px;
  padding-bottom: 4px;
  white-space: nowrap;
}

.open-tab-actions .secondary-btn {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.open-tab-actions .secondary-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.open-tab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  width: 156px;
  min-width: 156px;
  height: 36px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--panel);
  color: var(--muted);
  padding: 0 9px;
  font-size: 13px;
  font-weight: 800;
  position: relative;
  transform: translateY(1px);
}

.open-tab.active {
  border-color: var(--blue);
  background: var(--bg);
  color: var(--text);
  z-index: 1;
}

.open-tab.pinned {
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
}

.open-tab.pinned span {
  color: var(--blue);
}

.open-tab.active::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: -1px;
  height: 3px;
  background: var(--blue);
}

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

.open-tab strong {
  color: inherit;
  font-size: 14px;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.editor-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-text-btn {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.icon-text-btn.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.editor-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
}

.editor-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.editor-tool-actions .secondary-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.path-label {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.path-link {
  max-width: 180px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-link:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.path-link[aria-current="page"] {
  color: var(--text);
  font-weight: 800;
}

.path-separator {
  color: var(--muted);
}

.note-find-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.note-find-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 180px;
  flex: 1;
  color: var(--muted);
}

.note-find-bar input {
  width: 100%;
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  outline: none;
}

.note-find-count {
  min-width: 46px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.note-find-bar .icon-btn {
  width: 30px;
  min-height: 30px;
  height: 30px;
}

.note-find-bar.not-found {
  border-color: var(--red);
}

.outline-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
}

.outline-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 0 8px;
  padding-left: calc(8px + var(--outline-depth, 0) * 12px);
  text-align: left;
}

.outline-item:hover {
  background: var(--blue-soft);
}

.outline-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.outline-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

:root[data-tags="hide"] .tag-list {
  display: none;
}

.tag-chip,
.tag-empty {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.tag-empty {
  background: transparent;
  color: var(--muted);
}

.note-stats {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0;
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-x: auto;
  white-space: nowrap;
}

.note-stats span {
  padding: 0 8px;
  border-right: 1px solid var(--line);
}

.note-stats span:first-child {
  border-left: 1px solid var(--line);
}

.note-stats .warning {
  color: var(--red);
  font-weight: 800;
}

.save-state {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.memo-editor {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  line-height: 1.65;
  outline: none;
}

.memo-editor.readonly {
  background: color-mix(in srgb, var(--panel) 82%, var(--bg));
  color: var(--muted);
  cursor: default;
}

:root[data-font-size="small"] .memo-editor,
:root[data-font-size="small"] .markdown-preview {
  font-size: 14px;
}

:root[data-font-size="medium"] .memo-editor,
:root[data-font-size="medium"] .markdown-preview {
  font-size: 16px;
}

:root[data-font-size="large"] .memo-editor,
:root[data-font-size="large"] .markdown-preview {
  font-size: 18px;
}

:root[data-line-height="compact"] .memo-editor,
:root[data-line-height="compact"] .markdown-preview {
  line-height: 1.45;
}

:root[data-line-height="normal"] .memo-editor,
:root[data-line-height="normal"] .markdown-preview {
  line-height: 1.65;
}

:root[data-line-height="relaxed"] .memo-editor,
:root[data-line-height="relaxed"] .markdown-preview {
  line-height: 1.9;
}

.tree-list {
  display: grid;
  gap: 4px;
}

.tree-node {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

.tree-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 24px;
  gap: 6px;
  align-items: center;
  width: 100%;
  min-height: 34px;
  background: transparent;
  padding: 5px 7px;
}

.tree-row.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.tree-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 800;
}

.tree-meta {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.tree-node.expanded > .tree-row .tree-meta,
.tree-node:not(.has-children) > .tree-row .tree-meta {
  display: none;
}

.tree-children {
  display: grid;
  gap: 4px;
  padding: 0 4px 5px 16px;
}

.small-btn {
  width: 24px;
  min-width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--blue);
  font-weight: 800;
}

.small-btn:disabled {
  display: none;
}

.tree-toggle,
.tree-label-btn {
  border: 0;
  background: transparent;
}

.tree-toggle {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
}

.tree-toggle:not(:disabled):hover {
  background: #f1f5f9;
  color: var(--blue);
}

.tree-label-btn {
  min-width: 0;
  min-height: 28px;
  padding: 0;
  color: inherit;
  font-size: 14px;
  text-align: left;
}

.title-input {
  min-height: 44px;
  padding: 0 12px;
  font-size: 22px;
  font-weight: 800;
}

.tree-editor .memo-editor {
  min-height: 560px;
}

.markdown-preview {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  line-height: 1.7;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
  margin: 0 0 12px;
  line-height: 1.3;
  letter-spacing: 0;
}

.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
  font-size: 1em;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol {
  margin: 0 0 12px;
}

.markdown-preview blockquote {
  margin: 0 0 12px;
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  background: var(--blue-soft);
  color: var(--muted);
}

.markdown-preview hr {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.task-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  list-style: none;
}

.task-list-item input {
  margin-top: 5px;
  accent-color: var(--blue);
  cursor: pointer;
}

.markdown-preview code {
  border-radius: 6px;
  background: #f1f5f9;
  padding: 2px 6px;
}

.markdown-preview pre {
  margin: 0 0 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 12px;
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

:root[data-theme="dark"] .markdown-preview code,
:root[data-theme="dark"] .tree-toggle:not(:disabled):hover {
  background: #111827;
}

.wiki-link {
  border: 0;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 1px 5px;
  font-weight: 800;
}

.markdown-preview a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.markdown-preview a:hover {
  text-decoration: underline;
}

.tag-inline {
  color: var(--green);
  font-weight: 800;
}

.backlinks-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

:root[data-backlinks="hide"] .backlinks-panel {
  display: none;
}

.backlinks-panel h3 {
  margin: 0;
  font-size: 16px;
}

.backlink-list {
  display: grid;
  gap: 8px;
}

.backlink-item,
.quick-result,
.graph-link {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
}

.backlink-item span,
.quick-result span {
  color: var(--muted);
  font-size: 13px;
}

.quick-result:focus-visible,
.result-item:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  outline: none;
}

.backlink-item.missing-link {
  border-style: dashed;
}

.backlink-item.missing-link strong {
  color: var(--blue);
}

.quick-popover {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: start center;
  background: rgba(15, 23, 42, 0.28);
  padding: 64px 18px 18px;
}

.quick-popover.hidden {
  display: none;
}

.quick-card {
  width: min(680px, 100%);
  max-height: calc(100vh - 96px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  padding: 18px;
}

.quick-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.settings-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.settings-input:focus,
.settings-select:focus,
.settings-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.settings-textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  line-height: 1.5;
}

.server-settings-row {
  align-items: start;
  grid-template-columns: 1fr;
}

.server-settings-row > div:first-child {
  width: 100%;
  min-width: 0;
  word-break: keep-all;
}

.server-settings-form {
  display: grid;
  gap: 10px;
  width: 100%;
}

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

.server-guide-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--blue-soft) 54%, var(--panel));
}

.server-guide-box strong {
  color: var(--text);
  font-size: 13px;
}

.server-guide-box ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

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

.server-profile-box,
.server-analysis-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 86%, var(--bg));
}

.server-profile-box strong,
.server-analysis-box strong {
  color: var(--text);
  font-size: 13px;
}

.server-profile-box p,
.server-analysis-box p {
  margin: 3px 0 0;
}

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

.server-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.server-status-text.ok {
  color: var(--green);
}

.server-status-text.warn {
  color: var(--amber);
}

.server-status-text.bad {
  color: var(--red);
}

.server-meta-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.server-meta-text.has-pending {
  color: var(--amber);
}

.server-capabilities-text {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.server-capability-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 82%, var(--bg));
}

.server-analysis-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.server-analysis-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.server-analysis-item strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-analysis-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
}

.server-analysis-side {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.server-analysis-apply {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--blue);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
}

.server-analysis-apply:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.server-analysis-status.done {
  background: #dcfce7;
  color: #166534;
}

.server-analysis-status.failed {
  background: #fee2e2;
  color: #991b1b;
}

.server-analysis-status.running,
.server-analysis-status.queued {
  background: #fef3c7;
  color: #92400e;
}

.server-analysis-preview {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-popover-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 160px;
  gap: 8px;
  margin-bottom: 10px;
}

.search-count {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.header-count {
  margin: 8px 0 0;
  white-space: nowrap;
}

.compact-action {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.compact-select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.search-option-help {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.search-option-help span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 5px 8px;
}

.search-option-help strong {
  color: var(--text);
}

.search-hit {
  border-radius: 4px;
  background: color-mix(in srgb, var(--blue) 24%, transparent);
  color: var(--text);
  padding: 0 2px;
  font-weight: 900;
}

.quick-results,
.graph-list {
  display: grid;
  gap: 8px;
}

.graph-card {
  width: min(820px, 100%);
}

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

.graph-link span {
  color: var(--blue);
  font-weight: 900;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state .primary-btn {
  margin-top: 10px;
}

.tree-panel .empty-state {
  min-height: 180px;
  padding: 24px 14px;
}

.empty-state strong {
  color: var(--text);
  font-size: 20px;
}

.hidden {
  display: none;
}

.toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, var(--blue-soft));
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: color-mix(in srgb, #dc2626 42%, var(--line));
  background: color-mix(in srgb, var(--panel) 92%, #fee2e2);
}

.toast.success {
  border-color: color-mix(in srgb, #059669 38%, var(--line));
  background: color-mix(in srgb, var(--panel) 92%, #d1fae5);
}

.results-list {
  display: grid;
  gap: 0;
}

.result-item {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: transparent;
  text-align: left;
}

.result-item:last-child {
  border-bottom: 0;
}

.result-item strong {
  font-size: 17px;
}

.result-item span,
.result-item p {
  margin: 0;
  color: var(--muted);
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(38, 52, 70, 0.38);
}

.confirm-backdrop.hidden {
  display: none;
}

.confirm-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(38, 52, 70, 0.22);
  padding: 22px;
}

.confirm-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.confirm-card p {
  margin: 0;
  color: var(--text);
  white-space: pre-line;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-rail {
    position: static;
    grid-auto-flow: column;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .daily-layout,
  .tree-layout {
    grid-template-columns: 1fr;
  }

  .resize-handle {
    display: none;
  }

  .daily-layout.compact {
    grid-template-columns: 1fr;
  }

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

  .feature-list {
    justify-content: flex-start;
  }

  .search-popover-toolbar {
    grid-template-columns: 1fr;
  }

  .note-find-bar {
    grid-template-columns: 1fr;
  }

  .open-tabs-bar {
    grid-template-columns: 1fr;
  }

  .open-tab-actions {
    justify-content: flex-end;
  }

  .shortcut-groups {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .toast-region {
    right: 14px;
    bottom: 14px;
    width: calc(100vw - 28px);
  }

  .view-header {
    display: grid;
  }

  .shortcut-list {
    grid-template-columns: 1fr;
  }

  .server-identity-grid,
  .server-profile-grid {
    grid-template-columns: 1fr;
  }

  .memo-editor,
  .empty-state {
    min-height: 360px;
  }
}
