*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--app-bg, #e5e7eb);
  color: var(--text, #111827);
}

body {
  font-family: var(--font-ui, system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text);
}

.app-root {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--app-bg);
  font-family: var(--font-ui, system-ui, sans-serif);
  transition: background 0.3s ease;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 50%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
}

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

/* Kindle 纸感：叠在纯色底上，避免覆盖 index 中的 background 简写 */
html[data-bg='22'] .app-root {
  background-color: var(--app-bg);
  background-image: repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.014) 2px,
      rgba(0, 0, 0, 0.014) 3px
    ),
    radial-gradient(ellipse 120% 90% at 50% -10%, rgba(255, 255, 255, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 100% 100%, rgba(0, 0, 0, 0.04) 0%, transparent 50%);
}

.no-api {
  padding: 24px;
}

.tab-bar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 4px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  position: relative;
  z-index: 30;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  box-shadow: 0 1px 4px color-mix(in srgb, #000 3%, transparent);
}

.tab-bar::-webkit-scrollbar {
  height: 5px;
}

.tab-bar::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  border-radius: 3px;
}

.tab {
  display: inline-flex;
  flex: 0 0 160px;
  align-items: stretch;
  min-width: 120px;
  max-width: 200px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: inherit;
  overflow: hidden;
  transition: background 0.15s;
}

.tab:not(.active):hover {
  background: var(--hover);
}

.tab.active {
  background: var(--app-bg);
  border-color: var(--border);
  box-shadow: 0 -2px 0 var(--accent), 0 1px 0 var(--app-bg);
  position: relative;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--app-bg);
}

.tab-main {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 4px 7px 12px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}

.tab-close {
  flex: 0 0 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}

.tab-close:hover {
  color: #e53e3e;
  background: color-mix(in srgb, #e53e3e 10%, transparent);
}

.tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.tab.active .tab-title {
  font-weight: 600;
}

.tab .dot {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  margin-right: 2px;
}

.tab-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 4px;
  min-width: 120px;
}

.tab-context-menu button {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.12s;
}

.tab-context-menu button:hover {
  background: var(--hover);
}

.toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  position: relative;
  z-index: 120;
  isolation: isolate;
  box-shadow: 0 1px 4px color-mix(in srgb, #000 3%, transparent);
}

.toolbar button,
.sidebar-tabs button,
.path-row button,
.dir-item,
.outline-title,
.outline-level--branch {
  font: inherit;
  cursor: pointer;
}

.toolbar button {
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.toolbar button:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--btn-bg));
  box-shadow: 0 1px 4px color-mix(in srgb, var(--accent) 15%, transparent);
}

.toolbar button:active {
  transform: scale(0.97);
}

.toolbar-tail {
  margin-left: auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.bg-select {
  flex: 0 0 7.5rem;
  width: 7.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  margin-left: 0;
  font-size: 11px;
  color: var(--muted);
}

.bg-select select,
.bg-select .toolbar-mini-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  position: relative;
  z-index: 130;
  font: inherit;
  font-size: 12px;
  transition: border-color 0.15s;
}

.bg-select select:focus,
.bg-select .toolbar-mini-input:focus {
  outline: none;
  border-color: var(--accent);
}

.bg-select .toolbar-mini-input {
  -moz-appearance: textfield;
}

.bg-select .toolbar-mini-input::-webkit-outer-spin-button,
.bg-select .toolbar-mini-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 98%, var(--accent));
}

