:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel-bg: #ffffff;
  --border: #d9dee7;
  --text: #17233b;
  --text-muted: #60708f;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --success: #0f766e;
  --danger: #b91c1c;
  --warning: #9a6700;
  --shadow: 0 6px 20px rgba(17, 24, 39, 0.08);

  --editor-bg: #ffffff;
  --editor-text: #111827;
  --tab-nav-bg: #fafcff;
  --tab-toggle-bg: #e8ecf2;
  --tab-toggle-active-bg: #ffffff;
  --tab-toggle-active-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --file-tab-bg: #f3f6fb;
  --file-tab-hover-bg: #e8edf6;
  --file-tab-text: #334155;
  --file-tab-active-text: #17233b;
  --file-tab-dirty: #d97706;
  --file-tab-close-hover-bg: #fee2e2;
  --file-tab-border: #d9dee7;
  --preview-text: #1f2937;
  --code-block-bg: #f8fafc;
  --code-header-bg: #f3f7ff;
  --copy-border: #bec9dd;
  --copy-border-hover: #9fb0cc;
  --copy-bg: #ffffff;
  --copy-text: #334155;
  --copy-text-hover: #0f172a;
  --copy-copied-border: #8ed4ce;
  --code-line-number-bg: #eef2ff;
  --code-line-number-text: #64748b;
  --mermaid-bg: #ffffff;
  --mermaid-max-height: 420px;
  --mermaid-error-border: #fecaca;
  --mermaid-error-bg: #fef2f2;
  --mermaid-error-text: #991b1b;
  --math-display-bg: #fafcff;
  --math-display-border: #dbeafe;
  --math-error-text: #991b1b;
  --math-error-bg: #fef2f2;
  --math-error-border: #fecaca;
  --frontmatter-bg: #f8fafc;
  --frontmatter-border: #dbe2ee;
  --frontmatter-key: #5b6c8d;
  --frontmatter-chip-bg: #e9eef8;
  --frontmatter-chip-text: #1f2c47;
  --modal-overlay: rgba(0, 0, 0, 0.5);
  --modal-bg: #ffffff;
  --modal-shadow: 0 10px 34px rgba(2, 6, 23, 0.28);
  --modal-title: #111827;
  --modal-message: #4b5563;
  --modal-hint: #6b7280;
  --modal-primary: #2563eb;
  --modal-primary-hover: #1d4ed8;
  --modal-danger: #dc2626;
  --modal-danger-hover: #b91c1c;
  --modal-neutral: #e5e7eb;
  --modal-neutral-hover: #d1d5db;
  --modal-neutral-text: #1f2937;
  --table-border: #d9dee7;
  --table-header-bg: #f0f4fa;
  --table-header-text: #17233b;
  --table-row-alt-bg: #f7f8fa;
  --table-row-hover-bg: #eef2f9;
  --drag-over-bg: #f0f7ff;

  /* Blank space below the last line so content can scroll above the floating toolbar (normal + focus mode). */
  --editor-end-scroll-padding: 80px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}

html.loading *,
html.loading *::before,
html.loading *::after {
  transition: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  color: var(--text);
  background: var(--bg);
}

.loading-banner {
  min-height: 100vh;
  display: grid;
  place-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.container {
  height: 100vh;
  min-height: 0;
  display: flex;
  gap: 14px;
  padding: 12px;
  overflow: hidden;
}

.container.sidebar-collapsed {
  gap: 0;
}

.hidden {
  display: none !important;
}

#sidebar {
  width: 24%;
  min-width: 220px;
  max-width: 340px;
  min-height: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.container.sidebar-collapsed #sidebar {
  display: none;
}

#sidebar h3 {
  margin: 2px 0 10px;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

#toc-container {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

#toc-container.collapsed {
  flex: 0 0 auto;
}

#toc-collapsible {
  flex: 1 1 auto;
  min-height: 0;
}

#toc {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

#toc ul {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}

#toc ul.root-list {
  padding-left: 0;
}

#toc li {
  margin: 4px 0;
}

