@font-face {
  font-family: "JBM";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/jbm-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JBM";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/fonts/jbm-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b0e0c;
  --bg-2: #111713;
  --bg-3: #17201a;
  --line: #233027;
  --fg: #d9e2da;
  --dim: #6f8073;
  --green: #5af78e;
  --green-dim: #2c8a4e;
  --cyan: #57c7ff;
  --yellow: #f3f99d;
  --red: #ff5c57;
  --magenta: #ff6ac1;
  --glow: rgba(90, 247, 142, .4);
  --ink: #04140a;
  --mono: "JBM", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

/* Hidden phosphor themes: `theme <name>` in the CLI, 7 taps on the prompt, or the Konami code. */
html[data-theme="amber"] {
  --bg: #0e0a05; --bg-2: #17110a; --bg-3: #20180d; --line: #3a2b12;
  --fg: #f3e3c3; --dim: #8f7a55; --green: #ffb000; --green-dim: #9a6a00;
  --cyan: #ffd27a; --yellow: #fff1b8; --magenta: #ff8c42; --red: #ff5f45;
  --glow: rgba(255, 176, 0, .4); --ink: #1a1000;
}
html[data-theme="ice"] {
  --bg: #080b10; --bg-2: #0e131b; --bg-3: #141b26; --line: #223042;
  --fg: #e6f1ff; --dim: #6f8399; --green: #9be7ff; --green-dim: #3d7f99;
  --cyan: #c9f2ff; --yellow: #fff7c2; --magenta: #c3a6ff; --red: #ff7b8a;
  --glow: rgba(155, 231, 255, .4); --ink: #021018;
}
html[data-theme="love"] {
  --bg: #120810; --bg-2: #1b0d18; --bg-3: #241221; --line: #3d1d36;
  --fg: #ffe3f4; --dim: #9a6d8d; --green: #ff6ac1; --green-dim: #a33d7c;
  --cyan: #ffb3e0; --yellow: #ffe28a; --magenta: #ff9fd6; --red: #ff5c57;
  --glow: rgba(255, 106, 193, .45); --ink: #2a0019;
}
html[data-theme="mono"] {
  --bg: #0a0a0a; --bg-2: #141414; --bg-3: #1c1c1c; --line: #2e2e2e;
  --fg: #e8e8e8; --dim: #7a7a7a; --green: #f2f2f2; --green-dim: #8a8a8a;
  --cyan: #cfcfcf; --yellow: #ffffff; --magenta: #bdbdbd; --red: #ff6b6b;
  --glow: rgba(255, 255, 255, .25); --ink: #000;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 var(--mono);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
@media (max-width: 360px) { html, body { font-size: 13px; } }
::selection { background: var(--green); color: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); }

#term {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  max-width: 600px; margin: 0 auto;
}

