/* ==========================================================================
   DOULATY-UNIX // VT320 Retro Phosphor Terminal Design System
   Vanilla CSS — HSL Phosphor Tokens, CRT Optics & Hardware Bezel
   ========================================================================== */

:root,
[data-theme="green"] {
  --crt-bg-edge: hsl(132, 35%, 3.2%);
  --crt-bg-center: hsl(132, 30%, 6.5%);
  --fg: hsl(128, 92%, 62%);
  --fg-bright: hsl(124, 100%, 80%);
  --fg-dim: hsl(128, 48%, 41%);
  --fg-muted: hsl(128, 35%, 28%);
  --prompt-user: hsl(125, 100%, 74%);
  --prompt-path: hsl(142, 88%, 68%);
  --dir-color: hsl(122, 100%, 82%);
  --exec-color: hsl(92, 95%, 70%);
  --err-color: hsl(14, 92%, 66%);
  --match-bg: hsl(128, 92%, 60%);
  --match-fg: hsl(132, 40%, 5%);
  --glow-soft: hsla(128, 95%, 55%, 0.34);
  --glow-strong: hsla(126, 100%, 68%, 0.55);
  --led-color: hsl(126, 95%, 56%);
  --selection-bg: hsla(128, 90%, 58%, 0.28);
}

[data-theme="amber"] {
  --crt-bg-edge: hsl(28, 42%, 3.2%);
  --crt-bg-center: hsl(32, 36%, 6.8%);
  --fg: hsl(38, 100%, 58%);
  --fg-bright: hsl(44, 100%, 78%);
  --fg-dim: hsl(35, 68%, 43%); /* ≥ 4.5:1 on amber CRT background */
  --fg-muted: hsl(32, 48%, 26%);
  --prompt-user: hsl(42, 100%, 70%);
  --prompt-path: hsl(48, 100%, 74%);
  --dir-color: hsl(45, 100%, 80%);
  --exec-color: hsl(54, 100%, 72%);
  --err-color: hsl(12, 95%, 66%);
  --match-bg: hsl(39, 100%, 58%);
  --match-fg: hsl(28, 45%, 5%);
  --glow-soft: hsla(38, 100%, 54%, 0.36);
  --glow-strong: hsla(42, 100%, 66%, 0.55);
  --led-color: hsl(38, 100%, 56%);
  --selection-bg: hsla(38, 100%, 58%, 0.28);
}

[data-theme="white"] {
  --crt-bg-edge: hsl(208, 22%, 4.2%);
  --crt-bg-center: hsl(205, 18%, 7.8%);
  --fg: hsl(196, 28%, 83%);
  --fg-bright: hsl(195, 65%, 95%);
  --fg-dim: hsl(200, 16%, 54%);
  --fg-muted: hsl(202, 14%, 34%);
  --prompt-user: hsl(195, 55%, 92%);
  --prompt-path: hsl(184, 48%, 78%);
  --dir-color: hsl(192, 72%, 92%);
  --exec-color: hsl(165, 55%, 78%);
  --err-color: hsl(12, 82%, 70%);
  --match-bg: hsl(195, 45%, 86%);
  --match-fg: hsl(208, 26%, 6%);
  --glow-soft: hsla(195, 55%, 80%, 0.26);
  --glow-strong: hsla(195, 70%, 90%, 0.42);
  --led-color: hsl(188, 70%, 76%);
  --selection-bg: hsla(195, 45%, 82%, 0.26);
}

:root {
  --font-retro: "VT323", "IBM Plex Mono", ui-monospace, "Cascadia Mono", "Source Code Pro", Menlo, Consolas, monospace;
  --font-crisp: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --term-font: var(--font-retro);
  --term-size: clamp(22px, 2.1vw, 28px);
  --term-line-height: 1.28;
  --bezel-outer: hsl(30, 6%, 11%);
  --bezel-inner: hsl(30, 5%, 6%);
  --bezel-rim: hsl(30, 6%, 18%);
  --bezel-text: hsl(34, 10%, 56%);
}

[data-font="crisp"] {
  --term-font: var(--font-crisp);
  --term-size: clamp(16px, 1.45vw, 20px);
  --term-line-height: 1.5;
}

[data-scale="xl"] {
  --term-size: clamp(25px, 2.5vw, 33px);
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: hsl(30, 8%, 6%);
  color: var(--fg);
  font-family: var(--term-font);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection-bg);
  color: var(--fg-bright);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Hardware Monitor Chassis & CRT Glass Tube
   ========================================================================== */

.monitor-chassis {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding: 16px 20px 12px;
  background:
    radial-gradient(120% 90% at 50% 0%, hsl(32, 7%, 15%) 0%, var(--bezel-outer) 58%, hsl(30, 8%, 7%) 100%);
}

