.stain-photo:has(img) {
  aspect-ratio: 4 / 3;
  background: #111;
  margin: 18px 0;
  box-shadow: 0 8px 25px #0004;
}

.stain-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stain-photo:has(img)::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 35px #0005;
}

.stain-photo:has(img) time {
  z-index: 2;
  background: #0009;
  padding: 5px 8px;
}

.decision-locked .sidebar nav button:not(.active) {
  pointer-events: none;
  opacity: .18;
}

.decision-locked .operator {
  opacity: .3;
}

.decision-status {
  border: 1px solid #8d4939;
  color: #8d4939;
  padding: 10px 13px;
  text-align: center;
  font-family: var(--mono);
}

.decision-status span,
.decision-status small {
  display: block;
}

.decision-status span {
  font-size: 10px;
  font-weight: 600;
}

.decision-status small {
  margin-top: 4px;
  font-size: 7px;
}

.hypothesis-card.discarded {
  opacity: .28;
  cursor: default;
}

.travel-location {
  width: 100%;
  margin-top: 32px;
  border: 0;
  background: var(--acid);
  color: var(--ink);
  padding: 17px 20px;
  display: flex;
  justify-content: space-between;
  font: 600 10px var(--mono);
  letter-spacing: .08em;
  cursor: pointer;
}

.location-view {
  justify-content: center;
  background: #171a17;
  color: #e8e7df;
}

.location-arrival {
  width: min(850px, 100%);
  margin: auto;
  border: 1px solid #50564d;
  padding: 52px;
  background: #20241f;
}

.location-arrival h2 {
  margin: 12px 0 5px;
  font: 600 clamp(46px, 7vw, 88px)/.9 var(--serif);
}

.location-type {
  color: var(--acid);
  font: 600 10px var(--mono);
  letter-spacing: .1em;
}

.location-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 35px;
  margin: 38px 0;
  border-block: 1px solid #50564d;
  padding: 20px 0;
}

.location-grid dt {
  color: #7f877d;
  font: 8px var(--mono);
  margin-top: 12px;
}

.location-grid dd {
  margin: 5px 0;
  font: 12px var(--mono);
}

.location-arrival .directive {
  border-color: #667064;
}

.location-arrival .primary-btn {
  width: 100%;
  margin-top: 25px;
}

.closure-dialog {
  width: min(680px, calc(100vw - 32px));
  border: 1px solid #555b52;
  padding: 0;
  background: #171a17;
  color: #e7e8df;
  box-shadow: 0 30px 100px #000;
}

.closure-dialog::backdrop {
  background: #070807e8;
  backdrop-filter: blur(6px);
}

.closure-dialog-inner { padding: 36px; }

.closure-warning-mark {
  width: 44px;
  height: 44px;
  border: 1px solid var(--rust);
  color: var(--rust);
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  font-size: 0;
  transform: rotate(45deg);
}

