/* S!GNAL / DISPLAY FIELD
 * Keep the edges visible. A window should tell you where it ends.
 */
:root { color-scheme: light; font-family: Tahoma, Verdana, Arial, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #c8cfd4; color: #1d2b34; font: 13px/1.4 Tahoma, Verdana, Arial, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .62; }
:focus-visible { outline: 3px solid #125b9d; outline-offset: 2px; }
.portal-skip { position: absolute; top: -50px; left: 8px; z-index: 100; padding: 6px; background: #fff; }
.portal-skip:focus { top: 8px; }
.portal-frame { min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; background: #d8dddf; }
.portal-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 58px; padding: 8px 14px; background: #304d66; border-bottom: 3px solid #1b3345; color: #fff; }
.portal-brand { display: flex; align-items: center; gap: 10px; }
.portal-brand-mark { width: 34px; height: 34px; background: #fff; mask: url('/identity.svg') center / contain no-repeat; -webkit-mask: url('/identity.svg') center / contain no-repeat; }
.portal-brand strong, .portal-brand small { display: block; }
.portal-brand strong { letter-spacing: .13em; font: bold 14px Arial, sans-serif; }
.portal-brand small { font: 9px Tahoma, sans-serif; letter-spacing: .05em; }
.portal-connection { font: bold 10px Tahoma, sans-serif; text-align: right; }
.portal-main { width: 100%; min-height: 0; padding: 16px 10px 22px; background: #d8dddf; }
.portal-window { border: 1px solid #62717a; box-shadow: 1px 1px 0 #fff inset, 3px 3px 0 #87939b; background: #efefeb; }
.portal-login, .portal-recovery { width: min(100%, 510px); margin: 9vh auto 0; }
.portal-titlebar { min-height: 31px; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 10px; background: #44627a; border-bottom: 2px solid #2a4559; color: #fff; font: bold 11px Tahoma, sans-serif; letter-spacing: .06em; }
.portal-titlebar button { min-width: 30px; min-height: 24px; border: 1px solid #17354b; border-top-color: #dce6eb; border-left-color: #dce6eb; background: #9cabb4; font: bold 17px/1 Tahoma, sans-serif; }
.portal-window-body { padding: 14px; }
.portal-window-body > p:first-child { margin-top: 0; }
.portal-login .portal-window-body { padding: 20px; }
.portal-id-entry { display: flex; align-items: end; gap: 8px; margin: 18px 0; }
.portal-id-entry label:first-child { width: 37%; }
.portal-id-entry label:last-child { flex: 1; }
.portal-id-entry b { padding-bottom: 12px; }
.portal-id-entry input { text-transform: uppercase; text-align: center; font: bold 23px Consolas, 'Courier New', monospace; letter-spacing: .12em; }
.portal-window label { display: block; margin: 9px 0; font-weight: bold; }
.portal-window label small { font-weight: normal; }
.portal-window input:not([type='radio']):not([type='checkbox']), .portal-window select { display: block; width: 100%; min-height: 36px; margin-top: 4px; padding: 6px 8px; border: 1px solid #73828d; border-radius: 0; background: #fff; color: #17242d; box-shadow: inset 1px 1px 2px #afb7bc; }
.portal-window input[type='radio'], .portal-window input[type='checkbox'] { margin-right: 8px; }
.portal-window fieldset { margin: 12px 0; padding: 8px 12px; border: 1px solid #8c989d; }
.portal-window legend { padding: 0 4px; font: bold 11px Tahoma, sans-serif; }
.portal-button, .portal-footer button { min-height: 36px; padding: 5px 12px; border: 1px solid #667680; border-top-color: #fff; border-left-color: #fff; border-radius: 0; box-shadow: 1px 1px 0 #74838c; background: #d5dde0; color: #182c39; font: bold 11px Tahoma, sans-serif; }
.portal-button:active, .portal-footer button:active { border-color: #667680 #fff #fff #667680; box-shadow: inset 1px 1px 2px #87949a; }
.portal-text-button { border: 0; background: transparent; color: #114b78; text-decoration: underline; font: bold 11px Tahoma, sans-serif; }
.portal-small { color: #56626a; font-size: 10px; }
.portal-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
#portal-login-status, #portal-recovery-status, [id$='-status'] { min-height: 17px; }
#portal-login-status { margin-top: 8px; }
#portal-login-status + .portal-small { margin-top: 8px; }
#portal-code-entry { display: grid; gap: 10px; margin-bottom: 18px; }
#portal-code-entry > label, #portal-code-entry > input { margin: 0; }
#portal-code-help { margin: 2px 0 0; line-height: 1.45; }
.portal-code-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.portal-code-actions .portal-text-button { min-height: 32px; padding: 4px 0; line-height: 1.4; text-align: left; }
[data-state='error'], .portal-error { color: #8b241f; font-weight: bold; }
.portal-signal-line { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 8px; border: 1px solid #a6adb0; background: #e2e7dc; }
.portal-signal-face { font: bold 16px 'Courier New', monospace; white-space: nowrap; }
.portal-ascii { max-width: 100%; overflow-x: auto; padding: 12px; border: 1px solid #8e9b98; background: #172b2a; color: #a9e5b4; font: 12px/1.35 'Courier New', monospace; }
.portal-desktop { max-width: 1020px; margin: 0 auto; }
.portal-workbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px; margin-bottom: 12px; padding: 6px 9px; background: #bdc8c8; border: 1px solid #7d8d8d; font: 11px Tahoma, sans-serif; }
.portal-workbar b { font: bold 14px 'Courier New', monospace; }
.portal-launcher { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0 0 12px; }
.portal-icon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 62px; padding: 5px 2px; border: 1px solid #84919b; border-top-color: #f9fafa; border-left-color: #f9fafa; background: #d1dbdd; color: #233743; font: bold 10px Tahoma, sans-serif; overflow-wrap: anywhere; }
.portal-icon span { font: bold 23px 'Courier New', monospace; line-height: 1; color: #416072; }
.portal-icon:hover, .portal-icon:focus-visible { background: #e8eeeb; }
.portal-program { min-height: 270px; }
.portal-program .portal-window-body { min-height: 240px; }
.portal-program h2 { margin: 12px 0 5px; font: bold 13px Tahoma, sans-serif; border-bottom: 1px solid #9eaaa9; }
.portal-readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; border: 1px solid #708783; background: #324842; color: #dbf4d4; font: 10px/1.3 'Courier New', monospace; }
.portal-readout span { padding: 7px; border-right: 1px solid #65796f; }
.portal-readout b { display: block; font-size: 15px; }
.portal-list { border-top: 1px solid #9ba6a7; }
.portal-list-row, .portal-doc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 7px 9px; border: 0; border-bottom: 1px solid #a5aeb0; background: #e7e9e5; text-align: left; font: 11px Tahoma, sans-serif; }
button.portal-list-row:hover { background: #d7e2e0; }
.portal-list-row span { white-space: nowrap; font: bold 10px 'Courier New', monospace; }
.portal-doc-row:nth-child(even), .portal-list-row:nth-child(even) { background: #dfe4e3; }
.portal-doc-row span { overflow-wrap: anywhere; }
.portal-document { margin-top: 15px; padding: 13px; border: 1px solid #9aa49f; background: #fffef5; }
.portal-document pre { white-space: pre-wrap; font: 12px/1.5 'Courier New', monospace; }
.portal-legal { padding: 10px; border: 2px solid #8c733e; background: #fff8e8; }
.portal-legal strong { color: #6e491b; }
.portal-legal p { margin-bottom: 0; }
.portal-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.portal-tabs button { min-height: 36px; padding: 6px 9px; border: 1px solid #60717b; background: #c5d0d1; font: bold 10px Tahoma, sans-serif; }
.portal-tabs button[aria-pressed='true'] { background: #3e5a6d; color: #fff; }
.portal-chat-log { height: min(45vh, 300px); min-height: 180px; overflow-y: auto; padding: 5px; border: 1px solid #7b8b88; background: #f5f6ef; }
.portal-chat-message { padding: 5px; border-bottom: 1px dotted #a3adaa; }
.portal-chat-message strong { font: bold 10px 'Courier New', monospace; }
.portal-chat-message p { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#chat-form { display: flex; align-items: end; gap: 7px; }
#chat-form label { flex: 1; }
.portal-system-list { display: grid; grid-template-columns: 1fr auto; max-width: 530px; margin: 8px 0 22px; border-top: 1px solid #9ca9a9; font: 11px 'Courier New', monospace; }
.portal-system-list dt, .portal-system-list dd { margin: 0; padding: 6px 3px; border-bottom: 1px solid #aeb8b7; }
.portal-system-list dd { font-weight: bold; text-align: right; }
.portal-game-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); width: min(100%, 350px); margin-top: 12px; }
.portal-game-cell { aspect-ratio: 1; min-width: 0; border: 1px solid #6c7f83; border-top-color: #fff; border-left-color: #fff; background: #cbd5d5; font: bold 12px 'Courier New', monospace; }
.portal-game-cell:disabled { opacity: 1; background: #e7e9dd; }
.portal-assistant { position: fixed; right: 12px; bottom: 57px; z-index: 20; display: flex; align-items: center; gap: 8px; width: min(330px, calc(100vw - 24px)); padding: 10px; border: 2px solid #39536a; background: #edf1d7; box-shadow: 3px 3px 0 #87949a; font: 11px Tahoma, sans-serif; }
.portal-assistant button { margin-left: auto; min-width: 28px; min-height: 28px; }
.portal-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 45px; padding: 7px 10px; background: #bdc6c8; border-top: 2px solid #7b898b; color: #32434a; font: 9px Tahoma, sans-serif; }
.portal-footer span:last-child { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.portal-footer button { min-height: 28px; padding: 4px 6px; font-size: 9px; }
.portal-footer a { color: #194f73; }
.career-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(30, 40, 47, .55); }
.career-window { width: min(100%, 410px); max-height: 90svh; overflow-y: auto; background: #efefeb; }
.career-body { padding: 14px; }
.career-body label { display: block; }
.career-consent { display: flex; gap: 7px; margin: 12px 0; }
.career-consent label { margin: 0; }
@media (min-width: 680px) {
  .portal-main { padding: 28px; }
  .portal-launcher { grid-template-columns: repeat(9, minmax(0, 1fr)); }
  .portal-icon { min-height: 75px; }
  .portal-program .portal-window-body { min-height: 340px; }
}
@media (max-width: 480px) {
  .portal-connection { display: none; }
  .portal-workbar { flex-wrap: wrap; }
  .portal-doc-row { align-items: stretch; flex-direction: column; }
  .portal-doc-row .portal-button { align-self: flex-start; }
  .portal-footer { align-items: flex-start; flex-direction: column; }
  .portal-assistant { bottom: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* The recovered portal is a new display system; the access and recovery screens keep their legacy UI. */
body.portal-active {
  --portal-green: #12ff6c;
  --portal-ink: #d8ffe3;
  --portal-muted: #8ebda0;
  --portal-line: #247e4c;
  background: var(--portal-deep);
  color: var(--portal-ink);
  font: 13px/1.5 'Courier New', Consolas, monospace;
}
body.portal-active :focus-visible { outline-color: var(--portal-green); outline-offset: 3px; }
body.portal-active .portal-frame { background: var(--portal-deep); }
body.portal-active .portal-topbar {
  background: var(--portal-bg);
  border-bottom: 1px solid var(--portal-line);
  color: var(--portal-green);
}
body.portal-active .portal-brand-mark { background: var(--portal-green); }
body.portal-active .portal-brand strong,
body.portal-active .portal-brand small { font-family: 'Courier New', Consolas, monospace; }
body.portal-active .portal-main {
  padding: clamp(12px, 3vw, 32px);
  background: radial-gradient(ellipse at 50% 0, var(--portal-surface) 0, var(--portal-bg) 48%, var(--portal-deep) 100%);
}
body.portal-active .portal-desktop { max-width: 1180px; margin: 0 auto; }
body.portal-active .portal-workbar {
  min-height: 50px;
  margin-bottom: 0;
  padding: 8px 14px;
  border: 1px solid var(--portal-line);
  border-bottom: 0;
  background: var(--portal-bg);
  color: var(--portal-muted);
  font: 11px/1.4 'Courier New', Consolas, monospace;
  letter-spacing: .08em;
}
body.portal-active .portal-workbar strong,
body.portal-active .portal-workbar b { color: var(--portal-green); }
body.portal-active .portal-workbar b { font-size: 17px; }
body.portal-active .portal-text-button { color: var(--portal-green); font: bold 11px 'Courier New', Consolas, monospace; }
body.portal-active .portal-program::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, color-mix(in srgb, var(--portal-deep) 60%, transparent) 4px 5px);
  content: '';
  opacity: .16;
  pointer-events: none;
}
body.portal-active .portal-workspace { display: grid; gap: 14px; margin-top: 14px; align-items: start; }
body.portal-active .portal-launcher { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid var(--portal-line); background: var(--portal-line); }
body.portal-active .portal-icon {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  gap: 6px;
  min-height: 54px;
  padding: 8px;
  border: 0;
  background: var(--portal-bg);
  box-shadow: none;
  color: var(--portal-ink);
  text-align: left;
  font: bold 11px/1.3 'Courier New', Consolas, monospace;
}
body.portal-active .portal-icon span { color: var(--portal-green); font: 10px 'Courier New', Consolas, monospace; }
body.portal-active .portal-icon b { overflow-wrap: anywhere; }
body.portal-active .portal-icon:hover,
body.portal-active .portal-icon:focus-visible,
body.portal-active .portal-icon[aria-current='page'] { background: var(--portal-surface); color: var(--portal-ink); }
body.portal-active .portal-icon[aria-current='page'] { box-shadow: inset 3px 0 var(--portal-green); }
body.portal-active .portal-program { position: relative; min-height: 420px; border: 1px solid var(--portal-line); background: var(--portal-bg); box-shadow: 0 0 24px color-mix(in srgb, var(--portal-green) 4.31%, transparent); }
body.portal-active .portal-titlebar {
  min-height: 40px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--portal-line);
  background: var(--portal-bg);
  color: var(--portal-green);
  font: bold 11px 'Courier New', Consolas, monospace;
  letter-spacing: .12em;
}
body.portal-active .portal-titlebar button { border: 1px solid var(--portal-line); background: var(--portal-bg); color: var(--portal-green); }
body.portal-active .portal-window-body { min-height: 380px; padding: clamp(14px, 2vw, 26px); color: var(--portal-ink); font-size: 13px; }
body.portal-active #portal-program-body:focus-visible { outline: 1px solid var(--portal-line); outline-offset: -2px; }
body.portal-active .portal-program h2 { border-color: var(--portal-line); color: var(--portal-green); font: bold clamp(16px, 2vw, 23px) 'Courier New', Consolas, monospace; }
body.portal-active .portal-window label,
body.portal-active .portal-window legend { color: var(--portal-ink); font-family: 'Courier New', Consolas, monospace; }
body.portal-active .portal-window fieldset { border-color: var(--portal-line); }
body.portal-active .portal-window input:not([type='radio']):not([type='checkbox']),
body.portal-active .portal-window select,
body.portal-active .portal-window textarea {
  min-height: 40px;
  border: 1px solid var(--portal-muted);
  background: var(--portal-deep);
  color: var(--portal-ink);
  box-shadow: inset 0 0 0 1px var(--portal-bg);
  font-family: 'Courier New', Consolas, monospace;
}
body.portal-active .portal-window input::placeholder,
body.portal-active .portal-window textarea::placeholder { color: var(--portal-muted); }
body.portal-active .portal-button,
body.portal-active .portal-footer button {
  min-height: 40px;
  border: 1px solid var(--portal-green);
  background: var(--portal-surface);
  box-shadow: none;
  color: var(--portal-green);
  font: bold 11px 'Courier New', Consolas, monospace;
}
body.portal-active .portal-button:hover,
body.portal-active .portal-footer button:hover { background: var(--portal-line); }
body.portal-active .portal-small { color: var(--portal-muted); font-size: 11px; }
body.portal-active .portal-ascii { color: var(--portal-green); }
body.portal-active .portal-readout { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); font-size: 11px; }
body.portal-active .portal-readout span { border-color: var(--portal-line); }
body.portal-active .portal-readout b { color: var(--portal-green); }
body.portal-active .portal-list { border-color: var(--portal-line); }
body.portal-active .portal-list-row,
body.portal-active .portal-doc-row,
body.portal-active .portal-doc-row:nth-child(even),
body.portal-active .portal-list-row:nth-child(even) { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); font-family: 'Courier New', Consolas, monospace; }
body.portal-active button.portal-list-row:hover { background: var(--portal-line); }
body.portal-active .portal-list-row span { color: var(--portal-green); }
body.portal-active .portal-list-row,
body.portal-active .portal-doc-row { font-size: 12px; line-height: 1.45; }
body.portal-active .portal-document { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .portal-legal { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .portal-chat-log { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .portal-chat-message,
body.portal-active .portal-system-list,
body.portal-active .portal-system-list dt,
body.portal-active .portal-system-list dd { border-color: var(--portal-line); }
body.portal-active .portal-tabs button { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .portal-tabs button[aria-pressed='true'] { background: var(--portal-line); color: var(--portal-green); }
body.portal-active .portal-game-cell { border-color: var(--portal-line); background: var(--portal-surface); color: var(--portal-green); }
body.portal-active .portal-game-cell:disabled { background: var(--portal-bg); }
body.portal-active .portal-assistant {
  right: 16px;
  bottom: 16px;
  display: block;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--portal-ink);
}
body.portal-active .portal-signal-face {
  position: relative;
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin: 0;
  padding: 2px;
  border: 2px solid var(--portal-green);
  border-radius: 0;
  background: repeating-linear-gradient(to bottom, var(--portal-bg) 0 3px, var(--portal-bg) 4px 5px);
  box-shadow: 0 0 0 3px var(--portal-deep), 0 0 17px color-mix(in srgb, var(--portal-green) 43.92%, transparent), inset 0 0 14px color-mix(in srgb, var(--portal-green) 20%, transparent);
  cursor: pointer;
}
body.portal-active .portal-signal-face:hover,
body.portal-active .portal-signal-face[aria-expanded='true'] { background-color: var(--portal-line); }
body.portal-active .portal-signal-face canvas { display: block; width: 72px; height: 72px; image-rendering: pixelated; }
body.portal-active .portal-signal-indicator { position: absolute; top: 5px; right: 5px; width: 4px; height: 4px; background: var(--portal-green); animation: signal-beacon 3s steps(1, end) infinite; }
body.portal-active .portal-assistant-bubble {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(292px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid var(--portal-green);
  background: var(--portal-bg);
  box-shadow: 0 0 16px color-mix(in srgb, var(--portal-green) 29.02%, transparent);
  font: 12px/1.45 Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-assistant-bubble > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--portal-green); font-size: 10px; }
body.portal-active .portal-assistant-bubble p { margin: 9px 0 2px; }
body.portal-active .portal-assistant-bubble button { min-width: 28px; min-height: 28px; margin: 0; border: 1px solid var(--portal-line); background: var(--portal-bg); color: var(--portal-green); }
@keyframes signal-beacon { 0%, 70%, 100% { opacity: 1; } 75%, 95% { opacity: .25; } }
body.portal-active .portal-brand strong,
body.portal-active .portal-brand small,
body.portal-active .portal-workbar,
body.portal-active .portal-text-button,
body.portal-active .portal-icon,
body.portal-active .portal-titlebar,
body.portal-active .portal-program h2,
body.portal-active .portal-window label,
body.portal-active .portal-window legend,
body.portal-active .portal-button,
body.portal-active .portal-footer,
body.portal-active .portal-footer button,
body.portal-active .portal-list-row,
body.portal-active .portal-doc-row { font-family: Monaco, 'Lucida Console', 'Courier New', monospace; }
body.portal-active { font-family: Monaco, 'Lucida Console', 'Courier New', monospace; -webkit-font-smoothing: none; }
body.portal-active .portal-titlebar,
body.portal-active .portal-icon b { text-shadow: 0 0 4px color-mix(in srgb, var(--portal-green) 50.2%, transparent); }
body.portal-active .portal-footer { border-top: 1px solid var(--portal-line); background: var(--portal-bg); color: var(--portal-muted); font: 10px 'Courier New', Consolas, monospace; }
body.portal-active .portal-footer a { color: var(--portal-green); }
@media (min-width: 760px) {
  body.portal-active .portal-workspace { grid-template-columns: 218px minmax(0, 1fr); }
  body.portal-active .portal-launcher { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body.portal-active .portal-main { padding-bottom: 90px; }
  body.portal-active .portal-assistant { right: 10px; bottom: 10px; }
  body.portal-active .portal-signal-face { width: 60px; height: 60px; }
  body.portal-active .portal-signal-face canvas { width: 48px; height: 48px; }
  body.portal-active .portal-icon { grid-template-columns: 1fr; gap: 2px; min-height: 50px; }
  body.portal-active .portal-icon[aria-current='page'] { box-shadow: inset 0 3px var(--portal-green); }
}

/* Open programs share the desktop and remain available from the taskbar. */
body.portal-active .portal-program[hidden] { display: none; }
body.portal-active .portal-window-tabs {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
body.portal-active .portal-window-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  max-width: 160px;
  height: 33px;
  padding: 3px 9px;
  overflow: hidden;
  color: var(--portal-muted);
  font: 11px Monaco, 'Lucida Console', monospace;
  text-align: left;
}
body.portal-active .portal-window-tab .portal-pixel-icon { flex: none; width: 19px; height: 19px; }
body.portal-active .portal-window-tab .icon-fill { fill: var(--app-accent); }
body.portal-active .portal-window-tab .icon-screen { fill: var(--portal-bg); }
body.portal-active .portal-window-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.portal-active .portal-window-tab[aria-pressed='true'] {
  border-color: var(--app-accent);
  background: var(--portal-surface);
  color: var(--portal-ink);
  box-shadow: inset 1px 1px 4px color-mix(in srgb, var(--portal-ink) 31.37%, transparent), 0 0 7px color-mix(in srgb, var(--portal-green) 16.08%, transparent);
}
body.portal-active .portal-window-tab.is-minimized { opacity: .58; }
body.portal-active .portal-window-tab:focus-visible,
body.portal-active .portal-program .portal-titlebar:focus-visible { outline: 2px solid var(--portal-ink); outline-offset: -2px; }
body.portal-active .portal-program:focus-visible,
body.portal-active .portal-program .portal-window-body:focus-visible { outline: 1px solid var(--window-accent); outline-offset: -2px; }
body.portal-active .portal-program .portal-program-minimize,
body.portal-active .portal-program .portal-program-close { flex: none; }
body.portal-active .portal-program .portal-program-minimize { margin-left: 0; }

@media (max-width: 600px) {
  body.portal-active .portal-taskbar:has(.portal-window-tab) .portal-task-status { display: none; }
  body.portal-active .portal-window-tab { min-width: 86px; max-width: 130px; height: 38px; padding: 4px 6px; }
  body.portal-active .portal-program .portal-window-mode { display: none; }
}

/* Recovered MONTNET desktop: program shortcuts live on the surface, one window opens at a time. */
body.portal-active .portal-main { padding: clamp(8px, 2vw, 22px); }
body.portal-active .portal-desktop {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1320px;
  min-height: min(780px, calc(100svh - 155px));
  border: 1px solid var(--portal-muted);
  background: var(--portal-bg);
  box-shadow: 0 0 0 2px var(--portal-deep), 0 0 0 3px var(--portal-line);
}
body.portal-active .portal-workbar {
  min-height: 43px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--portal-line);
  background: var(--portal-surface);
  box-shadow: inset 0 1px var(--portal-muted);
}
body.portal-active .portal-workspace {
  position: relative;
  display: block;
  flex: 1;
  min-height: 590px;
  margin: 0;
  padding: 24px;
  background-color: var(--portal-bg);
  background-image: linear-gradient(color-mix(in srgb, var(--portal-line) 20%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--portal-line) 20%, transparent) 1px, transparent 1px);
  background-size: 24px 24px;
}
body.portal-active .portal-launcher {
  display: grid;
  grid-template-columns: repeat(2, 108px);
  grid-auto-rows: 98px;
  gap: 14px 16px;
  width: max-content;
  margin: 0;
  border: 0;
  background: transparent;
}
body.portal-active .portal-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 108px;
  min-height: 98px;
  padding: 7px 5px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--portal-ink);
  text-align: center;
}
body.portal-active .portal-icon:hover,
body.portal-active .portal-icon:focus-visible,
body.portal-active .portal-icon[aria-current='page'] {
  border: 1px dotted var(--portal-green);
  background: color-mix(in srgb, var(--portal-line) 60%, transparent);
  box-shadow: none;
}
body.portal-active .portal-icon[aria-current='page'] { background: color-mix(in srgb, var(--portal-line) 73.33%, transparent); }
body.portal-active .portal-pixel-icon { display: block; width: 48px; height: 48px; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 var(--portal-deep)); }
body.portal-active .portal-pixel-icon .icon-fill { fill: var(--portal-green); }
body.portal-active .portal-pixel-icon .icon-screen { fill: var(--portal-surface); }
body.portal-active .portal-icon[data-kind='folder'] .icon-fill { fill: var(--portal-green); }
body.portal-active .portal-icon b {
  display: block;
  max-width: 100%;
  padding: 2px 4px;
  background: color-mix(in srgb, var(--portal-bg) 80%, transparent);
  color: var(--portal-ink);
  font: bold 11px/1.25 Monaco, 'Lucida Console', monospace;
  overflow-wrap: anywhere;
}
body.portal-active .portal-desktop-hint {
  position: absolute;
  right: 25px;
  bottom: 18px;
  margin: 0;
  color: var(--portal-muted);
  font: 11px/1.6 Monaco, 'Lucida Console', monospace;
  letter-spacing: .1em;
  text-align: right;
}
body.portal-active .portal-desktop.program-open .portal-desktop-hint { display: none; }
body.portal-active .portal-program {
  position: absolute;
  top: 30px;
  right: 25px;
  left: 270px;
  z-index: 5;
  width: auto;
  min-height: 420px;
  max-height: calc(100% - 60px);
  overflow: auto;
  border: 1px solid var(--portal-muted);
  background: var(--portal-bg);
  box-shadow: 5px 5px 0 var(--portal-deep), 0 0 0 1px var(--portal-surface) inset;
}
body.portal-active .portal-program .portal-window-body { min-height: 375px; }
body.portal-active .portal-taskbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 43px;
  padding: 5px 8px;
  border-top: 1px solid var(--portal-muted);
  background: var(--portal-surface);
  box-shadow: inset 0 1px var(--portal-line);
  color: var(--portal-ink);
  font: bold 10px Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-taskbar button {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--portal-green);
  background: var(--portal-line);
  box-shadow: inset 1px 1px var(--portal-green), 2px 2px var(--portal-deep);
  color: var(--portal-ink);
  font: bold 10px Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-taskbar button:active { box-shadow: inset 2px 2px var(--portal-bg); }
body.portal-active #portal-task-label { min-width: 90px; padding: 5px 9px; border: 1px solid var(--portal-line); background: var(--portal-bg); }
body.portal-active .portal-task-status { margin-left: auto; color: var(--portal-muted); }
body.portal-active .portal-task-status i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; background: var(--portal-green); }
@media (min-width: 901px) {
  body.portal-active .portal-assistant { right: 20px; bottom: 90px; }
}
@media (max-width: 900px) {
  body.portal-active .portal-workspace { min-height: 540px; padding: 20px; }
  body.portal-active .portal-launcher { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 94px; width: 100%; gap: 8px; }
  body.portal-active .portal-icon { width: 100%; min-height: 94px; }
  body.portal-active .portal-program { position: relative; inset: auto; width: 100%; max-height: none; min-height: 0; margin-top: 20px; }
  body.portal-active .portal-desktop-hint { position: static; margin-top: 30px; }
}
@media (max-width: 600px) {
  body.portal-active .portal-main { padding: 8px 8px 90px; }
  body.portal-active .portal-desktop { min-height: 0; }
  body.portal-active .portal-workspace { min-height: 490px; padding: 12px; }
  body.portal-active .portal-launcher { grid-auto-rows: 88px; gap: 5px; }
  body.portal-active .portal-icon { min-height: 88px; padding: 5px 2px; }
  body.portal-active .portal-pixel-icon { width: 42px; height: 42px; }
  body.portal-active .portal-icon b { font-size: 9px; }
  body.portal-active .portal-desktop.program-open .portal-launcher { display: none; }
  body.portal-active .portal-program { margin-top: 0; }
body.portal-active .portal-task-status { display: none; }
}

/* Full-screen personal desktop. The portal alone owns the viewport after recovery. */
body.portal-active .portal-topbar,
body.portal-active .portal-footer { display: none; }
body.portal-active .portal-frame { display: block; min-height: 100svh; height: 100svh; overflow: hidden; }
body.portal-active .portal-main { width: 100%; height: 100svh; min-height: 0; padding: 0; background: var(--portal-bg); }
body.portal-active .portal-desktop {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-height: 100svh;
  height: 100svh;
  margin: 0;
  border: 0;
  box-shadow: none;
}
body.portal-active .portal-workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--portal-bg);
  background-image: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-green) 3.14%, transparent) 0 1px, transparent 1px 4px), radial-gradient(ellipse at 28% 23%, color-mix(in srgb, var(--portal-line) 13.73%, transparent), transparent 53%);
  background-size: auto;
}
body.portal-active .portal-launcher {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}
body.portal-active .portal-icon {
  position: absolute;
  left: var(--desk-x);
  top: var(--desk-y);
  transform: translateX(-50%);
  width: 108px;
  min-height: 96px;
  height: 96px;
  padding: 6px 3px;
}
body.portal-active .portal-icon[aria-current='page'] { box-shadow: none; }
body.portal-active .portal-program {
  top: 7%;
  left: clamp(165px, 20vw, 320px);
  right: clamp(30px, 12vw, 170px);
  max-height: 86%;
  margin: 0;
}
body.portal-active .portal-taskbar { position: relative; flex: none; min-height: 50px; padding: 5px 10px; z-index: 10; }
body.portal-active #portal-home {
  display: grid;
  place-items: center;
  width: 43px;
  height: 38px;
  min-height: 38px;
  padding: 3px;
}
body.portal-active #portal-home img { display: block; width: 27px; height: 27px; filter: brightness(0) saturate(100%) invert(80%) sepia(80%) saturate(850%) hue-rotate(77deg); }
body.portal-active #portal-task-label { min-width: 100px; }
body.portal-active .portal-task-status { display: inline; }
body.portal-active .portal-task-status b { color: var(--portal-green); }
body.portal-active .portal-start-menu {
  position: absolute;
  z-index: 30;
  left: 8px;
  bottom: 53px;
  width: min(350px, calc(100vw - 16px));
  max-height: calc(100svh - 65px);
  overflow: auto;
  border: 1px solid var(--portal-green);
  background: var(--portal-bg);
  box-shadow: 5px 5px 0 var(--portal-deep), inset 1px 1px var(--portal-line);
  color: var(--portal-ink);
  font: bold 11px Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-start-heading { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--portal-line); background: var(--portal-surface); color: var(--portal-green); }
body.portal-active .portal-start-heading img { width: 32px; height: 32px; filter: brightness(0) saturate(100%) invert(80%) sepia(80%) saturate(850%) hue-rotate(77deg); }
body.portal-active .portal-start-heading small { display: block; margin-top: 4px; color: var(--portal-ink); font-size: 10px; }
body.portal-active .portal-start-apps { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 8px; }
body.portal-active .portal-start-menu button,
body.portal-active .portal-start-menu a { min-height: 35px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: none; }
body.portal-active .portal-start-menu button:hover,
body.portal-active .portal-start-menu button:focus-visible,
body.portal-active .portal-start-menu a:hover,
body.portal-active .portal-start-menu a:focus-visible { background: var(--portal-line); color: var(--portal-ink); }
body.portal-active .portal-start-app { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 4px 5px; }
body.portal-active .portal-start-app .portal-pixel-icon { flex: none; width: 25px; height: 25px; }
body.portal-active .portal-start-app span { overflow-wrap: anywhere; }
body.portal-active .portal-start-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 8px; border-top: 1px solid var(--portal-line); }
body.portal-active .portal-start-tools button,
body.portal-active .portal-start-tools a { display: flex; align-items: center; padding: 5px 7px; }
body.portal-active #portal-signout { color: var(--portal-green); }
body.portal-active .portal-assistant { right: 18px; bottom: 65px; }
body.portal-active .portal-signal-face,
body.portal-active .portal-signal-face:hover,
body.portal-active .portal-signal-face[aria-expanded='true'] {
  width: 116px;
  height: 116px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body.portal-active .portal-signal-face canvas { width: 112px; height: 112px; image-rendering: pixelated; filter: drop-shadow(0 3px 0 var(--portal-deep)) drop-shadow(0 0 6px color-mix(in srgb, var(--portal-green) 43.92%, transparent)); }
body.portal-active .portal-signal-indicator { display: none; }

@media (max-width: 900px) {
  body.portal-active .portal-program { top: 6%; left: 12%; right: 5%; max-height: 88%; }
}
@media (max-width: 600px) {
  body.portal-active .portal-workspace { min-height: 0; }
  body.portal-active .portal-icon {
    left: var(--phone-x);
    top: var(--phone-y);
    width: 82px;
    height: 83px;
    min-height: 83px;
    gap: 2px;
    padding: 3px 1px;
    font-size: 9px;
  }
  body.portal-active .portal-pixel-icon { width: 41px; height: 41px; }
  body.portal-active .portal-program { position: absolute; inset: 7px; width: auto; min-height: 0; max-height: none; overflow: auto; }
  body.portal-active .portal-program .portal-window-body { min-height: 0; }
  body.portal-active .portal-taskbar { gap: 8px; min-height: 48px; padding: 4px 7px; }
  body.portal-active #portal-task-label { min-width: 0; }
  body.portal-active .portal-task-status { display: inline; }
  body.portal-active .portal-task-status span { display: none; }
  body.portal-active .portal-assistant { right: 7px; bottom: 52px; }
  body.portal-active .portal-signal-face,
  body.portal-active .portal-signal-face:hover,
  body.portal-active .portal-signal-face[aria-expanded='true'] { width: 92px; height: 92px; }
  body.portal-active .portal-signal-face canvas { width: 88px; height: 88px; }
}

/* Signal archive desktop: dark instrument surfaces and restrained screen colors. */
body.portal-active {
  --portal-green: #8df4ab;
  --portal-ink: #d5e3dc;
  --portal-muted: #91a89c;
  --portal-line: #426653;
  background: var(--portal-deep);
  color: var(--portal-ink);
}
body.portal-active .portal-workspace {
  background-color: var(--portal-deep);
  background-image: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-ink) 2.35%, transparent) 0 1px, transparent 1px 4px), radial-gradient(ellipse at 51% 45%, var(--portal-surface) 0, var(--portal-deep) 66%);
}
body.portal-active .portal-launcher { z-index: 1; }
body.portal-active .portal-icon { color: var(--app-accent); }
body.portal-active .portal-pixel-icon .icon-fill,
body.portal-active .portal-icon[data-kind='folder'] .icon-fill { fill: var(--app-accent, var(--portal-green)); }
body.portal-active .portal-pixel-icon .icon-screen { fill: var(--portal-bg); }
body.portal-active .portal-icon b {
  background: color-mix(in srgb, var(--portal-deep) 90.98%, transparent);
  color: var(--app-accent);
  text-shadow: 0 1px var(--portal-deep);
}
body.portal-active .portal-icon:hover,
body.portal-active .portal-icon:focus-visible,
body.portal-active .portal-icon[aria-current='page'] { border-color: var(--app-accent); background: color-mix(in srgb, var(--portal-surface) 72.94%, transparent); }
body.portal-active .portal-start-app .portal-pixel-icon .icon-fill { fill: var(--app-accent); }
body.portal-active .portal-start-app .portal-pixel-icon .icon-screen { fill: var(--portal-bg); }
body.portal-active .portal-taskbar { border-top: 2px solid var(--portal-line); background: var(--portal-bg); box-shadow: inset 0 1px var(--portal-line); }
body.portal-active .portal-taskbar::before { content: ''; position: absolute; top: -2px; left: 0; width: min(270px, 48vw); height: 2px; background: linear-gradient(90deg, var(--portal-ink) 0 28%, var(--portal-ink) 28% 43%, var(--portal-green) 43% 78%, var(--portal-ink) 78%); }
body.portal-active .portal-taskbar button { border-color: var(--portal-muted); background: var(--portal-surface); box-shadow: inset 1px 1px var(--portal-ink), 2px 2px var(--portal-deep); }
body.portal-active #portal-task-label { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .portal-task-status { color: var(--portal-muted); }
body.portal-active .portal-task-status b { color: var(--portal-ink); }
body.portal-active .portal-start-menu { border-color: var(--portal-muted); background: var(--portal-bg); box-shadow: 5px 5px 0 var(--portal-deep), inset 1px 1px var(--portal-line); }
body.portal-active .portal-start-heading { border-bottom-color: var(--portal-line); background: var(--portal-surface); color: var(--portal-ink); }
body.portal-active .portal-start-tools { border-top-color: var(--portal-line); }
body.portal-active .portal-start-menu button:hover,
body.portal-active .portal-start-menu button:focus-visible,
body.portal-active .portal-start-menu a:hover,
body.portal-active .portal-start-menu a:focus-visible { background: var(--portal-line); }

body.portal-active .portal-program {
  position: absolute;
  z-index: 12;
  display: flex;
  flex-direction: column;
  top: 10%;
  left: 20%;
  right: auto;
  bottom: auto;
  width: min(650px, calc(100% - 40px));
  height: min(590px, calc(100% - 42px));
  min-height: 0;
  max-height: none;
  overflow: hidden;
  border: 2px solid var(--window-accent, var(--portal-green));
  background: var(--portal-bg);
  box-shadow: 7px 7px 0 var(--portal-deep), inset 0 0 0 1px var(--portal-surface);
}
body.portal-active .portal-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 41px;
  padding: 5px 7px 5px 12px;
  border-bottom: 2px solid var(--window-accent);
  background: var(--portal-surface);
  color: var(--window-accent);
  cursor: grab;
  touch-action: none;
  user-select: none;
  text-shadow: none;
}
body.portal-active .portal-titlebar:active { cursor: grabbing; }
body.portal-active .portal-titlebar::before { content: ''; width: 15px; height: 12px; flex: none; border-left: 3px solid var(--window-accent); border-right: 3px solid var(--window-accent); opacity: .65; }
body.portal-active .portal-window-mode { margin-left: auto; color: var(--portal-ink); font-size: 10px; letter-spacing: .05em; }
body.portal-active .portal-titlebar button { flex: none; margin-left: 6px; border-color: var(--window-accent); background: var(--portal-bg); color: var(--window-accent); cursor: pointer; }
body.portal-active .portal-program .portal-window-body {
  flex: 1;
  min-height: 0;
  padding: 20px 22px;
  overflow: auto;
  background: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-ink) 1.18%, transparent) 0 1px, transparent 1px 4px), var(--portal-bg);
  color: var(--portal-ink);
  scrollbar-color: var(--window-accent) var(--portal-bg);
}
body.portal-active .portal-program h2 { color: var(--window-accent); border-color: var(--portal-line); }
body.portal-active .portal-program:not([data-program='CORTEX']) input:not([type='radio']):not([type='checkbox']),
body.portal-active .portal-program:not([data-program='CORTEX']) select,
body.portal-active .portal-program:not([data-program='CORTEX']) textarea { border-color: var(--window-accent); background-color: var(--portal-bg); }
body.portal-active .portal-program .portal-button,
body.portal-active .portal-program .portal-text-button { color: var(--window-accent); border-color: var(--window-accent); }
body.portal-active .portal-program .portal-list-row:hover,
body.portal-active .portal-program .portal-doc-row:hover { background: var(--portal-surface); }
body.portal-active .portal-desktop.program-open .portal-launcher { display: block; }

body.portal-active .portal-program[data-program='CORTEX'] {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100vw;
  height: 100svh;
  max-height: none;
  border: 0;
  box-shadow: none;
}
body.portal-active .portal-program[data-program='CORTEX'] .portal-titlebar,
body.portal-active .portal-program[data-program='CORTEX'] .portal-titlebar:active { background: var(--portal-surface); cursor: default; }
body.portal-active .portal-program[data-program='CORTEX'] .portal-window-mode { color: var(--portal-ink); }
body.portal-active .portal-program[data-program='CORTEX'] .portal-window-body { padding: clamp(18px, 4vw, 52px); background-color: var(--portal-bg); background-image: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-ink) 2.75%, transparent) 0 1px, transparent 1px 4px), linear-gradient(90deg, var(--portal-bg), var(--portal-bg) 53%, var(--portal-bg)); }
body.portal-active .portal-program[data-program='CORTEX'] .portal-window-body > :not(.portal-cortex-boot) { max-width: 980px; margin-left: auto; margin-right: auto; }
body.portal-active .portal-cortex-header { display: flex; flex-direction: column; gap: 3px; margin-bottom: 22px; padding: 14px 18px 16px; border-left: 4px solid var(--portal-green); border-bottom: 1px solid var(--portal-muted); background: linear-gradient(90deg, var(--portal-surface), var(--portal-bg) 72%); }
body.portal-active .portal-cortex-header small { color: var(--portal-ink); font: bold 10px Monaco, 'Lucida Console', monospace; letter-spacing: .18em; }
body.portal-active .portal-cortex-header strong { color: var(--portal-ink); font: bold clamp(35px, 5vw, 70px)/1 Monaco, 'Lucida Console', monospace; letter-spacing: .06em; }
body.portal-active .portal-cortex-header span { color: var(--portal-ink); font-size: 10px; letter-spacing: .12em; }
body.portal-active .portal-program[data-program='CORTEX'] .portal-readout { margin-bottom: 18px; }
body.portal-active #cortex-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; border: 0; background: transparent; }
body.portal-active #cortex-list .portal-list-row { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 12px; min-height: 170px; padding: 15px; border: 1px solid var(--portal-muted); background: var(--portal-surface); color: var(--portal-ink); text-align: left; }
body.portal-active #cortex-list .portal-list-row:nth-child(2) { border-color: var(--portal-muted); background: var(--portal-surface); }
body.portal-active #cortex-list .portal-list-row:nth-child(3) { border-color: var(--portal-muted); background: var(--portal-surface); }
body.portal-active #cortex-list .portal-list-row small { color: var(--portal-ink); font: bold 10px Monaco, 'Lucida Console', monospace; letter-spacing: .1em; }
body.portal-active #cortex-list .portal-list-row b { color: var(--portal-ink); font-size: clamp(15px, 2vw, 20px); }
body.portal-active #cortex-list .portal-list-row span { align-self: flex-end; color: var(--portal-green); font-size: 10px; }
body.portal-active #cortex-list .portal-list-row:disabled { opacity: .82; }
body.portal-active .portal-desktop.cortex-open .portal-taskbar,
body.portal-active .portal-desktop.cortex-open .portal-assistant { visibility: hidden; }

body.portal-active .portal-cortex-boot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 100%; color: var(--portal-green); font: bold 11px Monaco, 'Lucida Console', monospace; letter-spacing: .1em; }
body.portal-active .cortex-boot-top { display: flex; justify-content: space-between; gap: 28px; width: min(520px, 100%); color: var(--portal-ink); border-bottom: 1px solid var(--portal-muted); padding-bottom: 8px; }
body.portal-active .cortex-boot-display { position: relative; width: min(360px, 90%); height: min(230px, 33svh); overflow: hidden; border: 1px solid var(--portal-muted); background: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-muted) 20%, transparent) 0 1px, transparent 1px 20px), repeating-linear-gradient(90deg, color-mix(in srgb, var(--portal-muted) 20%, transparent) 0 1px, transparent 1px 20px), var(--portal-bg); box-shadow: inset 0 0 0 5px var(--portal-bg); }
body.portal-active .cortex-boot-target { position: absolute; inset: 17px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; color: var(--portal-ink); font-size: 24px; }
body.portal-active .cortex-boot-target span:nth-child(2),
body.portal-active .cortex-boot-target span:nth-child(4) { text-align: right; }
body.portal-active .cortex-boot-target span:nth-child(3),
body.portal-active .cortex-boot-target span:nth-child(4) { align-self: end; }
body.portal-active .cortex-boot-target b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--portal-ink); font-size: 39px; animation: cortex-pulse 700ms steps(2, end) infinite; }
body.portal-active .cortex-boot-scan { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--portal-green); box-shadow: 0 0 9px var(--portal-green); animation: cortex-scan 1.5s steps(18, end) forwards; }
body.portal-active .cortex-boot-readout { display: grid; gap: 4px; width: min(520px, 100%); color: var(--portal-muted); }
body.portal-active .cortex-boot-readout span::before { content: '[OK] '; color: var(--portal-ink); }
body.portal-active .cortex-boot-track { width: min(520px, 100%); height: 14px; padding: 2px; border: 1px solid var(--portal-muted); background: var(--portal-bg); }
body.portal-active .cortex-boot-track i { display: block; width: 0; height: 100%; background: repeating-linear-gradient(90deg, var(--portal-ink) 0 10px, var(--portal-bg) 10px 12px); animation: cortex-progress 1.5s steps(18, end) forwards; }
body.portal-active .cortex-boot-cursor { color: var(--portal-ink); animation: cortex-pulse 650ms steps(2, end) infinite; }
@keyframes cortex-progress { to { width: 100%; } }
@keyframes cortex-scan { to { top: 100%; } }
@keyframes cortex-pulse { 50% { opacity: .2; } }

@media (max-width: 600px) {
  body.portal-active .portal-program:not([data-program='CORTEX']) {
    position: absolute;
    inset: auto;
    top: 5%;
    left: 4%;
    width: 92%;
    height: min(68svh, calc(100% - 100px));
    min-height: 0;
    max-height: none;
  }
  body.portal-active .portal-program .portal-window-body { padding: 15px 13px; }
  body.portal-active .portal-window-mode { display: none; }
  body.portal-active .portal-program[data-program='CORTEX'] { position: fixed; inset: 0; width: 100vw; height: 100svh; }
  body.portal-active .portal-program[data-program='CORTEX'] .portal-window-body { padding: 18px 14px; }
  body.portal-active .cortex-boot-readout { font-size: 9px; }
  body.portal-active #cortex-list { grid-template-columns: 1fr; }
  body.portal-active #cortex-list .portal-list-row { min-height: 108px; }
}
@media (prefers-reduced-motion: reduce) {
  body.portal-active .cortex-boot-target b,
  body.portal-active .cortex-boot-scan,
  body.portal-active .cortex-boot-track i,
  body.portal-active .cortex-boot-cursor { animation: none; }
  body.portal-active .cortex-boot-track i { width: 100%; }
  body.portal-active .cortex-boot-scan { top: 50%; }
}

/* CRT treatment informed by fine scanlines, edge falloff, and restrained phosphor bloom. */
body.portal-active {
  --portal-green: #a9dfae;
  --portal-ink: #c7d9c9;
  --portal-muted: #829d86;
  --portal-line: #3b6345;
  background: var(--portal-deep);
}
body.portal-active .portal-desktop::before,
body.portal-active .portal-desktop::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}
body.portal-active .portal-desktop::before {
  z-index: 90;
  background: radial-gradient(ellipse at center, transparent 58%, color-mix(in srgb, var(--portal-deep) 7.06%, transparent) 82%, color-mix(in srgb, var(--portal-deep) 21.96%, transparent) 100%);
  box-shadow: inset 0 0 26px color-mix(in srgb, var(--portal-deep) 18.82%, transparent);
}
body.portal-active .portal-desktop::after {
  z-index: 91;
  background-image:
    repeating-linear-gradient(to bottom, color-mix(in srgb, var(--portal-deep) 20%, transparent) 0 .5px, transparent .5px 3px),
    repeating-linear-gradient(to right, color-mix(in srgb, var(--portal-ink) 2.35%, transparent) 0 1px, color-mix(in srgb, var(--portal-green) 2.35%, transparent) 1px 2px, color-mix(in srgb, var(--portal-ink) 2.35%, transparent) 2px 3px);
  opacity: .45;
}
body.portal-active .portal-workspace,
body.portal-active .portal-program[data-program='CORTEX'] .portal-window-body {
  background-color: var(--portal-bg);
  background-image: radial-gradient(ellipse at 50% 42%, var(--portal-surface) 0, var(--portal-bg) 61%, var(--portal-deep) 100%);
}

body.portal-active .portal-icon {
  width: 88px;
  min-height: 76px;
  height: 76px;
  gap: 3px;
  border: 1px solid transparent;
  background: transparent;
}
body.portal-active .portal-icon .portal-pixel-icon { width: 37px; height: 37px; filter: drop-shadow(0 0 2px color-mix(in srgb, var(--portal-green) 43.92%, transparent)) drop-shadow(0 0 5px color-mix(in srgb, var(--portal-green) 20%, transparent)); }
body.portal-active .portal-icon .portal-pixel-icon .icon-fill,
body.portal-active .portal-icon[data-kind='folder'] .icon-fill { fill: var(--portal-ink); }
body.portal-active .portal-icon .portal-pixel-icon .icon-screen { fill: var(--portal-bg); }
body.portal-active .portal-icon b {
  padding: 0 2px;
  background: color-mix(in srgb, var(--portal-deep) 66.67%, transparent);
  color: var(--portal-ink);
  font: normal 11px/1.2 Monaco, 'Lucida Console', monospace;
  letter-spacing: .025em;
  text-shadow: 0 0 1px color-mix(in srgb, var(--portal-green) 45.88%, transparent);
}
body.portal-active .portal-icon:hover,
body.portal-active .portal-icon:focus-visible,
body.portal-active .portal-icon[aria-current='page'] {
  border-color: var(--portal-muted);
  background: color-mix(in srgb, var(--portal-surface) 51.37%, transparent);
}
body.portal-active .portal-start-app .portal-pixel-icon .icon-fill { fill: var(--portal-ink); }
body.portal-active .portal-start-app .portal-pixel-icon .icon-screen { fill: var(--portal-bg); }

body.portal-active .portal-program {
  border-width: 1px;
  background: var(--portal-deep);
  box-shadow: 0 0 2px var(--window-accent), 0 0 14px color-mix(in srgb, var(--portal-green) 13.33%, transparent), 5px 5px 0 color-mix(in srgb, var(--portal-deep) 73.33%, transparent);
}
body.portal-active .portal-program .portal-titlebar {
  min-height: 33px;
  padding: 3px 5px 3px 9px;
  border-bottom-width: 1px;
  background: var(--portal-bg);
  color: var(--window-accent);
  font-size: 11px;
  letter-spacing: .07em;
  text-shadow: 0 0 1px currentColor, 0 0 5px color-mix(in srgb, var(--portal-green) 26.67%, transparent);
}
body.portal-active .portal-titlebar::before {
  width: 13px;
  height: 9px;
  border: 0;
  background: repeating-linear-gradient(90deg, currentColor 0 1px, transparent 1px 4px);
}
body.portal-active .portal-titlebar button { min-width: 29px; min-height: 27px; border-width: 1px; background: var(--portal-bg); }
body.portal-active .portal-window-mode { color: var(--portal-ink); font-size: 10px; }
body.portal-active .portal-program .portal-window-body {
  background-color: var(--portal-deep);
  background-image: none;
  color: var(--portal-ink);
  text-shadow: 0 0 1px color-mix(in srgb, var(--portal-green) 20%, transparent);
}
body.portal-active .portal-program:not([data-program='CORTEX']) input:not([type='radio']):not([type='checkbox']),
body.portal-active .portal-program:not([data-program='CORTEX']) select,
body.portal-active .portal-program:not([data-program='CORTEX']) textarea { border-width: 1px; border-color: var(--portal-muted); box-shadow: inset 0 0 3px color-mix(in srgb, var(--portal-muted) 20%, transparent); }
body.portal-active .portal-program .portal-list-row,
body.portal-active .portal-program .portal-doc-row { border-color: var(--portal-line); background: var(--portal-bg); }
body.portal-active .portal-program .portal-button,
body.portal-active .portal-program .portal-text-button { box-shadow: 0 0 5px color-mix(in srgb, var(--portal-green) 20%, transparent); }
body.portal-active .portal-program h2 { text-shadow: 0 0 4px currentColor; }

body.portal-active .portal-taskbar {
  min-height: 43px;
  border-top: 1px solid var(--portal-line);
  background: var(--portal-bg);
  box-shadow: 0 -2px 9px color-mix(in srgb, var(--portal-green) 10.98%, transparent);
  text-shadow: 0 0 3px color-mix(in srgb, var(--portal-green) 40%, transparent);
}
body.portal-active .portal-taskbar::before { display: none; }
body.portal-active .portal-taskbar button { border-color: var(--portal-muted); background: var(--portal-bg); box-shadow: inset 0 0 4px color-mix(in srgb, var(--portal-green) 26.67%, transparent); }
body.portal-active #portal-home { width: 36px; height: 33px; min-height: 33px; }
body.portal-active #portal-home img { width: 23px; height: 23px; }
body.portal-active #portal-task-label { border-color: var(--portal-line); background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .portal-task-status b { color: var(--portal-ink); }
body.portal-active .portal-start-menu { bottom: 46px; border-color: var(--portal-muted); background: var(--portal-bg); box-shadow: 0 0 12px color-mix(in srgb, var(--portal-green) 20%, transparent), 4px 4px 0 var(--portal-deep); }
body.portal-active .portal-start-heading { background: var(--portal-bg); border-bottom-color: var(--portal-line); color: var(--portal-ink); }

body.portal-active .portal-cortex-header { gap: 2px; margin-bottom: 15px; padding: 8px 12px 10px; border-left-width: 2px; background: var(--portal-bg); }
body.portal-active .portal-cortex-header strong { font-size: clamp(27px, 4vw, 46px); font-weight: 400; text-shadow: 0 0 3px currentColor, 0 0 12px color-mix(in srgb, var(--portal-green) 40%, transparent); }
body.portal-active .portal-program[data-program='CORTEX'] .portal-readout { margin-bottom: 14px; border-color: var(--portal-line); }
body.portal-active #cortex-list { gap: 7px; }
body.portal-active #cortex-list .portal-list-row,
body.portal-active #cortex-list .portal-list-row:nth-child(2),
body.portal-active #cortex-list .portal-list-row:nth-child(3) {
  min-height: 125px;
  padding: 11px 12px;
  border: 1px solid var(--portal-line);
  background: var(--portal-bg);
  box-shadow: inset 0 0 5px color-mix(in srgb, var(--portal-green) 7.06%, transparent);
}
body.portal-active #cortex-list .portal-list-row:nth-child(2) { border-top-color: var(--portal-muted); }
body.portal-active #cortex-list .portal-list-row:nth-child(3) { border-top-color: var(--portal-muted); }
body.portal-active #cortex-list .portal-list-row b { font-size: 15px; font-weight: 400; text-shadow: 0 0 3px color-mix(in srgb, var(--portal-ink) 47.06%, transparent); }
body.portal-active .portal-program[data-program='CORTEX'] .portal-titlebar { background: var(--portal-bg); }

@media (max-width: 600px) {
  body.portal-active .portal-desktop::after { opacity: .35; }
  body.portal-active .portal-icon { width: 76px; min-height: 68px; height: 68px; }
  body.portal-active .portal-icon .portal-pixel-icon { width: 33px; height: 33px; }
  body.portal-active .portal-taskbar { min-height: 47px; }
  body.portal-active #portal-home { width: 44px; height: 44px; min-height: 44px; }
  body.portal-active .portal-program .portal-titlebar { min-height: 46px; }
  body.portal-active .portal-titlebar button { min-width: 42px; min-height: 40px; }
  body.portal-active .portal-start-menu button,
  body.portal-active .portal-start-menu a { min-height: 44px; }
  body.portal-active .portal-start-menu { bottom: 50px; }
  body.portal-active #cortex-list .portal-list-row,
  body.portal-active #cortex-list .portal-list-row:nth-child(2),
  body.portal-active #cortex-list .portal-list-row:nth-child(3) { min-height: 104px; }
}

/* Two user-arranged desktop columns, with one empty slot before CORTEX. */
body.portal-active .portal-launcher,
body.portal-active .portal-desktop.program-open .portal-launcher {
  display: grid;
  grid-template-columns: 88px 88px;
  grid-template-rows: repeat(7, 76px);
  align-content: start;
  justify-content: space-between;
  gap: 4px 0;
  padding: 16px clamp(12px, 2.5vw, 30px);
  overflow: auto;
}
body.portal-active .portal-launcher .portal-icon {
  position: static;
  left: auto;
  top: auto;
  transform: none;
  width: 88px;
  height: 76px;
  min-height: 76px;
  padding: 6px 2px;
  gap: 5px;
}
body.portal-active .portal-launcher .portal-icon .portal-pixel-icon { width: 34px; height: 34px; }
body.portal-active .portal-launcher .portal-icon b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.portal-active .portal-launcher .portal-icon[data-program='S!GNALCRUSH'] b { font-size: 9px; letter-spacing: 0; }
body.portal-active .portal-launcher .portal-icon[data-program='SCRAP'] { grid-column: 1; grid-row: 1; }
body.portal-active .portal-launcher .portal-icon[data-program='SYSTEM'] { grid-column: 1; grid-row: 2; }
body.portal-active .portal-launcher .portal-icon[data-program='BIO'] { grid-column: 1; grid-row: 3; }
body.portal-active .portal-launcher .portal-icon[data-program='DOCS'] { grid-column: 2; grid-row: 1; }
body.portal-active .portal-launcher .portal-icon[data-program='INBOX'] { grid-column: 2; grid-row: 2; }
body.portal-active .portal-launcher .portal-icon[data-program='MONTLINK'] { grid-column: 2; grid-row: 3; }
body.portal-active .portal-launcher .portal-icon[data-program='S!GNALCRUSH'] { grid-column: 2; grid-row: 4; }
body.portal-active .portal-launcher .portal-icon[data-program='CORTEX'] { grid-column: 2; grid-row: 6; }

/* Each program keeps its own width and takes only the height its contents need. */
body.portal-active .portal-program {
  width: min(var(--program-width, 520px), calc(100% - 20px));
  height: auto;
  max-height: calc(100% - 20px);
}
body.portal-active .portal-program .portal-window-body {
  flex: 0 1 auto;
  min-height: 0;
  max-height: calc(100svh - 110px);
  overflow: auto;
}
body.portal-active .portal-program[data-program='BIO'] { --program-width: 500px; }
body.portal-active .portal-program[data-program='DOCS'] { --program-width: 560px; }
body.portal-active .portal-program[data-program='INBOX'] { --program-width: 520px; }
body.portal-active .portal-program[data-program='MONTLINK'] { --program-width: 610px; }
body.portal-active .portal-program[data-program='S!GNALCRUSH'] { --program-width: 490px; }
body.portal-active .portal-program[data-program='SCRAP'] { --program-width: 410px; }
body.portal-active .portal-program[data-program='SYSTEM'] { --program-width: 510px; }
body.portal-active .portal-program[data-program='CORTEX'] { width: 100%; height: 100%; max-height: none; }
body.portal-active .portal-program[data-program='CORTEX'] .portal-window-body { flex: 1 1 auto; max-height: none; }

body.portal-active .portal-taskbar .portal-task-status {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 74px;
  margin-left: auto;
  padding-right: 3px;
  white-space: nowrap;
  color: var(--portal-ink);
}
body.portal-active .portal-taskbar .portal-task-status b { color: var(--portal-ink); }

@media (max-width: 600px) {
  body.portal-active .portal-program:not([data-program='CORTEX']) { inset: auto; width: min(var(--program-width, 520px), calc(100% - 20px)); height: auto; max-height: calc(100% - 16px); }
  body.portal-active .portal-program .portal-window-body { max-height: calc(100svh - 112px); }
  body.portal-active .portal-taskbar:has(.portal-window-tab) .portal-task-status { display: inline-flex; }
  body.portal-active .portal-taskbar .portal-task-status { min-width: 57px; padding-right: 1px; font-size: 10px; }
  body.portal-active .portal-window-tab { min-width: 80px; }
}
@media (max-height: 700px) {
  body.portal-active .portal-launcher,
  body.portal-active .portal-desktop.program-open .portal-launcher {
    --shortcut-row-height: clamp(55px, calc((100svh - 230px) / 7), 68px);
    grid-template-rows: repeat(7, var(--shortcut-row-height));
    padding-top: 10px;
  }
  body.portal-active .portal-launcher .portal-icon {
    height: var(--shortcut-row-height);
    min-height: var(--shortcut-row-height);
    padding: 3px 2px;
    gap: 2px;
  }
  body.portal-active .portal-launcher .portal-icon .portal-pixel-icon { width: 30px; height: 30px; }
}

/* Window buttons stay together at the right edge at every viewport width. */
body.portal-active .portal-program .portal-titlebar { justify-content: flex-start; gap: 8px; }
body.portal-active .portal-program .portal-program-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.portal-active .portal-program .portal-window-controls {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
}
body.portal-active .portal-program .portal-window-controls button { width: 29px; min-width: 29px; height: 27px; min-height: 27px; margin-left: 0; padding: 0; line-height: 1; }
body.portal-active .portal-program[data-program='CORTEX'] .portal-program-maximize { display: none; }
body.portal-active .portal-program.is-maximized:not([data-program='CORTEX']) {
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  box-shadow: none;
}
body.portal-active .portal-program.is-maximized .portal-window-body { flex: 1 1 auto; max-height: none; }

@media (max-width: 600px) {
  body.portal-active .portal-program .portal-window-controls { margin-left: auto; }
  body.portal-active .portal-program .portal-window-controls button { width: 42px; min-width: 42px; height: 40px; min-height: 40px; }
}

/* A quieter S!GNAL and an old terminal-style taskbar readout. */
body.portal-active .portal-assistant { right: 34px; bottom: 88px; }
body.portal-active .portal-signal-face canvas {
  filter: drop-shadow(0 2px 0 var(--portal-deep)) drop-shadow(0 0 3px color-mix(in srgb, var(--portal-green) 21.96%, transparent));
}
body.portal-active .portal-taskbar { min-height: 52px; gap: 8px; padding: 0 10px 0 0; }
body.portal-active .portal-taskbar #portal-home {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--portal-muted);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
body.portal-active .portal-taskbar #portal-home:hover,
body.portal-active .portal-taskbar #portal-home:active { background: var(--portal-surface); box-shadow: none; }
body.portal-active .portal-taskbar #portal-home img { width: 25px; height: 25px; }
body.portal-active .portal-taskbar .portal-task-status { gap: 7px; min-width: 0; padding-right: 2px; }
body.portal-active .portal-taskbar .portal-task-status .portal-dt-digits {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 67px;
  height: 31px;
  padding: 3px 6px 2px;
  border: 1px solid var(--portal-muted);
  background: var(--portal-deep);
  box-shadow: inset 2px 2px var(--portal-deep), inset -1px -1px var(--portal-line), 0 0 5px color-mix(in srgb, var(--portal-green) 10.98%, transparent);
}
body.portal-active .portal-taskbar .portal-dt-digits b {
  color: var(--portal-ink);
  font: bold 15px/1 Monaco, 'Lucida Console', monospace;
  letter-spacing: .1em;
  text-shadow: 0 0 4px color-mix(in srgb, var(--portal-green) 36.86%, transparent);
}
body.portal-active .portal-taskbar .portal-task-status .portal-dt-token {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--portal-ink);
  border-radius: 50%;
  background: var(--portal-surface);
  box-shadow: inset 0 0 0 2px var(--portal-line), 0 0 6px color-mix(in srgb, var(--portal-ink) 26.67%, transparent);
  color: var(--portal-ink);
  font: bold 10px/1 Monaco, 'Lucida Console', monospace;
  letter-spacing: -.06em;
  text-shadow: none;
}
@media (max-width: 600px) {
  body.portal-active .portal-assistant { right: 22px; bottom: 78px; }
  body.portal-active .portal-taskbar .portal-task-status { gap: 5px; padding-right: 2px; }
  body.portal-active .portal-taskbar .portal-task-status .portal-dt-digits { min-width: 57px; padding-right: 4px; }
  body.portal-active .portal-taskbar .portal-dt-digits b { font-size: 13px; }
  body.portal-active .portal-taskbar .portal-task-status .portal-dt-token { width: 29px; height: 29px; font-size: 9px; }
}

/* S!GNAL keeps a private conversation open at the edge of the desktop. */
body.portal-active .portal-assistant {
  right: 20px;
  bottom: 67px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: min(330px, calc(100vw - 32px));
  height: min(335px, calc(100svh - 145px));
  min-height: 190px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--portal-muted);
  background: var(--portal-deep);
  box-shadow: 0 0 0 1px var(--portal-bg) inset, 4px 4px 0 var(--portal-deep), 0 0 18px color-mix(in srgb, var(--portal-green) 14.12%, transparent);
  color: var(--portal-ink);
  font: 11px/1.4 Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-signal-terminal-heading {
  display: grid;
  grid-template-columns: 48px 1fr 7px;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--portal-line);
  background: var(--portal-bg);
}
body.portal-active .portal-signal-terminal-heading > div { display: grid; gap: 2px; min-width: 0; }
body.portal-active .portal-signal-terminal-heading strong { color: var(--portal-green); font-size: 13px; letter-spacing: .13em; }
body.portal-active .portal-signal-terminal-heading span { color: var(--portal-muted); font-size: 8px; letter-spacing: .08em; }
body.portal-active .portal-signal-terminal-heading i { width: 6px; height: 6px; background: var(--portal-green); box-shadow: 0 0 6px var(--portal-green); }
body.portal-active .portal-signal-face,
body.portal-active .portal-signal-face:hover,
body.portal-active .portal-signal-face[aria-expanded='true'] {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body.portal-active .portal-signal-face canvas { width: 42px; height: 42px; filter: drop-shadow(0 0 3px color-mix(in srgb, var(--portal-green) 39.61%, transparent)); }
body.portal-active .portal-signal-terminal-log {
  flex: 1 1 auto;
  min-height: 0;
  padding: 9px 11px;
  overflow: auto;
  background: repeating-linear-gradient(to bottom, var(--portal-deep) 0 3px, var(--portal-bg) 4px 5px);
  scrollbar-color: var(--portal-muted) var(--portal-bg);
}
body.portal-active .portal-signal-empty { margin: 3px 0; color: var(--portal-muted); font-size: 10px; }
body.portal-active .portal-signal-message { display: grid; grid-template-columns: 58px 1fr; gap: 7px; margin: 0 0 10px; }
body.portal-active .portal-signal-message strong { color: var(--portal-green); font-size: 10px; }
body.portal-active .portal-signal-message[data-sender='employee'] strong { color: var(--portal-ink); }
body.portal-active .portal-signal-message p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
body.portal-active .portal-signal-earlier { flex: none; padding: 4px; border: 0; border-top: 1px solid var(--portal-line); background: var(--portal-bg); color: var(--portal-green); font: 9px Monaco, 'Lucida Console', monospace; }
body.portal-active .portal-signal-earlier[hidden] { display: none; }
body.portal-active .portal-signal-terminal-form { flex: none; display: grid; gap: 4px; padding: 7px 9px 8px; border-top: 1px solid var(--portal-line); background: var(--portal-bg); }
body.portal-active .portal-signal-terminal-form label { color: var(--portal-muted); font-size: 9px; letter-spacing: .08em; }
body.portal-active .portal-signal-terminal-form > div { display: flex; gap: 5px; }
body.portal-active .portal-signal-terminal-form textarea { flex: 1 1 auto; min-width: 0; min-height: 40px; max-height: 100px; resize: vertical; padding: 5px 6px; border: 1px solid var(--portal-muted); border-radius: 0; background: var(--portal-deep); color: var(--portal-ink); font: 11px/1.4 Monaco, 'Lucida Console', monospace; }
body.portal-active .portal-signal-terminal-form textarea::placeholder { color: var(--portal-muted); }
body.portal-active .portal-signal-terminal-form button { flex: none; min-width: 52px; padding: 4px; border: 1px solid var(--portal-muted); border-radius: 0; background: var(--portal-surface); color: var(--portal-ink); font: 10px Monaco, 'Lucida Console', monospace; }
body.portal-active .portal-signal-terminal-form button:disabled { opacity: .55; }
body.portal-active .portal-signal-terminal-status { flex: none; margin: 0; padding: 4px 9px; border-top: 1px solid var(--portal-line); color: var(--portal-green); font-size: 9px; }
body.portal-active .portal-signal-terminal-status:empty { display: none; }
body.portal-active .portal-assistant[data-state='error'] .portal-signal-terminal-status { color: var(--portal-ink); }
body.portal-active .portal-desktop.fullscreen-open .portal-assistant { display: none; }

@media (max-width: 600px) {
  body.portal-active .portal-assistant {
    right: 9px;
    bottom: 60px;
    width: min(272px, calc(100vw - 18px));
    height: min(240px, calc(100svh - 160px));
    min-height: 170px;
  }
  body.portal-active .portal-signal-terminal-heading { min-height: 47px; grid-template-columns: 40px 1fr 6px; gap: 6px; padding: 3px 7px; }
  body.portal-active .portal-signal-face,
  body.portal-active .portal-signal-face:hover,
  body.portal-active .portal-signal-face[aria-expanded='true'] { width: 38px; height: 38px; min-width: 38px; min-height: 38px; }
  body.portal-active .portal-signal-face canvas { width: 36px; height: 36px; }
  body.portal-active .portal-signal-terminal-form { padding: 5px 7px 6px; }
  body.portal-active .portal-signal-terminal-form textarea { min-height: 32px; }
}

/* Bottom-wide command terminal with S!GNAL watching from the right edge. */
body.portal-active .portal-workspace { margin-bottom: 184px; }
body.portal-active .portal-desktop.fullscreen-open .portal-workspace { margin-bottom: 0; }
body.portal-active .portal-assistant {
  left: 0;
  right: 0;
  bottom: 52px;
  width: 100%;
 height: 184px;
  min-height: 0;
  flex-direction: row;
  align-items: stretch;
 border: 0;
 border-top: 1px solid var(--portal-muted);
 border-bottom: 1px solid var(--portal-muted);
  box-shadow: 0 -5px 22px color-mix(in srgb, var(--portal-deep) 65.88%, transparent);
}
body.portal-active .portal-signal-console {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--portal-deep);
}
body.portal-active .portal-signal-terminal-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-height: 31px;
  padding: 8px 13px 5px;
  border-bottom: 1px solid var(--portal-line);
  background: var(--portal-bg);
}
body.portal-active .portal-signal-terminal-heading strong { font-size: 10px; }
body.portal-active .portal-signal-terminal-heading span { text-align: right; }
body.portal-active .portal-signal-terminal-log { padding: 9px 13px; }
body.portal-active .portal-signal-message { grid-template-columns: 70px 1fr; gap: 8px; margin-bottom: 5px; }
body.portal-active .portal-signal-message strong { white-space: nowrap; }
body.portal-active .portal-signal-terminal-form {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 37px;
  padding: 5px 13px;
  background: var(--portal-bg);
}
body.portal-active .portal-signal-terminal-form label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body.portal-active .portal-signal-terminal-form span { color: var(--portal-green); font-size: 15px; }
body.portal-active .portal-signal-terminal-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 1px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--portal-ink);
  font: 11px/1.5 Monaco, 'Lucida Console', monospace;
  letter-spacing: .04em;
}
body.portal-active .portal-signal-terminal-form input::placeholder { color: var(--portal-muted); }
body.portal-active .portal-signal-terminal-form input:focus-visible { box-shadow: 0 1px var(--portal-green); }
body.portal-active .portal-signal-terminal-form button { display: none; }
body.portal-active .portal-signal-face,
body.portal-active .portal-signal-face:hover,
body.portal-active .portal-signal-face[aria-expanded='true'] {
  display: flex;
  flex: 0 0 136px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 136px;
  height: 100%;
  min-width: 136px;
  min-height: 0;
  border-left: 1px solid var(--portal-line);
  background: radial-gradient(circle at center, var(--portal-surface), var(--portal-deep) 68%);
}
body.portal-active .portal-signal-face canvas { width: 76px; height: 76px; }
body.portal-active .portal-signal-face span { color: var(--portal-green); font: 9px Monaco, 'Lucida Console', monospace; letter-spacing: .19em; }
body.portal-active .portal-desktop.fullscreen-open .portal-assistant { display: none; }

@media (max-width: 600px) {
 body.portal-active .portal-workspace { margin-bottom: 144px; }
  body.portal-active .portal-desktop.fullscreen-open .portal-workspace { margin-bottom: 0; }
 body.portal-active .portal-assistant { left: 0; right: 0; bottom: 52px; width: 100%; height: 144px; }
  body.portal-active .portal-signal-terminal-heading { min-height: 28px; padding: 7px 8px 4px; }
  body.portal-active .portal-signal-terminal-heading span { font-size: 7px; }
  body.portal-active .portal-signal-terminal-log { padding: 6px 8px; }
  body.portal-active .portal-signal-message { grid-template-columns: 47px 1fr; gap: 5px; font-size: 9px; }
  body.portal-active .portal-signal-message strong { font-size: 9px; }
  body.portal-active .portal-signal-terminal-form { min-height: 34px; padding: 4px 8px; }
  body.portal-active .portal-signal-face,
  body.portal-active .portal-signal-face:hover,
  body.portal-active .portal-signal-face[aria-expanded='true'] {
    flex-basis: 78px;
    width: 78px;
    min-width: 78px;
    height: 100%;
    min-height: 0;
  }
  body.portal-active .portal-signal-face canvas { width: 50px; height: 50px; }
 body.portal-active .portal-signal-face span { font-size: 7px; }
}

/* The terminal opens at a clean prompt, with S!GNAL in the adjacent bay. */
body.portal-active .portal-signal-console {
 display: block;
 padding: 12px 14px;
 overflow-y: auto;
 scrollbar-color: var(--portal-muted) var(--portal-deep);
}
body.portal-active .portal-signal-terminal-log {
 display: block;
 min-height: 0;
 padding: 0;
 overflow: visible;
 background: none;
}
body.portal-active .portal-signal-empty {
 margin: 0 0 3px;
 color: var(--portal-green);
 font-size: 12px;
 line-height: 1.45;
}
body.portal-active .portal-signal-message {
 grid-template-columns: minmax(75px, auto) 1fr;
 gap: 7px;
 margin-bottom: 4px;
 font-size: 11px;
}
body.portal-active .portal-signal-terminal-form {
 display: flex;
 align-items: baseline;
 gap: 8px;
 min-height: 0;
 padding: 0;
 border: 0;
 background: none;
}
body.portal-active .portal-signal-terminal-form #portal-assistant-prompt {
 flex: none;
 color: var(--portal-green);
 font-size: 12px;
 white-space: nowrap;
}
body.portal-active .portal-signal-terminal-form input {
 padding: 0;
 font-size: 12px;
}
body.portal-active .portal-signal-terminal-form input:focus-visible {
 box-shadow: none;
}
body.portal-active .portal-signal-terminal-status {
 padding: 0 0 4px;
 border: 0;
}
@media (max-width: 600px) {
 body.portal-active .portal-signal-console { padding: 9px 8px; }
 body.portal-active .portal-signal-empty,
 body.portal-active .portal-signal-terminal-form #portal-assistant-prompt,
 body.portal-active .portal-signal-terminal-form input { font-size: 10px; }
 body.portal-active .portal-signal-terminal-form { gap: 5px; }
 body.portal-active .portal-signal-message { grid-template-columns: minmax(47px, auto) 1fr; }
}

/* Program windows can cross the desktop into the terminal area. */
body.portal-active .portal-workspace { z-index: 40; overflow: visible; }
body.portal-active .portal-taskbar { z-index: 80; }
body.portal-active .portal-start-menu { z-index: 85; }

/* MONTDOS is a desktop program; S!GNAL remains a free-floating shortcut. */
body.portal-active .portal-workspace {
  margin-bottom: 0;
}
body.portal-active .portal-launcher,
body.portal-active .portal-desktop.program-open .portal-launcher {
  grid-template-columns: 88px 88px minmax(0, 1fr) 88px;
  column-gap: 4px;
  justify-content: stretch;
}
body.portal-active .portal-launcher .portal-icon[data-program='MONTDOS'] { grid-column: 2; grid-row: 1; }
body.portal-active .portal-launcher .portal-icon[data-program='DOCS'],
body.portal-active .portal-launcher .portal-icon[data-program='INBOX'],
body.portal-active .portal-launcher .portal-icon[data-program='MONTLINK'],
body.portal-active .portal-launcher .portal-icon[data-program='S!GNALCRUSH'],
body.portal-active .portal-launcher .portal-icon[data-program='CORTEX'] { grid-column: 4; }
body.portal-active .portal-program[data-program='MONTDOS'] { --program-width: 610px; }
body.portal-active .portal-program[data-program='MONTDOS'] .portal-window-body {
  padding: 0;
  background: var(--portal-deep);
}
body.portal-active .portal-program[data-program='MONTDOS'] .portal-signal-console {
  box-sizing: border-box;
  width: 100%;
  height: min(300px, calc(100svh - 150px));
  min-height: 190px;
  overflow-y: auto;
}
body.portal-active .portal-program[data-program='MONTDOS'] .portal-signal-terminal-form input:not([type='radio']):not([type='checkbox']) {
  min-height: 24px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  color: var(--portal-ink);
  font: 12px/1.5 Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-program[data-program='MONTDOS'] .portal-signal-terminal-form input:focus-visible {
  outline: 1px dotted var(--portal-green);
  outline-offset: 2px;
}
body.portal-active #portal-assistant {
  position: fixed;
  z-index: 60;
  left: auto;
  right: 24px;
  bottom: 67px;
  display: block;
  width: 92px;
  height: 92px;
  min-height: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
}
body.portal-active #portal-assistant .portal-signal-face,
body.portal-active #portal-assistant .portal-signal-face:hover,
body.portal-active #portal-assistant .portal-signal-face:focus-visible {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
body.portal-active #portal-assistant .portal-signal-face:focus-visible {
  outline: 1px dotted var(--portal-green);
  outline-offset: 3px;
}
body.portal-active #portal-assistant .portal-signal-face canvas {
  width: 76px;
  height: 76px;
}
body.portal-active .portal-desktop.fullscreen-open #portal-assistant { display: none; }
@media (max-width: 600px) {
  body.portal-active #portal-assistant { right: 10px; bottom: 59px; width: 74px; height: 74px; }
  body.portal-active #portal-assistant .portal-signal-face canvas { width: 64px; height: 64px; }
}

