:root {
  --bg: #050805;
  --bezel: #121812;
  --bezel-edge: #2a3a2a;
  --phosphor: #33ff66;
  --phosphor-dim: #1a9940;
  --phosphor-muted: #0d6630;
  --phosphor-glow: rgba(51, 255, 102, 0.45);
  --screen: #020402;
  --font: "Share Tech Mono", "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--phosphor);
  font-family: var(--font);
  overflow: hidden;
}

.crt-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% 40%, #0a1a0c 0%, var(--bg) 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.15) 2px,
      rgba(0, 0, 0, 0.15) 4px
    );
  z-index: 0;
  pointer-events: none;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.22) 3px,
    rgba(0, 0, 0, 0.22) 4px
  );
  z-index: 3;
  pointer-events: none;
  animation: scan-drift 8s linear infinite;
  opacity: 0.55;
}

.vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.65) 100%);
  z-index: 4;
  pointer-events: none;
}

@keyframes scan-drift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 100px;
  }
}

@keyframes screen-flicker {
  0%,
  100% {
    opacity: 1;
  }
  92% {
    opacity: 1;
  }
  93% {
    opacity: 0.88;
  }
  94% {
    opacity: 1;
  }
  97% {
    opacity: 0.92;
  }
  98% {
    opacity: 1;
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    text-shadow: 0 0 4px var(--phosphor-glow), 0 0 12px rgba(51, 255, 102, 0.2);
  }
  50% {
    text-shadow: 0 0 6px var(--phosphor-glow), 0 0 18px rgba(51, 255, 102, 0.35);
  }
}

.monitor {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 1.5rem));
  height: min(640px, calc(100vh - 1.5rem));
  margin: max(0.75rem, (100vh - min(640px, calc(100vh - 1.5rem))) / 2) auto;
  display: flex;
  flex-direction: column;
  background: var(--bezel);
  border: 3px solid var(--bezel-edge);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px #000,
    0 12px 40px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(80, 120, 80, 0.25);
  animation: screen-flicker 6s ease-in-out infinite;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--bezel-edge);
  background: linear-gradient(180deg, #1a281a 0%, #0e160e 100%);
  flex-shrink: 0;
}

.titlebar-label {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--phosphor-dim);
  animation: glow-pulse 3s ease-in-out infinite;
}

.titlebar-dots {
  display: flex;
  gap: 0.35rem;
}

.titlebar-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--phosphor-muted);
  border: 1px solid var(--phosphor-dim);
}

.screen {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--screen);
  margin: 0.4rem;
  border: 1px solid var(--phosphor-muted);
  border-radius: 4px;
  box-shadow: inset 0 0 40px rgba(0, 40, 10, 0.5);
  overflow: hidden;
}

/* Boot */
.boot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  transition: opacity 0.4s ease;
}

.boot.fade-out {
  opacity: 0;
  pointer-events: none;
}

.boot-title {
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px var(--phosphor-glow);
}

.progress-track {
  width: min(280px, 70%);
  height: 14px;
  border: 1px solid var(--phosphor);
  padding: 2px;
  box-shadow: 0 0 8px var(--phosphor-glow);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor-glow);
  transition: width 0.05s linear;
}

.boot-pct {
  margin: 0;
  font-size: 0.9rem;
  color: var(--phosphor-dim);
}

/* Terminal */
.terminal {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.75rem 0.9rem 0.5rem;
}

.output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: clamp(0.75rem, 1.8vw, 0.95rem);
  line-height: 1.45;
  scrollbar-width: thin;
  scrollbar-color: var(--phosphor-muted) transparent;
}

.output::-webkit-scrollbar {
  width: 6px;
}

.output::-webkit-scrollbar-thumb {
  background: var(--phosphor-muted);
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  min-height: 1.45em;
}

.line.cmd-echo {
  margin-top: 0.35rem;
}

.row {
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) 1fr;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  padding: 0.1rem 0;
}

.row.child {
  grid-template-columns: minmax(12rem, 15rem) 1fr;
  padding-left: 1.25rem;
}

.row .name {
  color: var(--phosphor);
  text-shadow: 0 0 4px var(--phosphor-glow);
}

.row .desc {
  color: var(--phosphor-dim);
}

.row a.name {
  text-decoration: none;
  color: var(--phosphor);
}

.row a.name:hover,
.row a.name:focus-visible {
  text-decoration: underline;
  outline: none;
}

.row .folder-btn,
.row .locked-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--phosphor);
  cursor: pointer;
  text-align: left;
  text-shadow: 0 0 4px var(--phosphor-glow);
}

.row .folder-btn:hover,
.row .locked-btn:hover,
.row .folder-btn:focus-visible,
.row .locked-btn:focus-visible {
  text-decoration: underline;
  outline: none;
}

.row .tag {
  color: var(--phosphor-muted);
  margin-left: 0.35rem;
  font-size: 0.85em;
}

.msg-denied {
  color: var(--phosphor);
  margin: 0.25rem 0 0.5rem;
}

.cmd-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--phosphor-muted);
  margin-top: 0.35rem;
  min-width: 0;
}

.prompt-label {
  flex-shrink: 0;
  color: var(--phosphor);
  text-shadow: 0 0 4px var(--phosphor-glow);
  font-size: clamp(0.75rem, 1.8vw, 0.95rem);
}

.cmd-input-group {
  position: relative;
  display: inline-block;
  min-width: 1ch;
  max-width: 100%;
  flex: 1 1 auto;
  vertical-align: bottom;
  line-height: 1.45;
}

#cmdline {
  display: block;
  width: 1ch;
  min-width: 1ch;
  max-width: 100%;
  background: transparent;
  border: none;
  color: var(--phosphor);
  font: inherit;
  font-size: clamp(0.75rem, 1.8vw, 0.95rem);
  line-height: 1.45;
  caret-color: transparent;
  outline: none;
  padding: 0;
  margin: 0;
}

#cmdline:disabled {
  opacity: 0.5;
}

.cursor-block {
  position: absolute;
  top: 50%;
  left: 0;
  width: 1ch;
  height: 1.15em;
  margin-top: -0.575em;
  background: var(--phosphor);
  box-shadow: 0 0 6px var(--phosphor-glow);
  animation: blink 1s step-end infinite;
  pointer-events: none;
  mix-blend-mode: difference;
}

.cmd-line:not(.ready) .cursor-block {
  display: none;
}

.cmd-line.typing .cursor-block {
  display: none;
}

.cmd-line.ready:focus-within .cursor-block {
  animation: blink 1s step-end infinite;
}

@media (max-width: 560px) {
  .monitor {
    width: calc(100vw - 0.75rem);
    height: calc(100vh - 0.75rem);
    margin: 0.375rem auto;
    border-radius: 6px;
  }

  .row,
  .row.child {
    grid-template-columns: 1fr;
    gap: 0.1rem;
    padding-bottom: 0.45rem;
  }

  .row.child {
    padding-left: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scanlines,
  .monitor,
  .titlebar-label,
  .cursor-block {
    animation: none !important;
  }

  .progress-fill {
    transition: none;
  }

  .boot {
    transition: none;
  }
}