#toc a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.45;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

#toc a:hover {
  color: var(--accent);
}

#toc a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-open-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-offset, var(--bg));
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.sidebar-open-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.sidebar-open-icon {
  flex-shrink: 0;
}

#file-tree-container {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

#file-tree-container.collapsed {
  flex: 0 0 auto;
}

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: none;
  padding: 4px 2px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.sidebar-section-toggle:hover {
  color: var(--text);
}

.toggle-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.sidebar-section-toggle[aria-expanded="true"] .toggle-chevron {
  transform: rotate(90deg);
}

.sidebar-collapsible {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  overflow: hidden;
}

.sidebar-collapsible.collapsed {
  display: none;
}

.sidebar-header {
  --sidebar-control-size: 30px;
  margin-bottom: 12px;
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.file-tree-search-wrapper {
  position: relative;
  width: 100%;
  min-width: 0;
  color: var(--text-muted);
}

.file-tree-search-icon {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
}

.file-tree-search {
  width: 100%;
  min-width: 0;
  height: var(--sidebar-control-size);
  padding: 0 10px 0 30px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text);
  outline: none;
}

.file-tree-search:focus {
  border-color: var(--accent);
  background: var(--editor-bg);
}

.file-tree-search-wrapper:focus-within .file-tree-search-icon {
  color: var(--accent);
}

.file-tree-search::placeholder {
  color: var(--text-muted);
}


.sidebar-action-btn {
  width: var(--sidebar-control-size);
  height: var(--sidebar-control-size);
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-action-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.sidebar-action-btn svg {
  width: 14px;
  height: 14px;
}

.sidebar-action-btn[aria-busy="true"] svg {
  animation: sidebar-action-spin 0.8s linear infinite;
}

@keyframes sidebar-action-spin {
  to {
    transform: rotate(360deg);
  }
}

.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 160px;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--modal-shadow);
  padding: 4px 0;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  font-size: 0.875rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.context-menu-item:hover,
.context-menu-item:focus {
  background: var(--accent-soft);
  color: var(--accent);
}

.context-menu-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

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


#file-tree {
  max-height: 40vh;
  overflow: auto;
  overscroll-behavior: contain;
}

.tree-root,
.tree-children {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

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

.tree-folder,
.tree-file {
  margin: 2px 0;
}

.tree-folder-header {
  width: 100%;
  border: 0;
  padding: 4px 6px;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: left;
}

.tree-folder-header:hover {
  background: var(--accent-soft);
}

.folder-icon {
  font-size: 10px;
  color: var(--text-muted);
  width: 12px;
}

.folder-name {
  font-size: 13px;
  font-weight: 500;
}

.tree-file-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  font-size: 13px;
  border-radius: 4px;
  padding: 4px 6px 4px 24px;
  cursor: pointer;
}

.tree-file-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.tree-file-link.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.tree-empty-state {
  margin: 8px 4px;
  font-size: 13px;
  color: var(--text-muted);
}

#main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-nav {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--tab-nav-bg);
}

.nav-left-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.undo-redo-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.history-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.history-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.history-button svg {
  width: 16px;
  height: 16px;
}

.tab-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.current-file-path {
  min-width: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

#current-file-text {
  display: inline-block;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-dropdown {
  position: relative;
}

.quick-actions-menu {
  position: relative;
}

.quick-actions-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 10px;
  font-size: 13px;
}

.quick-actions-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.quick-actions-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quick-actions-menu.open .quick-actions-toggle .dropdown-chevron {
  transform: rotate(180deg);
}

.quick-actions-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.quick-actions-dropdown[hidden] {
  display: none !important;
}

.quick-actions-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.quick-actions-item svg {
  width: 16px;
  height: 16px;
}

.quick-actions-item:hover,
.quick-actions-item:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
  outline: none;
}

.quick-actions-theme {
  position: relative;
}

.quick-actions-theme-toggle {
  grid-template-columns: auto 1fr auto;
}

.quick-actions-item-label {
  white-space: nowrap;
}

