:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667387;
  --line: #dce3ec;
  --accent: #0f6f68;
  --accent-soft: #e4f4f2;
  --warn: #fff7df;
  --warn-line: #edd68c;
  --shadow: 0 16px 44px rgba(18, 31, 46, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #edf2f6;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

h1, h2, h3, h4 { margin: 0; letter-spacing: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.55rem; line-height: 1.2; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.control {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--panel);
  color: var(--ink);
}

.control:focus {
  outline: 3px solid rgba(15, 111, 104, 0.16);
  border-color: var(--accent);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.count, .crumbs, .meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.doc-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 2px;
}

.doc-item {
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border-radius: 6px;
  text-align: left;
  line-height: 1.25;
  background: transparent;
}

.doc-item:hover,
.doc-item.active {
  background: var(--accent-soft);
  border-color: rgba(15, 111, 104, 0.4);
}

.doc-title {
  display: block;
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  max-width: 980px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions button {
  width: 42px;
  height: 42px;
  border-radius: 6px;
}

.document {
  max-width: 980px;
  margin: 0 auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.document > *:first-child { margin-top: 0; }
.document h1, .document h2, .document h3, .document h4 {
  margin: 1.35em 0 0.55em;
  line-height: 1.25;
}
.document h1 { font-size: 1.7rem; }
.document h2 { font-size: 1.35rem; }
.document h3 { font-size: 1.1rem; color: var(--ink); }
.document p { margin: 0 0 1rem; }
.document ul, .document ol { padding-left: 1.35rem; }
.document li { margin: 0.25rem 0; }
.document code {
  border-radius: 4px;
  background: #eef2f7;
  padding: 0.08rem 0.28rem;
}
.document pre {
  overflow: auto;
  border-radius: 6px;
  background: #111827;
  color: #f8fafc;
  padding: 14px;
}
.document table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.document th, .document td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}
.document th { background: #f0f4f8; text-align: left; }
.document blockquote {
  margin: 1rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 4px solid var(--accent);
  color: #39475a;
}
.figure-alt {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  background: var(--warn);
}
.figure-alt strong {
  display: block;
  margin-bottom: 6px;
  color: #765800;
}

.empty {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .workspace { padding: 18px; }
  .document { padding: 20px; }
}
