:root {
  --bg: #0a0e0a;
  --fg: #33ff66;
  --fg-dim: #1f9c40;
  --fg-muted: #147a2e;
  --accent: #7dffa8;
  --error: #ff5f56;
  --font: "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code",
    Menlo, Consolas, "Liberation Mono", monospace;
  --glow: 0 0 4px rgba(51, 255, 102, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  /* Solid base color for the entire page, including anything scrolled past
     the first viewport, so the background never changes tone on scroll. */
  background: var(--bg);
}

body {
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  text-shadow: var(--glow);
  -webkit-font-smoothing: antialiased;
}

/* CRT scanline + vignette as a fixed layer that always covers the viewport,
   so it looks identical before and after scrolling. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(120% 120% at 50% 0%, rgba(51, 255, 102, 0.04), transparent 60%),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.15) 3px
    );
}

.terminal {
  min-height: 100%;
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  padding-top: calc(env(safe-area-inset-top) + 16px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: text;
}

.output {
  flex: 0 0 auto;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.output::-webkit-scrollbar {
  width: 8px;
}
.output::-webkit-scrollbar-thumb {
  background: var(--fg-muted);
  border-radius: 4px;
}

.line {
  margin: 0;
}

.line.user {
  color: var(--fg);
}

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

.line.error {
  color: var(--error);
  text-shadow: 0 0 4px rgba(255, 95, 86, 0.35);
}

.line.banner {
  color: var(--accent);
}

.line .echo-prompt {
  color: var(--fg-muted);
  margin-right: 4px;
}

.chat-photo {
  display: block;
  max-width: min(320px, 80%);
  height: auto;
  margin: 6px 0;
  border: 1px solid var(--fg-muted);
  border-radius: 3px;
  /* subtle terminal-green tint so the photo sits in the aesthetic */
  filter: saturate(0.9) contrast(1.02);
  box-shadow: 0 0 10px rgba(51, 255, 102, 0.15);
}

.input-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 0 0 auto;
}

.prompt {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--fg-dim);
  user-select: none;
}

.prompt-user {
  color: var(--accent);
}
.prompt-host {
  color: var(--fg);
}
.prompt-path {
  color: var(--fg-dim);
}

.input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: block;
}

/* The command input is a textarea so long text wraps to new lines instead
   of scrolling off-screen. JS auto-grows its height to fit the content. */
.cmd {
  display: block;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  line-height: 1.5;
  text-shadow: inherit;
  /* hide the native caret; we render our own square block cursor */
  caret-color: transparent;
  padding: 0;
  margin: 0;
  resize: none;
  overflow: hidden; /* no inner scrollbar; height grows to fit */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cmd:focus-visible {
  outline: none;
}

/* Solid square block cursor. Positioned via JS (translate x/y) at the caret,
   which may be on any wrapped line. */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.6em;
  height: 1.05em;
  background: var(--fg);
  box-shadow: var(--glow);
  transform: translate(0, 0.2em);
  pointer-events: none;
}

/* Blink only while the input is focused. */
.input-line:focus-within .cursor {
  animation: block-blink 1.1s step-end infinite;
}
.input-line:not(:focus-within) .cursor {
  opacity: 0.4;
}

@media (prefers-reduced-motion: reduce) {
  .input-line:focus-within .cursor {
    animation: none;
  }
}

@keyframes block-blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 14px;
  }
  .terminal {
    padding-left: 12px;
    padding-right: 12px;
  }
}
