/* ================= specimens (interactive panels inside model cards) ================= */

.sp {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  min-height: 420px;
}
.sp__main {
  position: relative;
  padding: clamp(18px, 2.6vw, 32px);
}
.sp__side {
  padding: clamp(18px, 2.6vw, 32px);
  border-left: 1px solid var(--hair);
  background: rgba(255, 255, 255, 0.015);
}
.sp h4 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sp__note {
  font-size: 13px;
  color: var(--mute);
  margin-top: 4px;
  text-wrap: pretty;
}
.sp__label {
  font-size: 13px;
  color: var(--mute);
}
@media (max-width: 860px) {
  .sp {
    grid-template-columns: 1fr;
  }
  .sp__side {
    border-left: 0;
    border-top: 1px solid var(--hair);
  }
}

/* horizontal bars shared by specimens */
.hbars {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.hbars li {
  display: grid;
  grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr) 4.2em;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.hbars .k {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbars .k.mono {
  font-size: 13px;
}
.hbars i {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--tile-3);
  overflow: hidden;
}
.hbars i::before {
  content: '';
  display: block;
  height: 100%;
  width: calc(var(--v, 0) * 100%);
  background: var(--heat, var(--ink));
  border-radius: inherit;
  transition: width 0.9s var(--ease), background-color 0.4s;
}
.hbars .v {
  font: 500 13px var(--mono);
  text-align: right;
  white-space: nowrap;
}

/* ---------- ORBITUNE ---------- */

.orbit {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}
.orbit__stage {
  position: relative;
  aspect-ratio: 1.15;
  min-height: 360px;
  touch-action: none;
}
.orbit__stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.orbit__play {
  position: absolute;
  left: 50%;
  bottom: 20px;
  translate: -50% 0;
  z-index: 2;
}
.orbit__play[data-state='playing'] {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  border-color: var(--hair-2);
}
.orbit__panel {
  border-left: 1px solid var(--hair);
  padding: clamp(18px, 2.6vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.orbit__ver p {
  margin-top: 12px;
  font-size: 15px;
  color: var(--ink-2);
  min-height: 4.6em;
  text-wrap: pretty;
}
.orbit__eq {
  padding: 16px 18px;
  border-radius: var(--r-m);
  background: var(--tile-2);
  transition: opacity 0.3s;
}
.orbit__eq .math {
  display: block;
  font-size: min(24px, 4.3vw);
  color: var(--ink);
  white-space: nowrap;
}
@media (min-width: 861px) {
  .orbit__eq .math {
    font-size: clamp(14px, 1.7vw, 24px);
    font-size: clamp(14px, 1.95cqi, 24px);
  }
}
.orbit__eq small {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--mute);
}
.orbit__eq.is-dim {
  opacity: 0.35;
}
.orbit__read {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.orbit__read div {
  border-top: 1px solid var(--hair);
  padding-top: 10px;
}
.orbit__read dt {
  font-size: 12px;
  color: var(--mute);
}
.orbit__read dd {
  margin-top: 4px;
  font: 500 18px/1.1 var(--mono);
  white-space: nowrap;
}
.orbit__speed {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--mute);
}
.orbit__hint {
  font-size: 13px;
  color: var(--mute);
  margin-top: auto;
  text-wrap: pretty;
}
@media (max-width: 860px) {
  .orbit {
    grid-template-columns: 1fr;
  }
  .orbit__panel {
    border-left: 0;
    border-top: 1px solid var(--hair);
  }
  .orbit__stage {
    aspect-ratio: 0.86;
    min-height: 0;
  }
  .orbit__play {
    bottom: 14px;
  }
}

/* ---------- RetailIQ leakage ---------- */

.leak__auc {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}
.leak__row {
  display: grid;
  grid-template-columns: 5.6em minmax(0, 1fr) 3.6em;
  gap: 14px;
  align-items: center;
  font-size: 14px;
}
.leak__row .t {
  position: relative;
  height: 34px;
  border-radius: 8px;
  background: var(--tile-2);
  overflow: hidden;
}
.leak__row .t i {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--v, 0) * 100%);
  background: var(--heat, var(--ink));
  border-radius: 8px;
  transition: width 0.8s var(--ease), background-color 0.5s;
}
.leak__row .n {
  font: 500 15px var(--mono);
  text-align: right;
}
.leak__axis {
  display: grid;
  grid-template-columns: 5.6em minmax(0, 1fr) 3.6em;
  gap: 14px;
  font-size: 12px;
  color: var(--mute);
}
.leak__axis span {
  display: flex;
  justify-content: space-between;
}
.leak__verdict {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: var(--r-m);
  border: 1px solid var(--hair);
  font-size: 15px;
  color: var(--ink-2);
  min-height: 5.4em;
}
.leak__verdict b {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- price engine ---------- */

.price__examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.price__examples .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.price__hl {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--r-m);
  background: var(--tile-2);
  font-size: 17px;
  line-height: 1.7;
  min-height: 3.6em;
  overflow-wrap: anywhere;
}
.price__hl mark {
  color: #000;
  border-radius: 4px;
  padding: 1px 3px;
  background: var(--heat);
}
.price__feats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.price__feats div {
  padding: 10px 12px;
  border-radius: var(--r-s);
  border: 1px solid var(--hair);
}
.price__feats dt {
  font: 12px var(--mono);
  color: var(--mute);
}
.price__feats dd {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 560;
}
.price__feats dd.none {
  color: var(--mute);
  font-weight: 400;
}

