:root {
  color-scheme: light;
  --ink: #191b1f;
  --ink-soft: #363a42;
  --muted: #727985;
  --line: #d8ded9;
  --paper: #f5f7f2;
  --surface: #ffffff;
  --panel: #eef3ef;
  --lime: #b7ff2a;
  --cyan: #49b6c7;
  --yellow: #f1c844;
  --red: #e55239;
  --shadow: 0 18px 60px rgba(29, 34, 38, 0.12);
  --radius: 8px;
  --mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", Menlo, monospace;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", var(--body);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(183, 255, 42, 0.2) 0 8px, transparent 8px),
    var(--paper);
  font-family: var(--body);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(73, 182, 199, 0.55);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  max-width: 1580px;
  margin: 0 auto 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 40px;
  color: var(--lime);
  background: var(--ink);
  border: 4px solid #2f3540;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1;
  text-transform: uppercase;
}

.state-strip {
  display: grid;
  grid-template-columns: repeat(4, 18px);
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.state-dot {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.state-normal {
  background: #0f1217;
}

.state-money {
  background: var(--lime);
}

.state-warn {
  background: var(--yellow);
}

.state-alert {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(260px, 310px);
  gap: 14px;
  max-width: 1580px;
  margin: 0 auto;
}

.sidebar,
.reader,
.inspector {
  min-height: calc(100vh - 118px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar,
.inspector {
  align-self: start;
  max-height: calc(100vh - 118px);
  overflow: auto;
}

.filter-panel {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.search-label,
.tag-label,
.select-row label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.search-box {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-box svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: 10px;
  color: var(--ink);
  background: var(--lime);
  border: 1px solid #8ecf16;
  border-radius: var(--radius);
}

.document-list {
  padding: 12px;
}

.nav-group + .nav-group {
  margin-top: 18px;
}

.nav-group h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

.doc-button {
  display: grid;
  width: 100%;
  gap: 5px;
  margin-bottom: 8px;
  padding: 11px;
  text-align: left;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.doc-button[data-active="true"] {
  border-color: #91c918;
  box-shadow: inset 4px 0 0 var(--lime);
}

.doc-button:hover {
  background: #fbfcf9;
  border-color: #b9c2bb;
}

.doc-title {
  font-weight: 850;
}

.doc-path {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.mini-status,
.status-pill {
  justify-self: start;
  padding: 4px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-canon {
  color: #426105;
  background: rgba(183, 255, 42, 0.25);
}

.status-open,
.status-pending,
.status-draft {
  color: #8c5d00;
  background: rgba(241, 200, 68, 0.2);
}

.status-exploration {
  color: #0c6170;
  background: rgba(73, 182, 199, 0.18);
}

.reader {
  min-width: 0;
  padding: 26px;
  overflow: auto;
}

.reader-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--ink);
}

.reader h2 {
  font-family: var(--display);
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  text-transform: uppercase;
}

.summary {
  max-width: 760px;
  margin: 18px 0 12px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.5;
}

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

.tag-cloud span,
.topic-chip {
  padding: 6px 9px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
}

.topic-chip {
  background: var(--surface);
}

.markdown-body {
  max-width: 850px;
  margin-top: 26px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 30px 0 10px;
  font-family: var(--display);
  line-height: 1.05;
  text-transform: uppercase;
}

.markdown-body h1 {
  font-size: 34px;
}

.markdown-body h2 {
  font-size: 27px;
}

.markdown-body h3 {
  font-size: 22px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre {
  margin: 0 0 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
}

.markdown-body li + li {
  margin-top: 5px;
}

.markdown-body code {
  padding: 2px 5px;
  background: var(--panel);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.92em;
}

.markdown-body pre {
  overflow-x: auto;
  padding: 14px;
  background: #15181e;
  border-radius: var(--radius);
}

.markdown-body pre code {
  padding: 0;
  color: #eaf4e8;
  background: transparent;
}

.markdown-body a {
  color: #0b6a79;
  font-weight: 800;
}

.loading,
.empty-state {
  color: var(--muted);
}

.notice {
  padding: 18px;
  background: rgba(229, 82, 57, 0.08);
  border: 1px solid rgba(229, 82, 57, 0.35);
  border-radius: var(--radius);
}

.notice h3 {
  margin-bottom: 8px;
}

.inspector {
  padding: 16px;
}

.inspector-section + .inspector-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.inspector-section h2 {
  margin-bottom: 10px;
  font-family: var(--display);
  font-size: 22px;
  text-transform: uppercase;
}

.inspector-section p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.stats-grid div {
  padding: 11px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stats-grid dt {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 900;
}

.stats-grid dd {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 310px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    min-height: auto;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .reader-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .reader,
  .inspector {
    min-height: auto;
    max-height: none;
  }

  .reader {
    padding: 18px;
  }

  .reader h2 {
    font-size: 38px;
  }
}
