/* APORIA — modals: base, inspect, toolkit, report, manual, pause, confirm. */

.modal-layer { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: auto;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 2px, transparent 2px 4px),
    rgba(3, 6, 14, .66);
  animation: screen-in .16s steps(2);
}
.modal-backdrop.is-under { background: transparent; }
.modal-backdrop.is-under .modal { filter: brightness(.55); }
.modal-backdrop + .modal-backdrop { background: rgba(3, 6, 14, .5); }

.modal {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  animation: modal-in .2s steps(4);
  outline: none;
}
.modal-sm { width: min(440px, 100%); }
.modal-lg { width: min(880px, 100%); }
.modal-xl { width: min(1180px, 100%); }
@keyframes modal-in { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 16px;
  background: linear-gradient(180deg, var(--bg3), var(--bg2));
  box-shadow: inset 0 0 0 2px var(--line), inset 0 -4px 0 rgba(0, 0, 0, .3);
  flex: none;
}
.modal-icon {
  font-size: 26px;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  background: #0a1122;
  box-shadow: inset 0 0 0 2px var(--line-hi), var(--notch2);
  flex: none;
}
.modal-titles { flex: 1; min-width: 0; }
.modal-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-title {
  font-size: 19px;
  text-transform: uppercase;
  letter-spacing: .08em;
  line-height: 1.2;
  text-shadow: 2px 2px 0 var(--outline);
}
.modal-close {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: #0a1122;
  box-shadow: inset 0 0 0 2px var(--line-hi), var(--notch2);
  font-weight: 900;
  flex: none;
}
.modal-close:hover { background: var(--red); color: #1b0306; box-shadow: inset 0 0 0 2px var(--red-2), var(--notch2); }
.modal-close .keycap { font-size: 10px; }
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 18px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 16px 14px;
  background: rgba(0, 0, 0, .25);
  box-shadow: inset 0 2px 0 var(--line);
  flex: none;
}
.foot-info { margin-right: auto; color: var(--ink-dim); font-size: 14px; }

/* ── inspect ──────────────────────────────────────────────────────────── */
.ev-desc { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.ev-photo {
  flex: none;
  width: 84px; height: 84px;
  display: grid;
  place-items: center;
  font-size: 46px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 210, 63, .07) 0 6px, transparent 6px 12px),
    #0a1122;
  box-shadow: inset 0 0 0 2px var(--yellow-2), var(--notch2);
}
.ev-desc p { font-size: 15px; line-height: 1.55; }
.proc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.proc-step-label { font-size: 12px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; color: var(--yellow); }
.proc-pips { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.proc-pips li {
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-faint);
  background: #0a1122;
  box-shadow: inset 0 0 0 2px var(--line);
}
.proc-pips li.is-current { color: var(--yellow-ink); background: var(--yellow); box-shadow: inset 0 -3px 0 var(--yellow-2); }
.proc-pips li.is-done { color: #021a0c; background: var(--green); box-shadow: inset 0 -3px 0 var(--green-2); }
.proc-prompt { font-size: 17px; font-weight: 800; margin: 4px 0 12px; }
.proc-options { display: grid; gap: 10px; }
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
  background: var(--bg2);
  box-shadow: inset 0 0 0 2px var(--line), inset 0 -4px 0 rgba(0, 0, 0, .35), var(--notch2);
}
.option-btn:hover:not(:disabled) { background: var(--bg3); box-shadow: inset 0 0 0 2px var(--cyan), inset 0 -4px 0 rgba(0, 0, 0, .35), var(--notch2); }
.option-btn:active:not(:disabled) { transform: translate(1px, 2px); }
.option-mark { width: 1.2em; flex: none; color: var(--cyan); font-weight: 900; }
.option-text { flex: 1; }
.option-btn.is-wrong { color: var(--ink-faint); background: rgba(255, 77, 94, .06); box-shadow: inset 0 0 0 2px rgba(255, 77, 94, .45), var(--notch2); cursor: not-allowed; }
.option-btn.is-wrong .option-mark { color: var(--red); }
.option-btn.is-wrong .option-text { text-decoration: line-through; text-decoration-thickness: 2px; }
.option-btn.is-right { color: var(--ink); background: rgba(69, 224, 138, .12); box-shadow: inset 0 0 0 2px var(--green), var(--notch2); opacity: 1; }
.option-btn.is-right .option-mark { color: var(--green); }
.option-btn:disabled:not(.is-wrong):not(.is-right) { opacity: .45; cursor: default; }
.proc-simple { padding: 12px 0; }