.theme-dots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  width: 18px;
  height: 18px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--tab-toggle-bg);
}

.theme-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.14);
  justify-self: center;
  align-self: center;
}

.dropdown-chevron {
  flex-shrink: 0;
  color: currentColor;
  transition: transform 0.16s ease;
}

.theme-dropdown.open .dropdown-chevron {
  transform: rotate(180deg);
}

.theme-dropdown-menu {
  position: absolute;
  top: 0;
  right: calc(100% + 6px);
  z-index: 100;
  list-style: none;
  margin: 0;
  padding: 4px;
  min-width: 200px;
  max-width: min(260px, calc(100vw - 24px));
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.theme-dropdown-menu[hidden] {
  display: none;
}

.theme-dropdown.open .theme-dropdown-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.theme-dropdown-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 13px;
  cursor: pointer;
}

.theme-dropdown-item:hover,
.theme-dropdown-item:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
  outline: none;
}

.theme-dropdown-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-dropdown-item-dots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  width: 18px;
  height: 18px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--tab-toggle-bg);
}

.theme-dropdown-item-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.16);
  justify-self: center;
  align-self: center;
}

.theme-dropdown-item-label {
  text-align: left;
  white-space: nowrap;
}

.theme-dropdown-check {
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0;
}

.theme-dropdown-item.active .theme-dropdown-check {
  opacity: 1;
}

.theme-dropdown-check svg {
  display: block;
}

#save-status {
  font-size: 12px;
  color: var(--text-muted);
}

#save-status.is-saving {
  color: var(--warning);
}

#save-status.is-saved {
  color: var(--success);
}

#save-status.is-error {
  color: var(--danger);
}

.file-tabs-bar {
  display: flex;
  gap: 2px;
  min-height: 36px;
  align-items: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 10px 0;
  background: var(--tab-nav-bg);
  position: relative;
}

.file-tabs-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--file-tab-border);
  pointer-events: none;
}

.file-tabs-bar.hidden {
  display: none !important;
}

.file-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  min-width: 90px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--file-tab-text);
  padding: 5px 10px 6px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.file-tab:hover {
  background: var(--file-tab-hover-bg);
  border-color: var(--file-tab-border);
  color: var(--file-tab-active-text);
}

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

.file-tab-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  line-height: 1.4;
}

.file-tab-dirty {
  font-size: 14px;
  color: var(--file-tab-dirty);
  line-height: 1;
  flex-shrink: 0;
}

.file-tab-close {
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  opacity: 0;
  color: var(--text-muted);
  flex-shrink: 0;
  pointer-events: none;
}

.file-tab:hover .file-tab-close,
.file-tab.active .file-tab-close {
  opacity: 0.75;
  pointer-events: auto;
}

.file-tab-close:hover,
.file-tab-close:focus-visible {
  opacity: 1;
  color: var(--text);
  background: var(--tab-toggle-bg);
  outline: none;
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.view.active {
  display: flex;
  flex-direction: column;
}

.view-area {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.floating-toolbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.search-bar {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  animation: search-bar-fade-in 0.15s ease;
}

.search-bar-input {
  width: 230px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text);
  font-size: 13px;
  padding: 6px 9px;
  outline: none;
}

.search-bar-input:focus {
  border-color: var(--accent);
  background: var(--editor-bg);
}

.search-bar-input::placeholder {
  color: var(--text-muted);
}

.search-match-count {
  min-width: 54px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.search-nav-btn,
.search-close-btn {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.search-nav-btn svg {
  width: 14px;
  height: 14px;
}

.search-nav-btn:hover,
.search-close-btn:hover {
  border-color: var(--border);
  color: var(--accent);
  background: var(--accent-soft);
}

.search-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.search-nav-btn:disabled:hover {
  border-color: transparent;
  color: var(--text-muted);
  background: transparent;
}

.search-nav-btn:focus-visible,
.search-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.search-nav-btn:disabled:focus-visible {
  outline: none;
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.toolbar-button {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.toolbar-button svg {
  width: 18px;
  height: 18px;
}

.toolbar-button:hover,
.toolbar-button.active {
  border-color: var(--border);
  color: var(--accent);
  background: var(--accent-soft);
}

.toolbar-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toolbar-button-label {
  width: auto;
  gap: 6px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
}

.format-group {
  position: relative;
}

.format-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}

.format-menu-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 7px 8px;
  font-size: 13px;
  cursor: pointer;
}

.format-menu-item:hover,
.format-menu-item:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.content-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  opacity: 0.85;
  z-index: 10;
}

.content-loading-overlay.hidden {
  display: none !important;
}

.content-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: content-loading-spin 0.7s linear infinite;
}

@keyframes content-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  z-index: 5;
}