/* Mobile Safari zooms the viewport when a focused form control is under 16px. */
@media (max-width: 1024px) and (pointer: coarse) {
  .portal-frame input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
  .portal-frame textarea,
  .portal-frame select {
    font-size: 16px;
  }
  body.portal-active .portal-program[data-program='MONTDOS'] .portal-signal-terminal-form input:not([type='checkbox']):not([type='radio']) {
    font-size: 16px;
  }
}

/* DOCS uses a file browser inside its normal movable program window. */
body.portal-active .portal-program[data-program='DOCS'] .portal-window-body { padding: 0; }
body.portal-active .portal-doc-browser { min-height: 300px; color: var(--portal-ink); font: 11px/1.35 Monaco, 'Lucida Console', monospace; }
body.portal-active .portal-doc-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 43px;
  border-bottom: 1px solid var(--portal-muted);
  background: var(--portal-bg);
}
body.portal-active .portal-doc-toolbar > button,
body.portal-active .portal-doc-path button {
  min-height: 32px;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--portal-green);
  font: inherit;
  cursor: pointer;
}
body.portal-active .portal-doc-toolbar > button { border-right: 1px solid var(--portal-line); }
body.portal-active .portal-doc-toolbar button:hover:not(:disabled),
body.portal-active .portal-doc-toolbar button:focus-visible { background: var(--portal-surface); }
body.portal-active .portal-doc-toolbar button:focus-visible,
body.portal-active .portal-doc-tile:focus-visible { outline: 1px solid var(--portal-green); outline-offset: -2px; }
body.portal-active .portal-doc-toolbar button:disabled { opacity: .45; cursor: default; }
body.portal-active .portal-doc-path { min-width: 0; overflow-x: auto; white-space: nowrap; padding: 0 5px; scrollbar-width: thin; }
body.portal-active .portal-doc-path button { display: inline; min-height: 0; padding: 3px 5px; }
body.portal-active .portal-doc-wallet { padding: 0 10px; border-left: 1px solid var(--portal-line); color: var(--portal-ink); white-space: nowrap; }
body.portal-active .portal-doc-count { padding: 5px 12px; border-bottom: 1px solid var(--portal-line); color: var(--portal-muted); font-size: 10px; }
body.portal-active .portal-doc-content { min-height: 230px; padding: 16px; }
body.portal-active .portal-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px 8px; align-content: start; }
body.portal-active .portal-doc-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 104px;
  padding: 8px 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--portal-ink);
  cursor: pointer;
  font: 11px/1.2 Monaco, 'Lucida Console', monospace;
  text-align: center;
}
body.portal-active .portal-doc-tile:hover { border-color: var(--portal-muted); background: var(--portal-surface); }
body.portal-active .portal-doc-tile[data-kind='policy'],
body.portal-active .portal-doc-tile[data-kind='archive'] { color: var(--portal-ink); }
body.portal-active .portal-doc-tile[data-kind='index'] { color: var(--portal-ink); }
body.portal-active .portal-doc-tile[data-locked='true'] { opacity: .67; }
body.portal-active .portal-doc-tile span { max-width: 100%; overflow-wrap: anywhere; }
body.portal-active .portal-doc-tile small { color: var(--portal-muted); font-size: 9px; letter-spacing: .08em; }
body.portal-active .portal-doc-glyph { flex: none; width: 42px; height: 42px; filter: drop-shadow(0 0 4px currentColor); }
body.portal-active .portal-doc-glyph .icon-fill { fill: currentColor; }
body.portal-active .portal-doc-glyph .icon-screen { fill: var(--portal-bg); }
body.portal-active .portal-doc-detail { max-width: 590px; }
body.portal-active .portal-doc-detail-heading { display: flex; align-items: center; gap: 13px; padding-bottom: 12px; border-bottom: 1px solid var(--portal-line); }
body.portal-active .portal-doc-detail-heading .portal-doc-glyph { width: 48px; height: 48px; color: var(--portal-ink); }
body.portal-active .portal-doc-detail-heading small { color: var(--portal-muted); font-size: 10px; }
body.portal-active .portal-doc-detail-heading h2 { margin: 3px 0 0; border: 0; font-size: 15px; }
body.portal-active .portal-doc-page { margin: 15px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--portal-ink); font: 12px/1.6 Monaco, 'Lucida Console', monospace; }
body.portal-active .portal-doc-restriction { margin: 16px 0; color: var(--portal-ink); }
@media (max-width: 600px) {
  body.portal-active .portal-doc-toolbar > button { padding: 5px; font-size: 10px; }
  body.portal-active .portal-doc-wallet { padding: 0 6px; }
  body.portal-active .portal-doc-content { padding: 10px; }
  body.portal-active .portal-doc-grid { gap: 5px; }
}