.crt-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: radial-gradient(ellipse at 50% 45%, var(--crt-bg-center) 0%, var(--crt-bg-edge) 100%);
  border: 3px solid var(--bezel-inner);
  box-shadow:
    0 0 0 1px var(--bezel-rim),
    inset 0 0 55px rgba(0, 0, 0, 0.82),
    inset 0 2px 12px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

/* Subtle CRT Scanlines & Phosphor Aperture Overlay */
.crt-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0) 50%,
      rgba(0, 0, 0, 0.26) 50%
    );
  background-size: 100% 4px;
  opacity: 0.72;
}

/* Subtle Curved Glass Vignette */
.crt-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background:
    radial-gradient(
      circle at 50% 50%,
      transparent 64%,
      rgba(0, 0, 0, 0.46) 100%
    );
}

[data-crt="off"] .crt-frame::before {
  display: none;
}

/* Subtle turn-on warmup animation */
@keyframes crt-power-on {
  0% {
    opacity: 0.15;
    filter: brightness(2.1);
  }
  100% {
    opacity: 1;
    filter: brightness(1);
  }
}

.crt-screen {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 30px 24px;
  font-family: var(--term-font);
  font-size: var(--term-size);
  line-height: var(--term-line-height);
  letter-spacing: 0.025em;
  color: var(--fg);
  text-shadow: 0 0 6px var(--glow-soft);
  scroll-behavior: auto;
  animation: crt-power-on 260ms ease-out;
  cursor: text;
}

/* Custom retro scrollbar inside screen */
.crt-screen::-webkit-scrollbar {
  width: 10px;
}

.crt-screen::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
}

.crt-screen::-webkit-scrollbar-thumb {
  background: var(--fg-muted);
  border: 2px solid transparent;
  background-clip: content-box;
}

.crt-screen::-webkit-scrollbar-thumb:hover {
  background: var(--fg-dim);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ==========================================================================
   Terminal Output Blocks, ASCII Art & File Listings
   ========================================================================== */

#terminal-output {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.term-banner {
  white-space: pre;
  overflow-x: auto;
  color: var(--fg-bright);
  text-shadow: 0 0 10px var(--glow-strong);
  line-height: 1.05;
  margin: 6px 0 10px;
  font-size: clamp(14px, 1.9vw, 26px);
}

.term-boot {
  color: var(--fg-dim);
}

.term-ok {
  color: var(--fg-bright);
}

.term-err {
  color: var(--err-color);
  text-shadow: 0 0 6px rgba(255, 95, 65, 0.32);
}

.term-dim {
  color: var(--fg-dim);
}

.term-bright {
  color: var(--fg-bright);
  text-shadow: 0 0 8px var(--glow-strong);
}

.term-dir {
  color: var(--dir-color);
  font-weight: bold;
  text-shadow: 0 0 8px var(--glow-strong);
}

.term-exec {
  color: var(--exec-color);
}

.term-match {
  background: var(--match-bg);
  color: var(--match-fg);
  padding: 0 2px;
  text-shadow: none;
  font-weight: bold;
}

/* Links & Interactive Command Chips inside Output */
.term-link {
  color: var(--fg-bright);
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.term-link:hover,
.term-link:focus-visible {
  background: var(--match-bg);
  color: var(--match-fg);
  text-decoration: none;
  text-shadow: none;
  outline: none;
}

/* Clickable file / directory names inside ls, tree & find output */
.fs-link {
  cursor: pointer;
  border-bottom: 1px dotted var(--fg-muted);
  transition: border-color 120ms ease;
}

.fs-link:hover,
.fs-link:focus-visible {
  border-bottom-color: currentColor;
  text-decoration: none;
  outline: none;
}

.fs-link:hover .term-dir,
.fs-link:hover > span {
  filter: brightness(1.25);
}

.cmd-col {
  display: inline-block;
  min-width: 30ch;
  padding-right: 2ch;
}

/* MOTD quick-start hint rows (2-column table on desktop, stacked on mobile) */
.motd-row {
  white-space: pre-wrap;
}

.motd-desc {
  color: var(--fg);
}

.motd-name-mobile {
  display: none;
}

.term-pre {
  white-space: pre;
  overflow-x: auto;
  line-height: 1.12;
}

.sl-train {
  white-space: pre;
  overflow: hidden;
  line-height: 1.05;
  color: var(--fg-bright);
  text-shadow: 0 0 8px var(--glow-strong);
}

.term-hint-dim {
  color: var(--fg-dim);
  font-size: 0.86em;
  font-style: italic;
}

.cmd-hint {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--fg-bright);
  text-shadow: 0 0 8px var(--glow-strong);
  border-bottom: 1px dashed var(--fg-dim);
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
}

