body {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  overflow: hidden;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
}

.top {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.55rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex: none;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: none;
  margin-left: auto;
}
.chip {
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0.28rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  line-height: 1;
}
.chip.icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 0.95rem;
}
.chip:hover, .chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.triptych {
  display: grid;
  grid-template-columns: minmax(200px, 250px) 1fr minmax(200px, 260px);
  min-height: 0;
}

.left, .right {
  display: grid;
  min-height: 0;
}
.left {
  grid-template-rows: auto auto 1fr;
  border-right: 1px solid var(--line);
}
.right {
  grid-template-rows: auto auto 1fr;
  border-left: 1px solid var(--line);
}

.search-wrap {
  position: relative;
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
}
#q {
  width: 100%;
  border: 1px solid var(--ink);
  background: var(--paper);
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}
.hits {
  position: absolute;
  left: 0.55rem; right: 0.55rem;
  top: calc(100% - 2px);
  margin: 0; padding: 0;
  list-style: none;
  border: 1px solid var(--ink);
  background: var(--paper);
  max-height: 260px;
  overflow: auto;
  z-index: 8;
}
.hits button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  display: grid;
  gap: 0.1rem;
}
.hits button:hover, .hits button.active { background: var(--soft); }
.hit-lab { font-weight: 600; font-size: 0.88rem; }
.hit-meta { font-family: var(--font-mono); font-size: 0.65rem; color: var(--mute); }

.panel-label {
  margin: 0;
  padding: 0.45rem 0.65rem 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.bars, .hips {
  overflow: auto;
  min-height: 0;
  padding: 0.25rem 0.45rem 0.75rem;
}

.bar {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.1rem 0.4rem;
  border: 0;
  background: transparent;
  padding: 0.35rem 0.4rem;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
}
.bar:hover { background: var(--soft); }
.bar.sel { border-left-color: var(--ink); background: var(--soft); }
.bar.on { border-left-color: var(--accent); }
.bar-lab { font-size: 0.88rem; font-weight: 500; }
.bar-n { font-family: var(--font-mono); font-size: 0.72rem; color: var(--mute); }
.bar-track {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--line);
}
.bar-track i {
  display: block;
  height: 100%;
  background: var(--ink);
}
.bar.on .bar-track i { background: var(--accent); }

.stage {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
}
.status {
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--mute);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: auto;
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 12%, transparent) 1px, transparent 0)
    0 0 / 18px 18px;
}
#c { display: block; width: 100%; height: 100%; cursor: crosshair; }
.legend {
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--mute);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.swatch {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.hip-meta {
  margin: 0;
  padding: 0 0.65rem 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trail-crumbs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.2rem;
  align-items: center;
  margin: 0 0 0.55rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--line);
  background: var(--soft);
  min-width: 0;
}
.crumb {
  border: 0;
  background: transparent;
  padding: 0.15rem 0.28rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumb:hover { text-decoration: underline; }
.crumb.on {
  background: var(--ink);
  color: var(--paper);
}
.crumb-sep {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--mute);
  padding: 0 0.1rem;
}

.hipo-group {
  list-style: none;
  margin: 0 0 0.45rem;
  padding: 0;
  border: 1px solid var(--line);
}
.hipo-group.collapsed {
  opacity: 0.72;
}
.hipo-group.collapsed .hipo-head {
  border-bottom: 0;
}
.hipo-group.latest {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.hipo-group.focus .hipo-padre { color: var(--accent); }
.hipo-head {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  width: 100%;
  border: 0;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  min-width: 0;
  text-align: left;
}
.hipo-padre {
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 0.86rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.hipo-n { opacity: 0.55; flex: none; }
.hipo-tag { margin-left: auto; font-size: 0.62rem; opacity: 0.7; flex: none; }
.hipo-group.latest .hipo-tag { color: var(--accent); opacity: 1; }
.hipo-kids { list-style: none; margin: 0; padding: 0.15rem 0; }
.hipo-more {
  padding: 0.3rem 0.55rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--mute);
}
.hipo {
  width: 100%;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.32rem 0.55rem;
  cursor: pointer;
}
.hipo:hover, .hipo.on { background: var(--soft); }
.hipo .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  flex: none;
}
.hipo.path .dot { background: var(--accent); border-color: var(--accent); }
.hipo-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent);
}
.hipo-lab {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}
.empty {
  list-style: none;
  padding: 0.75rem 0.55rem;
  color: var(--mute);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .triptych {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(160px, 28vh) 1fr minmax(160px, 28vh);
  }
  .left { border-right: 0; border-bottom: 1px solid var(--line); }
  .right { border-left: 0; border-top: 1px solid var(--line); }
}
