:root {
  --bg: #0b0e12;
  --panel: #11161c;
  --border: #1f2730;
  --text: #c9d1d9;
  --muted: #6e7681;
  --accent: #3fb950;
  --link: #58a6ff;
  --error: #f85149;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--mono);
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.terminal {
  width: 100%;
  max-width: 82ch;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  overflow: hidden;
  transition: opacity .6s;
}

.terminal.closed { opacity: 0; }

.titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.title { grid-column: 2; }

/* A decorative close button, drawn as two crossed lines. */
.close {
  justify-self: end;
  position: relative;
  width: 12px;
  height: 12px;
}

.close::before,
.close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--muted);
  transform: rotate(45deg);
}

.close::after { transform: rotate(-45deg); }

.screen {
  padding: 16px;
  min-height: 22em;
  max-height: 75vh;
  overflow-y: auto;
  cursor: text;
}

pre, p { margin: 0; }

pre {
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.motd { color: var(--muted); margin-bottom: 1em; }
.error { color: var(--error); }

.line {
  display: flex;
  gap: 1ch;
}

.ps1 {
  color: var(--accent);
  white-space: nowrap;
}

/* The real input is invisible and sits on top of a mirror that draws the
   typed text plus a block cursor. */
.field {
  flex: 1;
  min-width: 0;
  position: relative;
}

#input {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: transparent;
  font: inherit;
  caret-color: transparent;
}

#input::selection { background: transparent; }

.mirror {
  display: block;
  white-space: pre;
  overflow: hidden;
}

.cursor {
  background: var(--text);
  color: var(--panel);
  animation: blink 1s step-end infinite;
}

.field:not(:focus-within) .cursor {
  background: none;
  color: inherit;
  outline: 1px solid var(--muted);
  outline-offset: -1px;
  animation: none;
}

@keyframes blink {
  50% { background: none; color: inherit; }
}

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

a { color: var(--link); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

@media (max-width: 480px) {
  html, body { font-size: 13px; }
  body { padding: 8px; }
}
