:root {
  --bg: #01030b;
  --fg: #b7d7ff;
  --dim: #5d6f9e;
  --accent: #5b7bff;
  --line: rgba(183, 215, 255, .14);
  --grain: .07;
  --sel-bg: #b7d7ff;
  --sel-fg: #01030b;
  --tty-size: 22px;
}
body.env-terminal { display: flex; flex-direction: column; height: 100svh; overflow: hidden; background: #000; }
body.env-terminal main { flex: 1; min-height: 0; display: flex; }

.tty { position: relative; flex: 1; display: flex; padding: clamp(0px, 1.6vw, 22px); }
.tty-glass {
  position: relative; flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: clamp(14px, 3vw, 40px) clamp(14px, 3.4vw, 46px) 12px;
  border-radius: clamp(0px, 1.4vw, 18px);
  background: radial-gradient(130% 110% at 50% 45%, #061033 0%, #020718 55%, #000208 100%);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, .9), inset 0 0 18px rgba(91, 123, 255, .25), 0 0 0 1px #0c1640;
  overflow: hidden;
  animation: tty-flicker 6s steps(1) infinite;
}
.tty-glass::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background:
    radial-gradient(120% 100% at 50% 50%, transparent 62%, rgba(0, 0, 0, .55) 100%),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, .025) 0 1px, transparent 1px 2px, rgba(0, 0, 0, .35) 2px 3px);
}
.tty-glass::before {
  content: ""; position: absolute; left: 0; right: 0; top: -20%; height: 18%; z-index: 2; pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(120, 160, 255, .05), transparent);
  animation: roll 9s linear infinite;
}
@keyframes roll { to { transform: translateY(700%); } }
@keyframes tty-flicker { 0%, 96%, 100% { opacity: 1; } 97% { opacity: .93; } 98% { opacity: 1; } 99% { opacity: .96; } }

.tty-bar, .tty-out, .tty-in, .tty-chips { position: relative; z-index: 1; }
.tty-bar { display: flex; justify-content: space-between; margin-bottom: 14px; font: 16px/1 var(--f-bit); color: var(--dim); letter-spacing: .08em; }
.tty-dot { color: #9fdcae; animation: blink 2.4s steps(1) infinite; }

.tty-out, .tty-in, .tty-prompt, #cmd {
  font: var(--tty-size)/1.18 var(--f-bit);
  letter-spacing: .02em;
  color: var(--fg);
  text-shadow: .6px 0 0 rgba(95, 225, 255, .45), -.6px 0 0 rgba(90, 43, 255, .55), 0 0 7px rgba(110, 160, 255, .55);
}
.tty-out { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: #1a2a66 transparent; }
.tty-block { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 4px; }
.tty-echo { color: #e6efff; }
.tty-echo .p { color: var(--accent); }
.tty-out a { color: inherit; text-decoration: underline dotted 1px; text-underline-offset: .2em; }
.tty-out a:hover, .tty-out a:focus-visible { background: var(--accent); color: #fff; text-decoration: none; outline: none; }
.tty-out .dir { color: #8ea6ff; }
.tty-out .file { color: var(--fg); }
.tty-out .dim { color: var(--dim); }
.tty-out .hl { color: #fff; }
.tty-out .cmd { color: #fff; }
.tty-out .err { color: #ad9cff; }
.tty-out .ok { color: #9fdcae; text-shadow: 0 0 8px rgba(159, 220, 174, .6); }
.tty-out .warn { color: #fff; }

.tty-in { display: flex; align-items: baseline; padding-top: 4px; }
.tty-prompt { flex: none; white-space: pre; color: var(--accent); }
#cmd { flex: 1; min-width: 0; padding: 0; border: 0; background: none; outline: none; caret-color: #e6efff; }
#cmd:focus-visible { outline: none; }
.tty-in:focus-within .tty-prompt { color: #8ea6ff; }

.tty-chips { display: none; gap: 6px; flex-wrap: wrap; padding-top: 10px; }
.tty-chips button { padding: 2px 9px; border: 1px solid #1d2c6b; background: #030a24; color: var(--fg); font: 18px/1.2 var(--f-bit); }
.tty-chips button:active { background: var(--accent); color: #fff; }
@media (hover: none), (max-width: 700px) { .tty-chips { display: flex; } :root { --tty-size: 19px; } }

.tty-noscript { position: absolute; left: 40px; bottom: 40px; z-index: 5; color: var(--fg); font: 20px var(--f-bit); }

.strip { --strip-bg: #000; }

body.meltdown .tty-glass { animation: meltdown .18s infinite; }
body.meltdown .tty-out, body.meltdown .tty-prompt, body.meltdown #cmd { color: #fff; text-shadow: 3px 0 0 rgba(90, 43, 255, .9), -3px 0 0 rgba(31, 51, 255, .9), 0 0 18px #fff; }
@keyframes meltdown {
  0% { transform: translate(0, 0); filter: none; background: #020718; }
  20% { transform: translate(3px, -2px) skewX(1deg); filter: hue-rotate(40deg) contrast(1.4); }
  40% { transform: translate(-4px, 2px); background: #160a30; }
  60% { transform: translate(2px, 3px) skewX(-2deg); filter: invert(1) hue-rotate(180deg); }
  80% { transform: translate(-2px, -3px); filter: blur(1px) brightness(1.6); background: #e9f1ff; }
  100% { transform: translate(0, 0); filter: none; }
}
body.meltdown-out main { animation: leave .8s ease-in forwards; }

@media (prefers-reduced-motion: reduce) {
  .tty-glass, .tty-glass::before, .tty-dot { animation: none; }
  body.meltdown .tty-glass { animation: none; filter: invert(1); }
}

.tty-glass.is-powering-down { animation: crt-off 1.4s cubic-bezier(.6, 0, .4, 1) forwards; }
@keyframes crt-off {
  0% { transform: none; filter: none; }
  45% { transform: scale(1, .006); filter: brightness(2.6); }
  75% { transform: scale(.004, .006); filter: brightness(3); }
  100% { transform: scale(0, 0); filter: brightness(0); }
}
