/* Vault Browser — Dark Theme, Mobile-First */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2333;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-green: #3fb950;
  --accent-orange: #d29922;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Breadcrumb nav */
.breadcrumb {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .root-link { font-weight: 600; }
.breadcrumb .sep { color: var(--text-dim); margin: 0 4px; }
.breadcrumb .current { color: var(--text-dim); }

/* Back link */
.back-link {
  display: inline-block;
  padding: 6px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { background: var(--surface-hover); }

/* File list */
.file-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.entry:last-child { border-bottom: none; }
.entry:hover { background: var(--surface-hover); }

.entry-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.entry-link:hover .name { color: var(--accent); }

.icon { font-size: 18px; flex-shrink: 0; }
.name {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn-read {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.btn-read:hover { filter: brightness(1.15); }

.size {
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

/* Footer */
footer {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
}
.vault-name { font-weight: 600; }

/* Reader page specific */
.reader-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.reader-header a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.reader-header a:hover { text-decoration: underline; }
.reader-title {
  font-size: 14px;
  color: var(--text-dim);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rendered markdown content */
.markdown-body {
  padding: 10px 0;
  word-wrap: break-word;
}
.markdown-body h1 { font-size: 1.6em; margin: 0.6em 0 0.4em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.3em; margin: 0.6em 0 0.3em; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
.markdown-body h3 { font-size: 1.1em; margin: 0.5em 0 0.3em; }
.markdown-body p { margin: 0.5em 0; }
.markdown-body a { color: var(--accent); }
.markdown-body ul, .markdown-body ol { margin: 0.5em 0; padding-left: 1.5em; }
.markdown-body li { margin: 0.25em 0; }
.markdown-body pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.45;
  margin: 0.5em 0;
}
.markdown-body code {
  background: rgba(110,118,129,0.4);
  border-radius: 3px;
  padding: 0.2em 0.4em;
  font-size: 0.85em;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}
.markdown-body blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1em;
  color: var(--text-dim);
  margin: 0.5em 0;
}
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0;
  font-size: 14px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th { background: var(--surface); font-weight: 600; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.markdown-body .task-list-item { list-style: none; margin-left: -1.5em; }
.markdown-body .task-list-item input { margin-right: 0.5em; }

/* Loading spinner */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 15px;
  gap: 12px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error state */
.error-box {
  background: #3d1f1f;
  border: 1px solid #f85149;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: #f85149;
  margin: 40px 0;
}

/* Mobile refinements */
@media (max-width: 480px) {
  body { padding: 10px; }
  .entry { padding: 12px 12px; }
  .name { font-size: 14px; }
  .btn-read { padding: 6px 14px; font-size: 13px; }
}