.sidebar {
  flex: 0 0 auto;
  flex-shrink: 0;
  align-self: stretch;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 2px 0 8px color-mix(in srgb, #000 3%, transparent);
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-resize {
  width: 5px;
  cursor: col-resize;
  flex: 0 0 5px;
  background: transparent;
  transition: background 0.15s;
}

.sidebar-resize:hover {
  background: var(--accent);
  opacity: 0.35;
}

.sidebar-reopen {
  flex: 0 0 26px;
  width: 26px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-reopen:hover {
  background: var(--hover);
  color: var(--accent);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.sidebar-tabs button {
  flex: 1;
  padding: 11px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.sidebar-tabs button:hover {
  color: var(--text);
  background: var(--hover);
}

.sidebar-tabs button.on {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.sidebar-tabs button.on:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.file-filter {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.file-filter-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--btn-bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.file-filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.file-filter-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.file-pane,
.outline {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.path-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.path-row-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.path-row-actions button {
  width: 100%;
  min-width: 5.5rem;
  white-space: nowrap;
}

.path-row button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.path-row button:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--btn-bg));
}

.path-row button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.path {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-error {
  padding: 10px;
  color: #c62828;
  font-size: 13px;
}

.dir-list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 4px;
  flex-shrink: 0;
}

.dir-list-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-list-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.dir-list,
.outline {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.file-panel,
.history-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-panel {
  overflow: auto;
}

.dir-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.dir-item {
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  border-radius: 6px;
  transition: background 0.12s;
}

.dir-item:hover {
  background: var(--hover);
}

.outline-title,
.outline-level--branch {
  font: inherit;
  cursor: pointer;
}

.outline-entry {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 5px 10px 5px 8px;
  border-radius: 8px;
  transition: background 0.12s ease;
}

.outline-entry:hover {
  background: var(--hover);
}

.outline-entry--folded .outline-title {
  color: var(--muted);
}

.outline-level {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}

.outline-level--leaf {
  cursor: default;
  border-style: solid;
  opacity: 0.92;
}

.outline-level--branch {
  position: relative;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--btn-bg));
  color: var(--accent);
}

.outline-level--branch::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--btn-bg);
}

.outline-level--branch.outline-level--collapsed {
  border-style: dashed;
  background: var(--btn-bg);
  color: var(--muted);
  border-color: var(--muted);
}

.outline-level--branch.outline-level--collapsed::after {
  background: transparent;
  border: 2px solid var(--muted);
  box-shadow: none;
}

.outline-level-num {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.outline-level--h1 {
  min-width: 36px;
  height: 36px;
  font-size: 15px;
  border-width: 2px;
}

.outline-level--h1 .outline-level-num {
  font-size: 15px;
}

.outline-level--h2 {
  min-width: 34px;
  height: 34px;
}

.outline-level--h3 {
  min-width: 32px;
  height: 30px;
  font-weight: 650;
}

.outline-level--h3 .outline-level-num {
  font-size: 13px;
}

.outline-level--h4,
.outline-level--h5,
.outline-level--h6 {
  min-width: 30px;
  height: 28px;
  font-weight: 600;
  color: var(--muted);
  border-color: color-mix(in srgb, var(--border) 90%, var(--muted));
}

.outline-level--h4 .outline-level-num,
.outline-level--h5 .outline-level-num,
.outline-level--h6 .outline-level-num {
  font-size: 12px;
}

.outline-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 7px 6px 7px 0;
  border: none;
  background: transparent;
  color: inherit;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  word-break: break-word;
  transition: color 0.12s;
}

.outline-entry--h1 .outline-title {
  font-weight: 700;
  font-size: 14px;
}

.outline-entry--h2 .outline-title {
  font-weight: 650;
  font-size: 13.5px;
}

.outline-entry--h3 .outline-title {
  font-weight: 600;
  font-size: 13px;
}

.outline-entry--h4 .outline-title,
.outline-entry--h5 .outline-title,
.outline-entry--h6 .outline-title {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
}

.outline-panel {
  padding: 0;
}

.outline-panel-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.outline-pane {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.outline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.outline-toolbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.outline-toolbar-btn {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.outline-toolbar-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--btn-bg));
}

.outline-toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.outline-toolbar-meta {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
}

.outline-tree--root {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 6px 8px;
}

.outline-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 10px 4px 8px;
  border-radius: 6px;
  transition: background 0.12s ease;
}

.outline-tree-row:hover {
  background: var(--hover);
}

.outline-fold-btn {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--btn-bg);
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.outline-fold-btn:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--btn-bg));
  transform: scale(1.08);
}

.outline-fold-btn.is-collapsed {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

.outline-fold-spacer {
  flex: 0 0 24px;
  width: 24px;
}

.outline-tree-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s, background 0.12s;
}

.outline-tree-title:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.outline-tree-title--h1 {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.outline-tree-title--h2 {
  font-weight: 650;
  font-size: 13.5px;
}

.outline-tree-title--h3 {
  font-weight: 600;
  font-size: 13px;
}

.outline-tree-title--h4,
.outline-tree-title--h5,
.outline-tree-title--h6 {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
}

.outline-tree {
  list-style: none;
  margin: 0;
  padding: 4px 0 8px;
}

.outline-tree .outline-tree {
  margin: 2px 0 4px 8px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  position: relative;
}

.outline-tree .outline-tree::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 0;
  width: 2px;
  border-radius: 1px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--accent) 30%, transparent),
    color-mix(in srgb, var(--accent) 8%, transparent) 60%,
    transparent
  );
}