/* ---------- IRT ---------- */

.irt__fig {
  position: relative;
  height: 300px;
  margin-top: 12px;
}
.irt__fig svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.irt__ctrl {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.irt__ctrl label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--mute);
}
.irt__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.irt__next {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-m);
  background: var(--tile-2);
  font-size: 15px;
  color: var(--ink-2);
}
.irt__next b {
  color: var(--ink);
}

/* ---------- CONTRA flow ---------- */

.flow {
  position: relative;
  padding: clamp(18px, 2.6vw, 32px);
}
.flow__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 26px;
}
.flow__topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.flow__topics button[aria-pressed='true'] {
  border-color: rgba(255, 255, 255, 0.55);
  color: var(--ink);
}
.flow__grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px clamp(20px, 4vw, 64px);
}
.flow__col {
  display: grid;
  align-content: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.flow__heads {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 clamp(20px, 4vw, 64px);
  margin-bottom: 10px;
}
.flow__heads h5 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--mute);
}
@media (max-width: 760px) {
  .flow__heads {
    display: none;
  }
}
.node {
  padding: 12px 14px;
  border-radius: var(--r-s);
  background: var(--tile-2);
  border: 1px solid var(--hair);
  font-size: 14px;
  line-height: 1.3;
  transition: background-color 0.4s, color 0.4s, border-color 0.4s, transform 0.4s var(--ease);
}
.node small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--mute);
  transition: color 0.4s;
}
.node.is-lit {
  background: var(--heat);
  border-color: transparent;
  color: #000;
  transform: translateY(-2px);
}
.node.is-lit small {
  color: rgba(0, 0, 0, 0.65);
}
.flow svg.flow__wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}
.flow__status {
  margin-top: 22px;
  font-size: 14px;
  color: var(--mute);
  min-height: 1.6em;
}
@media (max-width: 760px) {
  .flow__grid {
    grid-template-columns: 1fr;
  }
  .flow svg.flow__wires {
    display: none;
  }
  .flow__col {
    padding-left: 14px;
    border-left: 1px solid var(--hair);
  }
}

/* ---------- scrap ---------- */

.split {
  display: flex;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 16px;
}
.split span {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #000;
  white-space: nowrap;
}
.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.mini-stats div {
  padding: 12px 14px;
  border-radius: var(--r-s);
  border: 1px solid var(--hair);
}
.mini-stats b {
  display: block;
  font-size: 24px;
  font-weight: 620;
  letter-spacing: -0.02em;
}
.mini-stats span {
  font-size: 13px;
  color: var(--mute);
}