.empty-state.hidden {
  display: none !important;
}

.empty-state-content {
  text-align: center;
  padding: 24px;
}

.empty-state-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.empty-state-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.empty-state-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state-action {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.empty-state-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.desktop-banner-host {
  padding: 0 24px 12px;
}

.desktop-update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.desktop-update-banner.hidden {
  display: none !important;
}

.desktop-update-copy {
  min-width: 0;
}

.desktop-update-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.desktop-update-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.desktop-update-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.desktop-update-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
}

.desktop-update-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.desktop-update-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.desktop-update-button.primary:hover {
  filter: brightness(0.96);
}

/* Desktop app: open-workspace picker — matches global .modal / modal tokens */

.desktop-picker-modal {
  width: min(640px, calc(100vw - 28px));
  max-height: min(560px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.desktop-picker-modal-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding-bottom: 16px;
  overflow: hidden;
}

.desktop-picker-modal .modal-title {
  margin-bottom: 8px;
}

.desktop-picker-lead {
  margin-bottom: 14px !important;
}

.desktop-picker-modal .modal-actions {
  margin-bottom: 16px;
}

#editor-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px;
  scroll-padding-bottom: calc(24px + var(--editor-end-scroll-padding) + 8px);
}

#editor-container.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: var(--drag-over-bg);
}

.wysiwyg-wrapper {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  min-height: calc(100% - 12px);
}

#wysiwyg-editor {
  min-height: 100%;
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--editor-text);
  line-height: 1.7;
  font-size: 16px;
  /* In-flow space after the last line (padding extends the scrollable box reliably in normal mode). */
  padding-bottom: calc(20px + var(--editor-end-scroll-padding));
}

#wysiwyg-editor:focus {
  outline: none;
}

#wysiwyg-editor > *:first-child {
  margin-top: 0;
}

#wysiwyg-editor > *:last-child {
  margin-bottom: 0;
}

#wysiwyg-editor p {
  margin: 0 0 0.85em;
}

#wysiwyg-editor a[href] {
  cursor: text;
}

html.link-open-modifier #wysiwyg-editor a[href] {
  cursor: pointer;
}

#wysiwyg-editor h1,
#wysiwyg-editor h2,
#wysiwyg-editor h3,
#wysiwyg-editor h4,
#wysiwyg-editor h5,
#wysiwyg-editor h6 {
  scroll-margin-top: 14px;
}

#wysiwyg-editor pre {
  margin: 14px 0 20px;
}

#wysiwyg-editor .frontmatter-properties {
  margin: 0 0 1.15rem;
  border: 1px solid var(--frontmatter-border);
  border-radius: 10px;
  background: var(--frontmatter-bg);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

#wysiwyg-editor .frontmatter-properties-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#wysiwyg-editor .frontmatter-properties-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#wysiwyg-editor .frontmatter-add-property,
#wysiwyg-editor .frontmatter-edit-property,
#wysiwyg-editor .frontmatter-delete-property {
  width: 24px;
  height: 24px;
}

#wysiwyg-editor .frontmatter-property-row {
  display: grid;
  grid-template-columns: minmax(92px, 180px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

#wysiwyg-editor .frontmatter-property-key {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--frontmatter-key);
  text-transform: lowercase;
  line-height: 1.8;
}