.outline-tree-node {
  margin: 0;
}

.outline-empty {
  margin: 16px 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 20px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--muted) 4%, transparent);
}

.sidebar-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 20px;
  text-align: center;
  min-height: 0;
}

.sidebar-empty-icon {
  font-size: 36px;
  opacity: 0.4;
  margin-bottom: 4px;
}

.sidebar-empty-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.sidebar-empty-hint {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.65;
  line-height: 1.45;
  max-width: 220px;
}

.outline-simple {
  list-style: none;
  margin: 0;
  padding: 6px 6px 10px;
}

.outline-simple-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}

.outline-simple-item:hover {
  background: var(--hover);
  color: var(--accent);
}

.outline-simple-item--h1 {
  font-weight: 700;
  font-size: 14px;
}

.outline-simple-item--h2 {
  font-weight: 650;
  font-size: 13.5px;
}

.outline-simple-item--h3 {
  font-weight: 600;
  font-size: 13px;
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.outline-simple-item--h4,
.outline-simple-item--h5,
.outline-simple-item--h6 {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
}

.history-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.history-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-toolbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.history-toolbar-meta {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
}

.history-clear-btn {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.history-clear-btn:hover {
  border-color: #e53e3e;
  color: #e53e3e;
  background: color-mix(in srgb, #e53e3e 6%, var(--btn-bg));
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 6px 6px 8px;
  flex: 1;
  overflow: auto;
}

.history-item {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}

.history-item:hover {
  background: var(--hover);
}

.history-item-icon {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1.4;
  margin-top: 1px;
}

.history-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-name {
  font-weight: 600;
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-path {
  font-size: 11px;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-kind {
  flex: 0 0 26px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  border-radius: 5px;
  padding: 3px 0;
  line-height: 1.1;
  color: #fff;
  letter-spacing: 0.02em;
}

.entry-kind--dir {
  background: #4f46e5;
}

.entry-kind--file {
  background: #047857;
}

.entry-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.md-format-wrap {
  width: 100%;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  position: relative;
  z-index: 25;
}

.md-format-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  max-height: 140px;
  overflow-y: auto;
}

.md-format-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-right: 1px solid var(--border);
}

.md-format-group:last-child {
  border-right: none;
}

.md-format-group-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 2px;
  user-select: none;
}

.md-format-group-btns {
  display: flex;
  gap: 2px;
}

.md-format-bar button {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

.md-format-bar button:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--btn-bg));
}

.dir-item[data-kind='dir'] {
  font-weight: 600;
  color: var(--accent);
}

.content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  z-index: 26;
}

.search-input {
  flex: 1;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.search-close-btn {
  flex: 0 0 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.search-close-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--btn-bg));
}

.search-next-btn {
  flex: 0 0 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.search-next-btn:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--btn-bg));
}

.status-bar {
  flex: 0 0 auto;
  padding: 6px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel-bg);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 30px;
  z-index: 20;
  letter-spacing: 0.01em;
}

.content-empty {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  gap: 14px;
}

.content-empty-icon {
  font-size: 52px;
  opacity: 0.3;
  margin-bottom: 6px;
}

.content-empty-hint {
  font-size: 13px;
  color: var(--muted);
  opacity: 0.7;
  max-width: 380px;
  line-height: 1.55;
}

.content-drop-zone {
  margin-top: 20px;
  padding: 28px 48px;
  border: 2px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 4%, var(--btn-bg));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.content-drop-zone:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--btn-bg));
  transform: scale(1.02);
}

.content-drop-zone-icon {
  font-size: 36px;
  opacity: 0.55;
}

.content-drag-over {
  outline: 3px dashed var(--accent);
  outline-offset: -6px;
  background: color-mix(in srgb, var(--accent) 8%, var(--app-bg));
}

.content-drag-over .content-drop-zone {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--btn-bg));
  transform: scale(1.03);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}

