:root {
  color-scheme: dark;
  --bg: #050706;
  --panel: #0a100d;
  --panel-2: #101915;
  --text: #f5fff7;
  --muted: #b9c7bd;
  --line: #d8ffe1;
  --line-soft: rgba(216, 255, 225, 0.34);
  --glow: rgba(187, 255, 202, 0.18);
  --accent: #c7ffd0;
  --warn: #fff4bf;
  --font: "Lucida Console", "Courier New", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 50%, rgba(0, 0, 0, 0.025) 50%) 0 0 / 100% 4px,
    radial-gradient(circle at 50% 20%, rgba(210, 255, 220, 0.08), transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button, a { font: inherit; }
input { font: inherit; }
.terminal-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 36px);
}
.terminal-panel {
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 48px));
  border: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.035), transparent 18%), var(--panel);
  box-shadow: 0 0 0 5px rgba(216,255,225,0.08), 0 0 42px var(--glow) inset, 0 24px 70px rgba(0,0,0,0.42);
  padding: clamp(18px, 3.4vw, 44px);
  position: relative;
  overflow: hidden;
}
.terminal-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 11px, rgba(255,255,255,0.035) 12px);
  mix-blend-mode: screen;
}
.terminal-frame-line {
  width: 100%;
  height: 1px;
  background: var(--line);
  margin-bottom: 28px;
}
.terminal-boot {
  display: grid;
  align-content: start;
}
.terminal-boot .access-gate[hidden] {
  display: grid !important;
  visibility: hidden;
  pointer-events: none;
}
.terminal-boot:not([data-access="true"]) .module-options,
.terminal-boot:not([data-access="true"]) .terminal-start { opacity: 0.34; }
.terminal-boot:not([data-ready="true"]) .terminal-start { pointer-events: none; }
.terminal-boot[data-ready="true"] .terminal-start { opacity: 1; transition: opacity 160ms ease; }
.terminal-kicker, .terminal-count, .terminal-status {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(0.78rem, 1.6vw, 0.96rem);
}
h1, h2 {
  margin: 10px 0 24px;
  font-size: clamp(1.6rem, 4.4vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 0 0 12px rgba(199,255,208,0.24);
}
.boot-log {
  display: grid;
  gap: 12px;
  width: min(100%, 620px);
  height: 220px;
  align-content: start;
  overflow: hidden;
  margin: 28px 0;
  color: var(--muted);
  font-size: clamp(0.92rem, 2vw, 1.18rem);
}
.boot-line {
  display: grid;
  grid-template-columns: 18px 270px minmax(120px, 1fr) 94px;
  align-items: baseline;
  gap: 4px;
  font-weight: 700;
}
.boot-line::before { content: ">"; color: var(--accent); }
.boot-line-plain {
  display: block;
}
.boot-line-plain::before { content: "> "; }
.boot-label { color: var(--muted); }
.boot-dots {
  color: var(--accent);
  width: 100%;
  overflow: hidden;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.boot-state {
  color: var(--accent);
  text-align: left;
  white-space: nowrap;
}
.module-options {
  display: grid;
  gap: 14px;
  width: min(100%, 680px);
  margin: 6px 0 24px;
  padding: 16px;
  border: 1px solid var(--line-soft);
}
.module-options legend {
  padding: 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(0.82rem, 1.7vw, 1rem);
}
.module-option {
  min-height: 58px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 12px;
  color: var(--text);
  cursor: pointer;
}
.module-static {
  min-height: 58px;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--text);
  padding-left: 2px;
}
.module-section-label {
  margin: 4px 0 -4px;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(0.78rem, 1.6vw, 0.92rem);
}
.module-check {
  color: var(--accent);
  font-weight: 700;
}
.module-option input {
  appearance: none;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.26);
  display: grid;
  place-items: center;
}
.module-option input:checked::before {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--line);
}
.module-name {
  display: block;
  font-weight: 700;
  text-transform: uppercase;
}
.module-description {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  font-weight: 400;
  text-transform: none;
}
.module-note { margin: 2px 0 0; }
.access-gate {
  display: grid;
  gap: 10px;
  width: min(100%, 520px);
  min-height: 122px;
  margin: 34px 0 22px;
}
.access-gate label {
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(0.82rem, 1.7vw, 1rem);
}
.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, auto);
  gap: 10px;
}
.access-row input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.24);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}
.access-row input:focus { box-shadow: 0 0 0 2px var(--glow); }
.access-gate[data-accepted="true"] label,
.access-gate[data-accepted="true"] .access-row {
  display: none;
}
.access-accepted {
  min-height: 82px;
  border: 1px solid var(--line);
  background: rgba(216,255,225,0.06);
  padding: 14px 16px;
  display: grid;
  align-content: center;
  gap: 8px;
}
.access-accepted span {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
}
.access-accepted strong {
  color: var(--accent);
  font-size: clamp(1.1rem, 2.2vw, 1.55rem);
  text-transform: uppercase;
}
.access-status {
  min-height: 22px;
  margin: 0;
  color: var(--warn);
  font-size: 0.9rem;
}
.access-link {
  margin: 8px 0 0;
  color: rgba(185, 199, 189, 0.68);
  font-size: 0.78rem;
  text-transform: uppercase;
}
.access-link a {
  color: rgba(216, 255, 225, 0.82);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.terminal-footer-links {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: clamp(18px, 5vh, 54px);
  color: rgba(185, 199, 189, 0.38);
  font-size: 0.64rem;
  text-transform: uppercase;
}
.terminal-footer-links a {
  color: rgba(185, 199, 189, 0.46);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.terminal-start, .terminal-actions button, .terminal-link, .access-row button {
  border: 1px solid var(--line);
  background: rgba(216,255,225,0.08);
  color: var(--text);
  text-decoration: none;
  min-height: 48px;
  padding: 12px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (hover: hover) {
  .terminal-start:hover, .terminal-actions button:hover, .terminal-link:hover,
  .response-button:hover { background: rgba(216,255,225,0.16); }
}
.terminal-start { min-width: min(100%, 320px); font-weight: 700; }
.terminal-progress-head {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 20px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 14px;
}
.terminal-progress-head > div { display: none; }
.terminal-question h2 { margin: 6px 0 0; font-size: clamp(1.25rem, 2.2vw, 2rem); }
.terminal-progress {
  height: 14px;
  border: 1px solid var(--line);
  margin: 18px 0 28px;
  background: rgba(255,255,255,0.04);
  overflow: hidden;
}
.terminal-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--line);
  transition: width 180ms ease;
}
.question-card {
  display: grid;
  gap: 18px;
  grid-template-rows: 188px 1fr;
  min-height: 456px;
}
.question-prompt {
  margin: 0;
  height: 188px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 24px;
  align-content: stretch;
  gap: 8px;
  overflow: hidden;
  white-space: pre-line;
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  line-height: 1.28;
  font-weight: 700;
  color: var(--text);
}
.prompt-label,
.prompt-instruction {
  color: var(--muted);
  font-size: clamp(0.72rem, 1.2vw, 0.88rem);
  line-height: 1.35;
  text-transform: uppercase;
}
.prompt-label { display: none; }
.prompt-statement {
  display: block;
  align-self: start;
  font-size: clamp(1.18rem, 2.15vw, 1.8rem);
  line-height: 1.28;
  max-height: 4.95em;
  overflow: hidden;
}
.prompt-statement-empty { visibility: hidden; }
.prompt-instruction {
  color: rgba(185, 199, 189, 0.72);
  align-self: end;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.prompt-input-range { text-align: right; white-space: nowrap; }
.response-grid {
  display: grid;
  gap: 12px;
  min-height: 378px;
  align-content: start;
  grid-auto-rows: minmax(66px, auto);
}
.response-grid--direct-pair {
  grid-auto-rows: minmax(104px, 104px);
}
.response-button {
  width: 100%;
  min-height: 66px;
  border: 1px solid var(--line-soft);
  background: var(--panel-2);
  color: var(--text);
  padding: 13px 18px;
  display: grid;
  grid-template-columns: minmax(38px, auto) 1fr;
  gap: 14px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.response-button[aria-pressed="true"] { outline: 2px solid var(--line); background: rgba(216,255,225,0.19); }
.response-button:focus { outline: none; }
.response-button:focus-visible { outline: 2px solid var(--line); }
.choice-mark { color: var(--accent); white-space: nowrap; font-weight: 700; }
.choice-text { line-height: 1.22; }
.choice-label { display: block; font-weight: 700; }
.choice-hint { display: block; color: var(--muted); margin-top: 3px; font-size: 0.92em; }
.terminal-status { min-height: 0; margin-top: 0; color: rgba(185, 199, 189, 0.72); }
.terminal-status:empty { display: none; }
.terminal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.terminal-actions button, .terminal-link { min-width: 120px; }
.result-lines {
  display: grid;
  gap: 0;
  margin: 40px 0;
  font-size: clamp(1rem, 2vw, 1.45rem);
}
.result-lines div {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(216,255,225,0.12);
}
.result-lines dt {
  color: var(--muted);
  font-size: 0.72em;
  text-transform: uppercase;
  line-height: 1.35;
}
.result-lines dd {
  margin: 0;
  min-width: 0;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.38;
  white-space: pre-line;
}
.result-primary {
  grid-template-columns: minmax(220px, 0.3fr) minmax(0, 1fr) !important;
  padding: 8px 0 14px !important;
}
.result-primary dt {
  align-self: center;
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 700;
}
.result-primary dd {
  font-size: clamp(2.05rem, 4vw, 3.2rem);
  line-height: 1.02;
  font-weight: 700;
}
.result-meta-start {
  margin-top: 30px;
  border-top: 1px solid rgba(216,255,225,0.12);
}
.result-secondary {
  grid-template-columns: minmax(220px, 0.3fr) minmax(0, 1fr) !important;
  padding: 8px 0 !important;
  font-size: 0.92rem;
}
.result-secondary dt {
  color: rgba(185, 199, 189, 0.78);
  font-size: 0.78rem;
}
.result-secondary dd {
  color: rgba(185, 199, 189, 0.82);
  font-size: 0.95rem;
  font-weight: 400;
}
#big-five-result-row dt {
  color: rgba(245, 255, 247, 0.9);
  font-weight: 700;
}
#big-five-result-row dd {
  color: var(--text);
  font-weight: 700;
}
#attachment-result-row {
  grid-template-columns: minmax(220px, 0.3fr) minmax(0, 1fr) !important;
  padding: 8px 0 14px !important;
}
#attachment-result-row dt {
  align-self: center;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}
