.case-menu {
  position: relative;
  flex: none;
  margin: 0 0 0 auto;
  z-index: 5;
}
.case-menu > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 4px 2px;
  border: 0;
  cursor: pointer;
  color: inherit;
  font: 650 14px/1.35 Inter, Arial, sans-serif;
  list-style: none;
}
.case-menu summary::-webkit-details-marker { display: none; }
.case-menu > summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg);
}
.case-menu[open] > summary::after { transform: translateY(2px) rotate(225deg); }
#case-links {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  display: block;
  width: min(355px, calc(100vw - 32px));
  max-height: min(65vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 6px;
  border: 1px solid #c6c1b7;
  border-radius: 9px;
  box-shadow: 0 9px 26px #27212b24;
  background: #fffefa;
  color: #29232d;
}
#case-links section { margin: 0; padding: 4px 0; }
#case-links section + section { border-top: 1px solid #dfdbd2; }
#case-links h2 {
  margin: 5px 10px;
  font: 650 11px/1.4 Inter, Arial, sans-serif;
  color: #645d63;
  letter-spacing: .025em;
  text-transform: uppercase;
}
#case-links a {
  display: block;
  position: relative;
  margin: 0;
  padding: 8px 28px 8px 10px;
  border-radius: 4px;
  color: inherit;
  font: 500 14px/1.4 Inter, Arial, sans-serif;
  text-decoration: none;
  overflow-wrap: anywhere;
}
#case-links a:hover, #case-links a:focus-visible { background: #efede7; }
#case-links a:focus-visible { outline: 2px solid #635085; outline-offset: -2px; }
#case-links a[aria-current="page"] { background: #edf2de; font-weight: 650; }
#case-links a[aria-current="page"]::after { content: "✓"; position: absolute; right: 9px; }
@media (max-width: 680px) {
  header .bar, body.live-reader header .bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand menu" "actions actions";
    gap: 4px 10px;
    padding-block: 8px;
  }
  header .bar .brand { grid-area: brand; }
  header .bar .case-menu { grid-area: menu; }
  header .bar .investigation-nav, body.live-reader header .bar .investigation-nav {
    grid-area: actions;
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    gap: 8px 14px;
  }
  .case-menu > summary { font-size: 13px; gap: 6px; }
}
@media (max-width: 380px) {
  header .brand { font-size: 18px; gap: 5px; }
  header .brand img { width: 24px; height: auto; }
}

#modal {
  width: min(540px, calc(100vw - 28px));
  max-height: 90dvh;
  margin: auto;
  overflow-y: auto;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid #ada59e;
  border-radius: 14px;
  background: #fffefa;
  color: #29232d;
  font: 15px/1.45 Inter, Arial, sans-serif;
  box-shadow: 0 16px 64px #29232d33;
}
#modal::backdrop { background: #28212d80; }
#modal .close { float: right; }
#modal .close button {
  border: 0; border-radius: 4px; padding: 3px 8px;
  background: transparent; color: inherit; font: 24px/1 sans-serif;
}
#modal h2 {
  margin: 0 28px 20px 0;
  font: 500 32px/1.15 Georgia, serif;
  letter-spacing: -.035em; text-transform: none;
}
#modal label { font-size: 14px; font-weight: 650; }
#modal textarea {
  display: block; width: 100%; min-height: 110px;
  margin-top: 6px; padding: 10px 12px; resize: vertical;
  border: 1px solid #b8b2aa; border-radius: 5px;
  background: white; color: inherit; font: inherit;
}
#live-mode { font-size: 13px; color: #625b64; }
#launch {
  border: 1px solid #29232d; border-radius: 6px; padding: 8px 16px;
  background: #29232d; color: white; font: 650 14px/1.4 Inter, Arial, sans-serif;
}
#launch:disabled { opacity: .55; cursor: default; }
#live-status:not(:empty) {
  margin: 12px 0 0; padding: 7px 10px;
  border-left: 3px solid #7f7350; background: #f3f1e9;
}
#modal :focus-visible { outline: 2px solid #635085; outline-offset: 2px; }
#research-activity h3 {
  margin: 16px 0 8px;
}
#activity-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  border: 1px solid var(--ink);
  max-height: min(32vh, 270px);
  overflow: auto;
}
#activity-steps li {
  margin: 0;
  padding: 9px 12px;
  border-left: 4px solid transparent;
  overflow-wrap: anywhere;
}
#activity-steps li + li {
  border-top: 1px solid #14141622;
}
#activity-steps li[data-state="running"] {
  background: #173dff0d;
  border-left-color: #55795b;
}
#activity-steps li[data-state="unresolved"] {
  border-left-color: #af8537;
}
#activity-steps li div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 10px;
}
#activity-steps li span,
#activity-steps small {
  font-size: 12px;
}
#activity-steps small {
  display: block;
}