.stats-panel {
  flex: 0 0 auto;
  min-width: 0;
  border-left: 1px solid var(--border);
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.stats-resize {
  width: 5px;
  cursor: col-resize;
  flex: 0 0 5px;
  background: transparent;
  transition: background 0.15s;
  position: relative;
  z-index: 1;
}

.stats-resize:hover,
.stats-resize:active {
  background: var(--accent);
}

.stats-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stats-panel-header-icon {
  font-size: 14px;
}

.stats-panel-body {
  flex: 1;
  overflow: auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stats-panel-body::-webkit-scrollbar {
  width: 4px;
}

.stats-panel-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.stats-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.stats-panel-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  padding-left: 2px;
}

.stats-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.stats-panel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  border-radius: 6px;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.stats-panel-item:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.stats-panel-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stats-panel-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.global-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: color-mix(in srgb, var(--accent) 12%, rgba(0, 0, 0, 0.4));
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: drop-overlay-in 0.18s ease;
}

@keyframes drop-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.global-drop-overlay-box {
  padding: 36px 64px;
  border: 3px dashed var(--accent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 15%, var(--btn-bg));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
}

.global-drop-overlay-icon {
  font-size: 52px;
}

.global-drop-overlay-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.editor-host {
  flex: 1;
  min-height: 0;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.editor-host .cm-editor {
  height: 100%;
  outline: none;
}

.editor-host .cm-editor .cm-scroller {
  font-family: var(--font-editor, 'Consolas', 'Courier New', monospace);
  line-height: 1.6;
}

.editor-host .cm-editor .cm-gutters {
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--muted);
}

.editor-host .cm-editor .cm-activeLineGutter {
  background: color-mix(in srgb, var(--accent) 6%, var(--panel-bg));
}

.editor-host .cm-editor .cm-activeLine {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.editor-host .cm-editor .cm-selectionBackground,
.editor-host .cm-editor.cm-focused .cm-selectionBackground {
  background: color-mix(in srgb, var(--accent) 25%, transparent) !important;
}

.editor-host .cm-editor .cm-cursor {
  border-left-color: var(--accent);
}

.preview-outer {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 24px 32px;
}

.preview-shell {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  width: 100%;
}

.preview-shell--tight {
  padding: 0 8px 8px;
}

.preview-resizer {
  position: absolute;
  top: 0;
  right: -10px;
  width: 16px;
  height: 100%;
  cursor: ew-resize;
  z-index: 5;
  border-radius: 6px;
  border: 2px solid var(--accent);
  background: var(--btn-bg);
  opacity: 0.9;
  transition: opacity 0.15s, filter 0.15s;
}

.preview-resizer:hover {
  opacity: 1;
  filter: brightness(1.08);
}

.preview-resizer::after {
  content: '‖';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--accent);
  pointer-events: none;
}

.preview {
  flex: 0 0 auto;
  overflow: visible;
  padding: 28px 36px 52px;
  width: 100%;
  font-size: 16px;
  line-height: var(--preview-line-height, 1.7);
  background: var(--preview-bg);
  color: var(--preview-text);
  border-radius: 10px;
  box-shadow: var(--preview-shadow);
  font-family: var(--font-preview, var(--font-ui, Georgia, serif));
}