.cmd-hint:hover,
.cmd-hint:focus-visible {
  background: var(--match-bg);
  color: var(--match-fg);
  text-shadow: none;
  border-bottom-color: transparent;
  outline: none;
}

/* Column grid for `ls` */
.ls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2px 24px;
  padding: 2px 0;
}

/* ==========================================================================
   Prompt & Authentic Block Cursor Input Line
   ========================================================================== */

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  margin-top: 4px;
  position: relative;
}

.prompt-row[hidden],
.boot-skip-bar[hidden],
.more-prompt-row[hidden] {
  display: none !important;
}

/* LILO / Slackware Boot Styles & Fast-Forward Badge */
.boot-cursor {
  display: inline-block;
  min-width: 1ch;
  background-color: var(--fg-bright);
  color: var(--match-fg);
  box-shadow: 0 0 8px var(--glow-strong);
  animation: cursor-blink 0.9s steps(1, end) infinite;
}

.boot-skip-bar {
  position: absolute;
  right: 22px;
  bottom: 18px;
  z-index: 7;
}

@keyframes skip-hint-blink {
  0%, 60% {
    opacity: 1;
  }
  61%, 100% {
    opacity: 0.25;
  }
}

.boot-skip-btn {
  appearance: none;
  background: rgba(0, 0, 0, 0.78);
  color: var(--fg-bright);
  border: 1px solid var(--fg-dim);
  padding: 3px 12px;
  font-family: var(--term-font);
  font-size: calc(var(--term-size) * 0.82);
  letter-spacing: 0.04em;
  cursor: pointer;
  text-shadow: 0 0 8px var(--glow-soft);
  animation: skip-hint-blink 1.1s steps(1, end) infinite;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.boot-skip-btn:hover,
.boot-skip-btn:focus-visible {
  color: var(--match-fg);
  background: var(--match-bg);
  border-color: var(--fg-bright);
  animation: none;
  outline: 2px solid var(--fg-bright);
  outline-offset: 2px;
}

.prompt-prefix {
  white-space: pre;
  margin-right: 0.5ch;
  user-select: text;
}

/* Ctrl+R bash-style reverse incremental history search */
.rsearch-prefix {
  white-space: pre;
  margin-right: 0.5ch;
  color: var(--fg-bright);
}

.rsearch-prefix[hidden],
.prompt-prefix[hidden],
.input-placeholder[hidden] {
  display: none !important;
}

.rsearch-prefix .rsearch-pat {
  color: var(--exec-color);
}

/* Touch-device "tap to type" affordance shown until first focus */
@keyframes placeholder-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.input-placeholder {
  color: var(--fg-dim);
  margin-left: 1ch;
  font-size: 0.88em;
  letter-spacing: 0.02em;
  animation: placeholder-pulse 1.6s ease-in-out infinite;
}

.prompt-user {
  color: var(--prompt-user);
  text-shadow: 0 0 8px var(--glow-soft);
}

.prompt-sep {
  color: var(--fg-dim);
}

.prompt-path {
  color: var(--prompt-path);
}

.prompt-dollar {
  color: var(--fg-bright);
}

.input-mirror-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 12ch;
  white-space: pre-wrap;
  word-break: break-all;
}

#input-before,
#input-after {
  color: var(--fg-bright);
}

/* Authentic Phosphor Block Cursor */
@keyframes cursor-blink {
  0%, 49% {
    background-color: var(--fg-bright);
    color: var(--match-fg);
    box-shadow: 0 0 10px var(--glow-strong);
  }
  50%, 100% {
    background-color: transparent;
    color: var(--fg-bright);
    box-shadow: none;
  }
}

#input-cursor {
  display: inline-block;
  min-width: 1ch;
  background-color: var(--fg-bright);
  color: var(--match-fg);
  text-shadow: none;
  box-shadow: 0 0 10px var(--glow-strong);
  animation: cursor-blink 1.05s steps(1, end) infinite;
}

.input-unfocused #input-cursor {
  animation: none;
  background-color: transparent;
  color: var(--fg-bright);
  outline: 1.5px solid var(--fg-dim);
  box-shadow: none;
}

/* Native input kept accessible for IME, mobile keyboards, paste & screen readers */
#terminal-input {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  font-size: 16px; /* Prevents iOS Safari auto-zoom on focus */
}

/* ==========================================================================
   Bottom Hardware Bezel Controls & Mobile Touch Bar
   ========================================================================== */

