/* Obsidian Vault Web Publisher — Wikipedia-like style */
:root {
  --font-body: Georgia, 'Times New Roman', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
  --max-width: 1100px;
  --sidebar-width: 240px;
  --bg: #ffffff;
  --bg-sidebar: #f8f9fa;
  --bg-code: #f6f6f6;
  --text: #202122;
  --text-muted: #54595d;
  --link: #0645ad;
  --link-visited: #0b0080;
  --link-hover: #0645ad;
  --border: #a2a9b1;
  --border-light: #eaecf0;
  --accent: #3680a4;
  --tag-bg: #eaf3fb;
  --tag-text: #0645ad;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

/* ── Layout ── */
.layout {
  display: flex;
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  gap: 0;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-brand {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-brand a {
  color: inherit;
  text-decoration: none;
}

.sidebar-brand a:hover { color: var(--link); }

.search-wrap input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  background: #fff;
  color: var(--text);
}

.search-wrap input:focus { border-color: var(--accent); }

.nav-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.nav-list li { margin: 2px 0; }

.nav-list a {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--link);
  text-decoration: none;
  display: block;
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-list a:hover { background: var(--border-light); }
.nav-list a.active { background: var(--tag-bg); font-weight: 600; }

.nav-section-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 6px 2px;
  margin-top: 6px;
}

/* ── Main Content ── */
.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
  max-width: 760px;
}

/* ── Typography ── */
.main h1 {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: normal;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
  margin-bottom: 0.6em;
  color: var(--text);
}

.main h2 {
  font-family: var(--font-body);
  font-size: 1.45rem;
  font-weight: normal;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.2em;
  margin: 1.4em 0 0.5em;
}

.main h3 {
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: bold;
  margin: 1.2em 0 0.4em;
}

.main h4, .main h5, .main h6 {
  font-family: var(--font-body);
  margin: 1em 0 0.4em;
}

.main p { margin: 0.7em 0; }

.main a { color: var(--link); text-decoration: none; }
.main a:hover { text-decoration: underline; }
.main a:visited { color: var(--link-visited); }

.main a.wiki-link { color: var(--link); border-bottom: 1px dashed var(--border); }
.main a.wiki-link.broken { color: #ba0000; border-bottom-color: #ba0000; }

.main ul, .main ol {
  margin: 0.6em 0;
  padding-left: 2em;
}

.main li { margin: 0.25em 0; }

.main blockquote {
  border-left: 4px solid var(--border);
  background: var(--bg-sidebar);
  padding: 0.6em 1em;
  margin: 1em 0;
  color: var(--text-muted);
  font-style: italic;
}

.main code {
  background: var(--bg-code);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.88em;
}

.main pre {
  background: var(--bg-code);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 0.87em;
}

.main pre code {
  background: none;
  padding: 0;
  font-size: 1em;
}

.main table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.9em;
}

.main th, .main td {
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  text-align: left;
}

.main th {
  background: var(--bg-sidebar);
  font-family: var(--font-ui);
  font-weight: 600;
}

.main tr:nth-child(even) td { background: #fafafa; }

.main hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 2em 0;
}

/* ── Tags ── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.8em 0; }
.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  text-decoration: none;
}
.tag:hover { background: #d4e4f4; text-decoration: none; }

/* ── Backlinks ── */
.backlinks {
  margin-top: 3em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border-light);
}

.backlinks h3 {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5em;
}

.backlinks ul {
  list-style: none;
  padding: 0;
}

.backlinks li { margin: 4px 0; }

.backlinks a {
  font-family: var(--font-ui);
  font-size: 0.9em;
  color: var(--link);
  text-decoration: none;
}

.backlinks a:hover { text-decoration: underline; }

/* ── Graph View ── */
.graph-section {
  margin-top: 2.5em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border-light);
}

.graph-section h3 {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6em;
}

#graph-container {
  width: 100%;
  height: 320px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fafbfc;
  overflow: hidden;
  position: relative;
}

#graph-container svg { width: 100%; height: 100%; }

.graph-node circle {
  cursor: pointer;
  transition: r 0.15s;
}

.graph-node text {
  font-family: var(--font-ui);
  font-size: 10px;
  fill: var(--text);
  pointer-events: none;
  user-select: none;
}

.graph-link {
  stroke: #ccc;
  stroke-width: 1px;
}

/* ── Index Page ── */
.index-header {
  margin-bottom: 1.5em;
}

.index-header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3em;
}

.index-header p {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.index-search {
  width: 100%;
  max-width: 480px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 15px;
  margin-bottom: 1.5em;
  outline: none;
}

.index-search:focus { border-color: var(--accent); }

.note-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.note-card {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.note-card a {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--link);
  text-decoration: none;
  flex: 1;
}

.note-card a:hover { text-decoration: underline; }

.note-card .note-dir {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Loading / Error ── */
.loading, .error-msg {
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--text-muted);
  padding: 2em 0;
}

.error-msg { color: #ba0000; }

/* ── Responsive ── */
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }
  .main { padding: 20px 16px 40px; }
}