/* CORTEX files: staggered archive tabs that pull forward into a document. */
body.portal-active .cortex-archive { width: min(780px, 100%); padding: 12px 0 28px; }
body.portal-active .cortex-archive-heading { display: flex; justify-content: space-between; gap: 12px; padding: 0 2px 14px; border-bottom: 1px solid var(--portal-muted); color: var(--portal-ink); font: 12px/1.4 Monaco, 'Lucida Console', monospace; letter-spacing: .1em; }
body.portal-active .cortex-archive-heading small { color: var(--portal-muted); font-size: 10px; white-space: nowrap; }
body.portal-active .cortex-work-count {
  margin-left: auto;
  padding: 2px 7px;
  border: 1px solid var(--portal-muted);
  background: var(--portal-bg);
  box-shadow: inset 0 1px 4px var(--portal-deep);
  color: var(--portal-ink);
  font-weight: normal;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
body.portal-active .cortex-file-stack { position: relative; isolation: isolate; padding: 55px 0 0; perspective: 900px; }
body.portal-active .cortex-file { --folder-paper: var(--portal-surface); position: relative; display: block; width: min(100%, calc(94% + var(--file-index) * 3%)); height: 158px; margin: -48px auto 0; padding: 0; z-index: calc(var(--file-index) + 1); border: 1px solid var(--portal-ink); border-radius: 3px 9px 2px 2px; box-shadow: 0 7px 0 var(--portal-bg), 0 10px 15px color-mix(in srgb, var(--portal-deep) 53.33%, transparent), inset 0 0 0 1px var(--portal-line); background: var(--folder-paper); color: var(--portal-surface); text-align: left; font: 12px/1.35 Monaco, 'Lucida Console', monospace; cursor: pointer; transition: transform 480ms cubic-bezier(.2,.7,.15,1), opacity 330ms ease, filter 330ms ease, box-shadow 330ms ease; }
body.portal-active .cortex-file:first-child { margin-top: 0; }
body.portal-active .cortex-file:nth-child(2) { --folder-paper: var(--portal-surface); }
body.portal-active .cortex-file:nth-child(3) { --folder-paper: var(--portal-surface); }
body.portal-active .cortex-file:nth-child(n+4) { --folder-paper: var(--portal-surface); }
body.portal-active .cortex-file-tab { position: absolute; left: 7%; top: -26px; display: grid; place-items: center; min-width: 32%; max-width: 52%; height: 27px; padding: 1px 12px 0; border: 1px solid var(--portal-ink); border-bottom: 0; border-radius: 9px 14px 0 0; background: var(--folder-paper); color: var(--portal-surface); font-size: 11px; font-weight: bold; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.portal-active .cortex-file:nth-child(3n+2) .cortex-file-tab { left: 34%; }
body.portal-active .cortex-file:nth-child(3n) .cortex-file-tab { left: 18%; }
body.portal-active .cortex-file-tab::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--folder-paper); }
body.portal-active .cortex-file:hover:not(:disabled), body.portal-active .cortex-file:focus-visible { transform: translateY(-9px); box-shadow: 0 13px 0 var(--portal-bg), 0 17px 22px color-mix(in srgb, var(--portal-deep) 66.67%, transparent), inset 0 0 0 1px var(--portal-line); }
body.portal-active .cortex-file:disabled { cursor: default; filter: saturate(.45); }
body.portal-active .cortex-file.is-selected { z-index: 10000; transform: translateY(-38px) scale(1.035) rotateX(2deg); box-shadow: 0 25px 35px color-mix(in srgb, var(--portal-deep) 73.33%, transparent), inset 0 0 0 1px var(--portal-line); filter: none; }
body.portal-active .cortex-file-stack.is-opening .cortex-file:not(.is-selected) { transform: translateY(20px) scale(.96); opacity: .28; }
body.portal-active .cortex-archive-note { margin: 25px 2px 0; color: var(--portal-muted); font: 11px/1.5 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-open-file { position: relative; width: min(860px, 100%); margin: 55px auto 36px; color: var(--portal-surface); animation: cortex-file-unfold 580ms cubic-bezier(.19,.72,.17,1) both; }
body.portal-active .cortex-open-file::before, body.portal-active .cortex-open-file::after { content: ''; position: absolute; z-index: -1; top: -17px; left: 2%; width: 96%; height: 90px; border: 1px solid var(--portal-muted); border-radius: 8px 8px 0 0; background: var(--portal-ink); }
body.portal-active .cortex-open-file::after { top: -9px; left: 1%; width: 98%; background: var(--portal-ink); }
body.portal-active .cortex-open-tab { position: absolute; top: -30px; left: 7%; z-index: 2; min-width: 30%; padding: 6px 22px 7px; border: 1px solid var(--portal-ink); border-bottom: 0; border-radius: 9px 13px 0 0; background: var(--portal-ink); font: bold 12px Monaco, 'Lucida Console', monospace; text-align: center; text-transform: uppercase; }
body.portal-active .cortex-document { position: relative; min-height: 440px; padding: clamp(18px, 4vw, 38px); border: 1px solid var(--portal-ink); border-radius: 3px; box-shadow: 8px 12px 0 var(--portal-deep), 0 18px 42px color-mix(in srgb, var(--portal-deep) 73.33%, transparent), inset 0 0 0 1px var(--portal-muted); background: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-deep) 3.14%, transparent) 0 1px, transparent 1px 4px), var(--portal-ink); }
body.portal-active .cortex-document-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 15px; border-bottom: 1px solid var(--portal-muted); font: 10px Monaco, 'Lucida Console', monospace; letter-spacing: .09em; }
body.portal-active .cortex-document-toolbar .portal-text-button { min-height: 36px; padding: 0 8px; color: var(--portal-surface); border: 1px solid var(--portal-muted); text-decoration: none; }
body.portal-active .cortex-document-heading { margin: 28px 0 20px; }
body.portal-active .cortex-document-heading small { font: 10px Monaco, 'Lucida Console', monospace; letter-spacing: .12em; }
body.portal-active .cortex-document-heading h2 { margin: 5px 0 12px; color: var(--portal-bg); font: bold clamp(25px, 5vw, 45px)/1.1 Monaco, 'Lucida Console', monospace; text-transform: uppercase; }
body.portal-active .cortex-document-heading p { max-width: 66ch; color: var(--portal-surface); line-height: 1.5; }
body.portal-active .cortex-document .portal-ascii { border-color: var(--portal-muted); background: var(--portal-bg); }
body.portal-active .cortex-document form { display: grid; gap: 17px; margin-top: 22px; }
body.portal-active .cortex-document form > label { display: grid; gap: 7px; }
body.portal-active .cortex-document form fieldset { border-color: var(--portal-muted); }
body.portal-active .cortex-document form input:not([type='radio']) { width: 100%; max-width: 620px; min-height: 42px; padding: 8px 10px; border: 1px solid var(--portal-line); background: var(--portal-ink); color: var(--portal-surface); font-size: 16px; }
body.portal-active .cortex-document form .portal-button { justify-self: start; min-height: 42px; padding: 9px 17px; border-color: var(--portal-surface); background: var(--portal-surface); color: var(--portal-ink); }
body.portal-active .cortex-complete-notice { margin-top: 22px; padding: 14px 16px; border: 1px solid var(--portal-muted); color: var(--portal-surface); font: 11px/1.5 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-open-file.is-closing { animation: cortex-file-close 280ms ease-in both; pointer-events: none; }
@keyframes cortex-file-unfold { from { opacity: .35; transform: translateY(85px) scale(.88) rotateX(9deg); } 60% { opacity: 1; } to { opacity: 1; transform: translateY(0) scale(1) rotateX(0); } }
@keyframes cortex-file-close { to { opacity: 0; transform: translateY(52px) scale(.92) rotateX(7deg); } }
@media (max-width: 600px) {
  body.portal-active .cortex-archive-heading { flex-wrap: wrap; }
  body.portal-active .cortex-file-stack { padding-top: 48px; }
  body.portal-active .cortex-file { width: 100%; height: 146px; margin-top: -47px; }
  body.portal-active .cortex-file-tab { min-width: 38%; max-width: 53%; font-size: 10px; }
  body.portal-active .cortex-open-file { margin-top: 45px; }
  body.portal-active .cortex-open-tab { left: 5%; max-width: 65%; font-size: 10px; }
  body.portal-active .cortex-document-toolbar span { text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
  body.portal-active .cortex-file { transition: none; }
  body.portal-active .cortex-open-file, body.portal-active .cortex-open-file.is-closing { animation: none; }
}

/* The archive drawing uses flat paper and fine ink outlines. */
body.portal-active .portal-desktop.cortex-open::after { display: none; }
body.portal-active .portal-program[data-program='CORTEX']::after { display: none; }
body.portal-active #cortex-list.cortex-file-stack { display: block; }
body.portal-active .cortex-file-frame { position: relative; }
body.portal-active #cortex-list.cortex-file-stack {
  height: calc(100dvh - 330px);
  min-height: 300px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 12px 8px 148px;
  scroll-padding-top: 12px;
  scroll-snap-type: y proximity;
  scrollbar-color: var(--portal-muted) transparent;
  scrollbar-width: thin;
  touch-action: pan-y;
}
body.portal-active #cortex-list.cortex-file-stack.has-more {
  -webkit-mask-image: linear-gradient(to bottom, var(--portal-deep) 0, var(--portal-deep) calc(100% - 195px), transparent 100%);
  mask-image: linear-gradient(to bottom, var(--portal-deep) 0, var(--portal-deep) calc(100% - 195px), transparent 100%);
}
body.portal-active .cortex-file-frame::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 150px;
  background: linear-gradient(to bottom, transparent, var(--portal-deep) 92%);
  opacity: 0;
  pointer-events: none;
}
body.portal-active .cortex-file-frame:has(#cortex-list.has-more)::after { opacity: 1; }
body.portal-active .cortex-scroll-cue {
  position: absolute;
  z-index: 1;
  bottom: 17px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  color: var(--portal-ink);
  font: 11px/1.2 Monaco, 'Lucida Console', monospace;
  letter-spacing: .12em;
  white-space: nowrap;
  text-shadow: 0 0 9px var(--portal-green);
  transition: opacity 180ms ease;
}
body.portal-active #cortex-list.has-more + .cortex-scroll-cue { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  body.portal-active .cortex-scroll-cue { transition: none; }
}
body[data-portal-motion='reduced'].portal-active .cortex-scroll-cue { transition: none; }
body.portal-active .cortex-file,
body.portal-active .cortex-file:nth-child(2),
body.portal-active .cortex-file:nth-child(3),
body.portal-active .cortex-file:nth-child(n+4) {
  --folder-paper: var(--portal-surface);
  height: 116px;
  margin-top: -42px;
  border: 1px solid var(--portal-surface);
  border-radius: 2px;
  box-shadow: 2px 3px 0 var(--portal-deep), 0 7px 12px color-mix(in srgb, var(--portal-deep) 33.33%, transparent);
  color: var(--portal-bg);
}
body.portal-active .cortex-file-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  width: min(54%, 230px);
  min-width: 0;
  max-width: none;
  height: 31px;
  top: -30px;
  padding: 1px 11px 0;
  border: 1px solid var(--portal-surface);
  border-bottom: 0;
  border-radius: 10px 14px 0 0;
  background: var(--folder-paper);
  color: var(--portal-bg);
  font-size: 11px;
  font-weight: normal;
  text-align: left;
}
body.portal-active .cortex-file-tab::after { background: var(--folder-paper); }
body.portal-active .cortex-file-tab-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.portal-active .cortex-file-checkbox { position: relative; display: block; flex: none; width: 15px; height: 15px; border: 1px solid var(--portal-bg); background: var(--portal-ink); }
body.portal-active .cortex-file-checkbox.is-checked::after { content: ''; position: absolute; left: 4px; top: 0; width: 5px; height: 9px; border: solid var(--portal-bg); border-width: 0 2px 2px 0; transform: rotate(43deg); }
body.portal-active .cortex-file:disabled { filter: none; opacity: .58; }
body.portal-active .cortex-file:hover:not(:disabled), body.portal-active .cortex-file:focus-visible { box-shadow: 2px 8px 0 var(--portal-deep), 0 13px 20px color-mix(in srgb, var(--portal-deep) 46.67%, transparent); }
body.portal-active .cortex-file.is-selected { box-shadow: 3px 15px 0 var(--portal-deep), 0 22px 28px color-mix(in srgb, var(--portal-deep) 60%, transparent); }
body.portal-active .cortex-open-file { color: var(--portal-bg); }
body.portal-active .cortex-open-file::before,
body.portal-active .cortex-open-file::after { border-color: var(--portal-surface); background: var(--portal-ink); }
body.portal-active .cortex-open-tab { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: min(54%, 240px); padding: 7px 13px; border-color: var(--portal-surface); background: var(--portal-ink); color: var(--portal-bg); font-weight: normal; text-align: left; }
body.portal-active .cortex-document { border-color: var(--portal-surface); box-shadow: 3px 5px 0 var(--portal-deep), 0 14px 28px color-mix(in srgb, var(--portal-deep) 53.33%, transparent); background: var(--portal-ink); color: var(--portal-bg); }
body.portal-active .cortex-document-toolbar { border-bottom-color: var(--portal-surface); }
body.portal-active .cortex-document-toolbar .portal-text-button { border-color: var(--portal-surface); color: var(--portal-bg); }
body.portal-active .cortex-document-heading h2,
body.portal-active .cortex-document-heading p { color: var(--portal-bg); }
body.portal-active .cortex-document form fieldset,
body.portal-active .cortex-document form input:not([type='radio']),
body.portal-active .cortex-complete-notice { border-color: var(--portal-surface); }
body.portal-active .cortex-document form input:not([type='radio']) { background: var(--portal-ink); color: var(--portal-bg); }
body.portal-active .cortex-complete-notice { color: var(--portal-bg); }