.monitor-bezel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px 0;
  color: var(--bezel-text);
  font-family: var(--font-crisp);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
}

.bezel-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.power-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--led-color);
  box-shadow: 0 0 8px var(--led-color);
  flex-shrink: 0;
}

.bezel-badge {
  font-weight: 600;
  color: hsl(34, 10%, 64%);
}

.bezel-sub {
  color: hsl(34, 8%, 58%); /* ≥ 4.5:1 on bezel */
}

/* Amber disk-activity LED (flickers on cat / less / find / grep) */
.disk-led-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  color: hsl(34, 8%, 58%);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.disk-led {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background-color: hsl(36, 40%, 16%);
  border: 1px solid hsl(36, 30%, 24%);
  transition: background-color 60ms ease, box-shadow 60ms ease;
}

.disk-led.active {
  background-color: hsl(38, 100%, 56%);
  box-shadow: 0 0 7px hsl(38, 100%, 56%);
  border-color: hsl(40, 100%, 70%);
}

/* Bezel Thermal Overheat Warning LED (activated during nvidia-smi runaway) */
.temp-led-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 4px;
  color: hsl(12, 90%, 66%);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.temp-led-wrap[hidden] {
  display: none !important;
}

@keyframes temp-led-strobe {
  0%, 49% {
    background-color: hsl(4, 100%, 58%);
    box-shadow: 0 0 10px hsl(4, 100%, 58%), 0 0 18px hsl(18, 100%, 52%);
    border-color: hsl(24, 100%, 78%);
  }
  50%, 100% {
    background-color: hsl(4, 60%, 20%);
    box-shadow: none;
    border-color: hsl(4, 40%, 30%);
  }
}

.temp-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: hsl(32, 100%, 54%);
  box-shadow: 0 0 7px hsl(32, 100%, 54%);
  border: 1px solid hsl(38, 100%, 70%);
}

.temp-led.critical {
  animation: temp-led-strobe 240ms steps(1, end) infinite;
}

.bezel-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bezel-panel {
  display: contents;
}

.hw-setup-toggle {
  display: none;
}

.hw-btn {
  appearance: none;
  background: hsl(30, 6%, 14%);
  color: hsl(34, 10%, 70%);
  border: 1px solid hsl(30, 6%, 23%);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-crisp);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.hw-btn:hover {
  background: hsl(30, 6%, 19%);
  color: hsl(34, 18%, 84%);
}

.hw-btn:focus-visible,
.touch-key:focus-visible,
.more-badge:focus-visible,
.more-quit-btn:focus-visible,
.less-quit-btn:focus-visible {
  outline: 2px solid var(--fg-bright);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.8);
}

.hw-btn:active {
  transform: translateY(1px);
}

.hw-link {
  text-decoration: none;
  display: inline-block;
}

.hw-switch-primary {
  background: hsla(128, 70%, 22%, 0.45);
  color: var(--fg-bright);
  border-color: var(--fg-dim);
  font-weight: 600;
}

.hw-switch-primary:hover,
.hw-switch-primary:focus-visible {
  background: var(--match-bg);
  color: var(--match-fg);
  border-color: var(--fg-bright);
}

/* ==========================================================================
   VI / VIM & GNU EMACS Mock Editor + Slamming Iron Jail Bars Trap
   ========================================================================== */

.editor-trap-overlay {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 45%, var(--crt-bg-center) 0%, var(--crt-bg-edge) 100%);
  font-family: var(--term-font);
  font-size: var(--term-size);
  line-height: var(--term-line-height);
  color: var(--fg);
  text-shadow: 0 0 6px var(--glow-soft);
  overflow: hidden;
}

.editor-trap-overlay[hidden],
.jail-layer[hidden],
.mock-ed-topbar[hidden] {
  display: none !important;
}

.mock-editor {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mock-ed-topbar {
  display: flex;
  justify-content: space-between;
  padding: 2px 16px;
  background: var(--match-bg);
  color: var(--match-fg);
  text-shadow: none;
  flex-shrink: 0;
  white-space: pre;
}

.mock-ed-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 20px;
  overflow: hidden;
  white-space: pre-wrap;
}

.vi-tilde {
  color: var(--fg-dim);
}

.vi-splash-center {
  text-align: center;
  color: var(--fg-bright);
}

.mock-ed-modeline {
  display: flex;
  justify-content: space-between;
  padding: 1px 16px;
  flex-shrink: 0;
  white-space: pre;
  color: var(--fg-bright);
}

.mock-ed-modeline.emacs-mode {
  background: var(--match-bg);
  color: var(--match-fg);
  text-shadow: none;
}

