/* Obsidian Web — self-contained static clone */

:root {
  --font-interface: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Source Code Pro", Consolas, monospace;
  --font-text: var(--font-interface);

  --background-primary: #1e1e1e;
  --background-primary-alt: #2b2b2b;
  --background-secondary: #262626;
  --background-secondary-alt: #333333;
  --background-modifier-cover: rgba(0, 0, 0, 0.6);
  --background-modifier-hover: rgba(255, 255, 255, 0.06);
  --background-modifier-active-hover: rgba(255, 255, 255, 0.12);
  --background-modifier-border: #3e3e3e;
  --background-modifier-border-hover: #4e4e4e;
  --background-modifier-error: #3d1818;

  --text-normal: #dcdcdc;
  --text-muted: #808080;
  --text-faint: #5d5d5d;
  --text-accent: #7f6df2;
  --text-accent-hover: #998afb;
  --text-error: #ff6666;
  --text-success: #7ee787;

  --interactive-normal: #2b2b2b;
  --interactive-hover: #3e3e3e;
  --interactive-accent: #7f6df2;
  --interactive-accent-hover: #998afb;

  --tag-background: #3e2a5b;
  --tag-color: #c4b5fd;
  --link-color: #7f6df2;
  --link-color-hover: #998afb;
  --link-unresolved-color: #7f6df2;
  --link-unresolved-opacity: 0.6;

  --icon-color: #999;
  --icon-color-hover: #ccc;
  --icon-kg: 1;

  --titlebar-height: 38px;
  --ribbon-width: 44px;
  --sidebar-width: 260px;
  --statusbar-height: 28px;
  --tab-height: 36px;

  --border-radius: 6px;
  --modal-border-radius: 8px;
  --transition-fast: 120ms ease-in-out;
  --transition-normal: 200ms ease-in-out;

  --accent-h: 252;
  --accent-s: 85%;
  --accent-l: 70%;
}