.closure-warning-mark:after { content: '!'; transform: rotate(-45deg); font: 600 22px var(--mono); }
.closure-dialog .eyebrow { color: var(--rust); }
.closure-dialog h2 { margin: 10px 0 14px; font: 600 48px/.95 var(--serif); }
.closure-dialog-inner > p:not(.eyebrow) { max-width: 570px; color: #a2a99f; font: 13px/1.65 var(--sans); }

.closure-note {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  margin: 26px 0;
  border-block: 1px solid #4d534b;
  padding: 18px 0;
}

.closure-note strong { color: var(--rust); font: 600 9px var(--mono); }
.closure-note span { color: #c2c6bd; font: 10px/1.55 var(--mono); }
.closure-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 10px; }
.closure-actions button { min-height: 52px; cursor: pointer; }
.closure-actions .outline-btn { border-color: #666d64; color: #c0c5bc; }

.danger-btn {
  border: 0;
  background: var(--rust);
  color: #fff;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font: 600 10px var(--mono);
  letter-spacing: .06em;
}

.danger-btn:hover { background: #a75543; }

.action-dialog {
  width: min(600px, calc(100vw - 32px));
  border: 1px solid #555b52;
  padding: 0;
  background: #171a17;
  color: #e7e8df;
  box-shadow: 0 30px 100px #000;
}

.action-dialog::backdrop {
  background: #070807df;
  backdrop-filter: blur(6px);
}

.action-dialog-inner { padding: 34px; }
.action-dialog .eyebrow { color: var(--acid); }
.action-dialog h2 { margin: 10px 0 12px; font: 600 42px/.95 var(--serif); }
.action-dialog-inner > p:not(.eyebrow) { color: #a2a99f; font: 12px/1.65 var(--sans); }

.action-dialog-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 24px 0;
  background: #4b5149;
  border: 1px solid #4b5149;
}

.action-dialog-meta span { padding: 16px; background: #20241f; }
.action-dialog-meta small,
.action-dialog-meta b { display: block; font-family: var(--mono); }
.action-dialog-meta small { color: #7f877d; font-size: 8px; }
.action-dialog-meta b { margin-top: 6px; color: #e4e6de; font-size: 15px; }
.action-dialog-buttons { display: grid; grid-template-columns: 1fr 1.25fr; gap: 10px; }
.action-dialog-buttons button { width: 100%; min-height: 52px; }
.action-dialog-buttons .outline-btn { border-color: #666d64; color: #c0c5bc; }

@media (max-width: 650px) {
  .location-arrival { padding: 28px 22px; }
  .location-grid { grid-template-columns: 1fr; gap: 5px; }
}

@media (max-width: 720px) {
  .topbar {
    height: 64px;
    grid-template-columns: minmax(0, 1fr) auto 88px;
  }

  .workspace { padding-top: 64px; }
  .sidebar { top: 64px; }

  #menu-toggle {
    position: static;
    width: 88px;
    height: 64px;
    border-left: 1px solid #41473f;
    background: #20241f;
    color: #e8e9e1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 10px;
    font-family: var(--mono);
  }

  #menu-toggle .menu-icon { color: var(--acid); font-size: 19px; line-height: 1; }
  #menu-toggle .menu-label { font-size: 9px; font-weight: 600; letter-spacing: .08em; }
  #menu-toggle[aria-expanded="true"] { background: var(--acid); color: var(--ink); }
  #menu-toggle[aria-expanded="true"] .menu-icon { color: var(--ink); }
  #menu-toggle[aria-expanded="true"] .menu-label { font-size: 0; }
  #menu-toggle[aria-expanded="true"] .menu-label:after { content: 'ZAMKNIJ'; font-size: 8px; }

  .inspection-view {
    height: calc(100dvh - 64px);
    min-height: 0;
  }

  .plan-view .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .plan-view .section-head h2 {
    margin: 7px 0;
    font-size: 28px;
    line-height: .95;
  }

  .plan-view .section-head p:last-child {
    margin-bottom: 0;
    font-size: 11px;
    line-height: 1.4;
  }

  .plan-view .decision-status {
    align-self: start;
    padding: 7px;
  }

  .plan-view .decision-status span { font-size: 8px; }
  .plan-view .decision-status small { display: none; }
  .hypothesis-grid { gap: 8px; }

  .hypothesis-card,
  .hypothesis-card:has(input:checked) {
    min-height: 0;
    padding: 14px 14px 12px;
  }

  .hypothesis-card input {
    top: 14px;
    right: 14px;
    width: 20px;
    height: 20px;
  }

  .hypothesis-card h3 {
    margin: 10px 34px 7px 0;
    font-size: 19px;
    line-height: 1.08;
  }

  .hypothesis-card p {
    margin: 0 0 10px;
    font-size: 11px;
    line-height: 1.4;
  }

  .hypothesis-card footer {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 10px;
    padding-top: 9px;
  }

  .hypothesis-card footer b {
    font-size: 15px;
    white-space: nowrap;
  }

  .hypothesis-card footer small {
    font-size: 7px;
    text-align: right;
  }

  .plan-action { margin-top: 10px; }
  .plan-results { margin-top: 10px; }

  .scene .pan-hint {
    display: block;
    top: 10px;
    bottom: auto;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 8px 10px;
    text-align: center;
    white-space: normal;
    pointer-events: none;
  }

  .protocol-view .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .protocol-view .section-head h2 {
    margin: 7px 0;
    font-size: 30px;
  }

  .protocol-view .section-head p:last-child {
    font-size: 10px;
    line-height: 1.4;
  }

  .protocol-view .selection-counter {
    align-self: start;
    text-align: right;
  }

  .protocol-view .selection-counter span { font-size: 30px; }
  .protocol-notice { padding: 11px; font-size: 9px; }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
  }

  .category-item {
    min-width: 0;
    min-height: 58px;
    align-items: flex-start;
    gap: 7px;
    padding: 9px 8px;
    font-size: 9px;
    line-height: 1.3;
  }

  .category-item input {
    width: 17px;
    height: 17px;
    margin: 0;
  }

  .category-item span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .category-item.protocol-locked span:after {
    display: block;
    margin-top: 4px;
    font-size: 7px;
  }

  .closure-dialog {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    border-width: 1px 0 0;
  }

  .closure-dialog-inner { padding: 26px 18px calc(18px + env(safe-area-inset-bottom)); }
  .closure-warning-mark { width: 38px; height: 38px; margin-bottom: 18px; }
  .closure-dialog h2 { font-size: 38px; }
  .closure-note { grid-template-columns: 1fr; gap: 8px; margin: 20px 0; }
  .closure-actions { grid-template-columns: 1fr; }
  .closure-actions .danger-btn { order: -1; }

  .action-dialog {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    border-width: 1px 0 0;
  }

  .action-dialog-inner { padding: 26px 18px calc(18px + env(safe-area-inset-bottom)); }
  .action-dialog h2 { font-size: 36px; }
  .action-dialog-buttons { grid-template-columns: 1fr; }
  .action-dialog-buttons .primary-btn { order: -1; }
}

@media (max-width: 390px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto 76px; }
  #menu-toggle { width: 76px; gap: 6px; }
  #menu-toggle .menu-label { font-size: 8px; }
}

/* Compact mobile type scale: preserve hierarchy without turning every screen into a poster. */
@media (max-width: 720px) {
  .login-screen { padding: 28px 18px; }
  .login-mark { width: 48px; height: 48px; margin-bottom: 22px; }
  .login-screen h1 { margin: 10px 0 26px; font-size: 50px; line-height: .82; }

  .section-head h2 { margin: 7px 0; font-size: 28px; line-height: .96; }
  .section-head p:last-child { font-size: 11px; line-height: 1.45; }
  .briefing-doc h2 { font-size: 24px; line-height: 1.08; }
  .briefing-doc > p { font-size: 14px; line-height: 1.52; }
  .action-rail .metric span { font-size: 24px; }

  .plan-view .section-head h2 { font-size: 25px; }
  .hypothesis-card h3 { font-size: 18px; }
  .plan-result h3 { font-size: 22px; }
  .plan-view.resolved .plan-result h3 { font-size: 28px; }
  .plan-view.resolved .plan-result p { font-size: 12px; line-height: 1.5; }

  .location-arrival h2 { font-size: 36px; line-height: .94; }
  .location-type { font-size: 8px; line-height: 1.4; }
  .location-grid dd { font-size: 11px; }

  .protocol-view .section-head h2 { font-size: 26px; }
  .protocol-view .selection-counter span { font-size: 27px; }
  .official-doc h3 { font-size: 22px; line-height: 1.12; }
  .official-doc p, .official-doc li { font-size: 14px; line-height: 1.55; }
  .official-doc .result-line { font-size: 10px; line-height: 1.45; }

  .evidence-body h3 { font-size: 21px; line-height: 1.08; }
  .evidence-body > p { font-size: 11px; line-height: 1.5; }
  .evidence-empty h3 { font-size: 23px; }

  .mode-dialog h2 { font-size: 29px; }
  .closure-dialog h2 { font-size: 31px; }
  .action-dialog h2 { font-size: 30px; }
  .result-inner h2 { font-size: 32px; line-height: .98; }
  .final-step legend { font-size: 19px; }
  .final-option b { font-size: 13px; }
  .toast { font-size: 9px; line-height: 1.45; }
}

@media (max-width: 390px) {
  .login-screen h1 { font-size: 44px; }
  .section-head h2 { font-size: 26px; }
  .location-arrival h2 { font-size: 33px; }
  .plan-view.resolved .plan-result h3 { font-size: 26px; }
  .closure-dialog h2, .action-dialog h2 { font-size: 28px; }
}