.custody-card {
  position: relative;
  padding: 16px 16px 14px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .02) 0 2px, transparent 2px 4px),
    #0a1224;
  box-shadow: inset 0 0 0 2px var(--yellow-2), inset 0 0 0 4px rgba(0, 0, 0, .5), var(--notch2);
  overflow: hidden;
}
.custody-card.is-new { animation: pop-in .3s steps(4); }
.custody-stamp {
  position: absolute;
  right: 12px; top: 12px;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--green);
  box-shadow: inset 0 0 0 3px var(--green);
  transform: rotate(-6deg);
  background: rgba(69, 224, 138, .08);
}
.custody-card.is-new .custody-stamp { animation: stamp .45s steps(4) both .2s; }
.custody-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-right: 140px; flex-wrap: wrap; }
.custody-icon { font-size: 28px; }
.custody-name { font-weight: 900; font-size: 16px; text-transform: uppercase; letter-spacing: .06em; }
.custody-sub { font-size: 13px; color: var(--ink-dim); }
.custody-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 14px;
}
.custody-dl dt { color: var(--ink-faint); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; padding-top: 2px; }
.custody-dl dd { margin: 0; overflow-wrap: anywhere; }
.custody-dl dd.hash { color: var(--cyan); font-size: 13px; }
.unlock-list { margin-top: 14px; display: grid; gap: 8px; }
.unlock-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(62, 230, 255, .06); box-shadow: inset 0 0 0 1px rgba(62, 230, 255, .3); }
.unlock-item > span:first-child { font-family: var(--emoji); }
.unlock-title { flex: 1; min-width: 0; }

/* ── toolkit ──────────────────────────────────────────────────────────── */
.modal-toolkit .modal-body { padding: 0; display: flex; overflow: hidden; }
.toolkit { display: flex; flex: 1; min-height: 0; min-width: 0; }
.tabs {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 230px;
  padding: 14px 10px;
  background: rgba(0, 0, 0, .28);
  box-shadow: inset -2px 0 0 var(--line);
  overflow: auto;
}
.tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--ink-dim);
  background: transparent;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, .04); }
.tab.is-active { color: var(--cyan-ink); background: var(--cyan); box-shadow: inset 0 -3px 0 var(--cyan-2), var(--notch2); }
.tab-icon { font-size: 18px; }
.tab-label { flex: 1; }
.tab-short { display: none; }
.tab-badge {
  min-width: 22px;
  padding: 2px 5px;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  color: var(--yellow-ink);
  background: var(--yellow);
}
.tab-badge.is-dim { color: var(--ink); background: var(--bg4); }
.tab-badge.is-good { color: #021a0c; background: var(--green); animation: blink 1s steps(2) infinite; }
.tab.is-active .tab-badge.is-dim { background: rgba(0, 0, 0, .25); color: var(--cyan-ink); }
.tab-panel { flex: 1; min-width: 0; overflow: auto; padding: 18px 20px 22px; outline: none; }
.section-head { margin-bottom: 16px; }
.section-head h3 { font-size: 18px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink); }
.section-head p { margin-top: 4px; font-size: 14px; }

.locker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.locker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 0;
  text-align: left;
  color: var(--ink);
  background: var(--bg2);
  box-shadow: inset 0 0 0 2px var(--line), var(--notch2);
  cursor: pointer;
}
button.locker-item:hover { box-shadow: inset 0 0 0 2px var(--yellow), var(--notch2); }
.locker-icon {
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  font-size: 26px;
  flex: none;
  background: #0a1122;
  box-shadow: inset 0 0 0 2px var(--yellow-2);
}
.locker-name { font-weight: 800; }
.locker-item.is-missing { cursor: default; background: transparent; box-shadow: inset 0 0 0 2px var(--line); color: var(--ink-faint); background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .02) 0 6px, transparent 6px 12px); }
.locker-item.is-missing .locker-icon { font-family: var(--font); font-weight: 900; color: var(--ink-faint); box-shadow: inset 0 0 0 2px var(--line); }