/* Hanging-file outlines: no paper fill, with closer tab and folder spacing. */
body.portal-active .cortex-file,
body.portal-active .cortex-file:nth-child(2),
body.portal-active .cortex-file:nth-child(3),
body.portal-active .cortex-file:nth-child(n+4) {
  --folder-line: var(--portal-line);
  --tab-left: 7%;
  --tab-width: clamp(145px, 40%, 180px);
  width: 100%;
  height: 29px;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  color: var(--folder-line);
  scroll-snap-align: start;
}
body.portal-active .cortex-file:first-child { margin-top: 0; }
body.portal-active .cortex-file:nth-child(3n+2) { --tab-left: 34%; }
body.portal-active .cortex-file:nth-child(3n) { --tab-left: 18%; }
/* Each tab occupies its own row, so the compact stack still has clear targets. */
body.portal-active .cortex-file:not(:last-child) {
  height: 29px;
}
body.portal-active .cortex-file:last-child { height: 44px; }
body.portal-active .cortex-file:not(:last-child):hover:not(:disabled),
body.portal-active .cortex-file:not(:last-child):focus-visible {
  height: 32px;
  margin-bottom: -3px;
}
body.portal-active .cortex-file:not(:last-child):has(+ .cortex-file:hover:not(:disabled)),
body.portal-active .cortex-file:not(:last-child):has(+ .cortex-file:focus-visible) {
  height: 26px;
  margin-bottom: 3px;
}
body.portal-active .cortex-file::before {
  content: '';
  position: absolute;
  top: 23px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, var(--folder-line) 0 var(--tab-left), transparent var(--tab-left) calc(var(--tab-left) + var(--tab-width)), var(--folder-line) calc(var(--tab-left) + var(--tab-width)) 100%);
}
body.portal-active .cortex-file::after {
  content: '';
  position: absolute;
  inset: 23px 0 0;
  pointer-events: none;
  background: linear-gradient(to right, var(--folder-line) 0 1px, transparent 1px calc(100% - 1px), var(--folder-line) calc(100% - 1px) 100%);
}
/* Carry each side rail through the next tab's height so the file outlines join. */
body.portal-active .cortex-file:not(:last-child)::after { bottom: -23px; }
body.portal-active .cortex-file:last-child::after { border-bottom: 1px solid var(--folder-line); }
body.portal-active .cortex-file-tab {
  top: 0;
  width: var(--tab-width);
  height: 24px;
  padding: 0 8px;
  border-color: var(--folder-line);
  border-radius: 7px 9px 0 0;
  background: transparent;
  color: var(--folder-line);
  font-size: 10px;
}
body.portal-active .cortex-file-tab::after { display: none; }
body.portal-active .cortex-file-checkbox { width: 13px; height: 13px; border-color: var(--folder-line); background: transparent; }
body.portal-active .cortex-file-checkbox.is-checked::after { left: 3px; top: -1px; width: 5px; height: 8px; border-color: var(--folder-line); }
body.portal-active .cortex-file[data-locked='true'] { opacity: .58; }
body.portal-active .cortex-file:hover:not(:disabled),
body.portal-active .cortex-file:focus-visible,
body.portal-active .cortex-file.is-selected { box-shadow: none; }
body.portal-active .cortex-file:hover:not(:disabled):not(.is-selected),
body.portal-active .cortex-file:focus-visible:not(.is-selected) { transform: translateY(-3px); }
body.portal-active .cortex-file:focus-visible { outline: none; }
body.portal-active .cortex-file:focus-visible .cortex-file-tab-label { text-decoration: underline; text-underline-offset: 3px; }
body.portal-active .cortex-open-file { color: var(--portal-ink); }
body.portal-active .cortex-open-file::before,
body.portal-active .cortex-open-file::after { display: none; }
body.portal-active .cortex-open-tab { top: -24px; left: 7%; width: clamp(145px, 40%, 180px); min-width: 0; height: 25px; padding: 0 8px; border-color: var(--portal-ink); border-radius: 7px 9px 0 0; background: transparent; color: var(--portal-ink); font-size: 10px; }
body.portal-active .cortex-document { border-color: var(--portal-ink); border-top: 0; box-shadow: none; background: transparent; color: var(--portal-ink); }
body.portal-active .cortex-document::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(to right, var(--portal-ink) 0 7%, transparent 7% calc(7% + clamp(145px, 40%, 180px)), var(--portal-ink) calc(7% + clamp(145px, 40%, 180px)) 100%); }
body.portal-active .cortex-document-toolbar { border-bottom-color: var(--portal-ink); }
body.portal-active .cortex-document-toolbar .portal-text-button { border-color: var(--portal-ink); color: var(--portal-ink); }
body.portal-active .cortex-document-heading h2,
body.portal-active .cortex-document-heading p { color: var(--portal-ink); }
body.portal-active .cortex-document form fieldset,
body.portal-active .cortex-document form input:not([type='radio']),
body.portal-active .cortex-complete-notice { border-color: var(--portal-ink); }
body.portal-active .cortex-document form input:not([type='radio']) { background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .cortex-complete-notice { color: var(--portal-ink); }

/* CORTEX is an employee work record, with a persistent debt account. */
body.portal-active .cortex-work-header { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(250px, .8fr); border: 1px solid var(--portal-muted); color: var(--portal-ink); font: 12px/1.4 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-work-identity { min-width: 0; padding: 18px 22px; }
body.portal-active .cortex-work-identity > small,
body.portal-active .cortex-work-debt > small { display: block; color: var(--portal-muted); font-size: 10px; letter-spacing: .1em; }
body.portal-active .cortex-work-identity > strong { display: block; margin: 10px 0 20px; color: var(--portal-ink); font-size: clamp(29px, 5vw, 46px); font-weight: normal; line-height: 1; letter-spacing: .035em; }
body.portal-active .cortex-work-identity dl { display: grid; gap: 7px; margin: 0; }
body.portal-active .cortex-work-identity dl > div { display: grid; grid-template-columns: 95px minmax(0, 1fr); gap: 8px; }
body.portal-active .cortex-work-identity dt { color: var(--portal-muted); }
body.portal-active .cortex-work-identity dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
body.portal-active .cortex-work-debt { display: flex; flex-direction: column; justify-content: space-between; gap: 8px; min-width: 0; padding: 18px 22px; border-left: 1px solid var(--portal-muted); }
body.portal-active .cortex-work-debt > span { color: var(--portal-ink); font-size: 10px; letter-spacing: .04em; }
body.portal-active .cortex-work-debt > strong { display: block; color: var(--portal-ink); font-size: clamp(24px, 3.7vw, 40px); font-weight: normal; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
body.portal-active .cortex-work-debt em { font-size: .4em; font-style: normal; vertical-align: baseline; }
body.portal-active .cortex-work-summary { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 10px 3px 12px; border-bottom: 1px solid var(--portal-muted); color: var(--portal-muted); font: 10px/1.45 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-work-summary b { margin-left: 6px; color: var(--portal-ink); font-size: 12px; font-weight: normal; }
body.portal-active .cortex-work-instructions { max-width: 72ch; margin: 15px 2px 0; color: var(--portal-ink); font: 12px/1.6 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-work-credit { margin: 15px 0 18px; padding: 9px 12px; border-left: 2px solid var(--portal-ink); color: var(--portal-ink); font: 11px/1.5 Monaco, 'Lucida Console', monospace; }
@media (max-width: 650px) {
  body.portal-active .cortex-work-header { grid-template-columns: 1fr; }
  body.portal-active .cortex-work-identity,
  body.portal-active .cortex-work-debt { padding: 14px 16px; }
  body.portal-active .cortex-work-identity > strong { margin: 7px 0 12px; }
  body.portal-active .cortex-work-debt { border-left: 0; border-top: 1px solid var(--portal-muted); }
  body.portal-active .cortex-work-debt > strong { font-size: clamp(25px, 8vw, 36px); }
  body.portal-active .cortex-work-summary { gap: 5px 18px; }
}

/* Keep the employee record and debt meter on one compact ledger strip. */
body.portal-active .cortex-work-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 9px 14px;
}
body.portal-active .cortex-work-identity { padding: 0; }
body.portal-active .cortex-work-identity > small { font-size: 9px; }
body.portal-active .cortex-work-identity > strong {
  overflow: hidden;
  margin: 2px 0;
  font-size: clamp(13px, 2vw, 17px);
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.portal-active .cortex-work-identity > span { color: var(--portal-muted); font-size: 9px; overflow-wrap: anywhere; }
body.portal-active .cortex-work-debt {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: end;
  gap: 3px 6px;
  padding: 0;
  border: 0;
}
body.portal-active .cortex-work-debt > span:first-child { grid-column: 1 / -1; text-align: right; }
body.portal-active .cortex-work-debt > span:last-child { color: var(--portal-ink); font-size: 10px; }
body.portal-active .cortex-work-debt > strong.cortex-debt-counter {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--portal-muted);
  background: var(--portal-deep);
  box-shadow: inset 1px 1px var(--portal-deep), inset -1px -1px var(--portal-line);
  color: var(--portal-ink);
  font: normal clamp(14px, 2.5vw, 19px)/1.15 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
body.portal-active .cortex-debt-digit {
  display: inline-grid;
  place-items: center;
  min-width: .78em;
  padding: 2px 0;
  border-right: 1px solid var(--portal-line);
  background: linear-gradient(var(--portal-bg), var(--portal-deep) 55%, var(--portal-bg));
  text-shadow: 0 0 5px var(--portal-ink);
}
body.portal-active .cortex-debt-digit:last-child { border-right: 0; }
body.portal-active .cortex-debt-digit.is-negative { color: var(--portal-ink); }
body.portal-active .cortex-debt-digit.is-separator {
  min-width: .45em;
  border-right: 0;
  background: var(--portal-deep);
}
body.portal-active .portal-desktop.cortex-open #portal-assistant {
  display: block;
  visibility: visible;
  right: 16px;
  bottom: 14px;
}
@media (max-width: 600px) {
  body.portal-active .cortex-work-header { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 8px 10px; }
  body.portal-active .cortex-work-debt { border: 0; }
  body.portal-active .cortex-work-debt > strong.cortex-debt-counter { font-size: 14px; }
  body.portal-active .portal-desktop.cortex-open #portal-assistant { right: 9px; bottom: 8px; }
}

/* S!GNAL's direct line opens from his floating face; MONTDOS stays a separate app. */
body.portal-active .portal-signal-dialog {
  position: fixed;
  z-index: 80;
  right: 126px;
  bottom: 74px;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 24px));
  max-height: min(560px, 72svh);
  border: 1px solid var(--portal-muted);
  background: var(--portal-bg);
  box-shadow: 0 0 0 3px var(--portal-deep), 5px 7px 20px color-mix(in srgb, var(--portal-deep) 73.33%, transparent), 0 0 18px color-mix(in srgb, var(--portal-muted) 16.86%, transparent);
  color: var(--portal-ink);
  font: 12px/1.4 Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-signal-dialog[hidden] { display: none; }
body.portal-active .portal-desktop.cortex-open .portal-signal-dialog { bottom: 22px; }
body.portal-active .portal-signal-dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 4px 7px 4px 12px;
  border-bottom: 1px solid var(--portal-muted);
  background: var(--portal-surface);
  letter-spacing: .08em;
}
body.portal-active .portal-signal-dialog-heading small { margin-left: 10px; color: var(--portal-muted); font-size: 9px; }
body.portal-active .portal-signal-dialog-heading button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--portal-muted);
  background: var(--portal-bg);
  color: var(--portal-ink);
  font: 20px/1 Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-signal-dialog-log {
  min-height: 140px;
  max-height: min(330px, 43svh);
  padding: 10px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.portal-active .portal-signal-dialog-welcome { margin: 0; color: var(--portal-ink); }
body.portal-active .portal-signal-dialog-message { padding: 6px 0 9px; border-bottom: 1px dotted var(--portal-line); }
body.portal-active .portal-signal-dialog-message + .portal-signal-dialog-message { margin-top: 5px; }
body.portal-active .portal-signal-dialog-message strong { display: block; margin-bottom: 3px; color: var(--portal-ink); font-size: 10px; letter-spacing: .05em; }
body.portal-active .portal-signal-dialog-message[data-sender='employee'] strong { color: var(--portal-ink); }
body.portal-active .portal-signal-dialog-message p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
body.portal-active .portal-signal-dialog-status { margin: 0; padding: 5px 10px; color: var(--portal-ink); font-size: 10px; }
body.portal-active .portal-signal-dialog-status:empty { display: none; }
body.portal-active .portal-signal-dialog-status[data-state='error'] { color: var(--portal-ink); }
body.portal-active .portal-signal-dialog-form { padding: 9px 10px 10px; border-top: 1px solid var(--portal-muted); }
body.portal-active .portal-signal-dialog-form label { display: block; margin-bottom: 5px; color: var(--portal-muted); font-size: 9px; letter-spacing: .08em; }
body.portal-active .portal-signal-dialog-form > div { display: flex; gap: 6px; }
body.portal-active .portal-signal-dialog-form input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--portal-muted);
  border-radius: 0;
  background: var(--portal-deep);
  color: var(--portal-ink);
  font: 16px/1.2 Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-signal-dialog-form button {
  min-width: 58px;
  padding: 5px;
  border: 1px solid var(--portal-muted);
  border-radius: 0;
  background: var(--portal-surface);
  color: var(--portal-ink);
  font: 11px Monaco, 'Lucida Console', monospace;
}
body.portal-active .portal-signal-dialog button:focus-visible,
body.portal-active .portal-signal-dialog input:focus-visible { outline: 1px dotted var(--portal-ink); outline-offset: 2px; }
@media (max-width: 600px) {
  body.portal-active .portal-signal-dialog { right: 9px; bottom: 149px; max-height: 58svh; }
  body.portal-active .portal-desktop.cortex-open .portal-signal-dialog { bottom: 94px; }
}

/* CORTEX creative responses stay in the existing document window. */
body.portal-active .cortex-source-context {
  margin: 0 0 20px;
  padding: 9px 13px;
  border-left: 2px solid var(--portal-muted);
  background: var(--portal-bg);
  color: var(--portal-ink);
}
body.portal-active .cortex-source-context small { color: var(--portal-ink); letter-spacing: .08em; }
body.portal-active .cortex-source-context blockquote {
  max-height: 14em;
  margin: 9px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.5 Monaco, 'Lucida Console', monospace;
}
body.portal-active .cortex-document audio { display: block; width: min(100%, 480px); margin: 0 0 18px; }
body.portal-active .cortex-creative-form { display: grid; gap: 16px; }
body.portal-active .cortex-creative-form label { color: var(--portal-ink); }
body.portal-active .cortex-creative-form textarea,
body.portal-active .cortex-creative-form select,
body.portal-active .cortex-document .cortex-creative-form input:not([type='radio']) {
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  border: 1px solid var(--portal-muted);
  border-radius: 0;
  background: var(--portal-bg);
  color: var(--portal-ink);
  font: 16px/1.45 Monaco, 'Lucida Console', monospace;
}
body.portal-active .cortex-creative-form textarea { min-height: 130px; resize: vertical; }
body.portal-active .cortex-creative-form .cortex-origin { max-width: 260px; font-size: 11px; }
body.portal-active .cortex-response-modes { display: flex; flex-wrap: wrap; gap: 8px 20px; border: 0; padding: 0; }
body.portal-active .cortex-response-modes legend { margin-bottom: 7px; color: var(--portal-ink); font-size: 11px; }
body.portal-active .cortex-response-modes label { display: inline-flex; align-items: center; gap: 6px; }
body.portal-active .cortex-response-actions { display: flex; flex-wrap: wrap; gap: 8px; }
body.portal-active .cortex-response-actions .portal-text-button { min-height: 38px; padding: 7px 10px; }
body.portal-active .cortex-sketch[hidden],
body.portal-active #cortex-layout-text[hidden],
body.portal-active #cortex-response-text[hidden],
body.portal-active .cortex-voice[hidden],
body.portal-active .cortex-document audio[hidden],
body.portal-active #cortex-voice-clear[hidden] { display: none; }
body.portal-active .cortex-voice { padding: 13px; border: 1px solid var(--portal-muted); background: var(--portal-bg); }
body.portal-active .cortex-voice p { margin: 0 0 10px; color: var(--portal-ink); font: 12px/1.5 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-voice-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
body.portal-active .cortex-voice-file { display: block; min-width: min(100%, 220px); font: 11px/1.4 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-document .cortex-voice-file input[type='file'] { max-width: 290px; padding: 7px; font-size: 13px; }
body.portal-active #cortex-voice-status { margin: 12px 0 8px; color: var(--portal-ink); }
body.portal-active .cortex-voice audio { margin-bottom: 0; }
body.portal-active .cortex-source-context audio { margin: 10px 0 0; }
body.portal-active .cortex-archived-voice { margin-top: 16px; color: var(--portal-ink); font: 11px/1.5 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-archived-voice audio { margin: 8px 0 0; }
body.portal-active .cortex-sketch-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 7px; margin-bottom: 8px; }
body.portal-active .cortex-sketch-tools button { min-height: 36px; padding: 6px 9px; border: 1px solid var(--portal-muted); background: var(--portal-bg); color: var(--portal-ink); font: 11px Monaco, 'Lucida Console', monospace; cursor: pointer; }
body.portal-active .cortex-sketch-tools button[aria-pressed='true'] { background: var(--portal-line); }
body.portal-active .cortex-sketch-tools #cortex-label-text { width: min(100%, 170px); margin: 0; }
body.portal-active #cortex-sketch-surface { display: block; width: 100%; max-height: 50vh; aspect-ratio: 5 / 3; border: 1px solid var(--portal-muted); background: var(--portal-bg); color: var(--portal-ink); touch-action: none; cursor: crosshair; }
body.portal-active .cortex-creative-form :focus-visible { outline: 1px dotted var(--portal-ink); outline-offset: 2px; }

/* Employee SYSTEM preferences. */
body.portal-active .portal-preferences-heading { display: flex; align-items: center; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--portal-line); }
body.portal-active .portal-preferences-heading p { margin: 0; }
body.portal-active .portal-preferences-heading h2 { margin: 2px 0 4px; border: 0; }
body.portal-active .portal-preferences-glyph { display: grid; place-items: center; flex: none; width: 56px; height: 56px; border: 2px solid var(--portal-green); box-shadow: 4px 4px 0 var(--portal-line); color: var(--portal-green); font-size: 35px; line-height: 1; }
body.portal-active .portal-preferences-form fieldset { margin: 16px 0; padding: 12px 14px 14px; }
body.portal-active .portal-preferences-form legend { padding: 0 6px; color: var(--portal-green); letter-spacing: .12em; }
body.portal-active .portal-preferences-form fieldset > p { margin: 0 0 10px; font-size: 11px; letter-spacing: .08em; }
body.portal-active .portal-theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
body.portal-active .portal-theme-choice { display: flex; align-items: center; gap: 6px; min-height: 46px; margin: 0; padding: 5px 7px; border: 1px solid var(--portal-line); cursor: pointer; font-size: 11px; }
body.portal-active .portal-theme-choice:has(input:checked) { border-color: var(--portal-green); background: color-mix(in srgb, var(--portal-green) 14%, var(--portal-deep)); }
body.portal-active .portal-theme-choice input { margin: 0; accent-color: var(--portal-green); }
body.portal-active .portal-theme-swatch { color: #12ff6c; font-size: 20px; }
body.portal-active .portal-theme-choice[data-theme='amber'] .portal-theme-swatch { color: #ffbf52; }
body.portal-active .portal-theme-choice[data-theme='blue'] .portal-theme-swatch { color: #6dc9ff; }
body.portal-active .portal-preference-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0; padding: 11px 2px; border-bottom: 1px solid var(--portal-line); cursor: pointer; }
body.portal-active .portal-preference-row:last-child { border-bottom: 0; }
body.portal-active .portal-preference-row strong, body.portal-active .portal-preference-row small { display: block; }
body.portal-active .portal-preference-row small { margin-top: 3px; color: var(--portal-muted); font-weight: normal; line-height: 1.35; }
body.portal-active .portal-preference-row input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--portal-green); }
body.portal-active .portal-preferences-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 4px 0 8px; }
body.portal-active .portal-preferences-status { color: var(--portal-muted); font-size: 11px; }
body.portal-active[data-portal-motion='reduced'] .portal-desktop *, body.portal-active[data-portal-motion='reduced'] .portal-desktop *::before, body.portal-active[data-portal-motion='reduced'] .portal-desktop *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
body.portal-active[data-portal-theme='amber'] { --portal-green: #ffbf52; --portal-ink: #fff0d0; --portal-muted: #c9a778; --portal-line: #865a2c; }
body.portal-active[data-portal-theme='blue'] { --portal-green: #6dc9ff; --portal-ink: #deefff; --portal-muted: #99b9d2; --portal-line: #34648a; }
body.portal-active[data-portal-theme='amber'] .portal-main { background: radial-gradient(ellipse at 50% 0, var(--portal-surface) 0, var(--portal-bg) 48%, var(--portal-deep) 100%); }
body.portal-active[data-portal-theme='blue'] .portal-main { background: radial-gradient(ellipse at 50% 0, var(--portal-surface) 0, var(--portal-bg) 48%, var(--portal-deep) 100%); }
body.portal-active[data-portal-theme='amber'] .portal-topbar, body.portal-active[data-portal-theme='amber'] .portal-workbar { background: var(--portal-bg); }
body.portal-active[data-portal-theme='blue'] .portal-topbar, body.portal-active[data-portal-theme='blue'] .portal-workbar { background: var(--portal-surface); }
body.portal-active[data-portal-theme='amber'] .portal-titlebar, body.portal-active[data-portal-theme='amber'] .portal-taskbar { background: var(--portal-surface); }
body.portal-active[data-portal-theme='blue'] .portal-titlebar, body.portal-active[data-portal-theme='blue'] .portal-taskbar { background: var(--portal-surface); }
@media (max-width: 600px) {
  body.portal-active .portal-theme-choices { grid-template-columns: 1fr; }
  body.portal-active .portal-preferences-glyph { width: 44px; height: 44px; font-size: 28px; }
}

/* One phosphor palette drives the entire employee desktop. */
body.portal-active {
  --portal-bg: #06120a;
  --portal-deep: #030805;
  --portal-surface: #07170d;
  --portal-raised: #10351d;
}
body.portal-active[data-portal-theme='amber'] {
  --portal-bg: #190f06;
  --portal-deep: #090603;
  --portal-surface: #241608;
  --portal-raised: #493016;
}
body.portal-active[data-portal-theme='blue'] {
  --portal-bg: #071624;
  --portal-deep: #03080e;
  --portal-surface: #102638;
  --portal-raised: #1c4261;
}
body.portal-active[data-portal-theme] { background: var(--portal-deep); }
body.portal-active[data-portal-theme] .portal-frame,
body.portal-active[data-portal-theme] .portal-main { background: var(--portal-deep); }
body.portal-active[data-portal-theme] .portal-program { background-color: var(--portal-surface); box-shadow: 0 0 24px color-mix(in srgb, var(--portal-green) 13%, transparent); }
body.portal-active[data-portal-theme] .portal-program:not([data-program='CORTEX']) { background-color: var(--portal-surface); }
body.portal-active[data-portal-theme] .portal-titlebar,
body.portal-active[data-portal-theme] .portal-taskbar,
body.portal-active[data-portal-theme] .portal-start-menu,
body.portal-active[data-portal-theme] .portal-signal-dialog { background-color: var(--portal-surface); border-color: var(--portal-line); }
body.portal-active[data-portal-theme] .portal-titlebar button,
body.portal-active[data-portal-theme] .portal-window-tab,
body.portal-active[data-portal-theme] .portal-button,
body.portal-active[data-portal-theme] .portal-start-menu button { background-color: var(--portal-raised); color: var(--portal-ink); border-color: var(--portal-line); }
body.portal-active[data-portal-theme] .portal-program h2,
body.portal-active[data-portal-theme] .portal-program legend,
body.portal-active[data-portal-theme] .portal-taskbar,
body.portal-active[data-portal-theme] .portal-start-menu { color: var(--portal-green); }
body.portal-active[data-portal-theme] .portal-pixel-icon .icon-fill,
body.portal-active[data-portal-theme] .portal-icon[data-kind='folder'] .icon-fill,
body.portal-active[data-portal-theme] .portal-start-app .portal-pixel-icon .icon-fill,
body.portal-active[data-portal-theme] .portal-window-tab .icon-fill { fill: var(--portal-green); }
body.portal-active[data-portal-theme] .portal-pixel-icon .icon-screen { fill: var(--portal-bg); }
body.portal-active[data-portal-theme] .portal-icon b { color: var(--portal-ink); text-shadow: 0 0 5px color-mix(in srgb, var(--portal-green) 65%, transparent); }
body.portal-active[data-portal-theme] .portal-icon:hover,
body.portal-active[data-portal-theme] .portal-icon:focus-visible,
body.portal-active[data-portal-theme] .portal-icon[aria-current='page'] { background-color: color-mix(in srgb, var(--portal-green) 12%, var(--portal-bg)); border-color: var(--portal-line); }
body.portal-active[data-portal-theme] .portal-signal-face canvas { filter: drop-shadow(0 2px 0 var(--portal-deep)) drop-shadow(0 0 6px color-mix(in srgb, var(--portal-green) 50%, transparent)); }
body.portal-active[data-portal-theme] #portal-assistant .portal-signal-face:focus-visible { outline-color: var(--portal-green); }
body.portal-active[data-portal-theme] #portal-home { position: relative; }
body.portal-active[data-portal-theme] #portal-home img { opacity: 0; }
body.portal-active[data-portal-theme] #portal-home::before { content: ''; position: absolute; inset: 0; width: 27px; height: 27px; margin: auto; background: var(--portal-green); mask: url('/identity.svg') center / contain no-repeat; -webkit-mask: url('/identity.svg') center / contain no-repeat; }
body.portal-active[data-portal-theme] .portal-start-heading img { filter: grayscale(1) brightness(3); }
body.portal-active[data-portal-theme] .portal-taskbar .portal-dt-digits b { color: var(--portal-green); text-shadow: 0 0 5px color-mix(in srgb, var(--portal-green) 60%, transparent); }
body.portal-active[data-portal-theme] .portal-taskbar .portal-task-status .portal-dt-digits { border-color: var(--portal-line); box-shadow: inset 2px 2px var(--portal-deep), 0 0 6px color-mix(in srgb, var(--portal-green) 20%, transparent); }
body.portal-active[data-portal-theme] .portal-signal-console,
body.portal-active[data-portal-theme] .portal-signal-empty,
body.portal-active[data-portal-theme] .portal-signal-message,
body.portal-active[data-portal-theme] .portal-signal-terminal-form #portal-assistant-prompt,
body.portal-active[data-portal-theme] .portal-signal-terminal-form input,
body.portal-active[data-portal-theme] .portal-signal-dialog,
body.portal-active[data-portal-theme] .portal-signal-dialog-message { color: var(--portal-ink); }
body.portal-active[data-portal-theme] .portal-signal-terminal-form input { caret-color: var(--portal-green); }
body.portal-active[data-portal-theme] .portal-signal-terminal-form input:focus-visible { outline-color: var(--portal-green); }
body.portal-active[data-portal-theme] .portal-signal-dialog-heading,
body.portal-active[data-portal-theme] .portal-signal-dialog-form { background: var(--portal-surface); border-color: var(--portal-line); }

/* Wallpapers use local CSS patterns and follow the chosen phosphor color. */
body.portal-active[data-portal-wallpaper] .portal-workspace { background-color: var(--portal-bg); }
body.portal-active[data-portal-wallpaper='standard'] .portal-workspace {
  background-image: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-green) 5%, transparent) 0 1px, transparent 1px 4px), radial-gradient(ellipse at 28% 23%, color-mix(in srgb, var(--portal-green) 12%, transparent), transparent 53%);
}
body.portal-active[data-portal-wallpaper='grid'] .portal-workspace {
  background-image: linear-gradient(color-mix(in srgb, var(--portal-green) 14%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--portal-green) 14%, transparent) 1px, transparent 1px), radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--portal-green) 15%, transparent), transparent 70%);
  background-size: 48px 48px, 48px 48px, auto;
}
body.portal-active[data-portal-wallpaper='stars'] .portal-workspace {
  background-image: radial-gradient(circle at 15px 24px, var(--portal-green) 1px, transparent 2px), radial-gradient(circle at 72px 96px, color-mix(in srgb, var(--portal-green) 55%, transparent) 1px, transparent 2px), radial-gradient(circle at 126px 42px, color-mix(in srgb, var(--portal-green) 38%, transparent) 1px, transparent 2px), radial-gradient(ellipse at 55% 45%, color-mix(in srgb, var(--portal-green) 10%, transparent), transparent 70%);
  background-size: 173px 139px, 211px 157px, 251px 189px, auto;
}
body.portal-active[data-portal-wallpaper='void'] .portal-workspace { background-image: none; }
body.portal-active .portal-wallpaper-label { margin-top: 18px !important; }
body.portal-active .portal-wallpaper-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
body.portal-active .portal-wallpaper-choice { display: grid; grid-template-columns: 18px 1fr; gap: 5px 4px; align-items: center; margin: 0; padding: 7px; border: 1px solid var(--portal-line); cursor: pointer; font-size: 10px; }
body.portal-active .portal-wallpaper-choice:has(input:checked) { border-color: var(--portal-green); background: color-mix(in srgb, var(--portal-green) 14%, var(--portal-bg)); }
body.portal-active .portal-wallpaper-choice input { margin: 0; accent-color: var(--portal-green); }
body.portal-active .portal-wallpaper-preview { grid-column: 1 / -1; height: 47px; border: 1px solid var(--portal-line); background-color: var(--portal-bg); }
body.portal-active .portal-wallpaper-choice[data-wallpaper='standard'] .portal-wallpaper-preview { background-image: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-green) 20%, transparent) 0 1px, transparent 1px 4px), radial-gradient(circle, color-mix(in srgb, var(--portal-green) 28%, transparent), transparent 75%); }
body.portal-active .portal-wallpaper-choice[data-wallpaper='grid'] .portal-wallpaper-preview { background-image: linear-gradient(color-mix(in srgb, var(--portal-green) 40%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--portal-green) 40%, transparent) 1px, transparent 1px); background-size: 12px 12px; }
body.portal-active .portal-wallpaper-choice[data-wallpaper='stars'] .portal-wallpaper-preview { background-image: radial-gradient(circle at 8px 12px, var(--portal-green) 1px, transparent 2px), radial-gradient(circle at 24px 31px, var(--portal-green) 1px, transparent 2px), radial-gradient(circle at 47px 16px, var(--portal-green) 1px, transparent 2px); background-size: 59px 43px; }
@media (max-width: 600px) {
  body.portal-active .portal-wallpaper-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Open CORTEX files close from the tab or the surrounding workspace. */
body.portal-active .cortex-file-close {
  position: absolute;
  z-index: 4;
  top: -32px;
  left: calc(7% + clamp(145px, 40%, 180px) + 8px);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--portal-ink);
  font: 25px/1 Monaco, 'Lucida Console', monospace;
  cursor: pointer;
}
body.portal-active .cortex-file-close:hover { color: var(--portal-ink); }
body.portal-active .cortex-file-close:focus-visible { outline: 1px dotted var(--portal-ink); outline-offset: 1px; }
body.portal-active .cortex-document-heading { margin: 10px 0 20px; }
body.portal-active .cortex-heading-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--portal-muted);
}
body.portal-active .cortex-document-heading .cortex-heading-top h2 {
  min-width: 0;
  margin: 0;
  border: 0;
}
body.portal-active .cortex-heading-credit {
  flex: none;
  padding: 3px 6px;
  border: 1px solid var(--portal-muted);
  color: var(--portal-ink);
  font: 12px/1.3 Monaco, 'Lucida Console', monospace;
  white-space: nowrap;
}
body.portal-active .portal-desktop.cortex-open #portal-assistant { z-index: 70; isolation: isolate; }
body.portal-active .portal-desktop.cortex-open #portal-assistant::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 8px;
  border-radius: 50%;
  background: var(--portal-bg);
}
@media (max-width: 600px) {
  body.portal-active .portal-desktop.cortex-open #portal-assistant::before { inset: 5px; }
}