/* ----------------------------------------------------------- prompt bar */
#bar {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
}
.ps { overflow: hidden; text-overflow: ellipsis; }
.ps-user, .ps-host { color: var(--green); font-weight: 700; text-shadow: 0 0 8px var(--glow); }
.ps-at { color: var(--dim); }
.ps-path { color: var(--cyan); font-weight: 700; }
.cursor {
  display: inline-block; flex: none;
  width: .6em; height: 1.15em; margin-left: 4px;
  background: var(--green); vertical-align: text-bottom;
  animation: blink 1.06s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ----------------------------------------------------------- screen */
#screen {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 14px 28px;
  -webkit-overflow-scrolling: touch;
}
.cmd { color: var(--fg); margin: 0 0 10px; word-break: break-all; }
.cmd .ps1 { color: var(--green); font-weight: 700; }
.cmd .cursor { height: 1em; }
.out > * + * { margin-top: 10px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.ok { color: var(--green); }
.warn { color: var(--yellow); }
.err { color: var(--red); }
.err:empty { display: none; }
.cy { color: var(--cyan); }
.mg { color: var(--magenta); }
.yl { color: var(--yellow); }
b, .b { font-weight: 700; color: #fff; }
h1.t { font-size: 17px; line-height: 1.35; margin: 4px 0 6px; color: #fff; }
.sec { color: var(--yellow); margin-top: 20px !important; }
.sec::before { content: "## "; color: var(--dim); }
p { margin: 0; }
.descr { white-space: pre-wrap; color: var(--fg); }
.hr { color: var(--line); overflow: hidden; white-space: nowrap; }
.hr::before { content: "────────────────────────────────────────────────────────────────────────"; }
.lnk { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.back { color: var(--dim); background: none; border: 0; padding: 0 0 8px; }

/* ----------------------------------------------------------- boxes & key/value */
.box {
  position: relative;
  border: 1px solid var(--line);
  padding: 14px 12px 12px;
  margin-top: 14px !important;
  background: linear-gradient(180deg, var(--glow), transparent 40%);
}
.box > .lg {
  position: absolute; top: -.8em; left: 10px;
  padding: 0 6px; background: var(--bg);
  color: var(--dim); font-size: 12px;
}
.kv { display: grid; grid-template-columns: 8ch 1fr; gap: 3px 10px; margin-top: 10px; }
.kv > .k { color: var(--dim); }
.kv > .k::after { content: ":"; }
.tags { color: var(--cyan); word-spacing: 4px; }
.common .lnk { color: var(--yellow); }
.badge-demo { color: var(--dim); font-size: 11px; border: 1px solid var(--line); padding: 0 4px; margin-left: 6px; }

/* ----------------------------------------------------------- avatar */
.avatar { position: relative; overflow: hidden; cursor: pointer; aspect-ratio: 4 / 3; background: #050705; }
.avatar pre.ascii {
  margin: 0; line-height: 1; letter-spacing: 0;
  font-family: var(--mono); font-size: 6px;
  color: var(--green); text-shadow: 0 0 5px var(--glow);
  white-space: pre; user-select: none;
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.avatar.m-crt img { filter: grayscale(1) sepia(1) hue-rotate(75deg) saturate(3.2) brightness(.9) contrast(1.15); }
.avatar.m-crt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .35) 0 1px, transparent 1px 3px);
}
.avatar .mode {
  position: absolute; right: 6px; bottom: 4px; z-index: 2;
  font-size: 11px; color: var(--green); background: rgba(0, 0, 0, .7); padding: 0 4px;
}
.mini {
  flex: none; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--green-dim); color: var(--green); font-weight: 700;
  background: #050705; overflow: hidden;
}
.mini img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) sepia(1) hue-rotate(75deg) saturate(3) brightness(.95); }

