body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.85rem 0 0;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  padding: 0 0.9rem;
  height: 100%;
  border-right: 1px solid var(--rule);
}

.brand__mark {
  width: 22px;
  height: 22px;
  flex: none;
}

.brand__name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
}

.brand__meta {
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.crumb {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb strong {
  color: var(--ink);
  font-weight: 500;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  margin-right: 0.35rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.status-pill[data-state="coding"] {
  color: var(--status-progress);
}

.status-pill[data-state="live"] {
  color: var(--live);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.status-pill[data-state="coding"] .dot {
  background: var(--status-progress);
}

.status-pill[data-state="live"] .dot {
  background: var(--live);
}

.cnt em {
  font-style: normal;
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn:hover:not(:disabled) {
  background: var(--paper-inset);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--code {
  background: var(--stripe-positionality);
  border-color: var(--stripe-positionality);
  color: #f3f7f8;
}

.btn--code:hover:not(:disabled) {
  filter: brightness(1.08);
}

.iconbtn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--ink-muted);
}

.iconbtn:hover {
  border-color: var(--rule);
  background: var(--paper);
}

.menu-btn {
  display: none;
}

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--rule);
  background: var(--paper-raised);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.7rem 0.85rem 0.4rem;
}

.sidebar__title {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.sidebar__count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  padding: 0 0.85rem 0.65rem;
  font-size: 0.68rem;
  color: var(--ink-muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.swatch {
  width: 8px;
  height: 12px;
  display: inline-block;
}

.swatch--coded { background: var(--status-coded); }
.swatch--progress { background: var(--status-progress); }
.swatch--archived { background: var(--status-archived); }
.swatch--memo { background: var(--status-memo); }

.tree {
  flex: 1;
  overflow: auto;
  padding: 0.15rem 0 0.8rem;
}

.tree-item {
  width: 100%;
  display: grid;
  grid-template-columns: var(--stripe-w) 1fr auto;
  align-items: start;
  gap: 0.55rem;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.45rem 0.85rem 0.45rem 0;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  text-decoration: none;
  color: inherit;
}

.tree-item:hover,
.tree-item.is-active {
  background: var(--paper);
}

.tree-item.is-coded .tree-item__file {
  color: var(--ink);
}

.tree-stripe {
  align-self: stretch;
  min-height: 100%;
}

.tree-item__body {
  min-width: 0;
}

.tree-item__file {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
}

.tree-item__blurb {
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 0.1rem;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  padding: 0.05rem 0.28rem;
  align-self: center;
}

.badge[data-status="coded"] {
  color: var(--status-coded);
  border-color: var(--status-coded);
}

.badge[data-status="in-progress"] {
  color: var(--status-progress);
  border-color: var(--status-progress);
}

.badge[data-status="archived"] {
  color: var(--status-archived);
}

.badge[data-status="memo"] {
  color: var(--status-memo);
  border-color: var(--status-memo);
}

.header-mail {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-decoration: none;
  margin-right: 0.35rem;
}

.header-mail:hover {
  color: var(--ink);
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}

.doc {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.pane {
  display: grid;
  grid-template-columns: var(--stripe-w) 1fr;
  min-height: 100%;
}

.doc-stripe {
  background: var(--tab-stripe, var(--stripe-positionality));
}

.sheet {
  padding: 1.1rem 1.4rem 2.5rem 1.1rem;
  min-width: 0;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin: 0;
}

.tab-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--live);
  font-family: var(--font-mono);
  font-size: 0.92em;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.sheet h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.85rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0.15rem 0 0.35rem;
}

.lede {
  font-family: var(--font-display);
  font-size: 1.12rem;
  color: var(--ink-muted);
  max-width: 40rem;
  margin: 0 0 0.8rem;
}

.codes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0 1.1rem;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0 0.4rem;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  line-height: calc(var(--line) - 2px);
}

.prose {
  max-width: 42rem;
  font-size: 0.98rem;
}

.prose p {
  margin: 0 0 0.85rem;
}

.sheet h2,
.prose h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.meta-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.4rem;
  font-size: 0.9rem;
  margin: 0 0 0.2rem;
}

.meta-row dt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  padding-top: 0.35rem;
}

.source-list,
.protocol-list,
.trail {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  max-width: 46rem;
}

.source {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 0.7rem 0.85rem 0.8rem;
  margin: 0 0 0.65rem;
}

.source header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
}

.source h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0.15rem 0 0.2rem;
  line-height: 1.3;
}

.source .venue,
.source .note {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.45;
}

.source .note {
  margin-top: 0.35rem;
}

.cite-live {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--live);
  margin: 0.35rem 0 0;
}