#attachment-result-row dd {
  color: var(--accent);
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  font-weight: 700;
  line-height: 1.08;
}
#big-five-result-row {
  display: block !important;
}
#big-five-result-row dt {
  margin-bottom: 10px;
}
#big-five-result-row dd {
  width: 100%;
}
.result-lines .big-five-bars {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  width: 100%;
  max-width: 740px;
  padding: 0;
  border-bottom: 0;
}
.result-lines .big-five-bar-row {
  display: grid;
  grid-template-columns: clamp(170px, 32%, 250px) minmax(180px, 1fr) 42px;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 0;
  border-bottom: 0;
}
.big-five-bar-label {
  color: rgba(185, 199, 189, 0.86);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-align: left;
}
.big-five-label-score {
  display: none;
}
.big-five-bar-track {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 2px;
  width: 100%;
  color: rgba(185, 199, 189, 0.82);
}
.big-five-bar-bracket {
  color: rgba(185, 199, 189, 0.88);
  line-height: 1;
}
.big-five-bar-meter {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  height: 13px;
  border: 1px solid rgba(185, 199, 189, 0.42);
  background: rgba(255,255,255,0.035);
  overflow: hidden;
}
.big-five-bar-cell {
  display: block;
  height: 100%;
  border-right: 1px solid rgba(5, 7, 6, 0.55);
}
.big-five-bar-cell:last-child {
  border-right: 0;
}
.big-five-bar-cell--filled {
  background: rgba(216, 255, 225, 0.78);
}
.big-five-bar-remainder {
  width: 66px;
  height: 0;
  border-top: 2px dashed rgba(185, 199, 189, 0.72);
}
.big-five-bar-score {
  color: rgba(185, 199, 189, 0.86);
  font-weight: 700;
  white-space: nowrap;
  text-align: left;
}
.big-five-bar-score small {
  color: rgba(185, 199, 189, 0.82);
  font-size: 0.78em;
  font-weight: 400;
}
.terminal-note,
.terminal-legal-details {
  max-width: 820px;
  margin: 18px 0 0;
  color: rgba(185, 199, 189, 0.58);
  font-size: 0.68rem;
  line-height: 1.45;
  text-transform: none;
}
.terminal-legal-details summary {
  cursor: pointer;
  color: rgba(185, 199, 189, 0.72);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.terminal-legal-details p {
  margin: 8px 0 0;
}
.terminal-legal-details a {
  color: rgba(199, 255, 208, 0.72);
}
.result-count { margin-top: -8px; }
.result-progress { max-width: 560px; margin-top: 16px; }
.result-progress span { width: 100%; }
[data-busy="true"] .response-button, [data-busy="true"] .terminal-start, [data-busy="true"] .access-row button { pointer-events: none; opacity: 0.68; }
.terminal-confirm {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}
.terminal-confirm-panel {
  width: min(100%, 520px);
  border: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.035), transparent 20%), var(--panel);
  box-shadow: 0 0 0 5px rgba(216,255,225,0.08), 0 0 42px var(--glow) inset, 0 24px 70px rgba(0,0,0,0.42);
  padding: clamp(18px, 4vw, 30px);
}
.terminal-confirm-panel h2 {
  margin: 8px 0 12px;
  font-size: clamp(1.4rem, 5vw, 2.4rem);
}
.terminal-confirm-panel p:not(.terminal-kicker) {
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 22px;
}
.terminal-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.terminal-confirm-actions button {
  min-height: 48px;
  border: 1px solid var(--line);
  background: rgba(216,255,225,0.08);
  color: var(--text);
  cursor: pointer;
}
.terminal-confirm-actions button:focus-visible {
  outline: 2px solid var(--line);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .terminal-shell {
    display: block;
    min-height: auto;
    padding: 6px;
  }
  .terminal-panel {
    min-height: auto;
    height: auto;
    max-height: none;
    padding: 10px;
    overflow: visible;
  }
  .terminal-boot {
    min-height: calc(100svh - 12px);
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .terminal-boot .module-options { order: 2; }
  .terminal-boot .terminal-start { order: 1; }
  .terminal-boot .terminal-footer-links {
    order: 3;
    margin-top: 18px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .terminal-question {
    min-height: 0;
    height: calc(100svh - 12px);
    max-height: calc(100svh - 12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .terminal-progress-head {
    align-items: flex-end;
    flex-direction: row;
    gap: 8px;
    padding-bottom: 8px;
  }
  .terminal-count { font-size: 0.82rem; }
  .terminal-progress {
    height: 10px;
    margin: 8px 0 10px;
  }
  .question-card {
    flex: 1 1 auto;
    gap: 9px;
    grid-template-rows: minmax(134px, 1fr) auto;
    min-height: 0;
  }
  .boot-log { height: 196px; }
  .question-prompt {
    height: auto;
    min-height: 0;
    max-height: none;
    grid-template-rows: minmax(0, 1fr) 20px;
    gap: 6px;
    font-size: 0.95rem;
  }
  .prompt-statement {
    font-size: clamp(1rem, 5.25vw, 1.25rem);
    line-height: 1.18;
    max-height: 4.72em;
  }
  .prompt-instruction {
    font-size: 0.66rem;
    line-height: 1.15;
    gap: 8px;
  }
  .response-grid {
    gap: 8px;
    min-height: 0;
    grid-auto-rows: minmax(52px, auto);
  }
  .response-grid--direct-pair {
    grid-auto-rows: minmax(92px, 92px);
  }
  .response-button {
    min-height: 52px;
    padding: 9px 11px;
    grid-template-columns: 42px 1fr;
    gap: 8px;
    font-size: clamp(0.78rem, 3.85vw, 0.96rem);
  }
  .choice-text { line-height: 1.12; }
  .choice-hint { margin-top: 1px; font-size: 0.86em; }
  .terminal-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
    padding-top: 2px;
  }
  .terminal-actions button,
  .terminal-link {
    min-width: 0;
    min-height: 40px;
    padding: 8px 6px;
    font-size: 0.74rem;
  }
  .terminal-start {
    width: 100%;
    margin: 4px 0 16px;
  }
  .access-row { grid-template-columns: 1fr; }
  .boot-line { grid-template-columns: 16px minmax(0, 1fr) 78px; gap: 3px; }
  .boot-dots { display: none; }
  .boot-state { grid-column: auto; margin-left: 0; }
  .result-lines div { grid-template-columns: 1fr; gap: 6px; }
  .result-lines {
    font-size: clamp(0.82rem, 3.2vw, 1rem);
  }
  .result-secondary {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  #attachment-result-row {
    grid-template-columns: minmax(132px, 0.58fr) minmax(0, 1fr) !important;
  }
  #attachment-result-row dd {
    font-size: clamp(1.25rem, 6vw, 1.9rem);
  }
  .terminal-disclaimer {
    overflow-wrap: anywhere;
  }
  #big-five-result-row {
    display: block !important;
  }
  .result-lines .big-five-bars {
    grid-template-columns: 1fr;
    gap: 5px;
    max-width: 100%;
    padding: 0;
    border-bottom: 0;
  }
  .result-lines .big-five-bar-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
    min-height: 32px;
    font-size: clamp(0.68rem, 3.1vw, 0.78rem);
  }
  .big-five-bar-label {
    white-space: normal;
  }
  .big-five-bar-track {
    width: 100%;
    min-width: 0;
  }
  .big-five-bar-meter { height: 10px; }
  .big-five-bar-remainder { display: none; }
  .big-five-label-score { display: inline; margin-left: 6px; }
  .big-five-bar-score { display: none; }
}