#wysiwyg-editor .frontmatter-property-values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

#wysiwyg-editor .frontmatter-property-value {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--frontmatter-chip-bg);
  color: var(--frontmatter-chip-text);
  font-size: 12px;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

#wysiwyg-editor .frontmatter-property-empty {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.8;
}

#wysiwyg-editor .frontmatter-property-actions {
  display: inline-flex;
  gap: 4px;
}

#wysiwyg-editor .frontmatter-properties-create {
  margin: 0 0 1.15rem;
  border: 1px dashed var(--frontmatter-border);
  border-radius: 10px;
  background: var(--frontmatter-bg);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#wysiwyg-editor .frontmatter-create-hint {
  font-size: 12px;
  color: var(--text-muted);
}

#wysiwyg-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

::highlight(search-all) {
  background: var(--accent-soft);
}

::highlight(search-current) {
  background: var(--accent);
  color: #fff;
}

/* ── Table Styling ── */

#wysiwyg-editor table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 20px;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}

#wysiwyg-editor thead {
  display: table-header-group;
}

#wysiwyg-editor tbody {
  display: table-row-group;
}

#wysiwyg-editor tr {
  display: table-row;
}

#wysiwyg-editor th,
#wysiwyg-editor td {
  display: table-cell;
}

#wysiwyg-editor th {
  border: 1px solid var(--table-border);
  padding: 10px 14px;
  font-weight: 600;
  background: var(--table-header-bg);
  color: var(--table-header-text);
  white-space: nowrap;
}

#wysiwyg-editor td {
  border: 1px solid var(--table-border);
  padding: 9px 14px;
}

#wysiwyg-editor tbody tr:nth-child(even) {
  background: var(--table-row-alt-bg);
}

#wysiwyg-editor tbody tr:hover {
  background: var(--table-row-hover-bg);
}

#wysiwyg-editor code {
  font-family:
    "JetBrains Mono",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
}

.code-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-block-bg);
}

.code-block-header {
  height: 34px;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--code-header-bg);
}

.code-language-label {
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 600;
}

.code-block-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.action-icon-button,
.copy-button,
.block-edit-trigger {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.65;
  padding: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.action-icon-button svg,
.copy-button svg,
.block-edit-trigger svg {
  width: 15px;
  height: 15px;
}

.action-icon-button:hover,
.copy-button:hover,
.block-edit-trigger:hover {
  opacity: 1;
}

.action-icon-button:focus-visible,
.copy-button:focus-visible,
.block-edit-trigger:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.copy-button.copied {
  opacity: 1;
  color: var(--success);
  border-color: var(--copy-copied-border);
}

.code-block pre {
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--code-block-bg) !important;
}

.code-block-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
}

.code-line-numbers {
  border-right: 1px solid var(--border);
  background: var(--code-line-number-bg);
  color: var(--code-line-number-text);
  padding: 12px 10px;
  min-width: 46px;
  text-align: right;
  font-size: 13px;
  line-height: 1.6;
  font-family:
    "JetBrains Mono",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
  user-select: none;
}

.code-line-number {
  display: block;
}

.code-block-content pre {
  overflow: auto;
  padding: 12px 0 !important;
  background: var(--code-block-bg) !important;
}

.code-block-content pre code {
  display: block;
  min-width: max-content;
  padding: 0 14px !important;
  font-size: 13px;
  line-height: 1.6;
  color: var(--preview-text);
  background: var(--code-block-bg) !important;
}

.code-block-content pre code.hljs {
  background: var(--code-block-bg) !important;
}

.mermaid-container {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0;
  overflow: hidden;
  background: var(--mermaid-bg);
  display: flex;
  flex-direction: column;
}

.mermaid-inline-toolbar {
  height: 36px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  z-index: 4;
}

.mermaid-canvas {
  position: relative;
  padding: 10px;
  min-height: 0;
  max-height: var(--mermaid-max-height);
  overflow: hidden;
}

.mermaid-container .mermaid {
  display: block;
  width: 100%;
  min-height: 0;
}

