* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  color: #d4d4d4;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #252526;
  border-bottom: 1px solid #3c3c3c;
}
.logo {
  font-weight: 600;
  color: #4ec9b0;
}
.current-path {
  flex: 1;
  font-size: 13px;
  color: #858585;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 0;
}
.search-wrap .search {
  width: 160px;
  padding: 6px 8px 6px 10px;
  border: 1px solid #3c3c3c;
  border-radius: 4px 0 0 4px;
  border-right: none;
  background: #3c3c3c;
  color: #d4d4d4;
  font-size: 13px;
}
.search-wrap .btn-search {
  padding: 6px 10px;
  border: 1px solid #3c3c3c;
  border-radius: 0 4px 4px 0;
  background: #3c3c3c;
  color: #858585;
  cursor: pointer;
  font-size: 14px;
}
.search-wrap .btn-search:hover {
  background: #4c4c4c;
  color: #d4d4d4;
}
.search {
  width: 180px;
  padding: 6px 10px;
  border: 1px solid #3c3c3c;
  border-radius: 4px;
  background: #3c3c3c;
  color: #d4d4d4;
  font-size: 13px;
}
.search::placeholder {
  color: #858585;
}
.btn {
  padding: 6px 12px;
  border: 1px solid #0e639c;
  border-radius: 4px;
  background: #0e639c;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover {
  background: #1177bb;
}
.btn-save {
  background: #0e639c;
}
.btn-delete {
  background: #7a1f1f;
  border-color: #a4262c;
}
.btn-delete:hover {
  background: #a4262c;
}
.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}
.btn-primary {
  background: #0e639c;
  border-color: #0e639c;
}
.username {
  font-size: 13px;
  color: #858585;
}
.main {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.sidebar {
  width: 260px;
  min-width: 200px;
  background: #252526;
  border-right: 1px solid #3c3c3c;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tabs {
  display: flex;
  border-bottom: 1px solid #3c3c3c;
}
.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: #858585;
  cursor: pointer;
  font-size: 13px;
}
.tab:hover {
  color: #d4d4d4;
}
.tab.active {
  color: #fff;
  border-bottom: 2px solid #0e639c;
  margin-bottom: -1px;
}
.tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
.tab-panel.active {
  display: flex;
}
.tree-toolbar {
  padding: 6px 8px;
  border-bottom: 1px solid #3c3c3c;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tree-toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tree-toolbar-search-label {
  font-size: 12px;
  color: #858585;
}
.file-tree .node.search-result {
  background: rgba(78, 201, 176, 0.15);
  border-left: 2px solid #4ec9b0;
}
.file-tree .node.search-result.selected {
  background: #094771;
  border-left: 2px solid #0e639c;
}
.file-tree {
  flex: 1;
  overflow: auto;
  padding: 8px;
  font-size: 13px;
}
.file-tree .node {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  user-select: none;
}
.file-tree .node:hover {
  background: #2a2d2e;
}
.file-tree .node.selected {
  background: #094771;
  border-left: 2px solid #0e639c;
}
.file-tree .node.file {
  padding-left: 20px;
}
.file-tree .node.dir > .node-label::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  font-size: 14px;
  margin-right: 2px;
}
.file-tree .node.dir.open > .node-label::before {
  content: "▾";
}
.file-tree .children {
  display: none;
  margin-left: 12px;
}
.file-tree .node.dir.open > .children {
  display: block;
}
/* Phase 2: TODO 列表（勿影响 Phase 1 文件树样式） */
.todo-list {
  padding: 8px;
  overflow: auto;
  font-size: 13px;
}
.todo-loading, .todo-error {
  color: #858585;
  padding: 8px 0;
}
.todo-group {
  margin-bottom: 12px;
}
.todo-group-title {
  font-weight: 600;
  color: #4ec9b0;
  padding: 4px 0;
  margin-bottom: 4px;
  font-size: 12px;
}
.todo-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.todo-item:hover {
  background: #2a2d2e;
  border-left-color: #0e639c;
}
.todo-item.completing {
  opacity: 0.7;
  pointer-events: none;
}
.todo-text {
  flex: 1 1 100%;
  color: #d4d4d4;
  font-size: 13px;
}
.todo-meta {
  flex: 1 1 100%;
  font-size: 11px;
  color: #858585;
}
.todo-item .btn-complete {
  flex-shrink: 0;
  background: #0e639c;
  border-color: #0e639c;
}
.btn-insert-todo {
  background: #2d2d30;
  border-color: #3c3c3c;
  color: #d4d4d4;
}
.btn-insert-todo:hover {
  background: #3c3c3c;
}
.repo-select {
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #3c3c3c;
  background: #2d2d30;
  color: #d4d4d4;
  font-size: 13px;
}
.git-status {
  font-size: 12px;
  color: #858585;
  min-width: 4em;
}