@media (max-width: 700px) and (max-height: 760px) {
  .terminal-panel { padding: 8px; }
  .terminal-boot { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
  .terminal-progress-head { padding-bottom: 6px; }
  .terminal-progress { margin: 6px 0 8px; }
  .question-card {
    gap: 7px;
    grid-template-rows: minmax(112px, 1fr) auto;
  }
  .question-prompt {
    min-height: 0;
    max-height: none;
    grid-template-rows: minmax(0, 1fr) 18px;
  }
  .prompt-statement {
    font-size: clamp(0.95rem, 5vw, 1.14rem);
    max-height: 4.72em;
  }
  .prompt-instruction { font-size: 0.62rem; }
  .response-grid {
    gap: 7px;
    grid-auto-rows: minmax(49px, auto);
  }
  .response-grid--direct-pair {
    grid-auto-rows: minmax(86px, 86px);
  }
  .response-button {
    min-height: 49px;
    padding: 7px 9px;
    font-size: clamp(0.74rem, 3.65vw, 0.9rem);
  }
  .terminal-actions {
    gap: 7px;
    margin-top: 12px;
    padding-top: 2px;
  }
  .terminal-actions button,
  .terminal-link {
    min-height: 36px;
    padding: 6px 4px;
    font-size: 0.68rem;
  }
}