/* Override Mermaid's inline max-width so the SVG fills the container (useMaxWidth sets px max-width). */
.mermaid-canvas svg {
  display: block;
  width: 100% !important;
  max-width: none !important;
  height: auto;
  min-height: 0;
  cursor: grab;
}

.mermaid-canvas svg:active {
  cursor: grabbing;
}

.mermaid-canvas .mermaid-zoom-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
  pointer-events: none;
}

.mermaid-canvas .mermaid-zoom-controls .mermaid-zoom-btn {
  pointer-events: auto;
}

.mermaid-zoom-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}

.mermaid-zoom-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.mermaid-zoom-btn:hover {
  opacity: 1;
}

.mermaid-zoom-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mermaid-fullscreen-trigger {
  position: static;
  z-index: auto;
}

.mermaid-fullscreen-trigger svg {
  width: 15px;
  height: 15px;
}

.mermaid-inline-toolbar .block-edit-trigger,
.mermaid-inline-toolbar .mermaid-fullscreen-trigger,
.mermaid-container .block-edit-trigger,
.mermaid-container .mermaid-fullscreen-trigger {
  cursor: pointer !important;
}

.mermaid-inline-toolbar .block-edit-trigger svg,
.mermaid-inline-toolbar .mermaid-fullscreen-trigger svg {
  pointer-events: none;
}

.mermaid-error {
  border: 1px solid var(--mermaid-error-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--mermaid-error-bg);
  color: var(--mermaid-error-text);
  white-space: pre-wrap;
}

.math-inline {
  padding: 0 2px;
}

.math-inline .katex {
  font-size: 1.05em;
}

.math-display {
  position: relative;
  border: 1px solid var(--math-display-border);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 16px 0;
  overflow-x: auto;
  text-align: center;
  background: var(--math-display-bg);
}

.math-display .katex-display {
  margin: 0;
}

.math-inline.math-error {
  color: var(--math-error-text);
  border-bottom: 1px dashed var(--math-error-text);
  cursor: help;
}

.math-error-block {
  border: 1px solid var(--math-error-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--math-error-bg);
  color: var(--math-error-text);
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.85em;
  text-align: left;
}

.math-copy-button {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.math-display:hover .math-copy-button {
  opacity: 1;
}

#wysiwyg-editor .task-list {
  margin-top: 0.2em;
  margin-bottom: 0.2em;
}

#wysiwyg-editor .task-list-item {
  list-style: none;
  position: relative;
  padding-left: 1.8em;
  margin: 0.35em 0;
}

#wysiwyg-editor .task-list-item > input[type="checkbox"] {
  position: absolute;
  left: 0;
  top: 0.35em;
  width: 1em;
  height: 1em;
  margin: 0;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--panel-bg);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-content: center;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    transform 0.1s ease;
}

#wysiwyg-editor .task-list-item > input[type="checkbox"]:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#wysiwyg-editor .task-list-item > input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#wysiwyg-editor .task-list-item > input[type="checkbox"]:active {
  transform: scale(0.96);
}

#wysiwyg-editor .task-list-item > input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent);
}

#wysiwyg-editor .task-list-item > input[type="checkbox"]:checked::before {
  content: "";
  width: 0.28em;
  height: 0.52em;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-5%, -5%);
}

#wysiwyg-editor .task-list-item:has(> input[type="checkbox"]:checked) {
  color: var(--text-muted);
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  backdrop-filter: blur(2px);
  z-index: 1200;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(540px, calc(100vw - 28px));
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--modal-bg);
  box-shadow: var(--modal-shadow);
  z-index: 1201;
}

.modal-content {
  padding: 20px;
}

.modal-title {
  margin: 0 0 10px;
  color: var(--modal-title);
  font-size: 19px;
  line-height: 1.35;
}

.modal-message {
  margin: 0 0 16px;
  color: var(--modal-message);
  font-size: 14px;
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-actions .btn {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
}

.modal-actions .btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.modal-actions .btn:active {
  transform: translateY(0);
}

.modal-actions .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--modal-primary);
  color: #ffffff;
}

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