.mock-ed-cmdline {
  padding: 2px 16px 4px;
  min-height: 1.45em;
  flex-shrink: 0;
  white-space: pre-wrap;
  color: var(--fg-bright);
}

.mock-ed-cmdline.ed-err {
  background: var(--err-color);
  color: #120402;
  text-shadow: none;
  font-weight: bold;
}

/* Iron Jail Bars Slamming Animation */
@keyframes jail-slam {
  0% {
    transform: translateY(-106%);
  }
  66% {
    transform: translateY(0%);
  }
  79% {
    transform: translateY(-3.2%);
  }
  89% {
    transform: translateY(0%);
  }
  95% {
    transform: translateY(-0.9%);
  }
  100% {
    transform: translateY(0%);
  }
}

@keyframes jail-rattle {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px) rotate(-0.3deg);
  }
  40% {
    transform: translateX(7px) rotate(0.3deg);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(4px);
  }
}

@keyframes crt-impact-shake {
  0%, 100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-3px, 5px);
  }
  45% {
    transform: translate(3px, -4px);
  }
  70% {
    transform: translate(-2px, 2px);
  }
}

.crt-frame.jail-impact {
  animation: crt-impact-shake 280ms ease-out;
}

@keyframes placard-pop {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.jail-layer {
  position: absolute;
  inset: 0;
  bottom: 2.8em; /* Keep editor's bottom :command / M-x echo bar visible below bars! */
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
}

.jail-bars {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: stretch;
  pointer-events: none;
  animation: jail-slam 540ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.jail-bars.rattling {
  animation: jail-rattle 300ms ease-in-out;
}

.jail-bar {
  width: clamp(11px, 1.3vw, 17px);
  height: 100%;
  background: linear-gradient(
    90deg,
    #050806 0%,
    var(--fg-muted) 22%,
    var(--fg-bright) 46%,
    var(--fg-dim) 68%,
    #060a07 100%
  );
  border-left: 1px solid rgba(0, 0, 0, 0.85);
  border-right: 1px solid rgba(0, 0, 0, 0.92);
  box-shadow:
    6px 0 14px rgba(0, 0, 0, 0.88),
    0 0 8px var(--glow-soft);
}

.jail-crossbar {
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  background:
    radial-gradient(circle at 12px 9px, var(--fg-bright) 2.5px, transparent 3.2px) repeat-x 0 0 / 64px 18px,
    linear-gradient(
      180deg,
      #060907 0%,
      var(--fg-dim) 35%,
      var(--fg-bright) 52%,
      var(--fg-muted) 80%,
      #040604 100%
    );
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.9);
}

.jail-crossbar-top {
  top: 7%;
}

.jail-crossbar-mid {
  top: 49%;
}

.jail-crossbar-bot {
  bottom: 4%;
}

.jail-placard {
  position: relative;
  z-index: 3;
  max-width: min(680px, 90%);
  background: var(--crt-bg-edge);
  border: 3px double var(--fg-bright);
  box-shadow:
    0 0 0 8px rgba(0, 0, 0, 0.96),
    0 18px 38px rgba(0, 0, 0, 0.98),
    0 0 24px var(--glow-soft);
  padding: 16px 24px;
  text-align: center;
  animation: placard-pop 260ms 380ms backwards ease-out;
}

.jail-badge {
  display: inline-block;
  padding: 1px 10px;
  background: var(--err-color);
  color: #140402;
  text-shadow: none;
  font-weight: bold;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.jail-title {
  font-size: 1.38em;
  color: var(--fg-bright);
  text-shadow: 0 0 12px var(--glow-strong);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.jail-rule {
  color: var(--exec-color);
  font-weight: bold;
  margin-bottom: 10px;
}

.jail-roast {
  background: rgba(0, 0, 0, 0.65);
  border: 1px dashed var(--fg-dim);
  padding: 8px 12px;
  color: var(--fg-bright);
  margin-bottom: 10px;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.jail-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  color: var(--fg-dim);
  font-size: 0.92em;
  margin-bottom: 10px;
}

.jail-actions {
  margin-bottom: 10px;
}

.jail-fake-btn {
  appearance: none;
  background: transparent;
  color: var(--fg-bright);
  border: 1px solid var(--fg);
  padding: 3px 14px;
  font: inherit;
  cursor: pointer;
  transition: background-color 100ms ease, color 100ms ease;
}

.jail-fake-btn:hover,
.jail-fake-btn:focus-visible {
  background: var(--err-color);
  color: #140402;
  border-color: var(--err-color);
  text-shadow: none;
  outline: none;
}

.jail-escape-hint {
  font-size: 0.8em;
  color: var(--fg-dim);
  line-height: 1.25;
}

/* Interactive UNIX less(1) Pager Overlay */
.less-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 45%, var(--crt-bg-center) 0%, var(--crt-bg-edge) 100%);
  font-family: var(--term-font);
  font-size: var(--term-size);
  line-height: var(--term-line-height);
  color: var(--fg);
  text-shadow: 0 0 6px var(--glow-soft);
}

.less-overlay[hidden] {
  display: none !important;
}

.less-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 30px;
  white-space: pre-wrap;
  outline: none;
}