.preview code {
  font-family: 'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.88em;
  background: color-mix(in srgb, var(--code-bg) 85%, var(--border));
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.preview .md-code-wrap {
  position: relative;
  margin: 1.2em 0;
  border: 1px solid color-mix(in srgb, var(--border) 90%, #000);
  border-radius: 8px;
  background: var(--code-bg);
  overflow: hidden;
}

.preview .md-code-wrap .md-code-lang {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
}

.preview .md-code-wrap pre.hljs {
  margin: 0;
  padding: 18px 20px;
  background: transparent;
  border-radius: 0;
  overflow-x: auto;
}

.preview .md-code-wrap pre.hljs code {
  font-family: 'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.55;
  background: transparent;
  padding: 0;
}

.preview .md-diagram-wrap {
  margin: 1.5em 0;
  padding: 24px 20px 28px;
  background: var(--preview-bg);
  border: 1px solid color-mix(in srgb, var(--border) 85%, #000);
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  contain: layout style;
}

.preview .md-diagram-wrap pre.mermaid {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  text-align: center;
}

.preview .md-diagram-wrap .mermaid-render-host {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 4rem;
  width: 100%;
  overflow: hidden;
}

.preview .md-diagram-wrap .mermaid-placeholder {
  min-height: 4rem;
  width: 100%;
}

.preview .md-diagram-wrap .mermaid-render-host svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.preview .md-diagram-wrap .mermaid-error {
  margin: 0;
  padding: 12px;
  text-align: left;
  font-size: 12px;
  color: #b91c1c;
  background: color-mix(in srgb, #fecaca 40%, transparent);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hybrid-preview .preview .md-diagram-wrap {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.preview img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.2em auto;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.1);
}

.preview h1,
.preview h2,
.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  font-family: inherit;
  color: inherit;
  margin-top: 1.3em;
  margin-bottom: 0.6em;
  line-height: 1.3;
}

.preview h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.4em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.preview h2 {
  font-size: 1.6rem;
  font-weight: 650;
}

.preview h3 {
  font-size: 1.3rem;
  font-weight: 600;
}

.preview h4 {
  font-size: 1.15rem;
  font-weight: 600;
}

.preview h5 {
  font-size: 1.05rem;
  font-weight: 600;
}

.preview h6 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.preview pre {
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: var(--code-bg);
}

.preview .hljs,
.preview .hljs code {
  font-family: 'Cascadia Code', 'Consolas', 'Monaco', 'Courier New', monospace !important;
}

.preview a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.12s;
}

.preview a:hover {
  text-decoration: underline;
  color: color-mix(in srgb, var(--accent) 80%, #fff);
}

.preview a.md-internal-link {
  color: var(--accent);
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}

.preview a.md-internal-link:hover {
  border-bottom-style: solid;
}

.preview hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
  height: 0;
  background: none;
}

.hybrid-row {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.hybrid-editor {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
}

.hybrid-sash {
  flex: 0 0 6px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
}

.hybrid-sash:hover {
  background: var(--accent);
  opacity: 0.3;
}

.hybrid-preview {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  background: var(--app-bg);
}

.hybrid-preview-shell {
  position: relative;
  width: 100%;
  max-width: 860px;
}

.hybrid-line-pulse {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 1.75em;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
  border-radius: 6px;
  background: rgba(250, 204, 21, 0.42);
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.35);
  animation: hybrid-line-pulse 1.35s ease-in-out forwards;
}

@keyframes hybrid-line-pulse {
  0%,
  100% {
    opacity: 0;
  }
  12%,
  30% {
    opacity: 1;
  }
  42% {
    opacity: 0;
  }
  54%,
  72% {
    opacity: 1;
  }
  84%,
  100% {
    opacity: 0;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-overlay-in 0.18s ease;
}

@keyframes modal-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(440px, calc(100% - 32px));
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

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

.modal-text-input {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.modal-actions button:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--btn-bg));
}

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

.modal-actions button.primary:hover {
  background: color-mix(in srgb, var(--accent) 85%, #000);
  border-color: color-mix(in srgb, var(--accent) 85%, #000);
}

.modal--wide {
  width: min(520px, calc(100% - 32px));
}

.modal-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-field {
  display: block;
  margin-bottom: 14px;
}

.modal-field .modal-text-input {
  margin-bottom: 0;
}

.modal-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 500;
}

.modal-row-btns {
  margin: -4px 0 14px;
}

.modal-row-btns button {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}

.modal-row-btns button:hover {
  border-color: var(--accent);
}

.color-picker-native {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.color-picker-spectrum {
  width: 56px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--btn-bg);
}

.color-swatch-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.color-swatch-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid var(--border);
  padding: 0;
  cursor: pointer;
  box-sizing: border-box;
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 120px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 4px;
}

.ctx-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}

.ctx-item.danger {
  color: #b91c1c;
}

.ctx-item:hover {
  background: var(--hover);
}

.preview .md-table-wrap {
  overflow-x: auto;
  margin: 1.3em 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94em;
  line-height: 1.6;
}

.preview thead th {
  background: color-mix(in srgb, var(--accent) 10%, var(--preview-bg));
  font-weight: 650;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.preview tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  vertical-align: top;
}

.preview tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}

.preview tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.preview tbody tr:last-child td {
  border-bottom: none;
}


.preview pre.mermaid:not(.md-diagram-wrap pre.mermaid) {
  margin: 1.5em 0;
  padding: 18px 16px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  text-align: center;
}

.preview-anchor-flash {
  animation: preview-anchor-flash 1.6s ease-out;
}

@keyframes preview-anchor-flash {
  0%,
  100% {
    background-color: transparent;
    box-shadow: none;
  }
  15%,
  40% {
    background-color: rgba(250, 204, 21, 0.35);
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.25);
    border-radius: 4px;
  }
  55% {
    background-color: transparent;
    box-shadow: none;
  }
  70% {
    background-color: rgba(250, 204, 21, 0.28);
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.2);
    border-radius: 4px;
  }
}
