/* hyrcanus — the approval queue, as a Telegram Mini App.
 *
 * Two materials, deliberately kept apart:
 *   CONTENT (the tweet) is rendered faithful to X — reading-size text, X's
 *   metric row, its restraint. It is a quotation from somewhere else.
 *   CHROME (everything the app itself says) rides Telegram's theme variables,
 *   so dark/light and the user's accent come free and the page reads as part of
 *   the client rather than a website stuffed into a window.
 *
 * The system's own voice — #seq, score, metrics, keys — is monospace with
 * tabular numerals. That typographic line is the whole point: at a glance you
 * can tell what a stranger wrote from what the machine measured.
 */

:root {
  /* Telegram supplies these; the fallbacks are for a plain browser. */
  --bg:        var(--tg-theme-bg-color, #17212b);
  --bg-soft:   var(--tg-theme-secondary-bg-color, #0e1621);
  --fg:        var(--tg-theme-text-color, #f5f5f5);
  --fg-dim:    var(--tg-theme-hint-color, #7d8e9e);
  --link:      var(--tg-theme-link-color, #6ab3f3);
  --accent:    var(--tg-theme-button-color, #5288c1);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);

  /* Ours, not Telegram's and not X's: the signal colour marks machine
   * annotation only, so it can never be mistaken for either. */
  --signal:  #d8a33a;
  --danger:  #e0555c;
  --hairline: color-mix(in srgb, var(--fg) 12%, transparent);
  --raise:    color-mix(in srgb, var(--fg) 6%, transparent);

  --read: 16px;      /* X's reading size, nudged up for a webview */
  --r: 12px;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;

  --bar: calc(64px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: var(--bar);
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.45 var(--ui);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

/* ── rail ─────────────────────────────────────────────────────────────── */

.rail {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-top));
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.rail__seq {
  font: 600 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--signal);
  letter-spacing: .02em;
}

.rail__pos {
  font: 400 12px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  margin-right: auto;
}

.rail__tab {
  appearance: none; border: 0; background: none;
  padding: 5px 9px; border-radius: 999px;
  font: 500 12.5px/1 var(--ui);
  color: var(--fg-dim);
  cursor: pointer;
}
.rail__tab[aria-current="true"] { color: var(--fg); background: var(--raise); }

/* ── the tweet: X's voice ─────────────────────────────────────────────── */

.view { padding: 14px; max-width: 680px; margin: 0 auto; }

.card { animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.tweet {
  background: var(--bg-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 14px;
}

.tweet__head { display: flex; align-items: center; gap: 10px; }

/* We never stored avatar URLs, so a deterministic monogram — honest, and it
 * reads as a choice rather than a broken image. */
.avatar {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 15px/1 var(--ui); color: #fff;
  background: var(--accent);
}

.tweet__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tweet__handle { font-weight: 600; font-size: 15px; }
.tweet__meta {
  font: 400 12.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
}

.tweet__out {
  margin-left: auto; color: var(--fg-dim); text-decoration: none;
  font-size: 17px; padding: 4px 6px; border-radius: 8px;
}
.tweet__out:hover { color: var(--link); background: var(--raise); }

.tweet__text {
  margin: 11px 0 0;
  font-size: var(--read); line-height: 1.42;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

.tweet__media { display: grid; gap: 6px; margin-top: 11px; }
.tweet__media:empty { display: none; }
.tweet__media img {
  width: 100%; max-height: 42vh; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--hairline);
  background: var(--raise); display: block;
}
.tweet__media--pair { grid-template-columns: 1fr 1fr; }
.tweet__vid { position: relative; }
.tweet__vid::after {
  content: "▶ video — open on X";
  position: absolute; inset: auto 8px 8px auto;
  font: 500 11px/1 var(--mono);
  background: rgba(0,0,0,.72); color: #fff;
  padding: 5px 8px; border-radius: 6px;
}

.tweet__metrics {
  display: flex; gap: 16px; margin-top: 11px;
  font: 400 12.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
}

/* ── the verdict strip: the signature ─────────────────────────────────── */

.verdict {
  margin-top: 10px; padding: 11px 13px;
  border-left: 2px solid var(--signal);
  background: color-mix(in srgb, var(--signal) 8%, transparent);
  border-radius: 0 var(--r) var(--r) 0;
}

.verdict__row { display: flex; align-items: center; gap: 10px; }

.verdict__score {
  font: 600 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--signal);
}

/* Ten segments with the pass threshold marked. A bare number tells you the
 * score; this tells you where the line is — which is the thing actually being
 * tuned week to week. */
.gauge { display: flex; gap: 2px; }
.gauge i {
  width: 7px; height: 12px; border-radius: 1px;
  background: color-mix(in srgb, var(--fg) 14%, transparent);
}
.gauge i[data-on] { background: var(--signal); }
.gauge i[data-edge] { box-shadow: inset -1px 0 0 var(--fg-dim); }

.verdict__hot {
  margin-left: auto;
  font: 600 10px/1 var(--mono); letter-spacing: .08em;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 3px 5px; border-radius: 4px;
}

.verdict__why {
  margin: 7px 0 0; font-size: 13px; line-height: 1.4; color: var(--fg-dim);
}

/* ── drafts ───────────────────────────────────────────────────────────── */

.drafts { display: grid; gap: 9px; margin-top: 12px; }

.draft {
  background: var(--bg-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 12px;
}
.draft__top {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
  font: 500 11px/1 var(--mono); letter-spacing: .04em;
  color: var(--fg-dim); text-transform: uppercase;
}
.draft__n { color: var(--signal); font-weight: 700; }
.draft__body { font-size: var(--read); line-height: 1.4; white-space: pre-wrap;
               overflow-wrap: anywhere; }
.draft__media {
  margin-top: 9px; padding: 9px; border-radius: 8px;
  background: var(--raise);
  font: 400 12.5px/1.45 var(--mono);
  color: var(--fg-dim); white-space: pre-wrap; overflow-wrap: anywhere;
}
.draft__count {
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.draft__count[data-over] { color: var(--danger); }

.draft__row { display: flex; gap: 7px; margin-top: 10px; }

/* ── working ──────────────────────────────────────────────────────────── */

.working {
  display: flex; align-items: center; gap: 9px;
  margin-top: 12px; padding: 13px;
  border: 1px dashed var(--hairline); border-radius: var(--r);
  font: 400 13px/1 var(--mono); color: var(--fg-dim);
}
.working__dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--signal);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

/* ── the publish kit ──────────────────────────────────────────────────── */

/* Where an approval ends: X posting is not wired, so this is the handoff.
 * It gets the signal colour and a solid left edge — it is the one screen that
 * asks you to go do something outside the app. */
.kit {
  border-left: 3px solid var(--signal);
  background: var(--bg-soft);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 14px;
  animation: rise .18s ease-out;
}

.kit__head {
  font: 600 12px/1 var(--mono); letter-spacing: .05em;
  text-transform: uppercase; color: var(--signal);
  margin-bottom: 13px;
}

.kit__block { margin-bottom: 13px; }

.kit__label {
  display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
  font: 500 11px/1 var(--mono); letter-spacing: .04em;
  text-transform: uppercase; color: var(--fg-dim);
}

.kit__copy {
  appearance: none; cursor: pointer; margin-left: auto;
  border: 1px solid var(--hairline); background: none; color: var(--fg);
  border-radius: 6px; padding: 4px 9px;
  font: 500 11px/1 var(--mono); letter-spacing: .03em;
}
.kit__copy:active { transform: scale(.95); }
.kit__copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.kit__body {
  margin: 0; padding: 11px;
  background: var(--raise); border-radius: 8px;
  font-size: var(--read); line-height: 1.42;
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text;
}
.kit__body--mono { font: 400 12.5px/1.5 var(--mono); color: var(--fg-dim); }

.kit .btn--wide:first-of-type { margin-top: 4px; }

/* ── editors ──────────────────────────────────────────────────────────── */

.editor { margin-top: 12px; }
.editor__label {
  display: block; margin: 0 0 6px;
  font: 500 11px/1 var(--mono); letter-spacing: .05em;
  text-transform: uppercase; color: var(--fg-dim);
}
.editor__hint { text-transform: none; letter-spacing: 0; opacity: .7; }

.editor__text, .editor__input {
  width: 100%; padding: 11px;
  background: var(--bg-soft); color: var(--fg);
  border: 1px solid var(--hairline); border-radius: 10px;
  font: 400 var(--read)/1.42 var(--ui);
  resize: vertical;
}
.editor__text--tall { min-height: 150px; font-family: var(--mono); font-size: 13px; }
.editor__text:focus, .editor__input:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.editor__text + .editor__label { margin-top: 12px; }
.editor__from { margin: 8px 0 0; font: 400 12px/1 var(--mono); color: var(--fg-dim); }
.editor__actions { display: flex; gap: 8px; margin-top: 11px; }

/* ── buttons ──────────────────────────────────────────────────────────── */

.btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--hairline);
  background: var(--bg-soft); color: var(--fg);
  border-radius: 10px; padding: 11px 14px;
  font: 500 14px/1 var(--ui);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .08s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn--go { background: var(--accent); color: var(--accent-fg); border-color: transparent; flex: 1; }
.btn--no { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn--ghost { background: none; }
.btn--wide { width: 100%; margin-top: 9px; }
.btn--small { padding: 8px 11px; font-size: 13px; }

.btn kbd {
  font: 500 10px/1 var(--mono); color: var(--fg-dim);
  border: 1px solid var(--hairline); border-radius: 3px;
  padding: 2px 4px;
}
/* A touch device has no keyboard to hint at. */
@media (pointer: coarse) { .btn kbd { display: none; } }

/* ── action bar: fixed in the thumb zone ──────────────────────────────── */

.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: 1fr 1fr .8fr .8fr; gap: 8px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
}
.actions .btn { padding: 13px 8px; }
.btn__face { font-size: 15px; }

/* ── worked / lists ───────────────────────────────────────────────────── */

.filter { display: flex; gap: 7px; margin-bottom: 12px; }
.chip {
  appearance: none; cursor: pointer;
  border: 1px solid var(--hairline); background: none; color: var(--fg-dim);
  border-radius: 999px; padding: 6px 13px;
  font: 500 12.5px/1 var(--mono); font-variant-numeric: tabular-nums;
}
.chip--on { color: var(--bg); background: var(--signal); border-color: transparent; }

.hit {
  border: 1px solid var(--hairline); border-radius: var(--r);
  background: var(--bg-soft); padding: 12px; margin-bottom: 9px;
}
.hit__top {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 7px;
  font: 500 12.5px/1 var(--mono); font-variant-numeric: tabular-nums;
}
.hit__likes { color: var(--signal); font-weight: 700; font-size: 15px; }
.hit__rest { color: var(--fg-dim); }
.hit__out { margin-left: auto; color: var(--fg-dim); text-decoration: none; }
.hit__said { font-size: var(--read); line-height: 1.4; white-space: pre-wrap;
             overflow-wrap: anywhere; }
.hit__to {
  margin-top: 8px; padding-left: 9px; border-left: 2px solid var(--hairline);
  font-size: 13px; color: var(--fg-dim); overflow-wrap: anywhere;
}

/* ── misc ─────────────────────────────────────────────────────────────── */

.empty, .note {
  color: var(--fg-dim); font-size: 13.5px; line-height: 1.5;
  margin: 0 0 12px;
}
.empty { text-align: center; padding: 56px 20px; }
.note--sep { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.note--count { font-family: var(--mono); font-variant-numeric: tabular-nums;
               color: var(--signal); }

.result { margin-top: 12px; font: 400 12.5px/1.55 var(--mono); }
.result b { color: var(--signal); font-weight: 600; }
.result s { color: var(--danger); text-decoration: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar) + 14px);
  transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 28px);
  background: var(--fg); color: var(--bg);
  padding: 10px 15px; border-radius: 999px;
  font: 500 13px/1.3 var(--ui); text-align: center;
  animation: rise .16s ease-out;
}
.toast[data-bad] { background: var(--danger); color: #fff; }

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