.less-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px 16px;
  background: var(--match-bg);
  color: var(--match-fg);
  text-shadow: none;
  flex-shrink: 0;
}

.less-quit-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0 4px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.less-hit {
  background: var(--match-bg);
  color: var(--match-fg);
  text-shadow: none;
  padding: 0 2px;
}

/* ==========================================================================
   top(1) / htop Full-Screen System Monitor Overlay
   ========================================================================== */

.sysmon-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 45%, var(--crt-bg-center) 0%, var(--crt-bg-edge) 100%);
  font-family: var(--term-font);
  font-size: var(--term-size);
  line-height: var(--term-line-height);
  color: var(--fg);
  text-shadow: 0 0 6px var(--glow-soft);
}

.sysmon-overlay[hidden],
.sysmon-fkeys[hidden] {
  display: none !important;
}

.sysmon-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 10px 18px 6px;
  white-space: pre;
  font-variant-ligatures: none;
  outline: none;
}

.sysmon-content.nv-smi-mode {
  font-size: clamp(11px, 1.55vw, 15.5px);
  line-height: 1.12;
  padding: 8px 16px 4px;
}

.sysmon-content .sm-inv {
  background: var(--fg);
  color: var(--match-fg);
  text-shadow: none;
}

.sysmon-content .sm-dim {
  color: var(--fg-dim);
}

.sysmon-content .sm-bright {
  color: var(--fg-bright);
}

.sysmon-content .sm-err {
  color: var(--err-color);
}

/* htop palette (knowingly anachronistic on a 1995 VT320) */
.sysmon-content .ht-cyan {
  color: hsl(186, 85%, 66%);
}

.sysmon-content .ht-green {
  color: hsl(128, 90%, 62%);
}

.sysmon-content .ht-red {
  color: hsl(6, 90%, 64%);
}

.sysmon-content .ht-yellow {
  color: hsl(48, 100%, 66%);
}

.sysmon-content .ht-blue {
  color: hsl(212, 90%, 70%);
}

.sysmon-content .ht-hdr {
  background: hsl(130, 70%, 38%);
  color: #021a05;
  text-shadow: none;
}

.sysmon-content .ht-sel,
.sysmon-content .ht-sort {
  background: hsl(186, 72%, 48%);
  color: #02181c;
  text-shadow: none;
}

.sysmon-content .ht-pane {
  display: inline-block;
  border: 1px solid hsl(186, 85%, 66%);
  padding: 2px 10px;
  margin-top: 2px;
  background: rgba(0, 0, 0, 0.55);
  vertical-align: top;
}

.sysmon-content .ht-input {
  background: hsl(186, 72%, 48%);
  color: #02181c;
  text-shadow: none;
}

/* ==========================================================================
   nvidia-smi Thermal Runaway, Heat Shimmer & Meltdown Effects
   ========================================================================== */

@keyframes nv-heat-wobble {
  0%, 100% {
    transform: translate(0, 0) skewX(0deg);
  }
  25% {
    transform: translate(-1.5px, 0.5px) skewX(-0.25deg);
  }
  50% {
    transform: translate(1.5px, -0.5px) skewX(0.25deg);
  }
  75% {
    transform: translate(-1px, -0.5px) skewX(0.15deg);
  }
}

@keyframes nv-critical-shake {
  0%, 100% {
    transform: translate(0, 0) skewX(0deg);
  }
  20% {
    transform: translate(-3px, 1.5px) skewX(-0.6deg);
  }
  40% {
    transform: translate(3px, -1.5px) skewX(0.6deg);
  }
  60% {
    transform: translate(-2.5px, -1px) skewX(0.4deg);
  }
  80% {
    transform: translate(2.5px, 1.5px) skewX(-0.4deg);
  }
}

@keyframes nv-melt-drip {
  0% {
    transform: translateY(0) scaleY(1) skewX(0deg);
    filter: hue-rotate(0deg) saturate(1.4) contrast(1.15);
  }
  50% {
    transform: translateY(6px) scaleY(1.03) skewX(-0.8deg);
    filter: hue-rotate(-28deg) saturate(2.2) contrast(1.35);
  }
  100% {
    transform: translateY(12px) scaleY(1.06) skewX(0.6deg);
    filter: hue-rotate(-45deg) saturate(2.6) contrast(1.45);
  }
}

