html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
  color: #1a1a1a;
  background: #f3f1ec;
  display: flex;
  flex-direction: column;
}
.top {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #666;
}
.filter-label svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  color: #333;
  background: #f3f1ec;
  border: 1px solid rgba(0,0,0,0.14);
  padding: 5px 10px 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: #1a1a1a; color: #1a1a1a; }
.chip.on { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
.chip-n {
  font-size: 11px;
  font-weight: 650;
  color: #666;
  background: rgba(0,0,0,0.07);
  border-radius: 999px;
  padding: 1px 6px;
}
.chip.on .chip-n { color: #1a1a1a; background: #fff; }
.clear {
  flex-shrink: 0;
  font: inherit;
  font-size: 13px;
  color: #0a7f96;
  background: transparent;
  border: 0;
  padding: 6px 4px;
  cursor: pointer;
  text-decoration: underline;
}
.clear.hidden { display: none; }

.nav-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 650;
  color: #1a1a1a;
  background: rgba(0,0,0,0.05);
  border: 0;
  padding: 7px 12px;
  border-radius: 999px;
  flex-shrink: 0;
  cursor: pointer;
}
.nav-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.workspace { flex: 1; display: flex; min-height: 0; }
.nav {
  width: 280px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid rgba(0,0,0,0.08);
  overflow: auto;
}
.nav-kicker {
  margin: 0;
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #555;
}
.nav-kicker.filtered { color: #0a7f96; }
.nav ul { list-style: none; margin: 0; padding: 6px 8px 16px; }
.nav li {
  display: flex;
  align-items: flex-start;
  border-radius: 10px;
}
.nav li:hover { background: rgba(0,0,0,0.04); }
.nav li.on, .nav li.on:hover { background: rgba(10,127,150,0.12); }
.nav li.hidden { display: none; }
.pick {
  flex: 1;
  min-width: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 10px 4px 10px 12px;
  cursor: pointer;
}
.nav-title { display: block; font-weight: 650; }
.nav-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.tag {
  font-size: 11px;
  color: #555;
  background: rgba(0,0,0,0.06);
  padding: 2px 8px;
  border-radius: 999px;
}
.nav li.on .tag { background: rgba(255,255,255,0.7); }

.info {
  position: fixed;
  z-index: 20;
  max-width: 320px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.14);
  pointer-events: none;
}
.info[hidden] { display: none; }
.info p { margin: 0; font-size: 13px; color: #333; overflow-wrap: anywhere; }
.info .info-src { margin-top: 6px; font-size: 12px; color: #777; }
.info .info-src:empty, .info .info-desc:empty { display: none; }

.side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 8px 8px 8px 0;
}
.popup {
  display: none;
  padding: 4px;
  border-radius: 8px;
  color: #0a7f96;
  line-height: 0;
}
.nav li.on .popup { display: block; }
.variants { display: flex; flex-direction: column; gap: 2px; }
.var {
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  color: #555;
  background: rgba(0,0,0,0.06);
  border: 0;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
}
.var:hover { background: rgba(0,0,0,0.12); }
.nav li.on .var.on { background: #0a7f96; color: #fff; }
.popup:hover { background: rgba(10,127,150,0.16); }
.popup svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-empty {
  margin: 8px 14px 0;
  font-size: 13px;
  color: #555;
}
.nav-empty.hidden { display: none; }
.nav-empty code { font-size: 12px; }

.stage { flex: 1; min-width: 0; background: #d9d6cf; position: relative; }
.stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.pdf-open { display: none; }

/* Phones and narrow windows: the artifact fills the screen and the list slides
   over it, because splitting a small screen in two leaves neither usable. */
@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  /* The chips get their own row so they can scroll across the full width. */
  .top { flex-wrap: wrap; row-gap: 8px; }
  .clear { margin-left: auto; padding: 6px 0; }
  .keywords {
    flex-basis: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .keywords::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }

  .workspace { position: relative; }
  .nav {
    position: absolute;
    inset: 0;
    width: auto;
    z-index: 10;
    border-right: 0;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }
  body.nav-open .nav { transform: none; }
  body.nav-open .stage { visibility: hidden; }

  /* No hover on touch, so each card carries its own description. */
  .info { display: none; }
  .nav li { flex-wrap: wrap; }
  .nav li::after {
    content: attr(data-desc);
    flex-basis: 100%;
    padding: 0 12px 10px;
    font-size: 13px;
    color: #555;
  }
  .nav li[data-desc=""]::after { display: none; }
  .pick { padding-bottom: 6px; }
  .popup { display: block; }
  .side { padding-top: 10px; }

  /* Phone browsers often refuse to draw a PDF inside a frame, so offer a way out. */
  body.pdf .pdf-open {
    display: block;
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 5;
    font-weight: 650;
    font-size: 13px;
    color: #fff;
    background: #1a1a1a;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  }
}
