:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #fbfbfc;
  --line: #d9dee7;
  --line-soft: #e7ebf0;
  --text: #111827;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --good-soft: #ecfdf5;
  --warn-soft: #fff7ed;
  --danger-soft: #fef2f2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 320px;
  grid-template-rows: 64px calc(100vh - 64px);
}

.topbar {
  grid-column: 1 / 4;
  display: grid;
  grid-template-columns: 280px minmax(260px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: #111827;
  color: white;
  font-weight: 800;
  font-size: 13px;
}

.brand-title {
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.search-box span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.summary-counts {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.sidebar,
.inspector {
  overflow: auto;
  background: var(--panel-soft);
  padding: 16px;
}

.sidebar {
  border-right: 1px solid var(--line);
}

.inspector {
  border-left: 1px solid var(--line);
}

.content {
  overflow: auto;
  background: #f8fafc;
  padding: 40px 48px 64px;
}

.sidebar-section,
.inspector-section {
  margin-bottom: 22px;
}

.section-label {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav-list,
.page-list {
  display: grid;
  gap: 6px;
}

.nav-item,
.page-item,
.result-item,
.side-card,
.tag-chip {
  border: 1px solid var(--line-soft);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.nav-item,
.page-item {
  width: 100%;
  cursor: pointer;
  text-align: left;
  padding: 9px 10px;
  color: var(--text);
}

.nav-item.active,
.page-item.active {
  border-color: #111827;
  background: #111827;
  color: white;
}

.nav-item .count {
  float: right;
  color: inherit;
  opacity: 0.7;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag-chip {
  cursor: pointer;
  padding: 6px 8px;
  color: #334155;
  font-size: 12px;
}

.tag-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #1d4ed8;
}

.page-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
  font-size: 13px;
}

.page-item-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.page-item.active .page-item-meta {
  color: rgba(255, 255, 255, 0.72);
}

.page-kicker {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.page-content h1 {
  margin: 0 0 28px;
  color: #1e293b;
  font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(29px, 3vw, 38px);
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.24;
}

.page-content h2 {
  margin: 40px 0 16px;
  padding: 20px 0 0;
  border-top: 1px solid #e2e8f0;
  color: #1e293b;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.page-content h3 {
  margin: 30px 0 12px;
  color: #334155;
  font-size: 17px;
  line-height: 1.45;
}

.page-content p,
.page-content li {
  color: #334155;
  font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 16px;
  line-height: 1.9;
}

.page-content p {
  margin: 0 0 16px;
}

.page-content strong {
  color: #172033;
  font-weight: 750;
}

.page-content em {
  color: #475569;
}

.page-content del {
  color: #94a3b8;
}

.page-content ul {
  margin: 8px 0 18px;
  padding-left: 1.5em;
}

.page-content ol {
  margin: 8px 0 18px;
  padding-left: 1.7em;
}

.page-content li {
  margin: 5px 0;
  padding-left: 4px;
}

.page-content li::marker {
  color: #64748b;
}

.page-content li > ul,
.page-content li > ol {
  margin: 5px 0 2px;
}

.task-box {
  display: inline-grid;
  width: 1.05em;
  height: 1.05em;
  place-items: center;
  margin: 0 0.45em 0 0.05em;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  color: white;
  font-family: system-ui, sans-serif;
  font-size: 0.75em;
  line-height: 1;
  vertical-align: 0.02em;
}

.task-box.done {
  border-color: #2563eb;
  background: #2563eb;
}

.page-content code {
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #f1f5f9;
  color: #be185d;
  padding: 2px 6px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.86em;
}

.page-content pre {
  overflow: auto;
  margin: 20px 0;
  border: 1px solid #1e293b;
  border-radius: 10px;
  background: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  color: #e2e8f0;
  padding: 18px 20px;
  line-height: 1.65;
}

.page-content pre code {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.page-content a {
  color: var(--accent);
  text-decoration: none;
}

.page-content a:hover {
  text-decoration: underline;
}

.page-content blockquote {
  margin: 20px 0;
  border-left: 4px solid #60a5fa;
  border-radius: 0 8px 8px 0;
  background: #eff6ff;
  color: #334155;
  padding: 14px 18px;
  font-family: ui-serif, Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 16px;
  line-height: 1.8;
}

.page-content hr {
  height: 1px;
  margin: 32px 0;
  border: 0;
  background: #e2e8f0;
}

.table-wrap {
  overflow-x: auto;
  margin: 22px 0 28px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.page-content table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 14px;
}

.page-content th,
.page-content td {
  border-bottom: 1px solid #e2e8f0;
  padding: 11px 14px;
  vertical-align: top;
  line-height: 1.65;
}

.page-content th {
  background: #f8fafc;
  color: #334155;
  font-weight: 750;
  white-space: nowrap;
}

.page-content tr:last-child td {
  border-bottom: 0;
}

.page-content td {
  color: #475569;
}

.inline-file-link {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
}

.inline-file-link.missing-target a {
  text-decoration: underline dotted;
  text-decoration-color: #dc2626;
}

.inline-open-button {
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 2px;
  font-size: 11px;
}

.inline-open-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.unresolved-link {
  color: var(--muted);
  text-decoration: underline dotted;
}

.reference-row-link {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  border-radius: 4px;
  padding: 2px 4px;
}

.reference-row-link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.reference-row-link code {
  overflow-wrap: anywhere;
}

.search-results {
  margin-bottom: 22px;
}

.search-results.hidden {
  display: none;
}

.result-item {
  cursor: pointer;
  margin-bottom: 8px;
  padding: 12px;
}

.result-title {
  font-weight: 750;
}

.result-meta,
.result-snippet {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.side-card {
  display: block;
  cursor: pointer;
  margin-bottom: 8px;
  padding: 10px;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.side-card:hover {
  border-color: var(--accent);
}

.source-actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}

.source-action-link,
.source-action-button {
  min-width: 56px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: #334155;
  padding: 5px 8px;
  text-align: center;
  text-decoration: none;
  font-size: 12px;
}

.source-action-link:hover,
.source-action-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.side-title {
  font-weight: 700;
  font-size: 13px;
}

.side-meta,
.raw-path,
.meta-row {
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 12px;
  font-size: 13px;
}

.public-empty-state {
  max-width: 620px;
  margin: 80px auto;
  padding: 28px;
  text-align: center;
}

.public-empty-state h1 {
  margin: 0 0 10px;
  font-size: 24px;
}

.action-button {
  width: 100%;
  cursor: pointer;
  border: 1px solid #111827;
  border-radius: var(--radius);
  background: #111827;
  color: white;
  padding: 9px 10px;
}

.action-button + .action-button {
  margin-top: 8px;
}

.secondary-action {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.action-status {
  min-height: 18px;
  margin-top: 8px;
  color: #047857;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.45;
}

.action-status.error {
  color: #b91c1c;
}

.type-pill {
  display: inline-block;
  margin-right: 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #1d4ed8;
  padding: 2px 6px;
  font-size: 11px;
}

.status-pill {
  display: inline-block;
  border-radius: 4px;
  background: var(--good-soft);
  color: #047857;
  padding: 2px 6px;
  font-size: 11px;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
  }

  .topbar {
    grid-column: 1 / 3;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 12px;
  }

  .sidebar {
    grid-column: 1 / 2;
    grid-row: 2 / 4;
  }

  .content {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
  }

  .inspector {
    grid-column: 2 / 3;
    grid-row: 3 / 4;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (min-width: 1041px) {
  .page-content {
    max-width: 960px;
    margin: 0 auto;
    border: 1px solid #e8edf3;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.06);
    padding: 48px 58px 64px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .content,
  .inspector {
    max-height: none;
    border: 0;
  }

  .content {
    padding: 24px 16px 44px;
  }

  .page-content table {
    min-width: 0;
    table-layout: fixed;
    font-size: 12px;
  }

  .page-content th,
  .page-content td {
    overflow-wrap: anywhere;
    padding: 8px 7px;
    white-space: normal;
  }
}

/* Public Pages keeps navigation and reading space, without local-only details. */
body.public-site .app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
}

body.public-site .topbar {
  grid-column: 1 / 3;
  grid-template-columns: 280px minmax(260px, 1fr) auto;
}

body.public-site .inspector {
  display: none;
}

@media (max-width: 1040px) {
  body.public-site .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  body.public-site .topbar {
    grid-column: 1 / 3;
  }
}
