:root {
  --bg: #0c0c0c;
  --fg: #33ff66;
  --accent: #4dd2ff;
  --dim: #1a8f3f;
  --font: ui-monospace, "Cascadia Mono", "Consolas", "Courier New", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: clamp(14px, 2.2vw, 16px);
  line-height: 1.5;
}

#terminal {
  height: 100%;
  overflow-y: auto;
  padding: 1rem 1.25rem 4rem;
  cursor: text;
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.5em;
}

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

.prompt-line {
  display: flex;
  align-items: baseline;
}

.prompt-line .prompt {
  flex: none;
  white-space: pre;
}

/* Once a command is submitted, the input is replaced by a plain span; let it
   shrink and wrap instead of overflowing on narrow screens. */
.prompt-line .echoed {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.prompt-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  color: var(--fg);
  font: inherit;
  caret-color: transparent;
  min-width: 2ch;
}

/* Custom block cursor overlaying the caret cell. left/width set inline by JS.
   The inner character is centered so it lines up with the input's own glyph —
   otherwise it appears to jump when the block blinks. */
.cursor {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 1.2em;
  display: flex;
  align-items: center;
  line-height: 1;
  background: var(--fg);
  color: var(--bg);
  white-space: pre;
  pointer-events: none;
  animation: blink 1s step-end infinite;
}

.cursor.solid {
  animation: none;
  opacity: 1;
}

.cursor.hollow {
  background: transparent;
  color: transparent;
  box-shadow: inset 0 0 0 1px var(--fg);
  animation: none;
  opacity: 1;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* Hidden span used to measure text width for cursor positioning. */
.measure {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  pointer-events: none;
  left: 0;
  top: 0;
}

/* Styled output segments, used by ls, tree, grep, and other row-based output. */
.seg-dir {
  color: var(--accent);
  font-weight: bold;
}

.seg-exec {
  color: var(--fg);
  font-weight: bold;
}

.seg-file {
  color: var(--fg);
}

.seg-dim {
  color: var(--dim);
}

.seg-match {
  color: var(--accent);
  font-weight: bold;
}

.banner {
  color: var(--dim);
}

/* Mobile quick-command bar */
#quick-commands {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  gap: 0.5rem;
  background: rgba(12, 12, 12, 0.95);
  border-top: 1px solid var(--dim);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#quick-commands button {
  flex: none;
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: 4px;
  color: var(--fg);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

#quick-commands button:active {
  background: var(--dim);
  color: var(--bg);
}

@media (max-width: 600px), (pointer: coarse) {
  #quick-commands {
    display: flex;
  }

  #terminal {
    padding-bottom: 5rem;
  }
}