.btn-secondary {
  background: var(--modal-danger);
  color: #ffffff;
}

.btn-secondary:hover {
  background: var(--modal-danger-hover);
}

.btn-tertiary {
  background: var(--modal-neutral);
  color: var(--modal-neutral-text);
}

.btn-tertiary:hover {
  background: var(--modal-neutral-hover);
}

.modal-hint {
  margin: 0;
  color: var(--modal-hint);
  font-size: 12px;
  text-align: center;
}

.block-edit-fields {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.block-edit-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.block-edit-input,
.block-edit-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--editor-text);
  font-family:
    "JetBrains Mono",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
  font-size: 13px;
  outline: none;
}

.block-edit-input {
  height: 34px;
  padding: 0 10px;
}

.block-edit-textarea {
  min-height: 180px;
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

.block-edit-input:focus,
.block-edit-textarea:focus {
  border-color: var(--accent);
}

.modal:not(.hidden) {
  animation: modal-fade-in 0.2s ease;
}

.modal-overlay:not(.hidden) {
  animation: overlay-fade-in 0.2s ease;
}

.mermaid-fullscreen-modal {
  position: fixed;
  inset: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--mermaid-bg);
  box-shadow: var(--modal-shadow);
  z-index: 1201;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mermaid-fullscreen-modal:not(.hidden) {
  animation: modal-fade-in 0.2s ease;
}

.mermaid-fullscreen-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  background: var(--panel-bg);
}

.mermaid-fullscreen-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}

.mermaid-fullscreen-btn svg {
  width: 16px;
  height: 16px;
}

.mermaid-fullscreen-btn:hover {
  opacity: 1;
}

.mermaid-fullscreen-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mermaid-fullscreen-canvas {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.mermaid-fullscreen-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.mermaid-fullscreen-loading {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mermaid-fullscreen-content svg {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  cursor: grab;
}

.mermaid-fullscreen-content svg:active {
  cursor: grabbing;
}

.mermaid-zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: translate(-50%, -47%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes search-bar-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Focus Mode ── */

body.focus-mode #sidebar,
body.focus-mode .tab-nav,
body.focus-mode #file-tabs-bar {
  display: none !important;
}

body.focus-mode #main-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

body.focus-mode .view-area {
  flex: 1;
  min-height: 0;
  /* Keep #editor-container as the scroll root; scrolling here bypasses its padding and hides the caret behind the toolbar. */
  overflow: hidden;
}

.focus-toc {
  display: none;
}

body.focus-mode .focus-toc {
  position: absolute;
  left: 24px;
  top: 28px;
  width: 180px;
  display: block;
  z-index: 5;
  pointer-events: auto;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding-right: 6px;
}

body.focus-mode .focus-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

body.focus-mode .focus-toc ul ul {
  padding-left: 12px;
}

body.focus-mode .focus-toc li {
  margin: 0 0 6px;
}

body.focus-mode .focus-toc a {
  display: block;
  color: color-mix(in srgb, var(--text-muted) 82%, transparent);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 400;
}

body.focus-mode .focus-toc a.active {
  color: color-mix(in srgb, var(--text) 72%, transparent);
  font-weight: 500;
}

body.focus-mode-css-fallback {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
}

@media (max-width: 980px) {
  .container {
    flex-direction: column;
  }

  #sidebar {
    width: auto;
    max-width: unset;
    min-width: 0;
    max-height: 30vh;
  }

  .current-file-path {
    display: none;
  }

  .tab-nav {
    grid-template-columns: auto 1fr;
  }

  .file-tab {
    max-width: 180px;
  }

  .floating-toolbar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    max-width: none;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .search-bar {
    top: 10px;
    right: 12px;
  }

  .search-bar-input {
    width: 150px;
  }

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

  .mermaid-fullscreen-modal {
    inset: 10px;
  }

  .mermaid-fullscreen-content {
    padding: 10px;
  }
}