.theme-light {
  --background-primary: #ffffff;
  --background-primary-alt: #f5f5f5;
  --background-secondary: #f8f8f8;
  --background-secondary-alt: #eeeeee;
  --background-modifier-cover: rgba(0, 0, 0, 0.4);
  --background-modifier-hover: rgba(0, 0, 0, 0.04);
  --background-modifier-active-hover: rgba(0, 0, 0, 0.08);
  --background-modifier-border: #e0e0e0;
  --background-modifier-border-hover: #c0c0c0;
  --background-modifier-error: #ffe6e6;

  --text-normal: #2e2e2e;
  --text-muted: #7a7a7a;
  --text-faint: #a0a0a0;
  --text-accent: #5b45d9;
  --text-accent-hover: #3e2bb0;
  --text-error: #d73a3a;
  --text-success: #1a7f37;

  --interactive-normal: #ffffff;
  --interactive-hover: #f0f0f0;
  --interactive-accent: #5b45d9;
  --interactive-accent-hover: #3e2bb0;

  --tag-background: #ede9fe;
  --tag-color: #5b45d9;
  --link-color: #5b45d9;
  --link-color-hover: #3e2bb0;
  --link-unresolved-color: #5b45d9;

  --background-modifier-cover: rgba(0, 0, 0, 0.3);
  --icon-color: #666;
  --icon-color-hover: #333;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-interface);
  font-size: 14px;
  color: var(--text-normal);
  background: var(--background-primary);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Titlebar */
.titlebar {
  height: var(--titlebar-height);
  background: var(--background-secondary);
  border-bottom: 1px solid var(--background-modifier-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  flex: 0 0 auto;
  -webkit-app-region: drag;
}

.titlebar .nav-btns {
  display: flex;
  gap: 2px;
}

.titlebar .nav-btns button,
.titlebar .view-modes button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.titlebar .nav-btns button:hover,
.titlebar .view-modes button:hover,
.titlebar .spacer button:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.titlebar .nav-btns button:disabled {
  opacity: 0.4;
  cursor: default;
}

.titlebar .spacer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.titlebar .note-title {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titlebar .view-modes {
  display: flex;
  gap: 2px;
}

.titlebar .view-modes button.active {
  color: var(--text-accent);
  background: var(--background-modifier-active-hover);
}

/* Workspace */
.workspace {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Ribbon */
.ribbon {
  width: var(--ribbon-width);
  background: var(--background-secondary);
  border-right: 1px solid var(--background-modifier-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  gap: 4px;
  flex: 0 0 auto;
  z-index: 2;
}

.ribbon button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--icon-color);
  border-radius: var(--border-radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.ribbon button:hover,
.ribbon button.active {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

/* Sidebars */
.sidebar {
  width: var(--sidebar-width);
  min-width: 160px;
  max-width: 45vw;
  background: var(--background-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--background-modifier-border);
  flex: 0 0 auto;
  overflow: hidden;
}

.sidebar.right {
  border-right: none;
  border-left: 1px solid var(--background-modifier-border);
}

.sidebar.collapsed {
  display: none;
}

.sidebar-resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex: 0 0 auto;
  transition: background var(--transition-fast);
}

.sidebar-resizer:hover,
.sidebar-resizer.dragging {
  background: var(--interactive-accent);
}

.sidebar-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--background-modifier-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header .actions {
  display: flex;
  gap: 2px;
}

.sidebar-header .actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-header .actions button:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

/* Main area */
.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--background-primary);
}

/* Tab bar */
.tab-bar {
  height: var(--tab-height);
  background: var(--background-secondary);
  border-bottom: 1px solid var(--background-modifier-border);
  display: flex;
  align-items: flex-end;
  padding-left: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab {
  height: var(--tab-height);
  max-width: 220px;
  min-width: 80px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--background-secondary);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex: 0 1 auto;
}

.tab:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.tab.active {
  background: var(--background-primary);
  color: var(--text-normal);
  border-color: var(--background-modifier-border);
  border-bottom: 1px solid var(--background-primary);
  margin-bottom: -1px;
}

.tab .tab-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab .tab-close {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.tab .tab-close:hover {
  background: var(--background-modifier-active-hover);
  opacity: 1;
}

.tab-bar:empty::before {
  content: "Open a note to begin";
  color: var(--text-faint);
  padding: 8px 12px;
  font-size: 12px;
}

/* Editor area */
.editor-frame {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.editor-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px 60px;
  line-height: 1.6;
  font-family: var(--font-text);
  font-size: 15px;
  position: relative;
}

@media (max-width: 768px) {
  .editor-container {
    padding: 24px 20px;
  }

  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 20;
    width: 80vw;
    max-width: none;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar.right {
    right: 0;
    left: auto;
    transform: translateX(100%);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-resizer {
    display: none;
  }

  .workspace.with-mobile-sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--background-modifier-cover);
    z-index: 15;
  }
}

/* Source textarea */
.source-editor {
  width: 100%;
  min-height: 100%;
  background: transparent;
  color: var(--text-normal);
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.source-editor::placeholder {
  color: var(--text-faint);
}

/* Live preview / reading view rendered markdown */
.markdown-preview,
.reading-view {
  color: var(--text-normal);
  max-width: 900px;
  margin: 0 auto;
}

.markdown-preview > *:first-child,
.reading-view > *:first-child {
  margin-top: 0;
}

.markdown-preview h1,
.reading-view h1,
.markdown-preview h2,
.reading-view h2,
.markdown-preview h3,
.reading-view h3,
.markdown-preview h4,
.reading-view h4,
.markdown-preview h5,
.reading-view h5,
.markdown-preview h6,
.reading-view h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.6em;
  margin-bottom: 0.6em;
  color: var(--text-normal);
}

.markdown-preview h1,
.reading-view h1 { font-size: 2em; border-bottom: 1px solid var(--background-modifier-border); padding-bottom: 0.2em; }
.markdown-preview h2,
.reading-view h2 { font-size: 1.5em; border-bottom: 1px solid var(--background-modifier-border); padding-bottom: 0.2em; }
.markdown-preview h3,
.reading-view h3 { font-size: 1.25em; }
.markdown-preview h4,
.reading-view h4 { font-size: 1.1em; }
.markdown-preview h5,
.reading-view h5 { font-size: 1em; }
.markdown-preview h6,
.reading-view h6 { font-size: 0.9em; color: var(--text-muted); }

.markdown-preview p,
.reading-view p {
  margin: 0.8em 0;
  line-height: 1.7;
}

.markdown-preview a,
.reading-view a {
  color: var(--link-color);
  text-decoration: none;
}

.markdown-preview a:hover,
.reading-view a:hover {
  color: var(--link-color-hover);
  text-decoration: underline;
}

.markdown-preview a.wikilink.unresolved,
.reading-view a.wikilink.unresolved {
  color: var(--link-unresolved-color);
  opacity: var(--link-unresolved-opacity);
}

.markdown-preview a.tag,
.reading-view a.tag,
.tag-pill {
  display: inline-block;
  background: var(--tag-background);
  color: var(--tag-color);
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 0.85em;
  text-decoration: none;
  margin: 0 2px;
  cursor: pointer;
}

.markdown-preview a.tag:hover,
.reading-view a.tag:hover {
  filter: brightness(1.15);
}

.markdown-preview ul,
.reading-view ul,
.markdown-preview ol,
.reading-view ol {
  padding-left: 1.8em;
  margin: 0.6em 0;
}

.markdown-preview li,
.reading-view li {
  margin: 0.25em 0;
}

.markdown-preview li.task-list-item,
.reading-view li.task-list-item {
  list-style: none;
  position: relative;
  padding-left: 0.2em;
}

.markdown-preview li.task-list-item > input[type="checkbox"],
.reading-view li.task-list-item > input[type="checkbox"] {
  position: absolute;
  left: -1.5em;
  top: 0.35em;
  width: 14px;
  height: 14px;
  accent-color: var(--interactive-accent);
  cursor: pointer;
}

.markdown-preview blockquote,
.reading-view blockquote {
  border-left: 4px solid var(--interactive-accent);
  padding: 0.2em 0 0.2em 1em;
  margin: 0.8em 0;
  color: var(--text-muted);
  background: var(--background-primary-alt);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.markdown-preview blockquote p,
.reading-view blockquote p {
  margin: 0.4em 0;
}

/* Callouts */
.markdown-preview .callout,
.reading-view .callout {
  border-left: 4px solid var(--interactive-accent);
  background: var(--background-primary-alt);
  border-radius: var(--border-radius);
  padding: 0.8em 1em;
  margin: 0.8em 0;
}

.markdown-preview .callout-title,
.reading-view .callout-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.4em;
  color: var(--text-normal);
}

.markdown-preview .callout-note,
.reading-view .callout-note { border-left-color: #7f6df2; }
.markdown-preview .callout-tip,
.reading-view .callout-tip { border-left-color: #4cc9f0; }
.markdown-preview .callout-important,
.reading-view .callout-important { border-left-color: #f72585; }
.markdown-preview .callout-warning,
.reading-view .callout-warning { border-left-color: #ff9e00; }
.markdown-preview .callout-danger,
.reading-view .callout-danger { border-left-color: #ff4444; }
.markdown-preview .callout-info,
.reading-view .callout-info { border-left-color: #4cc9f0; }
.markdown-preview .callout-success,
.reading-view .callout-success { border-left-color: #7ee787; }

.markdown-preview code,
.reading-view code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--background-secondary);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--text-normal);
}

.markdown-preview pre,
.reading-view pre {
  background: var(--background-secondary);
  border-radius: var(--border-radius);
  padding: 1em;
  overflow-x: auto;
  margin: 0.8em 0;
}

.markdown-preview pre code,
.reading-view pre code {
  background: transparent;
  padding: 0;
  font-size: 0.86em;
  border-radius: 0;
  color: inherit;
}

/* Syntax highlighting */
.markdown-preview .token-keyword,
.reading-view .token-keyword { color: #ff7b72; }
.markdown-preview .token-string,
.reading-view .token-string { color: #a5d6ff; }
.markdown-preview .token-number,
.reading-view .token-number { color: #79c0ff; }
.markdown-preview .token-comment,
.reading-view .token-comment { color: #8b949e; font-style: italic; }
.markdown-preview .token-function,
.reading-view .token-function { color: #d2a8ff; }
.markdown-preview .token-operator,
.reading-view .token-operator { color: #ff7b72; }

.markdown-preview table,
.reading-view table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
}

.markdown-preview th,
.reading-view th,
.markdown-preview td,
.reading-view td {
  border: 1px solid var(--background-modifier-border);
  padding: 0.45em 0.7em;
  text-align: left;
}

.markdown-preview th,
.reading-view th {
  background: var(--background-secondary);
  font-weight: 600;
}

.markdown-preview tr:nth-child(even),
.reading-view tr:nth-child(even) {
  background: var(--background-primary-alt);
}

.markdown-preview hr,
.reading-view hr {
  border: none;
  border-top: 1px solid var(--background-modifier-border);
  margin: 1.2em 0;
}

.markdown-preview .footnote,
.reading-view .footnote {
  font-size: 0.85em;
  color: var(--text-muted);
  border-top: 1px solid var(--background-modifier-border);
  margin-top: 1.5em;
  padding-top: 0.5em;
}

.markdown-preview .embed,
.reading-view .embed {
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  padding: 1em;
  margin: 0.8em 0;
  background: var(--background-primary-alt);
}

.markdown-preview .embed-title,
.reading-view .embed-title {
  font-weight: 600;
  margin-bottom: 0.4em;
  color: var(--text-muted);
}

/* Live-preview block editor */
.block-editor {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100%;
}

.block {
  margin: 0.3em 0;
  padding: 4px 0;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  transition: border-color var(--transition-fast), background var(--transition-fast);
  cursor: text;
}

.block:hover {
  border-color: var(--background-modifier-border);
}

.block.active {
  border-color: var(--interactive-accent);
  background: var(--background-primary-alt);
}

.block-rendered:empty::before {
  content: "\2060";
}

.block-source {
  width: 100%;
  min-height: 1.6em;
  background: transparent;
  color: var(--text-normal);
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  padding: 4px 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  resize: none;
  overflow: hidden;
}

.block-source code {
  background: transparent;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-faint);
  text-align: center;
  padding: 40px;
}

.empty-state h2 {
  margin-bottom: 0.5em;
  color: var(--text-muted);
}

.empty-state .shortcut {
  font-family: var(--font-mono);
  background: var(--background-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

/* File tree */
.tree {
  padding: 0 4px;
  user-select: none;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: var(--border-radius);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  min-height: 28px;
}

.tree-item:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.tree-item.active {
  background: var(--interactive-accent);
  color: white;
}

.tree-item.drag-over {
  outline: 2px dashed var(--interactive-accent);
  outline-offset: -2px;
}

.tree-item .tree-chevron {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: transform var(--transition-fast);
}

.tree-item .tree-chevron.collapsed {
  transform: rotate(-90deg);
}

.tree-item .tree-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.tree-item .tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-children {
  padding-left: 14px;
}

.tree-folder .tree-children {
  display: block;
}

.tree-folder.collapsed .tree-children {
  display: none;
}

/* Search / tags / outline panels */
.panel-search {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-search input {
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  padding: 6px 10px;
  color: var(--text-normal);
  font-size: 13px;
  outline: none;
}

.panel-search input:focus {
  border-color: var(--interactive-accent);
}

.search-results {
  font-size: 13px;
  padding: 0 12px;
}

.search-result {
  padding: 8px 10px;
  border-radius: var(--border-radius);
  cursor: pointer;
  margin-bottom: 4px;
}

.search-result:hover {
  background: var(--background-modifier-hover);
}

.search-result .result-title {
  color: var(--text-normal);
  font-weight: 500;
  margin-bottom: 2px;
}

.search-result .result-snippet {
  color: var(--text-faint);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result .match {
  background: rgba(127, 109, 242, 0.35);
  border-radius: 2px;
}

.tag-list,
.outline-list,
.link-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.tag-list li,
.outline-list li,
.link-list li {
  padding: 5px 8px;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
}

.tag-list li:hover,
.outline-list li:hover,
.link-list li:hover {
  background: var(--background-modifier-hover);
  color: var(--text-normal);
}

.tag-list .tag-count,
.outline-list .outline-count {
  color: var(--text-faint);
  font-size: 11px;
}

.outline-list .level-1 { padding-left: 8px; }
.outline-list .level-2 { padding-left: 20px; }
.outline-list .level-3 { padding-left: 32px; }
.outline-list .level-4 { padding-left: 44px; }
.outline-list .level-5 { padding-left: 56px; }
.outline-list .level-6 { padding-left: 68px; }

.link-list .context {
  color: var(--text-faint);
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status bar */
.status-bar {
  height: var(--statusbar-height);
  background: var(--background-secondary);
  border-top: 1px solid var(--background-modifier-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.status-bar .status-left,
.status-bar .status-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.status-bar .status-item {
  cursor: default;
}

/* Modals and overlays */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--background-modifier-cover);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--modal-border-radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  min-width: 320px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--background-modifier-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--background-modifier-border);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  font-size: 13px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--background-modifier-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal input[type="text"],
.modal input[type="number"],
.modal select {
  width: 100%;
  background: var(--background-primary-alt);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  padding: 8px 10px;
  color: var(--text-normal);
  font-size: 13px;
  outline: none;
  margin: 6px 0 12px;
}

.modal input[type="text"]:focus,
.modal input[type="number"]:focus,
.modal select:focus {
  border-color: var(--interactive-accent);
}

.modal label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.modal .setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--background-modifier-border);
}

.modal .setting-row:last-child {
  border-bottom: none;
}

/* Command palette / quick switcher */
.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: var(--background-modifier-cover);
}

.palette {
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--modal-border-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: 560px;
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.palette input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--background-modifier-border);
  padding: 14px 18px;
  color: var(--text-normal);
  font-size: 16px;
  outline: none;
}

.palette-results {
  overflow-y: auto;
  padding: 6px;
}

.palette-item {
  padding: 9px 14px;
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-normal);
  font-size: 13px;
}

.palette-item:hover,
.palette-item.selected {
  background: var(--interactive-accent);
  color: white;
}

.palette-item .palette-meta {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
}

.palette-item.selected .palette-meta {
  color: rgba(255, 255, 255, 0.75);
}

.palette-item kbd {
  font-family: var(--font-mono);
  background: var(--background-secondary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.palette-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-faint);
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 300;
  min-width: 180px;
  padding: 4px;
}

.context-menu-item {
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-normal);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.context-menu-item:hover {
  background: var(--background-modifier-hover);
}

.context-menu-item.danger {
  color: var(--text-error);
}

.context-menu-separator {
  height: 1px;
  background: var(--background-modifier-border);
  margin: 4px 0;
}

/* Notices */
.notice-container {
  position: fixed;
  bottom: calc(var(--statusbar-height) + 12px);
  right: 12px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notice {
  background: var(--background-secondary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  color: var(--text-normal);
  max-width: 320px;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Graph view */
.graph-view {
  flex: 1;
  position: relative;
  background: var(--background-primary);
  overflow: hidden;
}

.graph-view canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.graph-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  padding: 8px;
  z-index: 5;
}

.graph-controls label {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.graph-controls input[type="range"] {
  width: 100px;
}

.graph-tooltip {
  position: absolute;
  background: var(--background-secondary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  padding: 6px 10px;
  font-size: 12px;
  pointer-events: none;
  z-index: 6;
  max-width: 240px;
}

/* Prompt / confirmation */
.prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--background-modifier-cover);
  display: flex;
  align-items: center;
  justify-content: center;
}

.prompt {
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--modal-border-radius);
  padding: 18px;
  width: 400px;
  max-width: 90vw;
}

.prompt h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.prompt p {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.prompt .prompt-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Buttons */
.btn {
  background: var(--interactive-normal);
  border: 1px solid var(--background-modifier-border);
  color: var(--text-normal);
  border-radius: var(--border-radius);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn:hover {
  background: var(--interactive-hover);
}

.btn-primary {
  background: var(--interactive-accent);
  border-color: var(--interactive-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--interactive-accent-hover);
}

.btn-danger {
  color: var(--text-error);
  border-color: var(--text-error);
}

.btn-danger:hover {
  background: var(--background-modifier-error);
}

/* Hover preview */
.hover-preview {
  position: fixed;
  z-index: 300;
  width: 360px;
  max-height: 260px;
  overflow: hidden;
  background: var(--background-primary);
  border: 1px solid var(--background-modifier-border);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  padding: 12px 16px;
  font-size: 13px;
  pointer-events: none;
}

.hover-preview .markdown-preview h1,
.hover-preview .markdown-preview h2 {
  font-size: 1.2em;
}

.hover-preview .markdown-preview {
  overflow-y: auto;
  max-height: 220px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--background-modifier-border);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--background-modifier-border-hover);
}

::selection {
  background: rgba(127, 109, 242, 0.3);
}

/* Focus rings */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.block:focus-visible {
  outline: 2px solid var(--interactive-accent);
  outline-offset: -1px;
}

/* Tooltip preview delay helper */
.wikilink-hover {
  position: relative;
}
