/* Navigation */
.main-nav {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.nav-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.project-card:hover {
  border-color: #2a2a3e;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.project-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-name .folder-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.project-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

/* File Browser Layout */
.file-browser {
  display: flex;
  gap: 0;
  height: calc(100vh - 140px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.file-tree-panel {
  width: 280px;
  min-width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  flex-shrink: 0;
}

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

.tree-back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.tree-back-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.tree-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.tree-content::-webkit-scrollbar { width: 4px; }
.tree-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Tree Items */
.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

.tree-item-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.tree-item-icon svg {
  width: 14px;
  height: 14px;
}

.tree-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-indent {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
}

.tree-dir-toggle {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform 0.15s;
}

.tree-dir-toggle.open {
  transform: rotate(90deg);
}

/* File Editor Panel */
.file-editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.editor-filename {
  font-size: 13px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.editor-content::-webkit-scrollbar { width: 6px; }
.editor-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.empty-state-large {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

/* Rendered Markdown */
.markdown-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}

.markdown-body h1 { font-size: 24px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.markdown-body h2 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h3 { font-size: 16px; }

.markdown-body p { margin-bottom: 12px; }

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-body a:hover { text-decoration: underline; }

.markdown-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.markdown-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 12px;
  padding-left: 24px;
}

.markdown-body li { margin-bottom: 4px; }

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin-bottom: 12px;
  color: var(--text-dim);
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 16px;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  font-size: 13px;
}

.markdown-body th {
  background: var(--bg);
  font-weight: 600;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

/* Edit Textarea */
.file-edit-textarea {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 260px);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.file-edit-textarea:focus {
  border-color: var(--accent);
}

/* Raw file viewer (non-markdown) */
.file-raw {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  background: var(--bg);
}

.breadcrumb-item {
  cursor: pointer;
  color: var(--text-dim);
  transition: color 0.1s;
}

.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-muted); }

/* Mobile: file tree drawer */
@media (max-width: 768px) {
  .file-browser {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 140px);
  }

  .file-tree-panel {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .file-editor-panel {
    min-height: 50vh;
  }

  .tree-toggle-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 600;
  }

  .file-tree-panel.collapsed {
    max-height: 0;
    overflow: hidden;
    border-bottom: none;
  }
}

/* Loading spinner */
.tree-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Save toast */
.save-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 10px 20px;
  background: var(--green);
  color: #000;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  z-index: 100;
  animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
