:root {
  color-scheme: dark;
  /* main.js overwrites these from THEMES; defaults match the "green" theme. */
  --fg: #3ddc84;
  --fg-dim: #1e7a46;
  --hl: #ffd166;
  --border: #12391f;
  --soft: rgba(255, 255, 255, .72);
  --bg: #000;
}

html, body { height: 100%; margin: 0; background: var(--bg); }

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 16px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  background: var(--bg);
  color: var(--fg);
}

/* ---- header ------------------------------------------------------------ */
header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; user-select: none; }
.brand { font-weight: 700; letter-spacing: .02em; white-space: nowrap; text-decoration: none; color: inherit; }
.who { margin: 0; font-size: .85em; font-weight: 400; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .caret { display: inline-block; width: .6ch; margin-left: .25ch; animation: blink 1s steps(1, end) infinite; }
@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem;
  border: 1px solid var(--border); background: transparent; color: var(--soft);
  font: inherit; cursor: pointer;
}
.icon-btn:hover { color: var(--fg); border-color: var(--fg); }
.icon-btn:focus-visible { outline: 2px dashed var(--soft); outline-offset: 3px; }

/* ---- terminal ---------------------------------------------------------- */
.term {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
/* Rain sits behind the text: .out and .cmd are positioned above it. */
#mx { position: absolute; inset: 0; z-index: 0; pointer-events: none; display: none; opacity: .55; }
.matrix-on #mx { display: block; }

.out {
  flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; z-index: 1; padding: 12px;
  word-break: break-word; scrollbar-width: none;
  /* CRT scanlines; "local" makes them scroll with the text. */
  background-image: repeating-linear-gradient(to bottom, transparent 0, rgba(255, 255, 255, .045) 1.5px, transparent 3px);
  background-attachment: local;
}
.out::-webkit-scrollbar { width: 0; height: 0; }
.out.no-scan { background-image: none; }

.row { margin: .12rem 0; white-space: pre-wrap; }
.row.ascii { white-space: pre; line-height: 1.2; overflow-x: auto; scrollbar-width: none; }
.row a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--fg-dim); }
.row a:hover { color: var(--hl); border-bottom-color: var(--hl); }

.muted { color: var(--fg-dim); }
.hl    { color: var(--hl); }
.soft  { color: var(--soft); }
.err   { color: #ff5f5f; }

.glow .out { text-shadow: 0 0 2px var(--fg), 0 0 6px var(--fg); }

.cmd {
  display: flex; gap: .5rem; align-items: baseline; padding: 8px 12px;
  position: relative; z-index: 1;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, .35));
}
.ps1 { user-select: none; white-space: nowrap; }
.in {
  flex: 1 1 auto; min-width: 10ch;
  background: transparent; border: none; outline: none;
  color: inherit; font: inherit; caret-color: currentColor;
}
.in::placeholder { color: var(--fg-dim); }

/* ---- footer links ------------------------------------------------------ */
.links { padding: 10px 12px; }
.grid { display: grid; gap: .35rem .8rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.link a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--border); }
.link a:hover, .link a:focus-visible { color: var(--hl); border-bottom-color: var(--hl); outline: none; }
.link small { margin-left: .5ch; font-size: .8em; }

@media (max-width: 600px) {
  .app { font-size: 14px; }
  .who .role { display: none; }
  .out { padding: .75rem; }
  .cmd { padding: .35rem .75rem .75rem; }
  .row.ascii { font-size: min(1em, 2.4vw); }
}

@media (prefers-reduced-motion: reduce) {
  .who { margin: 0; font-size: .85em; font-weight: 400; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .caret { animation: none; }
}