.lab-list, .lab-locked { display: grid; gap: 10px; }
.lab-locked { margin-top: 18px; }
.lab-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  text-align: left;
  color: var(--ink);
  background: var(--bg2);
  box-shadow: inset 0 0 0 2px var(--line), var(--notch2);
  cursor: pointer;
}
button.lab-item:hover { box-shadow: inset 0 0 0 2px var(--cyan), var(--notch2); background: var(--bg3); }
.lab-icon { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; background: #0a1122; box-shadow: inset 0 0 0 2px var(--cyan-3); flex: none; }
.lab-main { flex: 1; min-width: 0; }
.lab-title { font-weight: 800; font-size: 15px; }
.lab-go { color: var(--cyan); font-weight: 900; }
.lab-item.is-resolved .lab-icon { box-shadow: inset 0 0 0 2px var(--green-2); }
.lab-item.is-locked { cursor: default; opacity: .55; background: transparent; }

.notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.note {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: #f3e7b8;
  color: #2a2208;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), var(--notch2), 3px 4px 0 rgba(0, 0, 0, .4);
  background-image: repeating-linear-gradient(180deg, transparent 0 22px, rgba(50, 90, 170, .18) 22px 23px);
}
.note .dim { color: #6d5d2a; }
.note-num { font-weight: 900; color: #b0302e; flex: none; }
.notes-list.is-compact .note { padding: 7px 10px; font-size: 14px; }

.custody-wrap { max-height: none; }
.custody-table td { white-space: nowrap; }
.custody-table td:last-child { white-space: normal; min-width: 220px; }
.custody-table .hash { color: var(--cyan); }
.custody-details { margin-top: 16px; }
.custody-details summary { cursor: pointer; color: var(--cyan); font-weight: 800; text-transform: uppercase; letter-spacing: .1em; font-size: 13px; padding: 6px 0; }
.custody-cards { display: grid; gap: 14px; margin-top: 10px; }

.objectives { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; font-size: 15px; }
.prog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 22px; }
.prog-label { display: flex; justify-content: space-between; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; color: var(--ink-dim); }
.prog-label span:last-child { color: var(--ink); font-weight: 800; }

.report-ready, .report-blocked { display: grid; gap: 12px; justify-items: start; }
.ready-stamp { font-weight: 900; letter-spacing: .24em; color: var(--green); padding: 4px 10px; box-shadow: inset 0 0 0 3px var(--green); transform: rotate(-2deg); }
.missing-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.missing-list li { display: flex; gap: 10px; }
.miss-mark { color: var(--red); font-weight: 900; }

/* ── report ───────────────────────────────────────────────────────────── */
.report-intro { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.report-intro p { margin: 6px 0 0; font-size: 16px; }
.report-portrait { font-size: 40px; width: 64px; height: 64px; display: grid; place-items: center; background: linear-gradient(180deg, #23417a, #10213f); box-shadow: inset 0 0 0 2px var(--cyan-2), var(--notch2); flex: none; }
.report-grid { display: grid; grid-template-columns: 1fr minmax(220px, 300px); gap: 18px; align-items: start; }
.report-qs { display: grid; gap: 14px; }
.report-q { margin: 0; border: 0; }
.report-q legend { display: flex; gap: 10px; align-items: baseline; font-weight: 800; font-size: 16px; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
.report-q legend + * { clear: both; }
.q-num { color: var(--yellow); font-weight: 900; flex: none; }
.report-notes { position: sticky; top: 0; display: grid; gap: 8px; }

/* choice list (shared by report + analysis) */
.choice-list { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--bg2);
  box-shadow: inset 0 0 0 2px var(--line), var(--notch2);
}
.choice:hover { background: var(--bg3); }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-box {
  width: 20px; height: 20px;
  flex: none;
  background: #050913;
  box-shadow: inset 0 0 0 2px var(--line-hi);
}
.choice input:checked + .choice-box { background: var(--cyan); box-shadow: inset 0 0 0 2px var(--cyan), inset 0 0 0 5px #050913; }
.choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--cyan), var(--notch2); }
.choice input:focus-visible + .choice-box { outline: 3px dashed var(--yellow); outline-offset: 3px; }
.choice.is-wrong { opacity: .6; cursor: not-allowed; box-shadow: inset 0 0 0 2px rgba(255, 77, 94, .5), var(--notch2); }
.choice.is-wrong .choice-text { text-decoration: line-through; text-decoration-thickness: 2px; }
.choice.is-wrong .choice-box { box-shadow: inset 0 0 0 2px var(--red); }
.choice.is-answer { opacity: 1; background: rgba(69, 224, 138, .12); box-shadow: inset 0 0 0 2px var(--green), var(--notch2); }
.choice.is-answer .choice-box { background: var(--green); box-shadow: inset 0 0 0 2px var(--green), inset 0 0 0 5px #050913; }
.choice-list.is-locked .choice { cursor: default; }

/* ── manual ───────────────────────────────────────────────────────────── */
.manual-progress { display: grid; gap: 8px; margin-bottom: 18px; font-weight: 800; color: var(--purple); }
.manual-progress .meter-fill { background: var(--purple); }
.manual-cat { margin-bottom: 20px; }
.manual-cat-title { font-size: 15px; text-transform: uppercase; letter-spacing: .14em; color: var(--ink); margin-bottom: 10px; }
.manual-cat-title > span:first-child { font-family: var(--emoji); }
.manual-grid { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.manual-entry {
  padding: 12px 14px;
  background: var(--bg2);
  box-shadow: inset 0 0 0 2px rgba(180, 140, 255, .45), inset 4px 0 0 var(--purple), var(--notch2);
}
.manual-entry h4 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--purple); margin-bottom: 6px; }
.manual-entry p { font-size: 14px; }
.manual-example { color: var(--ink-dim); }
.manual-entry.is-locked { background: transparent; box-shadow: inset 0 0 0 2px var(--line), var(--notch2); color: var(--ink-faint); background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .02) 0 6px, transparent 6px 12px); }
.manual-entry.is-locked h4 { color: var(--ink-faint); letter-spacing: .3em; }
.manual-entry.is-focus { animation: focus-flash 1.2s steps(2) 2; }
@keyframes focus-flash { 50% { box-shadow: inset 0 0 0 2px var(--yellow), inset 4px 0 0 var(--yellow), var(--notch2); } }

/* ── pause / controls / confirm ───────────────────────────────────────── */
.pause-info { text-align: center; margin-bottom: 16px; font-size: 15px; }
.pause-info strong { color: var(--cyan); font-size: 18px; }
.pause-menu { display: grid; gap: 14px; }
.pause-menu .btn { width: 100%; justify-content: flex-start; }
.pause-menu .btn .keycap { margin-left: auto; }
.controls-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.controls-table td { padding: 8px 6px; box-shadow: 0 2px 0 rgba(42, 58, 99, .5); }
.controls-table td:first-child { white-space: nowrap; width: 1%; padding-right: 18px; }
.controls-table .keycap { font-size: 12px; margin-right: 2px; }
.confirm-body p { font-size: 15px; }

/* ── small screens: modals go full-screen ─────────────────────────────── */
@media (max-width: 700px), (max-height: 520px) {
  .modal-backdrop { padding: 0; }
  .modal, .modal-sm, .modal-lg, .modal-xl { width: 100%; height: 100%; max-height: 100%; }
  .modal-confirm, .modal-pause { height: auto; max-height: 100%; width: min(440px, 100%); }
  .modal-backdrop:has(.modal-confirm), .modal-backdrop:has(.modal-pause) { padding: 12px; }
  .modal-head { padding: 8px 10px 8px 12px; }
  .modal-icon { width: 36px; height: 36px; font-size: 20px; }
  .modal-title { font-size: 16px; }
  .modal-body { padding: 14px; }
  .modal-close .keycap { display: none; }
  html.is-touch .modal-foot .keycap { display: none; }
  .report-grid { grid-template-columns: 1fr; }
  .report-notes { position: static; }
  .custody-head { padding-right: 0; }
  .custody-stamp { position: static; display: inline-block; margin-bottom: 10px; }
}
@media (max-width: 760px) {
  .toolkit { flex-direction: column; }
  .tabs { flex-direction: row; width: auto; padding: 8px; gap: 6px; overflow-x: auto; box-shadow: inset 0 -2px 0 var(--line); }
  .tab { flex: none; padding: 8px 10px; }
  .tab-label { display: none; }
  .tab-short { display: inline; }
  .tab-panel { padding: 14px; }
}
@media (max-height: 520px) and (min-width: 761px) {
  .tabs { width: 200px; padding: 8px; gap: 2px; }
  .tab { padding: 7px 10px; }
  .modal-foot { padding: 8px 12px; }
}

@media (max-width: 520px) {
  .lab-item { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px 12px; }
  .lab-item .status-chip { grid-column: 2; justify-self: start; }
  .lab-go { display: none; }
  .locker-grid, .manual-grid { grid-template-columns: minmax(0, 1fr); }
}