.cite-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.bibtex {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  background: var(--paper-inset);
  border: 1px solid var(--rule);
  padding: 0.5rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.instrument,
.rta-form {
  display: grid;
  gap: 0.55rem;
  max-width: 40rem;
  margin-top: 0.5rem;
}

label.field {
  display: grid;
  gap: 0.15rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.field input,
.field select,
.field textarea {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 0.4rem 0.5rem;
  width: 100%;
}

.field textarea {
  min-height: 4.5rem;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.45;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.result-card {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 0.7rem 0.85rem;
  margin-top: 0.3rem;
}

.result-card dl {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.15rem 0.6rem;
  margin: 0;
}

.result-card dt {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.control-high {
  color: var(--danger);
}

.control-low {
  color: var(--status-coded);
}

.trail-item {
  display: grid;
  grid-template-columns: 6.2rem var(--stripe-w) 1fr;
  gap: 0.7rem;
  margin: 0 0 0.85rem;
}

.trail-item__year {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  text-align: right;
  padding-top: 0.15rem;
}

.trail-item h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.15rem;
  line-height: 1.3;
}

.trail-item p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 0.8rem;
}

.matrix-wrap {
  overflow-x: auto;
  margin: 0.4rem 0 1.2rem;
}

.matrix,
.scheme {
  border-collapse: collapse;
  width: 100%;
  min-width: 36rem;
  font-size: 0.82rem;
}

.scheme {
  min-width: 0;
  max-width: 36rem;
}

.matrix caption,
.scheme caption {
  caption-side: top;
  text-align: left;
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 0 0 0.6rem;
}

.matrix th,
.matrix td,
.scheme th,
.scheme td {
  border: 1px solid var(--rule);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: middle;
}

.matrix thead th,
.scheme thead th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--paper-inset);
}

.heat-project {
  display: block;
  font-weight: 600;
}

.heat-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  font-weight: 400;
  margin-top: 0.15rem;
}

.heat {
  text-align: center;
  min-width: 4.6rem;
}

.heat__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.heat--lead {
  background: var(--stripe-positionality);
  color: #f3f7f8;
}

.heat--co {
  background: color-mix(in srgb, var(--stripe-positionality) 42%, var(--paper-raised));
}

.heat--team {
  background: color-mix(in srgb, var(--stripe-sources) 28%, var(--paper-raised));
}

.heat--draft {
  background: repeating-linear-gradient(
    -45deg,
    color-mix(in srgb, var(--status-progress) 28%, var(--paper-raised)),
    color-mix(in srgb, var(--status-progress) 28%, var(--paper-raised)) 6px,
    var(--paper-raised) 6px,
    var(--paper-raised) 10px
  );
}

.heat--none {
  background: var(--paper-inset);
  color: var(--ink-faint);
}

.method-note {
  max-width: 42rem;
  margin: 0 0 1rem;
}

.method-note h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.15rem;
}

.method-note ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.method-note li {
  margin: 0 0 0.25rem;
}

.timeline {
  max-width: 52rem;
  margin: 0.5rem 0 1.4rem;
}

.tl-row {
  display: grid;
  grid-template-columns: 9.2rem 1fr;
  gap: 0.6rem;
  align-items: center;
  margin: 0 0 0.4rem;
}

.tl-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.tl-track {
  position: relative;
  height: 12px;
  background: var(--paper-inset);
}

.tl-span {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--stripe-positionality);
}

.tl-track--marks {
  height: 16px;
  background: transparent;
  border-bottom: 1px solid var(--rule);
}

.tl-mark {
  position: absolute;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stripe-sources);
  transform: translateX(-50%);
}

.tl-axis {
  position: relative;
  height: 1.35rem;
  margin: 0.15rem 0 0 calc(9.2rem + 0.6rem);
}

.tl-tick {
  position: absolute;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
}

.design {
  max-width: 28rem;
  margin: 0.4rem 0 1rem;
}

.anova {
  display: grid;
  grid-template-columns: 2.6rem 1fr 1fr;
  gap: 4px;
  margin-top: 0.5rem;
}

.anova__h,
.anova__v {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-muted);
  display: grid;
  place-items: center;
}

.anova__cell {
  min-height: 2.3rem;
  border: 1px dashed var(--rule);
  background: var(--paper-raised);
}

.control-mid {
  color: var(--status-progress);
}

.statusbar {
  height: var(--statusbar);
  flex: none;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  background: var(--paper-raised);
  z-index: 3;
}

.help {
  color: var(--ink-muted);
}

.scrim {
  display: none;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .menu-btn {
    display: grid;
  }

  .sidebar {
    position: fixed;
    z-index: 8;
    inset: var(--topbar) auto var(--statusbar) 0;
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform 0.18s ease;
  }

  .sidebar.is-open {
    transform: none;
  }

  .scrim.is-on {
    display: block;
    position: fixed;
    inset: var(--topbar) 0 0 0;
    background: rgba(28, 36, 48, 0.28);
    z-index: 7;
  }

  .crumb {
    display: none;
  }

  .header-mail {
    display: none;
  }

  .tl-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .tl-axis {
    margin-left: 0;
  }

  .sheet {
    padding-left: 0.85rem;
    padding-right: 0.9rem;
  }

  .meta-row,
  .result-card dl {
    grid-template-columns: 1fr;
  }

  .trail-item {
    grid-template-columns: var(--stripe-w) 1fr;
  }

  .trail-item__year {
    text-align: left;
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