.crt-frame.nv-warm .sysmon-overlay {
  box-shadow: inset 0 0 60px rgba(255, 140, 20, 0.16);
}

.crt-frame.nv-hot .sysmon-overlay {
  box-shadow: inset 0 0 95px rgba(255, 80, 10, 0.28);
  animation: nv-heat-wobble 260ms ease-in-out infinite;
}

.crt-frame.nv-critical .sysmon-overlay {
  background: radial-gradient(ellipse at 50% 45%, #2a0802 0%, #100200 100%);
  box-shadow: inset 0 0 130px rgba(255, 36, 0, 0.45);
  animation: nv-critical-shake 140ms ease-in-out infinite;
}

.crt-frame.nv-melt .sysmon-content {
  animation: nv-melt-drip 2.4s ease-in forwards;
}

.crt-frame.nv-charred .sysmon-overlay {
  background: radial-gradient(ellipse at 50% 45%, #160302 0%, #050100 100%);
  box-shadow: inset 0 0 140px rgba(255, 24, 0, 0.32);
}

.sysmon-content .nv-cyan {
  color: hsl(186, 90%, 68%);
}

.sysmon-content .nv-green {
  color: hsl(128, 92%, 62%);
}

.sysmon-content .nv-yellow {
  color: hsl(46, 100%, 64%);
  text-shadow: 0 0 6px rgba(255, 200, 40, 0.35);
}

.sysmon-content .nv-orange {
  color: hsl(24, 100%, 62%);
  text-shadow: 0 0 8px rgba(255, 120, 20, 0.45);
}

.sysmon-content .nv-red {
  color: hsl(6, 100%, 64%);
  text-shadow: 0 0 10px rgba(255, 50, 20, 0.6);
  font-weight: bold;
}

.sysmon-content .nv-crit-badge {
  background: hsl(4, 95%, 52%);
  color: #fff6f2;
  padding: 0;
  text-shadow: none;
  font-weight: bold;
}

.sysmon-content .nv-plaid-badge {
  background: linear-gradient(90deg, #ff2a00, #ffae00, #ffee00);
  color: #160400;
  padding: 0;
  text-shadow: none;
  font-weight: bold;
}

.sysmon-content .nv-smoke {
  color: hsl(26, 28%, 68%);
  text-shadow: 0 0 10px rgba(255, 120, 60, 0.35);
}

.sysmon-content .nv-panic-box {
  color: hsl(8, 100%, 66%);
  text-shadow: 0 0 10px rgba(255, 45, 15, 0.65);
}

/* Function-key bar (F1Help F2Setup … F10Quit) */
.sysmon-fkeys {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 2px;
  padding: 2px 6px 4px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.5);
  scrollbar-width: none;
}

.sysmon-fkeys::-webkit-scrollbar {
  display: none;
}

.fkey-btn {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: stretch;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--fg-bright);
  cursor: pointer;
  text-shadow: none;
  min-height: 32px;
}

.fkey-btn .fkey-num {
  padding: 0 2px;
  color: var(--fg-bright);
  display: inline-flex;
  align-items: center;
}

.fkey-btn .fkey-label {
  background: hsl(186, 72%, 48%);
  color: #02181c;
  padding: 0 8px 0 4px;
  min-width: 5.5ch;
  text-align: left;
  display: inline-flex;
  align-items: center;
}

.fkey-btn:hover .fkey-label,
.fkey-btn:focus-visible .fkey-label {
  background: hsl(186, 90%, 70%);
}

.fkey-btn:focus-visible {
  outline: 2px solid var(--fg-bright);
  outline-offset: 1px;
}

/* Inline UNIX more(1) Stream Pager Bar (`--More--(42%)`) */
.more-prompt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  user-select: none;
}

.more-badge {
  appearance: none;
  border: none;
  background: var(--match-bg);
  color: var(--match-fg);
  font: inherit;
  padding: 0 8px;
  cursor: pointer;
  text-shadow: none;
}

.more-hint {
  color: var(--fg-dim);
  font-size: 0.92em;
}

.more-quit-btn {
  appearance: none;
  background: none;
  border: 1px solid var(--fg-dim);
  color: var(--fg);
  font: inherit;
  padding: 0 6px;
  cursor: pointer;
}

.more-quit-btn:hover {
  background: var(--match-bg);
  color: var(--match-fg);
}

/* Mobile Quick-Key Bar (shown on touch/small viewports) */
.touch-keybar {
  display: none;
  position: relative;
  z-index: 4;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.62);
  border-top: 1px solid var(--fg-muted);
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.touch-keybar::-webkit-scrollbar {
  display: none;
}

