@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(/assets/mono-400.ttf) format('truetype'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url(/assets/mono-500.ttf) format('truetype'); }

:root {
  --bg: #060607;
  --ink: #d9d5c7;
  --mid: #8f8b7e;
  --dim: #5d5a52;
  --faint: #2a2926;
  --line: #1b1a18;
  --red: #ff3d2e;
  --red-dim: #7a2018;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); }
body {
  color: var(--ink);
  font: 400 13px/1.55 var(--mono);
  font-variant-ligatures: none;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: var(--red); color: var(--bg); }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--red); }
b { font-weight: 500; }

.shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    radial-gradient(120% 80% at 35% 30%, rgba(255, 61, 46, .045), transparent 60%),
    radial-gradient(140% 120% at 50% 50%, transparent 55%, rgba(0, 0, 0, .75));
}

/* ───────── top bar ───────── */
.bar {
  display: flex; align-items: center; gap: 22px;
  padding: 10px 18px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  white-space: nowrap;
}
.bar-id { color: var(--ink); margin-right: auto; }
.bar-pi { color: var(--dim); margin-left: .6em; letter-spacing: .08em; }
.bar-item b { color: var(--mid); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); margin-right: 8px; vertical-align: 1px; }
.dot.on { background: var(--red); box-shadow: 0 0 10px var(--red); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ───────── layout ───────── */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; min-height: 0; }
.core { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; padding: 0 18px; }

/* ───────── the eye ───────── */
.gaze { display: flex; flex-direction: column; align-items: center; padding: 22px 0 10px; }
#eye {
  font: 400 min(13px, calc((100vw - 36px) / 35)) / 1 var(--mono);
  letter-spacing: 0;
  color: var(--faint);
  user-select: none; cursor: default;
  text-shadow: 0 0 12px rgba(217, 213, 199, .08);
}
#eye .e { color: var(--ink); }
#eye .s { color: var(--faint); }
#eye .i { color: #77736a; }
#eye .p { color: var(--red); font-weight: 500; text-shadow: 0 0 14px rgba(255, 61, 46, .7); }
#eye .v { color: var(--red-dim); }

.count {
  margin-top: 16px;
  font-size: clamp(22px, 4.6vw, 40px); line-height: 1; font-weight: 400;
  letter-spacing: .08em; font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 0 22px rgba(217, 213, 199, .18);
}
.count-sign { color: var(--dim); margin-right: .2em; }
.count-cs { color: var(--dim); font-size: .5em; letter-spacing: .06em; }
.count.near { color: var(--red); text-shadow: 0 0 26px rgba(255, 61, 46, .55); }
.count.near .count-sign, .count.near .count-cs { color: var(--red-dim); }
.count.past .count-sign { color: var(--red); }

.ca {
  margin-top: 14px; max-width: 100%;
  font: inherit; font-size: min(12px, calc((100vw - 36px) / 28)); letter-spacing: .04em;
  color: var(--mid); background: none; border: 1px solid var(--line); padding: 6px 12px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ca:hover, .ca:focus-visible { color: var(--ink); border-color: var(--red-dim); outline: 0; }
.ca::before { content: 'ca '; color: var(--red); }

/* ───────── terminal ───────── */
.term { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-height: 0; max-width: 780px; width: 100%; margin: 0 auto; padding-bottom: 12px; }
.log { overflow-y: auto; padding: 10px 0 6px; scrollbar-width: none; mask-image: linear-gradient(to bottom, transparent, #000 28px); }
.log::-webkit-scrollbar { display: none; }
.log p { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.55em; }
.log .sys { color: var(--dim); }
.log .ent { color: var(--ink); }
.log .red { color: var(--red); }
.log .you { color: var(--mid); }
.log .you::before { content: '> '; color: var(--dim); }
.log .kv { color: var(--mid); }

.prompt { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 10px 0 8px; }
.caret { color: var(--red); }
.prompt input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0;
  color: var(--ink); caret-color: var(--red);
  font: inherit; font-size: 16px; /* 16px stops iOS from zooming on focus */
}
@media (min-width: 720px) { .prompt input { font-size: 13px; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font: inherit; font-size: 11px; letter-spacing: .1em; color: var(--dim);
  background: none; border: 1px solid var(--line); padding: 5px 10px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chips button:hover, .chips button:focus-visible { color: var(--ink); border-color: var(--dim); outline: 0; }

/* ───────── observation stream ───────── */
.stream { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border-left: 1px solid var(--line); }
.stream-head {
  display: flex; justify-content: space-between; padding: 12px 16px 10px;
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--line);
}
.feed { list-style: none; overflow: hidden; padding: 8px 16px; mask-image: linear-gradient(to bottom, #000 60%, transparent); }
.feed li {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 11px; line-height: 1.9; white-space: nowrap; color: var(--dim);
  animation: arrive .5s ease-out;
}
.feed li > span:last-child { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.feed .blk { color: var(--mid); }
.feed .blk b { color: var(--ink); }
.feed .hash { color: var(--faint); }
.feed .obs { color: var(--ink); }
.feed .obs .n, .feed .obs .tag { color: var(--red); }
.feed a { text-decoration: none; }
.feed a:hover { color: var(--ink); }
@keyframes arrive { from { opacity: 0; transform: translateY(-6px); } }

/* ───────── the name, unfinished ───────── */
.name { border-top: 1px solid var(--line); overflow: hidden; padding: 7px 0; padding-bottom: max(7px, env(safe-area-inset-bottom)); color: var(--faint); font-size: 10px; letter-spacing: .3em; white-space: nowrap; }
.name-track { display: inline-block; animation: drift 240s linear infinite; }
.name-track span { color: var(--dim); }
@keyframes drift { to { transform: translateX(-50%); } }

/* ───────── glass ───────── */
.scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .16) 2px 3px);
  mix-blend-mode: multiply;
}
.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { filter: brightness(2.4) saturate(1.6); } 100% { filter: none; } }

/* ───────── narrow screens: the stream becomes a strip under the bar ───────── */
@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .stream { order: -1; border-left: 0; border-bottom: 1px solid var(--line); }
  .stream-head { display: none; }
  .feed { height: calc(3 * 1.9 * 11px + 12px); padding: 6px 14px; }
  .core { padding: 0 14px; }
  .gaze { padding: 14px 0 6px; }
  .count { margin-top: 10px; }
  .bar { gap: 14px; padding-left: 14px; padding-right: 14px; font-size: 10px; }
  .bar-wide, .bar-pi { display: none; }
}
@media (max-height: 620px) { #eye { font-size: min(9px, calc((100vw - 36px) / 35)); } }

@media (prefers-reduced-motion: reduce) {
  .name-track, .dot.on, .feed li, .flash { animation: none; }
}