/* Toast */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  min-width: 220px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 4px;
  background: #333333;
  color: #ffffff;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  z-index: 2000;
}
.toast.toast--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast.toast--success {
  background: #107c10;
}
.toast.toast--error {
  background: #c50f1f;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1900;
}
.modal-backdrop.modal-backdrop--visible {
  display: flex;
}
.modal {
  width: 320px;
  max-width: 90vw;
  background: #252526;
  border-radius: 6px;
  border: 1px solid #3c3c3c;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 10px 14px;
  border-bottom: 1px solid #3c3c3c;
  font-weight: 600;
}
.modal-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #cccccc;
}
.modal-body input,
.modal-body select {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #3c3c3c;
  background: #1e1e1e;
  color: #d4d4d4;
  font-size: 13px;
}
.modal-footer {
  padding: 8px 14px 10px;
  border-top: 1px solid #3c3c3c;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-error {
  margin-top: 4px;
  font-size: 12px;
  color: #f48771;
}
.modal .optional {
  color: #858585;
  font-size: 12px;
  font-weight: normal;
}
.modal .required {
  color: #f48771;
}
.modal-delete-path {
  font-size: 13px;
  margin-bottom: 4px;
  word-break: break-all;
}
.editor-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.cherry-editor {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
/* 让 Cherry 根容器填满右侧整块，并统一暗色 */
#cherryEditor,
#cherryEditor > div {
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  flex: 1;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
}

/* 隐藏 Cherry 工具栏区域，避免占位 */
#cherryEditor .cherry-toolbar,
#cherryEditor .cherry--no-toolbar .cherry-toolbar,
#cherryEditor .cherry-sidebar,
#cherryEditor .cherry-toolbar-wrapper {
  display: none !important;
}

/* 主容器：横向排列 + 整块暗色 */
#cherryEditor .cherry {
  flex: 1 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0;
  display: flex !important;
  flex-direction: row !important;
  overflow: hidden;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
}

/* 编辑区：整块暗色，包括内部所有 div/textarea */
#cherryEditor .cherry-editor {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-right: 1px solid #3c3c3c;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
}
#cherryEditor .cherry-editor *,
#cherryEditor .cherry-editor textarea {
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
  border-color: #3c3c3c !important;
}
#cherryEditor .cherry-editor textarea::placeholder {
  color: #858585;
}

/* 预览区：整块暗色，空白区域也是暗色；内部正文继承颜色 */
#cherryEditor .cherry-previewer {
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px;
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
  min-height: 100%;
}
#cherryEditor .cherry-previewer.cherry-markdown {
  background: #1e1e1e !important;
  color: #d4d4d4 !important;
}
/* 预览区内部容器不要白底，避免下方空白发白 */
#cherryEditor .cherry-previewer * {
  background-color: transparent !important;
}
#cherryEditor .cherry-previewer.cherry-markdown,
#cherryEditor .cherry-previewer .markdown-body {
  background: #1e1e1e !important;
}
#cherryEditor .cherry-previewer h1,
#cherryEditor .cherry-previewer h2,
#cherryEditor .cherry-previewer h3,
#cherryEditor .cherry-previewer p,
#cherryEditor .cherry-previewer li,
#cherryEditor .cherry-previewer td,
#cherryEditor .cherry-previewer th,
#cherryEditor .cherry-previewer blockquote {
  color: #d4d4d4 !important;
}
#cherryEditor .cherry-previewer a {
  color: #4ec9b0 !important;
}
#cherryEditor .cherry-previewer code,
#cherryEditor .cherry-previewer pre {
  background: #252526 !important;
  color: #d4d4d4 !important;
  border-color: #3c3c3c !important;
}

/* 编辑/预览之间的拖拽线 */
#cherryEditor .cherry-drag {
  flex: 0 0 6px;
  min-width: 6px;
  cursor: col-resize;
  background: #3c3c3c !important;
}