.touch-key {
  appearance: none;
  flex: 0 0 auto;
  background: rgba(0, 0, 0, 0.5);
  color: var(--fg);
  border: 1px solid var(--fg-dim);
  border-radius: 4px;
  padding: 6px 12px;
  min-height: 36px;
  font-family: var(--term-font);
  font-size: 19px;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
}

.touch-key:active {
  background: var(--match-bg);
  color: var(--match-fg);
}

/* Noscript static fallback inside CRT */
.noscript-box {
  border: 1px solid var(--fg-dim);
  padding: 16px 20px;
  margin-bottom: 16px;
}

/* ==========================================================================
   Responsive & Reduced Motion
   ========================================================================== */

@media (max-width: 768px) {
  .monitor-chassis {
    padding: 6px 6px 6px;
  }

  .crt-frame {
    border-radius: 10px;
  }

  .crt-screen {
    padding: 16px 14px 22px;
  }

  .term-banner {
    font-size: 13px;
  }

  .bezel-sub {
    display: none;
  }

  .touch-keybar {
    display: flex;
  }

  /* Keep the quick-key bar reachable under less/top/htop overlays on touch screens */
  .less-overlay,
  .sysmon-overlay {
    bottom: 54px;
  }

  .ls-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* Phone layout: collapse bezel into a ⚙ SETUP toggle, stack MOTD hints */
@media (max-width: 1500px) {
  .bezel-sub {
    display: none;
  }
}

@media (max-width: 600px) {
  :root {
    --term-size: 19px;
  }

  [data-font="crisp"] {
    --term-size: 14px;
  }

  [data-scale="xl"] {
    --term-size: 22px;
  }

  .monitor-chassis {
    padding: 4px 4px 6px;
  }

  .crt-screen {
    padding: 12px 10px 18px;
  }

  .monitor-bezel-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 6px 2px 0;
  }

  .bezel-brand {
    justify-content: space-between;
    font-size: 10px;
  }

  .bezel-controls {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "setup switch"
      "panel panel";
    gap: 6px;
    width: 100%;
  }

  .hw-setup-toggle {
    display: inline-block;
    grid-area: setup;
  }

  .hw-switch-primary {
    grid-area: switch;
    width: 100%;
    text-align: center;
    padding: 7px 8px;
  }

  .bezel-panel {
    grid-area: panel;
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    border: 1px solid hsl(30, 6%, 20%);
    border-radius: 6px;
    background: hsl(30, 6%, 9%);
  }

  .bezel-controls.open .bezel-panel {
    display: flex;
  }

  .bezel-panel .hw-btn {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    padding: 7px 6px;
  }

  /* MOTD: hide big ASCII banner, show compact name line + stacked hints */
  .term-banner,
  .motd-mobile-hide {
    display: none !important;
  }

  .motd-name-mobile {
    display: block;
    color: var(--fg-bright);
    text-shadow: 0 0 10px var(--glow-strong);
    font-size: 1.15em;
    margin: 2px 0 4px;
  }

  .motd-row {
    display: block;
    padding: 3px 0 4px;
    border-bottom: 1px dotted var(--fg-muted);
  }

  .motd-row .cmd-col {
    display: block;
    min-width: 0;
    padding-right: 0;
  }

  .motd-row .motd-desc {
    display: block;
    color: var(--fg-dim);
    font-size: 0.82em;
    line-height: 1.2;
  }

  .motd-row .motd-indent {
    display: none;
  }

  .ls-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2px 12px;
  }

  .less-content {
    padding: 12px 10px;
  }

  .less-help {
    display: none;
  }

  .sysmon-content {
    padding: 6px 8px 4px;
    font-size: 13px;
    line-height: 1.25;
  }

  .fkey-btn {
    min-height: 36px;
    font-size: 15px;
  }

  .boot-skip-bar {
    right: 10px;
    bottom: 10px;
  }

  .jail-placard {
    padding: 10px 12px;
    font-size: 0.86em;
  }
}

/* Fine pointer (desktop) never needs the placeholder */
@media (hover: hover) and (pointer: fine) {
  .input-placeholder {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crt-screen,
  #input-cursor,
  .boot-cursor,
  .boot-skip-btn,
  .input-placeholder,
  .jail-bars,
  .jail-bars.rattling,
  .jail-placard,
  .crt-frame.jail-impact {
    animation: none !important;
  }

  .jail-bars {
    transform: translateY(0) !important;
  }

  .crt-frame::before {
    opacity: 0.45;
  }

  .hw-btn,
  .cmd-hint,
  .fs-link,
  .disk-led {
    transition: none;
  }
}