/* Small monochrome desktop objects, with ink, paper and one shaded tone. */
body.portal-active .portal-pixel-icon .icon-paper { fill: var(--portal-ink); }
body.portal-active .portal-pixel-icon .icon-shade { fill: var(--portal-muted); }
body.portal-active .portal-pixel-icon .icon-ink { fill: var(--portal-bg); }
body.portal-active .portal-launcher .portal-icon .portal-pixel-icon {
  width: 36px;
  height: 36px;
  filter: drop-shadow(1px 1px 0 var(--portal-deep));
}

/* S!GNAL leaves his corner briefly to open CORTEX. */
body.portal-active .portal-desktop.cortex-booting #portal-assistant {
  visibility: hidden;
  pointer-events: none;
}
body.portal-active .portal-cortex-boot {
  min-height: 100%;
  gap: 11px;
  color: var(--portal-green);
}
body.portal-active .cortex-boot-face {
  width: clamp(150px, 20vw, 190px);
  aspect-ratio: 1;
  transform-origin: center;
}
body.portal-active .cortex-boot-face.is-entering {
  animation: cortex-signal-enter 260ms ease-out both;
}
body.portal-active .cortex-boot-face canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--portal-green) 32%, transparent));
}
body.portal-active .portal-cortex-boot .cortex-boot-track {
  width: min(310px, 72vw);
  height: 12px;
  margin-top: 6px;
  padding: 2px;
  border-color: var(--portal-line);
}
body.portal-active .portal-cortex-boot .cortex-boot-track i {
  width: 0;
  background: repeating-linear-gradient(90deg, var(--portal-green) 0 9px, var(--portal-bg) 9px 11px);
  animation: none;
}
body.portal-active .cortex-boot-caption {
  color: var(--portal-ink);
  font: 10px/1.4 Monaco, 'Lucida Console', monospace;
  letter-spacing: .2em;
}
@keyframes cortex-signal-enter {
  from { transform: translate(var(--boot-from-x, 0px), var(--boot-from-y, 0px)) scale(var(--boot-from-scale, .45)); }
  to { transform: translate(0, 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  body.portal-active .cortex-boot-face.is-entering { animation: none; }
}
body.portal-active[data-portal-motion='reduced'] .cortex-boot-face.is-entering { animation: none; }

/* Guided CORTEX scenes use local text art and the active phosphor color. */
body.portal-active .cortex-open-file { --cortex-accent: var(--portal-green, #9ae8ad); width: min(1120px, calc(100% - 16px)); margin-top: 38px; }
body.portal-active .cortex-open-file .cortex-document {
  min-height: 560px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid color-mix(in srgb, var(--cortex-accent) 45%, var(--portal-surface));
  background: radial-gradient(circle at 14% 9%, color-mix(in srgb, var(--cortex-accent) 11%, transparent), transparent 43%),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-ink) 1.96%, transparent) 0 1px, transparent 1px 4px), var(--portal-bg);
  box-shadow: 0 22px 55px color-mix(in srgb, var(--portal-deep) 66.67%, transparent), inset 0 0 0 1px var(--portal-bg);
}
body.portal-active .cortex-open-file .cortex-document::before { display: none; }
body.portal-active .cortex-adventure-topline, body.portal-active .cortex-adventure-step {
  display: flex; justify-content: space-between; gap: 12px;
  color: color-mix(in srgb, var(--cortex-accent) 70%, var(--portal-ink));
  font: 10px/1.5 Monaco, 'Lucida Console', monospace; letter-spacing: .16em;
}
body.portal-active .cortex-adventure-topline { padding-bottom: 13px; border-bottom: 1px dashed color-mix(in srgb, var(--cortex-accent) 37%, transparent); }
body.portal-active .cortex-open-file .cortex-document-heading { margin: 20px 0 24px; }
body.portal-active .cortex-open-file .cortex-heading-top { align-items: center; border-bottom: 0; }
body.portal-active .cortex-open-file .cortex-heading-top h2 { color: var(--portal-ink); font-size: clamp(30px, 5vw, 55px); letter-spacing: .06em; text-shadow: 0 0 20px color-mix(in srgb, var(--cortex-accent) 23%, transparent); }
body.portal-active .cortex-open-file .cortex-heading-credit { border-color: var(--cortex-accent); color: var(--cortex-accent); }
body.portal-active .cortex-adventure-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(20px, 3vw, 36px); align-items: start; }
body.portal-active .cortex-adventure-main, body.portal-active .cortex-adventure-response { min-width: 0; }
body.portal-active .cortex-guide { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 10px; align-items: start; }
body.portal-active .cortex-guide-avatar {
  display: block; width: 68px; height: 68px; padding: 8px;
  border: 1px solid var(--cortex-accent);
  background: color-mix(in srgb, var(--cortex-accent) 9%, var(--portal-bg));
  box-shadow: 4px 4px 0 var(--portal-deep), 0 0 18px color-mix(in srgb, var(--cortex-accent) 16%, transparent);
  color: var(--cortex-accent); image-rendering: pixelated;
}
body.portal-active .cortex-guide-speech { position: relative; min-height: 92px; padding: 13px 15px; border: 1px solid color-mix(in srgb, var(--cortex-accent) 55%, var(--portal-surface)); background: var(--portal-bg); }
body.portal-active .cortex-guide-speech::before { content: ''; position: absolute; left: -6px; top: 22px; width: 9px; height: 9px; border-left: 1px solid var(--cortex-accent); border-bottom: 1px solid var(--cortex-accent); background: var(--portal-bg); transform: rotate(45deg); }
body.portal-active .cortex-guide-name { color: var(--cortex-accent); font: bold 11px/1.4 Monaco, 'Lucida Console', monospace; letter-spacing: .13em; }
body.portal-active .cortex-guide-name small { color: var(--portal-muted); font-size: 9px; font-weight: normal; }
body.portal-active .cortex-guide-speech p { margin: 9px 0 0; color: var(--portal-ink); font: 15px/1.55 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-scene { position: relative; margin-top: 22px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--cortex-accent) 44%, var(--portal-surface)); background: var(--portal-deep); }
body.portal-active .cortex-scene::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(transparent 0 48%, color-mix(in srgb, var(--cortex-accent) 7%, transparent) 50%, transparent 52%); background-size: 100% 140px; animation: cortex-scene-scan 8s linear infinite; }
body.portal-active .cortex-scene-caption { display: block; padding: 9px 12px; border-bottom: 1px solid var(--portal-line); color: var(--portal-ink); font: 9px/1.4 Monaco, 'Lucida Console', monospace; letter-spacing: .16em; }
body.portal-active .cortex-scene .portal-ascii { margin: 0; padding: 20px 12px; border: 0; color: var(--cortex-accent); text-align: center; text-shadow: 0 0 11px color-mix(in srgb, var(--cortex-accent) 45%, transparent); }
body.portal-active .cortex-door-scene .portal-ascii { font-size: clamp(10px, 1.1vw, 15px); line-height: 1.12; }
body.portal-active .cortex-door-scene.is-opening .portal-ascii { animation: cortex-door-awaken 600ms steps(4, end); }
body.portal-active .cortex-adventure-response { padding: 15px; border: 1px solid color-mix(in srgb, var(--cortex-accent) 38%, var(--portal-surface)); background: var(--portal-bg); box-shadow: 5px 5px 0 var(--portal-deep); }
body.portal-active .cortex-adventure-step { margin: 0 0 16px; padding-bottom: 11px; border-bottom: 1px solid var(--portal-line); }
body.portal-active .cortex-adventure-response form { display: grid; gap: 16px; }
body.portal-active .cortex-adventure-response form fieldset { min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--portal-line); }
body.portal-active .cortex-adventure-response form legend { padding: 0 7px; color: var(--portal-ink); font: 11px/1.4 Monaco, 'Lucida Console', monospace; letter-spacing: .08em; }
body.portal-active .cortex-adventure-response form > fieldset:not(.cortex-response-modes):not(.cortex-door-choices) label { display: inline-flex; align-items: center; gap: 7px; margin: 4px; padding: 9px 12px; border: 1px solid var(--portal-muted); cursor: pointer; }
body.portal-active .cortex-adventure-response form > fieldset:not(.cortex-response-modes):not(.cortex-door-choices) label:has(input:checked) { border-color: var(--cortex-accent); background: color-mix(in srgb, var(--cortex-accent) 18%, var(--portal-bg)); }
body.portal-active .cortex-adventure-response form > label { display: grid; gap: 7px; color: var(--portal-ink); font: 11px/1.4 Monaco, 'Lucida Console', monospace; letter-spacing: .04em; }
body.portal-active .cortex-adventure-response form input:not([type='radio']) { max-width: none; background: var(--portal-bg); color: var(--portal-ink); }
body.portal-active .cortex-adventure-response form .portal-button { min-height: 46px; border-color: var(--cortex-accent); background: color-mix(in srgb, var(--cortex-accent) 20%, var(--portal-bg)); color: var(--portal-ink); letter-spacing: .12em; }
body.portal-active .cortex-adventure-response form .portal-button:hover { background: color-mix(in srgb, var(--cortex-accent) 34%, var(--portal-bg)); }
body.portal-active .cortex-door-followup { display: grid; gap: 16px; padding-top: 16px; border-top: 1px dashed var(--portal-line); animation: cortex-followup-reveal 300ms ease-out both; }
body.portal-active .cortex-door-followup[hidden] { display: none; }
body.portal-active .cortex-door-followup > label { display: grid; gap: 7px; color: var(--portal-ink); font: 11px/1.4 Monaco, 'Lucida Console', monospace; }
body.portal-active .cortex-door-followup > label input { width: 100%; }
body.portal-active .cortex-door-choices { border: 0 !important; padding: 0 !important; }
body.portal-active .cortex-door-choices legend { padding: 0 0 8px; }
body.portal-active .cortex-door-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body.portal-active .cortex-door-option { position: relative; display: block; min-width: 0; cursor: pointer; }
body.portal-active .cortex-door-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
body.portal-active .cortex-door-art { display: block; min-height: 196px; overflow: hidden; border: 1px solid var(--portal-line); background: radial-gradient(circle at 50% 42%, var(--portal-surface), var(--portal-deep) 72%); color: var(--cortex-accent); transition: transform 260ms ease, box-shadow 260ms ease, border-color 260ms ease; }
body.portal-active .cortex-door-art pre { width: max-content; margin: 17px auto 10px; font: clamp(9px, .95vw, 12px)/1.12 Monaco, 'Lucida Console', monospace; letter-spacing: 0; text-shadow: 0 0 10px color-mix(in srgb, var(--cortex-accent) 60%, transparent); }
body.portal-active .cortex-door-label { display: flex; justify-content: space-between; gap: 4px; padding: 9px 4px; color: var(--portal-ink); font: bold 11px/1.4 Monaco, 'Lucida Console', monospace; letter-spacing: .08em; }
body.portal-active .cortex-door-label span { color: var(--portal-muted); font-size: 9px; font-weight: normal; }
body.portal-active .cortex-door-option:hover .cortex-door-art, body.portal-active .cortex-door-option input:focus-visible + .cortex-door-art { transform: translateY(-4px); border-color: var(--cortex-accent); box-shadow: 0 0 21px color-mix(in srgb, var(--cortex-accent) 22%, transparent); }
body.portal-active .cortex-door-option input:focus-visible + .cortex-door-art { outline: 2px solid var(--portal-ink); outline-offset: 2px; }
body.portal-active .cortex-door-option input:checked + .cortex-door-art { transform: perspective(500px) rotateY(-10deg); border-color: var(--cortex-accent); background: radial-gradient(circle at 70% 45%, color-mix(in srgb, var(--cortex-accent) 40%, var(--portal-bg)), var(--portal-deep) 74%); box-shadow: inset -12px 0 18px var(--portal-deep), 0 0 24px color-mix(in srgb, var(--cortex-accent) 26%, transparent); }
body.portal-active .cortex-door-option input:checked ~ .cortex-door-label, body.portal-active .cortex-door-option input:checked ~ .cortex-door-label span { color: var(--cortex-accent); }
@keyframes cortex-scene-scan { to { background-position: 0 140px; } }
@keyframes cortex-door-awaken { 0%, 100% { opacity: 1; } 25% { opacity: .45; } 50% { opacity: .9; } 75% { opacity: .65; } }
@keyframes cortex-followup-reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 820px) { body.portal-active .cortex-adventure-layout { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
  body.portal-active .cortex-open-file { width: calc(100% - 10px); }
  body.portal-active .cortex-guide { grid-template-columns: 52px minmax(0, 1fr); }
  body.portal-active .cortex-guide-avatar { width: 52px; height: 52px; padding: 6px; }
  body.portal-active .cortex-guide-speech { min-height: 0; }
  body.portal-active .cortex-guide-speech p { font-size: 13px; }
  body.portal-active .cortex-door-art pre { font-size: clamp(8px, 2vw, 11px); }
}
@media (max-width: 390px) { body.portal-active .cortex-door-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  body.portal-active .cortex-scene::after { animation: none; }
  body.portal-active .cortex-door-scene.is-opening .portal-ascii { animation: none; }
  body.portal-active .cortex-door-art { transition: none; }
  body.portal-active .cortex-door-followup { animation: none; }
}
body.portal-active[data-portal-motion='reduced'] .cortex-scene::after { animation: none; }
body.portal-active[data-portal-motion='reduced'] .cortex-door-scene.is-opening .portal-ascii { animation: none; }
body.portal-active[data-portal-motion='reduced'] .cortex-door-art { transition: none; }
body.portal-active[data-portal-motion='reduced'] .cortex-door-followup { animation: none; }

/* CORTEX: a collection of quiet conversations with S!GNAL. */
body.portal-active .cortex-connections { width: min(940px, 100%); margin: 0 auto; }
body.portal-active .cortex-presence { display: grid; justify-items: center; text-align: center; gap: 16px; padding: 44px 16px 48px; }
body.portal-active .cortex-presence h2 { max-width: 620px; margin: 0; font-size: clamp(22px, 3vw, 32px); font-weight: normal; line-height: 1.5; }
body.portal-active .cortex-presence p { margin: 0; opacity: .72; }
body.portal-active .cortex-presence .cortex-guide-avatar,
body.portal-active .cortex-conversation .cortex-guide-avatar { width: 144px; height: 144px; border: 0; background: transparent; box-shadow: none; image-rendering: pixelated; filter: drop-shadow(0 0 24px color-mix(in srgb, var(--portal-green) 20%, transparent)); }
body.portal-active .portal-desktop.cortex-open #portal-assistant { visibility: visible; }
body.portal-active .cortex-conversation .cortex-file-close { left: auto; right: 12px; top: 0; border: 0; background: transparent; }
body.portal-active .cortex-connections .cortex-archive-heading { border: 0; opacity: .7; }
body.portal-active #cortex-list.cortex-moment-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; height: auto !important; padding: 12px 0 40px; }
body.portal-active .cortex-moment { position: relative; display: flex; align-items: flex-start; min-height: 164px; padding: 45px 20px 30px; text-align: left; color: var(--portal-ink); background: transparent; border: 0; border-radius: 0; cursor: pointer; font: inherit; }
body.portal-active .cortex-folder-shape { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
body.portal-active .cortex-folder-shape path { fill: var(--portal-bg); stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; }
body.portal-active .cortex-folder-shape path + path { fill: none; }
body.portal-active .cortex-moment .cortex-folder-number { position: absolute; top: 6%; left: 11%; font-size: 11px; letter-spacing: .04em; opacity: 1; }
body.portal-active .cortex-moment strong { position: relative; font-weight: normal; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
body.portal-active .cortex-moment .cortex-folder-state { position: absolute; right: 14px; bottom: 11px; font-size: 13px; opacity: 1; }
body.portal-active .cortex-moment[data-state="recorded"] .cortex-folder-shape path { fill: var(--portal-surface); }
body.portal-active .cortex-moment:hover,
body.portal-active .cortex-moment:focus-visible { color: var(--portal-ink); background: transparent; outline: 2px solid var(--portal-green); outline-offset: 3px; }
body.portal-active .cortex-moment[data-locked] { opacity: .55; }
body.portal-active .cortex-conversation { width: min(860px, 100%); margin: 20px auto 50px; border: 0; background: transparent; box-shadow: none; animation: none; }
body.portal-active .cortex-conversation .cortex-document { padding: 36px 24px; border: 0; background: transparent; box-shadow: none; }
body.portal-active .cortex-conversation .cortex-document::before,
body.portal-active .cortex-conversation .cortex-guide-speech::before { display: none; }
body.portal-active .cortex-conversation .cortex-heading-top { justify-content: center; }
body.portal-active .cortex-conversation .cortex-heading-top h2 { font-size: 12px; font-weight: normal; opacity: .6; letter-spacing: .2em; }
body.portal-active .cortex-conversation .cortex-adventure-layout { display: block; }
body.portal-active .cortex-conversation .cortex-guide { display: grid; grid-template-columns: 1fr; justify-items: center; gap: 24px; text-align: center; margin: 20px auto 32px; }
body.portal-active .cortex-conversation .cortex-guide-speech { max-width: 650px; border: 0; padding: 0; background: transparent; }
body.portal-active .cortex-conversation #cortex-guide-line { font-size: clamp(20px, 3vw, 28px); line-height: 1.6; }
body.portal-active .cortex-readiness { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; }
body.portal-active .cortex-conversation .cortex-adventure-response { max-width: 620px; margin: 36px auto 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
body.portal-active .cortex-conversation .cortex-adventure-step { border: 0; opacity: .6; }
body.portal-active .cortex-conversation .cortex-adventure-step > span:last-child { display: none; }
body.portal-active .cortex-conversation .cortex-scene { border: 0; background: transparent; text-align: center; }
body.portal-active .cortex-conversation .cortex-scene-caption { display: none; }
body.portal-active .cortex-conversation .cortex-response-modes,
body.portal-active .cortex-conversation .cortex-door-choices { border: 0; background: transparent; }
body.portal-active .cortex-conversation #opportunity-form input,
body.portal-active .cortex-conversation #opportunity-form textarea,
body.portal-active .cortex-conversation #opportunity-form select { font-size: 16px; }
body.portal-active .cortex-conversation [hidden] { display: none !important; }
body.portal-active .cortex-sound-choice { width: min(520px, 100%); margin: clamp(24px, 10vh, 100px) auto; padding: clamp(20px, 4vw, 32px); border: 1px solid var(--portal-line); background: var(--portal-surface); color: var(--portal-ink); font: 16px/1.6 monospace; box-sizing: border-box; }
body.portal-active .cortex-sound-choice h2 { margin: 16px 0; font: bold 24px/1.3 monospace; }
body.portal-active .cortex-sound-choice p { margin: 16px 0; }
body.portal-active .cortex-sound-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0; }
body.portal-active .cortex-sound-actions .portal-button { flex: 1 1 180px; min-height: 44px; white-space: normal; }
body.portal-active .cortex-sound-choice .cortex-sound-status { margin-bottom: 0; }
body.portal-active #cortex-listen { width: 30px; height: 30px; font-size: 22px; text-decoration: none; }
body.portal-active #cortex-listen:disabled { opacity: .35; }
body.portal-active .cortex-sound-toggle { display: grid; place-items: center; }
body.portal-active .cortex-sound-toggle[hidden] { display: none; }
body.portal-active .cortex-speaker-row { display: flex; align-items: center; gap: 10px; }
body.portal-active .cortex-speaker-row .cortex-guide-name { margin: 0; }
body.portal-active .cortex-speaker-row #cortex-listen { margin: 0; flex: 0 0 30px; }
body.portal-active .cortex-conversation { width: min(980px, 100%); border: 1px solid currentColor; background: color-mix(in srgb, var(--portal-bg) 90.98%, transparent); box-shadow: inset 0 0 45px color-mix(in srgb, var(--portal-deep) 53.33%, transparent); }
body.portal-active .cortex-conversation .cortex-document { padding: 0 24px 28px; }
body.portal-active .cortex-conversation .cortex-document-heading { margin: 0 -24px 24px; padding: 14px 48px 14px 18px; border-bottom: 1px solid color-mix(in srgb, var(--portal-green) 37.65%, transparent); background: color-mix(in srgb, var(--portal-green) 4.31%, transparent); }
body.portal-active .cortex-conversation .cortex-heading-top { justify-content: flex-start; }
body.portal-active .cortex-conversation .cortex-heading-top h2::before { content: 'CORTEX > '; }
body.portal-active .cortex-conversation .cortex-guide { grid-template-columns: 120px minmax(0, 1fr); align-items: start; text-align: left; justify-items: stretch; }
body.portal-active .cortex-conversation .cortex-guide-avatar { width: 112px; height: 112px; }
body.portal-active .cortex-conversation .cortex-guide-speech { text-align: left; width: 100%; }
body.portal-active .cortex-conversation #cortex-guide-line { font: 16px/1.7 monospace; min-height: 5em; white-space: pre-wrap; }
body.portal-active .cortex-conversation .cortex-guide-name::before { content: '> '; }
body.portal-active .cortex-terminal-history p { font: 14px/1.6 monospace; opacity: .55; margin: 0 0 20px; white-space: pre-wrap; }
body.portal-active #cortex-guide-line.is-typing::after { content: '▌'; margin-left: 2px; }
body.portal-active .cortex-conversation .cortex-adventure-response { border-top: 1px dashed color-mix(in srgb, var(--portal-green) 31.37%, transparent); padding-top: 20px; }
@media (max-width: 600px) {
  body.portal-active .cortex-conversation .cortex-guide { grid-template-columns: 1fr; gap: 18px; }
  body.portal-active .cortex-conversation .cortex-guide-avatar { justify-self: center; }
  body.portal-active .cortex-conversation .cortex-document-heading { margin-left: -12px; margin-right: -12px; }
}
@media (max-width: 600px) {
  body.portal-active #cortex-list.cortex-moment-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  body.portal-active .cortex-moment { padding: 35px 10px 28px; min-height: 140px; }
  body.portal-active .cortex-moment strong { font-size: 13px; }
  body.portal-active .cortex-moment .cortex-folder-number { font-size: 9px; }
  body.portal-active .cortex-conversation .cortex-document { padding: 32px 12px; }
}
@media (prefers-reduced-motion: reduce) { body.portal-active .cortex-moment { transition: none; } }
body.portal-active[data-portal-motion='reduced'] .cortex-moment { transition: none; }
body.portal-active .cortex-sound-library { padding: 24px 0 40px; border-top: 1px solid color-mix(in srgb, var(--portal-green) 15.69%, transparent); }
body.portal-active .cortex-sound-library summary { cursor: pointer; letter-spacing: .12em; font-size: 12px; }
body.portal-active .cortex-sound-library p { color: var(--portal-muted); font-size: 13px; line-height: 1.6; }
body.portal-active .cortex-sound-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
body.portal-active .cortex-mood { display: grid; gap: 12px; padding: 18px; color: var(--portal-ink); border: 1px solid color-mix(in srgb, var(--portal-green) 15.69%, transparent); background: color-mix(in srgb, var(--portal-green) 3.14%, transparent); font: inherit; text-align: left; cursor: pointer; }
body.portal-active .cortex-mood strong { font-weight: normal; }
body.portal-active .cortex-mood span { font-size: 12px; line-height: 1.5; opacity: .7; }
body.portal-active .cortex-mood:focus-visible { outline: 2px solid var(--portal-green); outline-offset: 3px; }
@media (max-width: 600px) { body.portal-active .cortex-sound-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
body.portal-active .cortex-conversation { position: relative; margin-top: 56px; border-color: var(--portal-ink); }
body.portal-active .cortex-conversation .cortex-document-heading { position: absolute; top: -31px; left: -1px; margin: 0; padding: 7px 25px 7px 14px; max-width: calc(100% - 40px); height: 31px; border: 1px solid var(--portal-ink); border-bottom: 0; background: var(--portal-bg); clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 100%, 0 100%); }
body.portal-active .cortex-conversation .cortex-heading-top h2 { margin: 0; font: 11px/16px monospace; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.portal-active .cortex-conversation .cortex-heading-top h2::before { content: none; }
body.portal-active .cortex-conversation .cortex-document { min-height: 0; height: auto; padding: 26px 20px 24px; }
body.portal-active .cortex-conversation .cortex-guide { grid-template-columns: 64px minmax(0, 1fr); gap: 18px; margin: 0 0 18px; align-items: start; }
body.portal-active .cortex-conversation .cortex-guide-avatar { width: 64px; height: 64px; justify-self: start; }
body.portal-active .cortex-conversation .cortex-speaker-row { display: inline-flex; gap: 6px; align-items: center; min-height: 24px; }
body.portal-active .cortex-conversation .cortex-guide-name { display: inline; font: 12px/24px monospace; letter-spacing: .05em; }
body.portal-active .cortex-conversation .cortex-speaker-row #cortex-listen { width: 24px; height: 24px; min-height: 0; padding: 0; font: 18px/24px monospace; flex-basis: 24px; border: 0; background: transparent; box-shadow: none; }
body.portal-active .cortex-conversation #cortex-guide-line { min-height: 0; margin: 8px 0 0; font: 15px/1.6 monospace; }
body.portal-active .cortex-conversation #cortex-speech-status:empty { display: none; }
body.portal-active .cortex-conversation .cortex-adventure-layout { display: block; }
body.portal-active .cortex-conversation .cortex-adventure-step { display: none; }
body.portal-active .cortex-conversation .cortex-adventure-response { margin-top: 18px; padding-top: 18px; }
body.portal-active .cortex-conversation .cortex-terminal-reply { opacity: 1; color: var(--portal-ink); }
body.portal-active .cortex-conversation .cortex-scene { margin-top: 18px; }
body.portal-active .cortex-conversation { margin: 38px auto 24px; }
body.portal-active .cortex-conversation .cortex-file-close { top: -34px; right: 0; width: 28px; height: 28px; padding: 0; font: 24px/28px monospace; }
body.portal-active .cortex-conversation .cortex-document { padding: 16px 16px 18px; }
body.portal-active .cortex-conversation .cortex-guide { gap: 12px; margin-bottom: 10px; grid-template-columns: 48px minmax(0, 1fr); }
body.portal-active .cortex-conversation .cortex-guide-avatar { width: 48px; height: 48px; }
body.portal-active .cortex-conversation .cortex-adventure-response { margin-top: 10px; padding-top: 10px; border-top: 0; }
body.portal-active .cortex-conversation form { margin-top: 0; gap: 10px; }
body.portal-active .cortex-conversation form label { gap: 5px; font: 13px/1.4 monospace; }
body.portal-active .cortex-conversation textarea { min-height: 90px; height: 110px; padding: 8px 10px; font: 16px/1.4 monospace; border: 1px solid var(--portal-muted); background: var(--portal-bg); color: var(--portal-ink); border-radius: 0; }
body.portal-active .cortex-conversation form input:not([type='radio']),
body.portal-active .cortex-conversation form select { min-height: 34px; padding: 5px 8px; font: 16px/1.4 monospace; }
body.portal-active .cortex-conversation .cortex-turn-actions,
body.portal-active .cortex-conversation .cortex-response-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
body.portal-active .cortex-conversation .portal-button,
body.portal-active .cortex-conversation .portal-text-button { min-height: 32px; padding: 5px 9px; border: 1px solid var(--portal-muted); background: transparent; color: var(--portal-ink); box-shadow: none; border-radius: 0; text-decoration: none; font: 12px/1.4 monospace; }
body.portal-active .cortex-conversation .cortex-turn-actions .portal-text-button { border: 0; padding: 5px 3px; }
body.portal-active .cortex-conversation .cortex-followup-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 24px 0 18px; }
body.portal-active .cortex-conversation .cortex-followup-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-width: 0; min-height: 128px; padding: clamp(10px, 2vw, 18px); border: 2px solid var(--portal-green); border-right-color: var(--portal-muted); border-bottom-color: var(--portal-muted); background: var(--portal-raised); box-shadow: 3px 3px 0 var(--portal-deep), inset 1px 1px 0 color-mix(in srgb, var(--portal-ink) 35%, transparent); text-align: center; white-space: normal; cursor: pointer; }
body.portal-active .cortex-followup-label { font: bold clamp(12px, 2.8vw, 14px)/1.35 monospace; }
body.portal-active .cortex-followup-reward { color: var(--portal-green); font: bold clamp(22px, 5vw, 30px)/1.15 monospace; }
body.portal-active .cortex-followup-multiplier { color: var(--portal-ink); font: 11px/1.4 monospace; letter-spacing: .02em; }
body.portal-active .cortex-conversation .cortex-followup-button:hover { background: color-mix(in srgb, var(--portal-green) 15%, var(--portal-bg)); }
body.portal-active .cortex-conversation .cortex-followup-button:focus-visible { outline: 2px solid var(--portal-green); outline-offset: 4px; }
body.portal-active .cortex-conversation .cortex-followup-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--portal-deep), inset 1px 1px 0 var(--portal-muted); }
body.portal-active .cortex-conversation .cortex-voice-response { padding: 8px 0; margin: 0; }
body.portal-active .cortex-conversation .cortex-voice { padding: 10px 0; margin: 0; background: transparent; border: 0; }
body.portal-active .cortex-recorder-head { display: flex; justify-content: space-between; gap: 12px; font: 10px/1.4 monospace; letter-spacing: .08em; opacity: .8; }
body.portal-active #cortex-voice-wave { display: block; width: 100%; height: 64px; margin: 8px 0; border-top: 1px solid color-mix(in srgb, var(--portal-muted) 31.37%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--portal-muted) 31.37%, transparent); }
body.portal-active .cortex-conversation .cortex-voice-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
body.portal-active #cortex-voice-status { margin: 8px 0; font: 11px/1.5 monospace; }
body.portal-active #cortex-voice-preview { width: 100%; height: 34px; margin-top: 8px; color-scheme: dark; }
body.portal-active .cortex-record-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
body.portal-active .cortex-record-row #cortex-voice-record { flex: 0 0 36px; width: 36px; height: 36px; min-height: 0; padding: 0; font: 22px/36px monospace; }
body.portal-active .cortex-record-row #cortex-voice-wave { flex: 1; min-width: 0; width: 0; height: 48px; margin: 0; }
body.portal-active .cortex-record-row #cortex-take-play { flex: 0 0 30px; width: 30px; height: 36px; padding: 0; font: 18px/36px monospace; border: 0; }
body.portal-active #cortex-voice-wave[role='slider'] { cursor: pointer; }
body.portal-active #cortex-replace-take { padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--portal-muted) 31.37%, transparent); font: 12px/1.5 monospace; }
body.portal-active .cortex-conversation .cortex-guide { row-gap: 8px; }
body.portal-active .cortex-conversation .cortex-guide-speech { display: contents; }
body.portal-active .cortex-conversation .cortex-guide-avatar { grid-column: 1; grid-row: 1; }
body.portal-active .cortex-conversation .cortex-speaker-row { grid-column: 2; grid-row: 1; align-self: center; }
body.portal-active .cortex-conversation .cortex-terminal-history,
body.portal-active .cortex-conversation #cortex-guide-line,
body.portal-active .cortex-conversation #cortex-speech-status { grid-column: 1 / -1; margin-left: 0; }
body.portal-active .cortex-conversation .cortex-terminal-history:empty { display: none; }
body.portal-active .cortex-conversation .cortex-guide { grid-auto-rows: min-content; align-content: start; row-gap: 6px; margin-bottom: 4px; }
body.portal-active .cortex-conversation .cortex-terminal-history { margin: 0; padding: 0; }
body.portal-active .cortex-conversation .cortex-terminal-history p { margin: 0 0 6px; font: 14px/1.5 monospace; }
body.portal-active .cortex-conversation .cortex-terminal-screen { grid-column: 1 / -1; min-width: 0; min-height: 110px; max-height: clamp(180px, 38svh, 360px); padding: 16px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--portal-muted) var(--portal-deep); scrollbar-gutter: stable; border: 1px solid var(--portal-line); border-radius: 5px; background-color: var(--portal-bg); background-image: repeating-linear-gradient(to bottom, transparent 0 2px, color-mix(in srgb, var(--portal-deep) 20%, transparent) 2px 3px), radial-gradient(ellipse at center, color-mix(in srgb, var(--portal-green) 5%, transparent), transparent 75%); box-shadow: inset 0 2px 8px var(--portal-deep), inset 0 0 28px color-mix(in srgb, var(--portal-deep) 65%, transparent); overflow-wrap: anywhere; text-shadow: 0 0 8px color-mix(in srgb, var(--portal-green) 18%, transparent); }
body.portal-active .cortex-conversation .cortex-terminal-screen:focus-visible { outline: 1px solid var(--portal-green); outline-offset: 2px; }
body.portal-active .cortex-conversation .cortex-terminal-screen .cortex-terminal-history p { margin-bottom: 12px; }
@media (max-width: 480px) {
  body.portal-active .cortex-conversation .cortex-terminal-screen { padding: 12px; }
}
body.portal-active .cortex-conversation #cortex-guide-line { margin: 0; padding: 0; min-height: 0; }
body.portal-active .cortex-conversation .cortex-adventure-response { margin: 4px 0 0; padding: 0; max-width: none; }
body.portal-active .cortex-conversation .cortex-turn-actions { margin: 0; align-items: center; gap: 10px; }
body.portal-active .cortex-conversation .cortex-turn-actions::before { content: '>'; color: var(--portal-ink); font: 16px/1 monospace; animation: cortex-input-cursor 1.2s steps(1, end) infinite; }
@keyframes cortex-input-cursor { 0%, 55% { opacity: 1; } 56%, 100% { opacity: .15; } }
body.portal-active .cortex-turn-actions:focus-within::before { visibility: hidden; }
body.portal-active .cortex-turn-actions button { position: relative; }
body.portal-active .cortex-turn-actions button:focus::before { content: '>'; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); animation: cortex-input-cursor 1.2s steps(1, end) infinite; }
body.portal-active .cortex-turn-actions button:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }
body.portal-active[data-portal-motion='reduced'] .cortex-turn-actions button:focus::before { animation: none; }
@media (prefers-reduced-motion: reduce) { body.portal-active .cortex-turn-actions button:focus::before { animation: none; } }
body.portal-active[data-portal-motion='reduced'] .cortex-turn-actions::before { animation: none; }
@media (prefers-reduced-motion: reduce) { body.portal-active .cortex-turn-actions::before { animation: none; } }
body.portal-active .cortex-record-row #cortex-voice-record { display: grid; place-items: center; font-size: 0; line-height: 1; }
body.portal-active .cortex-record-row #cortex-voice-record::before { content: ''; display: block; width: 13px; height: 13px; border-radius: 50%; background: currentColor; }
body.portal-active .cortex-record-row #cortex-voice-record[aria-label='Stop recording']::before { border-radius: 0; }
body.portal-active .cortex-record-row #cortex-voice-record[aria-label='Cancel microphone request']::before { border-radius: 0; clip-path: polygon(0 15%, 15% 0, 50% 35%, 85% 0, 100% 15%, 65% 50%, 100% 85%, 85% 100%, 50% 65%, 15% 100%, 0 85%, 35% 50%); }
body.portal-active .cortex-record-row #cortex-voice-record { position: relative; }
body.portal-active .cortex-record-row #cortex-voice-record::before { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
body.portal-active .cortex-record-row #cortex-voice-record[aria-label='Stop recording']::before { animation: cortex-recording-pulse 1.2s ease-in-out infinite; }
@keyframes cortex-recording-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
body.portal-active[data-portal-motion='reduced'] .cortex-record-row #cortex-voice-record[aria-label='Stop recording']::before { animation: none; }
@media (prefers-reduced-motion: reduce) { body.portal-active .cortex-record-row #cortex-voice-record[aria-label='Stop recording']::before { animation: none; } }
body.portal-active .cortex-conversation .cortex-terminal-history { max-height: none; overflow: visible; }
body.portal-active .cortex-conversation #cortex-guide-line:empty { display: none; }
body.portal-active .cortex-conversation .is-retiring { opacity: 0; transition: opacity 240ms ease-out; pointer-events: none; }
body.portal-active .cortex-conversation .is-current-input { animation: cortex-input-arrive 220ms ease-out; }
body.portal-active .cortex-terminal-history { max-height: 110px; overflow-y: auto; margin-bottom: 14px; }
@keyframes cortex-input-arrive { from { opacity: 0; } to { opacity: 1; } }
body.portal-active[data-portal-motion='reduced'] .cortex-conversation .is-retiring { transition: none; }
body.portal-active[data-portal-motion='reduced'] .cortex-conversation .is-current-input { animation: none; }
@media (prefers-reduced-motion: reduce) { body.portal-active .cortex-conversation .is-retiring { transition: none; } body.portal-active .cortex-conversation .is-current-input { animation: none; } }
/* Authenticated task credits: the amount comes from the server ledger. */
body.portal-active .cortex-credit { position: relative; isolation: isolate; overflow: hidden; display: grid; justify-items: center; gap: 12px; margin: 24px 0; padding: 30px clamp(16px, 4vw, 32px) 24px; border: 1px solid var(--portal-green); background: color-mix(in srgb, var(--portal-green) 8%, var(--portal-bg)); box-shadow: inset 0 0 36px color-mix(in srgb, var(--portal-green) 7%, transparent); text-align: center; font: 12px/1.5 monospace; }
body.portal-active .cortex-credit > :not(.cortex-credit-confetti) { position: relative; z-index: 1; }
body.portal-active .cortex-credit-heading { color: var(--portal-ink); font: bold 13px/1.5 monospace; letter-spacing: .12em; }
body.portal-active .cortex-credit-heading::before { content: '[ + ]'; margin-right: 10px; color: var(--portal-green); }
body.portal-active .cortex-credit-award { color: var(--portal-green); font: bold clamp(42px, 7vw, 68px)/1.1 monospace; text-shadow: 0 0 24px color-mix(in srgb, var(--portal-green) 35%, transparent); }
body.portal-active .cortex-credit-award small { font-size: .5em; }
body.portal-active .cortex-credit-remaining { color: var(--portal-ink); font-size: 12px; }
body.portal-active .cortex-credit-track { width: 100%; height: 4px; margin-top: 4px; background: var(--portal-raised); overflow: hidden; }
body.portal-active .cortex-credit-track i { display: block; height: 100%; background: var(--portal-green); transform-origin: left; }
body.portal-active .cortex-credit.is-celebrating .cortex-credit-award { animation: cortex-credit-arrive 550ms cubic-bezier(.2,.8,.3,1) both; }
body.portal-active .cortex-credit.is-celebrating .cortex-credit-track i { animation: cortex-credit-fill 1s ease-out both; }
body.portal-active .cortex-credit-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
body.portal-active .cortex-credit-confetti i { position: absolute; left: 50%; top: 48%; width: 6px; height: 6px; background: var(--portal-green); opacity: 0; animation: cortex-credit-burst 1200ms var(--burst-delay) ease-out both; }
body.portal-active .cortex-credit-confetti i:nth-child(3n) { width: 4px; height: 10px; background: var(--portal-ink); }
body.portal-active .cortex-credit-confetti i:nth-child(4n) { background: transparent; border: 1px solid var(--portal-green); }
@keyframes cortex-credit-arrive { 0% { opacity: .3; transform: scale(.78); } 65% { opacity: 1; transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes cortex-credit-burst { 0% { opacity: 0; transform: translate(0, 0) rotate(0); } 12% { opacity: 1; } 48% { opacity: 1; transform: translate(calc(var(--burst-x) * .75), var(--burst-y)) rotate(calc(var(--burst-spin) * .5)); } 100% { opacity: 0; transform: translate(var(--burst-x), var(--burst-fall)) rotate(var(--burst-spin)); } }
@keyframes cortex-credit-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
body.portal-active[data-portal-motion='reduced'] .cortex-credit-confetti { display: none; }
body.portal-active[data-portal-motion='reduced'] .cortex-credit.is-celebrating :is(.cortex-credit-award, .cortex-credit-track i) { animation: none; }
@media (prefers-reduced-motion: reduce) { body.portal-active .cortex-credit-confetti { display: none; } body.portal-active .cortex-credit.is-celebrating :is(.cortex-credit-award, .cortex-credit-track i) { animation: none; } }
.cortex-home-chat { margin: .75rem 0 1.15rem; padding: .65rem; border: 1px solid #71977a; background: #06110b; box-shadow: 3px 3px 0 #203729; text-align: left; }
.cortex-terminal-title { display: flex; justify-content: space-between; margin: -.65rem -.65rem .6rem; padding: .35rem .65rem; border-bottom: 1px solid #71977a; background: #183020; font-size: .7rem; letter-spacing: .08em; }
.cortex-home-chat #cortex-chat-replay { margin-left: auto; padding: .25rem .5rem; }
.cortex-home-chat .cortex-speaker-row { display: flex; align-items: center; gap: .65rem; margin-bottom: .45rem; }
.cortex-home-chat .cortex-guide-avatar { width: 40px; height: 40px; flex: 0 0 40px; }
#cortex-chat-log { max-height: 8rem; overflow-y: auto; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }
.cortex-home-chat .cortex-guide-name, #cortex-chat-form button { font-size: 13px; }
#cortex-chat-log p { margin: .3rem 0; }
#cortex-chat-form { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
#cortex-chat-form input { flex: 1; min-width: 0; border: 0; border-bottom: 1px solid #42604a; background: transparent; color: inherit; font: inherit; font-size: 13px; padding: .4rem .2rem; border-radius: 0; }
@media (hover: none) and (pointer: coarse) { #cortex-chat-form input:focus { font-size: 16px; } }
#cortex-chat-form button { flex: 0 0 auto; padding: .4rem; }
#cortex-chat-status { margin: .2rem 0 0; font-size: .75rem; }
#cortex-chat-status:empty { display: none; }
.cortex-saved-response { display: grid; gap: .8rem; margin-top: .75rem; padding-top: .8rem; border-top: 1px dashed #42604a; }
.cortex-saved-response small { display: block; font-size: 12px; line-height: 1.4; opacity: .65; }
.cortex-saved-response .cortex-saved-heading { letter-spacing: .08em; }
.cortex-saved-field { display: grid; gap: .25rem; }
body.portal-active .cortex-saved-field p { margin: 0; font-size: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cortex-moment.is-signal-insertion { background: #10251c; }
.cortex-moment.is-signal-insertion .cortex-folder-shape { stroke-dasharray: 2 1; }
body.portal-active .cortex-moment.is-signal-insertion .cortex-folder-number { top: 11%; transform: translateY(-50%); font-size: 20px !important; line-height: 1; }
body.portal-active .cortex-conversation #opportunity-form .cortex-dream-checklist { display: grid; gap: 0; min-width: 0; width: 100%; box-sizing: border-box; margin: .5rem 0; padding: 0; border: 0; }
body.portal-active .cortex-conversation #opportunity-form .cortex-dream-checklist legend { font-size: 13px; line-height: 1.5; letter-spacing: 0; padding: 0 0 .5rem; }
body.portal-active .cortex-conversation #opportunity-form .cortex-dream-checklist label { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: .65rem; min-height: 44px; margin: 0; padding: .3rem 0; font-size: 16px; font-weight: normal; line-height: 1.4; border: 0; background: transparent; overflow-wrap: anywhere; }
body.portal-active .cortex-conversation #opportunity-form .cortex-dream-checklist input[type="checkbox"] { appearance: none; display: block; width: 18px; height: 18px; min-width: 18px; min-height: 18px; max-width: 18px; margin: 0; padding: 0; border: 1px solid currentColor; border-radius: 0; box-shadow: none; background: transparent; color: inherit; }
body.portal-active .cortex-conversation #opportunity-form .cortex-dream-checklist input:checked { background: currentColor; box-shadow: inset 0 0 0 3px var(--portal-bg); }
body.portal-active .cortex-conversation #opportunity-form .cortex-dream-checklist input:focus-visible { outline: 1px dotted currentColor; outline-offset: 4px; }
body.portal-active .portal-desktop.cortex-open:has(.cortex-conversation) #portal-assistant { display: none; }
body.portal-active .cortex-turn-actions button[aria-pressed="true"] { background: var(--portal-line); color: var(--portal-ink); }

/* The record interface yields to the active MONTNET terminal. */
.portal-system-handoff { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: #06110b; color: #b4dcb8; font: 15px/1.6 monospace; animation: portal-handoff-enter .65s ease-out both; }
.portal-handoff-terminal { width: min(100%, 560px); border: 1px solid #52755b; padding: clamp(18px, 5vw, 36px); box-shadow: 0 0 45px #7cbd7c12; }
.portal-handoff-heading { margin: 0 0 24px; color: #81a68a; font-size: 12px; letter-spacing: .12em; }
.portal-handoff-log { min-height: 150px; }
.portal-handoff-log p { margin: 0 0 10px; overflow-wrap: anywhere; }
.portal-handoff-log p:last-child::after { content: ' ▌'; }
.portal-handoff-meter { height: 5px; margin-top: 24px; background: #263d2c; }
.portal-handoff-meter span { display: block; width: var(--handoff-progress, 0%); height: 100%; background: #b4dcb8; transition: width .35s ease; }
@keyframes portal-handoff-enter { from { opacity: 0; background: #d8dddf; } to { opacity: 1; background: #06110b; } }
@media (prefers-reduced-motion: reduce) { .portal-system-handoff { animation: none; } .portal-handoff-meter span { transition: none; } }
body[data-portal-motion='reduced'] .portal-system-handoff { animation: none; }
body[data-portal-motion='reduced'] .portal-handoff-meter span { transition: none; }

/* S!GNAL's terminal lives inside the older recovery window. */
.portal-recovery { width: min(100%, 560px); margin: 4vh auto 0; }
.portal-recovery .portal-window-body { padding: 20px; background: #08150e; color: #c4dfc8; font-family: monospace; }
.portal-recovery .portal-signal-line { align-items: flex-start; gap: 16px; margin: 0 0 20px; padding: 0 0 18px; border: 0; border-bottom: 1px solid #35533e; background: transparent; }
#recovery-signal-face { flex: 0 0 56px; width: 56px; height: 56px; image-rendering: pixelated; }
.recovery-speaker { display: block; margin: 0 0 5px; color: #88b593; font-size: 12px; letter-spacing: .06em; }
#recovery-signal { margin: 0; font-size: 15px; line-height: 1.5; }
.portal-recovery #portal-recovery-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; }
.portal-recovery #portal-recovery-form > * { grid-column: 1 / -1; min-width: 0; margin: 0; }
.portal-recovery #portal-recovery-form > label:has(input[name='firstName']),
.portal-recovery #portal-recovery-form > label:has(input[name='lastName']) { grid-column: auto; }
.portal-recovery label { font: 13px/1.5 monospace; }
.portal-recovery label small { display: block; color: #91a796; font-size: 11px; }
.portal-recovery input:not([type='radio']):not([type='checkbox']), .portal-recovery select { min-height: 40px; padding: 8px 10px; border: 1px solid #54735d; background: #0c1d13; color: #e0eee2; font: 16px/1.4 monospace; box-shadow: none; }
.portal-recovery .portal-button { justify-self: start; margin-top: 6px !important; padding: 9px 16px; border: 1px solid #84a98c; background: #233e2b; color: #ddedde; box-shadow: none; font: 13px/1.4 monospace; }
.portal-recovery :focus-visible { outline: 2px solid #a7d6b1; outline-offset: 3px; }
.portal-update-notice { width: min(480px, calc(100vw - 32px)); padding: 0; color: #1d2b34; }
.portal-update-notice::backdrop { background: #1c2b3870; }
.portal-update-notice p { margin: 0 0 16px; }
body.portal-recovering { background: #06110b; color: #c4dfc8; color-scheme: dark; }
body.portal-recovering .portal-frame, body.portal-recovering .portal-main { background: #06110b; }
body.portal-recovering .portal-topbar { background: #0b1a11; color: #b4dcb8; border-bottom: 1px solid #35533e; }
body.portal-recovering .portal-brand-mark { background: #b4dcb8; }
body.portal-recovering .portal-brand strong, body.portal-recovering .portal-brand small { font-family: monospace; }
body.portal-recovering .portal-recovery { border: 1px solid #54735d; box-shadow: none; }
body.portal-recovering .portal-recovery .portal-titlebar { background: #12271a; color: #b4dcb8; border-bottom: 1px solid #35533e; font: 12px/1.5 monospace; }
body.portal-recovering .portal-footer { background: #0b1a11; color: #91a796; border-top: 1px solid #35533e; font-family: monospace; }
body.portal-recovering .portal-footer button { background: transparent; color: #b4dcb8; border: 1px solid #54735d; box-shadow: none; font-family: monospace; }
body.portal-recovering .portal-footer a { color: #b4dcb8; }
body.portal-active .portal-signal-dialog-message p { text-wrap: pretty; }
body.portal-active .portal-signal-dialog-message a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* Shared controls follow the selected phosphor, including nested chat/menu UI. */
body.portal-active[data-portal-theme] :is(.portal-start-heading, .portal-start-tools, .portal-signal-dialog-log, .portal-signal-dialog-form, .portal-signal-dialog-heading) { background-color: var(--portal-surface); border-color: var(--portal-line); color: var(--portal-ink); }
body.portal-active[data-portal-theme] :is(.portal-start-heading small, .portal-start-tools button, .portal-signal-dialog-welcome, .portal-signal-dialog-heading small, .portal-signal-dialog-form label, .portal-signal-dialog-status, .portal-signal-dialog-message strong) { color: var(--portal-muted); }
body.portal-active[data-portal-theme] .portal-signal-dialog-message { border-color: var(--portal-line); }
body.portal-active[data-portal-theme] :is(.portal-signal-dialog, .portal-program) :is(button, input:not([type='checkbox']):not([type='radio']), select, textarea),
body.portal-active[data-portal-theme] .portal-start-menu :is(button, a) { color: var(--portal-ink); border-color: var(--portal-line); background-color: var(--portal-bg); caret-color: var(--portal-green); }
body.portal-active[data-portal-theme] :is(.portal-signal-dialog, .portal-program, .portal-start-menu) :is(button, a):is(:hover, :focus-visible) { color: var(--portal-green); border-color: var(--portal-green); background-color: var(--portal-raised); }
body.portal-active[data-portal-theme] .portal-start-app .portal-pixel-icon .icon-fill { fill: var(--portal-ink); }
body.portal-active[data-portal-theme] .portal-start-app .portal-pixel-icon .icon-screen { fill: var(--portal-bg); }
body.portal-active[data-portal-theme] .portal-start-heading img { filter: none; background: var(--portal-green); object-position: -9999px; mask: url('/identity.svg') center / contain no-repeat; -webkit-mask: url('/identity.svg') center / contain no-repeat; }
body.portal-active[data-portal-theme] .cortex-turn-actions button[aria-pressed='true'] { color: var(--portal-green); background-color: var(--portal-raised); }
body.portal-active[data-portal-theme] #portal-signout { color: var(--portal-ink); }
body.portal-active[data-portal-theme] .portal-taskbar .portal-task-status .portal-dt-token { color: var(--portal-green); border-color: var(--portal-line); background-color: var(--portal-surface); box-shadow: inset 0 0 0 2px var(--portal-line); }

/* CORTEX uses the same phosphor tokens as the desktop, including consent. */
body.portal-active[data-portal-theme] .portal-program[data-program='CORTEX'] { --cortex-accent: var(--portal-green); background: var(--portal-deep); color: var(--portal-ink); }
body.portal-active[data-portal-theme] .portal-program[data-program='CORTEX'] .portal-titlebar { background: var(--portal-surface); border-color: var(--portal-line); color: var(--portal-green); }
body.portal-active[data-portal-theme] .portal-program[data-program='CORTEX'] .portal-window-body { background-color: var(--portal-bg); background-image: repeating-linear-gradient(0deg, color-mix(in srgb, var(--portal-green) 3%, transparent) 0 1px, transparent 1px 4px), radial-gradient(ellipse at 50% 30%, var(--portal-surface), var(--portal-deep)); color: var(--portal-ink); }
body.portal-active[data-portal-theme] :is(.cortex-work-header, .portal-legal, #cortex-consent-form fieldset) { border-color: var(--portal-line); background: var(--portal-surface); color: var(--portal-ink); }
body.portal-active[data-portal-theme] :is(.portal-legal strong, #cortex-consent-form legend) { color: var(--portal-green); }
body.portal-active[data-portal-theme] :is(.cortex-work-identity > strong, .cortex-work-debt > strong, #cortex-consent-form label, .portal-legal p) { color: var(--portal-ink); }
body.portal-active[data-portal-theme] :is(.cortex-work-identity > small, .cortex-work-identity > span, .cortex-work-debt > span) { color: var(--portal-muted); }
body.portal-active[data-portal-theme] .cortex-work-debt > strong.cortex-debt-counter { background: var(--portal-deep); box-shadow: 0 0 0 2px var(--portal-deep), inset 0 0 0 1px var(--portal-line); }
body.portal-active[data-portal-theme] .cortex-debt-digit { background: linear-gradient(var(--portal-raised), var(--portal-bg) 55%, var(--portal-surface)); border-color: var(--portal-line); color: var(--portal-ink); text-shadow: 0 0 6px color-mix(in srgb, var(--portal-green) 45%, transparent); }
body.portal-active[data-portal-theme] .cortex-debt-digit.is-negative { color: var(--portal-green); }
body.portal-active[data-portal-theme] .cortex-debt-digit.is-separator { background: var(--portal-deep); }
body.portal-active[data-portal-theme] :is(#cortex-consent-form, .cortex-conversation) input:is([type='radio'], [type='checkbox']) { accent-color: var(--portal-green); }
body.portal-active[data-portal-theme] .cortex-conversation :is(.cortex-document, .cortex-open-tab, .cortex-adventure-response, .cortex-source-context, .cortex-scene) { background-color: var(--portal-bg); border-color: var(--portal-line); color: var(--portal-ink); }
body.portal-active[data-portal-theme] .cortex-conversation :is(.cortex-guide-speech p, #cortex-guide-line, .cortex-creative-form label, .cortex-terminal-history p, .cortex-voice, .cortex-door-label) { color: var(--portal-ink); }
body.portal-active[data-portal-theme] .cortex-conversation :is(legend, .cortex-guide-name, .cortex-scene-caption, .cortex-recorder-head, .cortex-voice-status) { color: var(--portal-muted); border-color: var(--portal-line); }
body.portal-active[data-portal-theme] .portal-program .portal-window-mode,
body.portal-active[data-portal-theme] .portal-program[data-program='CORTEX'] .portal-window-mode { color: var(--portal-muted); text-shadow: none; }
body.portal-active[data-portal-theme] #cortex-consent-form :is(select, button, input) { font-family: inherit; }
body.portal-active[data-portal-theme] #cortex-consent-form input[type='radio'] { appearance: none; display: inline-block; vertical-align: middle; width: 16px; height: 16px; min-width: 16px; min-height: 16px; margin: 0 8px 0 0; padding: 0; border: 1px solid var(--portal-muted); border-radius: 50%; background: var(--portal-bg); box-shadow: none; }
body.portal-active[data-portal-theme] #cortex-consent-form input[type='radio']:checked { background: var(--portal-green); border-color: var(--portal-green); box-shadow: inset 0 0 0 3px var(--portal-bg); }
body.portal-active[data-portal-theme] .cortex-work-debt > strong.cortex-debt-counter { border-color: var(--portal-line); }
body.portal-active[data-portal-theme] input[type='file']::file-selector-button { margin-right: 10px; padding: 7px 10px; border: 1px solid var(--portal-line); background: var(--portal-surface); color: var(--portal-ink); font: inherit; cursor: pointer; }
body.portal-active[data-portal-theme] input[type='file']::file-selector-button:hover { border-color: var(--portal-green); background: var(--portal-raised); }
body.portal-active[data-portal-theme] input:is([type='radio'], [type='checkbox']) { appearance: none; width: 1em; height: 1em; min-width: 1em; min-height: 1em; vertical-align: middle; border: 1px solid var(--portal-muted); background: var(--portal-bg); color: var(--portal-green); box-shadow: none; }
body.portal-active[data-portal-theme] input[type='radio'] { border-radius: 50%; }
body.portal-active[data-portal-theme] input:is([type='radio'], [type='checkbox']):checked { border-color: var(--portal-green); background: var(--portal-green); box-shadow: inset 0 0 0 3px var(--portal-bg); }

body.portal-active[data-portal-theme] .cortex-moment[data-state='recorded'] { color: var(--portal-ink); padding-bottom: 48px; }
body.portal-active .cortex-moment[data-state='recorded'] .cortex-folder-shape path:first-child { fill: var(--portal-bg); stroke-width: 2; }
body.portal-active .cortex-moment[data-state='recorded'] .cortex-folder-shape path + path { fill: none; }
body.portal-active .cortex-moment[data-state='recorded'] strong { color: var(--portal-ink); }
body.portal-active .cortex-moment[data-state='recorded'] .cortex-folder-state { display: flex; align-items: center; justify-content: flex-end; gap: 6px; right: 14px; bottom: 12px; padding: 0; border: 0; background: transparent; color: var(--portal-ink); font: 11px/1.3 monospace; letter-spacing: .04em; }
body.portal-active .cortex-complete-check { font-size: 28px; line-height: 1; }
@media (max-width: 640px) {
  body.portal-active .cortex-moment[data-state='recorded'] .cortex-folder-state { right: 9px; bottom: 10px; gap: 4px; font-size: 9px; letter-spacing: 0; }
  body.portal-active .cortex-complete-check { font-size: 24px; }
}
.portal-recovery #portal-recovery-status:empty { display: none; }
@media (max-width: 480px) {
  .portal-recovery { margin-top: 12px; }
  .portal-recovery .portal-window-body { padding: 16px; }
  .portal-recovery #portal-recovery-form { grid-template-columns: minmax(0, 1fr); }
}
/* Email access codes remain readable without mobile focus zoom. */
#portal-access-code { box-sizing: border-box; display: block; width: 100%; min-width: 0; font: inherit; font-size: 16px; padding: .6rem; }
#portal-code-entry { margin-block: 1rem; }