/* ----------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 12px;
  background: transparent; color: var(--green);
  border: 1px solid var(--green-dim); border-radius: 0;
  white-space: nowrap; user-select: none;
  transition: background .1s, color .1s;
}
.btn:active, .btn.primary:active { background: var(--green); color: var(--bg); }
.btn.primary { background: var(--green); color: var(--bg); border-color: var(--green); font-weight: 700; }
.btn.danger { color: var(--red); border-color: rgba(255, 92, 87, .45); }
.btn.danger:active { background: var(--red); color: var(--bg); }
.btn.ghost { border-color: var(--line); color: var(--fg); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.grow > .btn { flex: 1 1 auto; }
.deck-actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; position: sticky; bottom: 0; padding: 10px 0 2px; background: linear-gradient(transparent, var(--bg) 30%); }
.deck-actions .skip { color: var(--red); border-color: rgba(255, 92, 87, .45); }
.deck-actions .skip:active { background: var(--red); color: var(--bg); }
.deck-actions .like { color: var(--magenta); border-color: rgba(255, 106, 193, .5); }
.deck-actions .like:active { background: var(--magenta); color: var(--bg); }

/* flags = chips */
.flags { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.flags::-webkit-scrollbar { display: none; }
.flags.wrap { flex-wrap: wrap; overflow: visible; }
.flag {
  flex: none; white-space: nowrap;
  padding: 5px 9px; min-height: 32px;
  background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 0;
}
.flag.on { background: var(--green); color: var(--bg); border-color: var(--green); font-weight: 700; }
.seg { display: flex; border: 1px solid var(--line); }
.seg-b { flex: 1; padding: 8px 4px; background: none; border: 0; color: var(--dim); }
.seg-b + .seg-b { border-left: 1px solid var(--line); }
.seg-b.on { color: var(--bg); background: var(--green); font-weight: 700; }

/* ----------------------------------------------------------- inputs */
.in {
  width: 100%; padding: 9px 10px;
  background: var(--bg-2); color: #fff;
  border: 1px solid var(--line); border-radius: 0;
  outline: none; caret-color: var(--green);
}
.in:focus { border-color: var(--green-dim); box-shadow: 0 0 0 1px var(--green-dim); }
textarea.in { resize: vertical; min-height: 64px; }
select.in { appearance: none; }
input.in[type="datetime-local"] { color-scheme: dark; min-height: 42px; }
.row-in { display: flex; gap: 8px; }
.row-in .in { flex: 1; min-width: 0; }
.field > * + * { margin-top: 8px; }
.qa { padding: 2px 0; }
.qa.done { color: var(--dim); cursor: pointer; }
.qa.done .ans { color: var(--fg); }
.qa.cur > * + * { margin-top: 10px; }
.q { color: var(--green); font-weight: 700; }
.lbl { color: var(--dim); display: block; margin: 14px 0 6px; }
.lbl::before { content: "# "; }

/* ----------------------------------------------------------- lists */
.list { border-top: 1px dashed var(--line); }
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.row:active { background: var(--bg-2); }
.row .title { color: #fff; overflow-wrap: anywhere; }
.row .sub { color: var(--dim); font-size: 12px; overflow-wrap: anywhere; }
.row .time { color: var(--cyan); font-size: 13px; text-align: right; min-width: 5ch; }
.row .cat { color: var(--magenta); font-size: 12px; }
.stars { color: var(--dim); font-size: 13px; white-space: nowrap; }
.stars.on { color: var(--yellow); }
.day { color: var(--yellow); margin: 16px 0 2px !important; }
.day::before { content: "# "; color: var(--dim); }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.person:active { background: var(--bg-2); }
.person .who { flex: 1; min-width: 0; }
.person .who .sub { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* mail */
.mail { border-bottom: 1px dashed var(--line); padding: 10px 0; }
.mail > * + * { margin-top: 6px; }
.st { font-size: 12px; padding: 0 5px; border: 1px solid currentColor; white-space: nowrap; }
.st-pending { color: var(--yellow); }
.st-accepted { color: var(--green); }
.st-declined { color: var(--red); }
.st-expired, .st-cancelled { color: var(--dim); }

/* ----------------------------------------------------------- cli & tmux */
#cli {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 4px 14px; border-top: 1px solid var(--line);
}
#cli input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff; padding: 6px 0; caret-color: var(--green); font-size: 16px; }
#cli input::placeholder { color: #3e4b41; }
.cli-out { margin-top: 14px; white-space: pre-wrap; }
.cli-out .cmd { margin-bottom: 4px; }

#tmux {
  flex: none; display: flex; align-items: stretch;
  background: var(--green); color: var(--ink);
  font-size: 13px; font-weight: 700;
  padding-bottom: var(--safe-bottom);
  user-select: none;
}
#tmux .sess { padding: 9px 6px 9px 10px; background: var(--ink); color: var(--green); }
#tmux .tw { flex: 1; padding: 9px 2px; background: none; border: 0; color: var(--ink); font-weight: 700; white-space: nowrap; }
#tmux .tw.on { background: var(--ink); color: var(--green); }
#tmux .tw .bdg { color: #a1002d; }
#tmux .tw.on .bdg { color: var(--yellow); }
#tmux .clock { padding: 9px 10px; display: none; }
@media (min-width: 470px) { #tmux .clock { display: block; } }

/* ----------------------------------------------------------- dialog */
#modal {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .68);
}
#modal.open { display: flex; }
.dlg {
  position: relative;
  width: min(600px, calc(100% - 16px));
  margin: 0 8px calc(8px + var(--safe-bottom));
  background: var(--bg); border: 1px solid var(--green);
  box-shadow: 0 0 0 1px #000, 0 0 24px var(--glow);
  animation: rise .14s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.dlg-title {
  position: absolute; top: -.8em; left: 50%; transform: translateX(-50%);
  background: var(--bg); color: var(--green); font-weight: 700; padding: 0 4px; white-space: nowrap;
}
.dlg-body { max-height: 66vh; overflow-y: auto; padding: 18px 14px 6px; }
.dlg-body > * + * { margin-top: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px 14px; flex-wrap: wrap; }
.irow {
  display: flex; width: 100%; align-items: baseline; gap: 10px; text-align: left;
  padding: 10px 0; background: none; border: 0; border-bottom: 1px dashed var(--line);
}
.irow[disabled] { cursor: default; }
.irow .ik { color: var(--dim); width: 7ch; flex: none; }
.irow .iv { flex: 1; color: #fff; overflow-wrap: anywhere; }
.irow .iv.dim { color: var(--yellow); }
.big-ascii { color: var(--magenta); text-align: center; line-height: 1.1; margin: 0; text-shadow: 0 0 10px rgba(255, 106, 193, .5); }

/* ----------------------------------------------------------- toasts */
#toasts {
  position: fixed; left: 0; right: 0; z-index: 60;
  bottom: calc(96px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; padding: 0 12px;
}
.toast {
  max-width: 560px; background: var(--bg-2); border: 1px solid var(--line);
  padding: 6px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  transition: opacity .3s, transform .3s;
}
.toast.bye { opacity: 0; transform: translateY(6px); }
.tk-ok { color: var(--green); } .tk-err { color: var(--red); } .tk-warn { color: var(--yellow); } .tk-info { color: var(--cyan); }

/* ----------------------------------------------------------- feed card motion */
.card { touch-action: pan-y; will-change: transform; }
.card.out-left { animation: out-l .26s steps(5) forwards; }
.card.out-right { animation: out-r .26s steps(5) forwards; }
@keyframes out-l { to { transform: translateX(-110%) skewX(8deg); opacity: 0; clip-path: inset(10% 0 30% 0); } }
@keyframes out-r { to { transform: translateX(110%) skewX(-8deg); opacity: 0; clip-path: inset(30% 0 10% 0); } }
.card.in { animation: card-in .22s steps(4); }
@keyframes card-in { from { opacity: 0; clip-path: inset(0 0 100% 0); } }

/* ----------------------------------------------------------- CRT overlay */
.crt {
  pointer-events: none; position: fixed; inset: 0; z-index: 100;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, .35) 100%);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ----------------------------------------------------------- toys */
.matrix { position: fixed; inset: 0; z-index: 90; pointer-events: none; transition: opacity .4s; }
.sl { position: fixed; left: 0; bottom: 120px; z-index: 80; margin: 0; color: var(--green); text-shadow: 0 0 6px var(--glow); white-space: pre; pointer-events: none; font-size: 12px; line-height: 1.15; }
pre.toy { margin: 0; white-space: pre; overflow-x: auto; line-height: 1.25; }
.neo { display: flex; gap: 14px; align-items: flex-start; }
.neo pre { margin: 0; color: var(--green); text-shadow: 0 0 6px var(--glow); line-height: 1.25; }
.neo .info { line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.neo .info .k { color: var(--green); font-weight: 700; }
.swatch { display: inline-block; width: 1.4em; height: 1em; vertical-align: middle; }
.top-row { display: grid; grid-template-columns: 4ch 5ch 1fr; gap: 8px; padding: 3px 0; cursor: pointer; }
.top-row:active { background: var(--bg-2); }
.motd { color: var(--dim); font-size: 12px; white-space: pre-wrap; border-left: 2px solid var(--line); padding-left: 8px; }
.git { white-space: pre-wrap; }
.git .h { color: var(--yellow); }