/* ================= command palette & lightbox ================= */

dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  max-width: none;
  max-height: none;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.palette {
  width: min(640px, 100vw - 32px);
  margin: 12vh auto auto;
  border-radius: var(--r-l);
  background: rgba(24, 24, 27, 0.96);
  border: 1px solid var(--hair-2);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.palette__in {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--hair);
}
.palette__in input {
  flex: 1;
  height: 58px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 18px;
}
.palette__in kbd {
  font: 11px var(--mono);
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--tile-3);
  color: var(--mute);
}
.palette__list {
  max-height: min(56vh, 420px);
  overflow-y: auto;
  padding: 8px;
}
.palette__list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: var(--r-s);
  font-size: 15px;
  cursor: pointer;
}
.palette__list li small {
  color: var(--mute);
  font-size: 13px;
  white-space: nowrap;
}
.palette__list li[aria-selected='true'] {
  background: rgba(255, 255, 255, 0.09);
}
.palette__group {
  padding: 10px 14px 4px;
  font-size: 12px;
  color: var(--mute);
}
.lightbox {
  width: min(1100px, 100vw - 32px);
  margin: auto;
}
.lightbox img {
  width: 100%;
  height: auto;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--r-m);
  background: #fff;
}
.lightbox__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 15px;
}

/* ---- model card sheet ---- */
html.has-sheet {
  overflow: hidden;
}
.sheet {
  width: min(1040px, 100vw - 32px);
  margin: auto;
}
.sheet__panel {
  position: relative;
  max-height: calc(100svh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(24px, 4vw, 56px);
  border-radius: var(--r-xl);
  background: var(--tile);
  border: 1px solid var(--hair-2);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
  animation: sheet-in 0.5s var(--ease);
}
.sheet.is-closing .sheet__panel {
  animation: sheet-out 0.26s ease-in forwards;
}
.sheet::backdrop {
  animation: fade-in 0.4s ease;
}
.sheet.is-closing::backdrop {
  animation: fade-out 0.26s ease-in forwards;
}
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(28px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-out {
  to { opacity: 0; transform: translateY(18px) scale(0.99); }
}
@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes fade-out {
  to { opacity: 0; }
}
.sheet__close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: -8px -8px 0 16px;
  border-radius: 50%;
  background: rgba(40, 40, 44, 0.9);
  border: 1px solid var(--hair-2);
  color: var(--ink);
  transition: background-color 0.2s;
}
.sheet__close:hover {
  background: rgba(64, 64, 70, 0.95);
}
.sheet__close svg {
  width: 14px;
  height: 14px;
}
.sheet__head {
  display: grid;
  gap: 14px;
  justify-items: start;
}
.sheet__line {
  max-width: 46ch;
  font-size: var(--fs-lead);
  line-height: 1.4;
  color: var(--ink-2);
  text-wrap: balance;
}
.sheet__head .card__links {
  margin-top: 6px;
}
@media (max-width: 760px) {
  /* a sheet that rises from the bottom edge */
  .sheet {
    width: 100vw;
    margin: auto auto 0;
  }
  .sheet__panel {
    max-height: 92svh;
    border-radius: 28px 28px 0 0;
    border-bottom: 0;
    padding: 22px 20px calc(28px + env(safe-area-inset-bottom));
    animation-name: sheet-up;
  }
  .sheet.is-closing .sheet__panel {
    animation-name: sheet-down;
  }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: none; }
  }
  @keyframes sheet-down {
    to { transform: translateY(100%); }
  }
}
@media (prefers-reduced-motion: reduce) {
  .sheet__panel,
  .sheet::backdrop {
    animation: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  translate: -50% 20px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #000;
  font-size: 14px;
  font-weight: 520;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, translate 0.35s var(--ease);
}
.toast.is-on {
  opacity: 1;
  translate: -50% 0;
}
@media (max-width: 760px) {
  .flow__col::before {
    content: attr(aria-label);
    font-size: 12px;
    color: var(--mute);
  }
}
