:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --bg-light: #f8fafc;
  --bg-dark: #1e293b;
  --text-light: #0f172a;
  --text-dark: #f1f5f9;
  --border-light: #e2e8f0;
  --border-dark: #334155;
  --editor-bg: #ffffff;
  --preview-bg: #ffffff;
  --code-bg: #282c34;
  --code-text: #abb2bf;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft Yahei", sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-light);
  color: var(--text-light);
  overflow: hidden;
}

.init-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem;
  text-align: center;
}

.init-screen h2 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--primary-color);
}

.init-screen p {
  color: #64748b;
  max-width: 600px;
}

.init-btn {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  cursor: pointer;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
  transition: all 0.2s ease;
}

.init-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

#folderInput {
  display: none;
}

.app {
  display: none;
  height: 100vh;
  flex-direction: row;
}

.file-list {
  width: 300px;
  background: white;
  border-right: 1px solid var(--border-light);
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1rem;
}

.file-list-title {
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-item {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-item:hover {
  background-color: #f1f5f9;
}

.file-item.active {
  background-color: var(--primary-color);
  color: white;
}

.file-item i {
  font-size: 0.85rem;
}

.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
}

.toolbar {
  padding: 0.75rem 1.5rem;
  background: white;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  background: var(--primary-color);
  color: white;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.active {
  background: var(--primary-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mode-btn {
  background: #f1f5f9;
  color: var(--text-light);
}

.mode-btn.active {
  background: var(--primary-color);
  color: white;
}

.current-file {
  font-size: 0.95rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.theme-toggle {
  background: #f1f5f9;
  color: var(--text-light);
  padding: 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
}

.edit-preview {
  display: flex;
  flex: 1;
  height: calc(100% - 60px);
}

#editor {
  flex: 1;
  padding: 1.5rem;
  font-size: 14px;
  line-height: 1.6;
  border: none;
  border-right: 1px solid var(--border-light);
  resize: none;
  outline: none;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: var(--editor-bg);
  color: var(--text-light);
}

.preview {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--preview-bg);
  line-height: 1.8;
}

.preview h1, .preview h2, .preview h3, .preview h4, .preview h5, .preview h6 {
  margin: 1.5rem 0 1rem 0;
  font-weight: 600;
  color: var(--primary-color);
}

.preview h1 {
  font-size: 2rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
  margin-top: 0;
}

.preview h2 {
  font-size: 1.75rem;
}

.preview h3 {
  font-size: 1.5rem;
}

.preview p {
  margin-bottom: 1rem;
}

.preview a {
  color: var(--primary-color);
  text-decoration: none;
}

.preview a:hover {
  text-decoration: underline;
}

.preview ul, .preview ol {
  margin-left: 2rem;
  margin-bottom: 1rem;
}

.preview blockquote {
  border-left: 4px solid var(--primary-color);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: #f1f5f9;
  border-radius: 0 0.375rem 0.375rem 0;
}

.preview pre {
  background: var(--code-bg) !important;
  color: var(--code-text) !important;
  padding: 1.25rem !important;
  border-radius: 0.5rem !important;
  margin: 1.5rem 0 !important;
  overflow-x: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.7;
}

.preview pre code {
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
  font-size: 14px !important;
}

/* 复制按钮样式 */
.preview pre {
  position: relative;
}

.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--code-text);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.preview pre:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.copy-button.copied {
  background: #10b981;
  color: white;
}

body.dark .copy-button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--code-text);
}

body.dark .copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.hljs-ln-numbers {
  border-right: 1px solid #495057 !important;
  padding-right: 1rem !important;
  margin-right: 1rem !important;
  color: #6b7280 !important;
  text-align: right !important;
}

.loading {
  padding: 2rem;
  color: #64748b;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.edit-only #editor {
  flex: none;
  width: 100%;
}

.edit-only .preview {
  display: none;
}

.preview-only #editor {
  display: none;
}

.preview-only .preview {
  flex: none;
  width: 100%;
}

body.dark {
  --bg-light: #0f172a;
  --text-light: #f1f5f9;
  --border-light: #334155;
  --editor-bg: #1e293b;
  --preview-bg: #1e293b;
}

body.dark .file-list,
body.dark .editor-container,
body.dark .toolbar {
  background: #1e293b;
}

body.dark .file-item:hover {
  background-color: #334155;
}

body.dark .preview blockquote {
  background: #334155;
}

body.dark .mode-btn {
  background: #334155;
  color: var(--text-light);
}

body.dark .theme-toggle {
  background: #334155;
  color: var(--text-light);
}

@media (max-width: 768px) {
  .file-list {
    width: 250px;
  }
  
  .current-file {
    max-width: 200px;
  }
  
  .btn-group {
    flex-wrap: wrap;
  }
}
