/* ==========================================================================
   REMNANTSMP — the glass system every page of the new site is built from.

   The background is a graphite video of drifting squares, so the whole site
   is one deliberate dark-glass world: there is no light theme to switch to,
   and every colour below is painted explicitly rather than inherited.

   Two kinds of glass, and the difference is legibility:
     .chrome   silver, white-to-grey, the "Apple silicon" surface. Buttons,
               the logo tile, the archive folder. Holds a word, not a page.
     .graphite darker, for anything somebody READS: the stats card, the
               support chat, every economy panel. Over a mid-grey video,
               white text on silver glass is a contrast failure; on graphite
               it is not.
   ========================================================================== */

:root {
  --base: #0a0a0d;
  --veil-top: rgba(8, 8, 12, 0.30);
  --veil-bot: rgba(8, 8, 12, 0.62);

  --ink: #f5f5f7;
  --ink-2: rgba(245, 245, 247, 0.74);
  --ink-3: rgba(245, 245, 247, 0.50);
  --ink-4: rgba(245, 245, 247, 0.28);

  --chrome-top: rgba(255, 255, 255, 0.30);
  --chrome-bot: rgba(214, 218, 226, 0.08);
  --graphite-top: rgba(30, 31, 38, 0.62);
  --graphite-bot: rgba(16, 16, 21, 0.50);
  --edge: rgba(255, 255, 255, 0.22);
  --edge-hi: rgba(255, 255, 255, 0.55);
  --edge-lo: rgba(255, 255, 255, 0.05);
  --shade: rgba(0, 0, 0, 0.42);

  --ice: #a9d4ff;
  --good: #30d158;
  --bad: #ff453a;
  --warn: #ffd60a;
  --cash: #c8cdd5;
  --mint: #64d2ff;
  --infl: #ff9f0a;

  --r-xl: 44px;
  --r-lg: 28px;
  --r-md: 18px;
  --r-sm: 12px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI Variable Display", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;

  --t-cap: 11px;
  --t-sm: 13px;
  --t-body: 15px;
  --t-lead: 17px;
  --t-h3: 22px;
  --t-h2: 34px;
  --t-h1: 52px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--base); }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* THE BODY IS CLEAR ON PURPOSE. The video sits on a fixed layer at z-index
   -2, and a painted body background is drawn ABOVE negative z-index layers -
   it covered the video everywhere the page had content and let it show only
   below the last line, which is exactly how the first build looked. The
   colour lives on <html> (the canvas), under everything. */
body { overflow-x: hidden; background: transparent; }

button, input { font: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
  border-radius: 10px;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.cap {
  font-size: var(--t-cap);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
/* A class that sets display beats the hidden attribute's own display:none,
   so anything with both was drawn anyway - the big head under the login box
   stayed on screen after it had moved into the box. One rule fixes them all. */
[hidden] { display: none !important; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ------------------------------------------------------------ background */

.stage {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: #3a3b40;
  overflow: hidden;
}
.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9);
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 38%, transparent 0%, rgba(8, 8, 12, 0.18) 55%, rgba(8, 8, 12, 0.5) 100%),
    linear-gradient(180deg, var(--veil-top), var(--veil-bot));
}
/* The data pages read more than they look: a heavier veil. */
.stage.deep::after {
  background:
    radial-gradient(120% 80% at 50% 30%, rgba(8, 8, 12, 0.35) 0%, rgba(8, 8, 12, 0.62) 70%),
    linear-gradient(180deg, rgba(8, 8, 12, 0.5), rgba(8, 8, 12, 0.72));
}

/* ------------------------------------------------------------ the two glasses */

.chrome {
  background: linear-gradient(155deg, var(--chrome-top) 0%, rgba(235, 238, 244, 0.14) 45%, var(--chrome-bot) 100%);
  -webkit-backdrop-filter: blur(26px) saturate(165%);
  backdrop-filter: blur(26px) saturate(165%);
  border: 1px solid var(--edge);
  box-shadow:
    inset 0 1px 0 var(--edge-hi),
    inset 0 -1px 0 var(--edge-lo),
    0 18px 48px var(--shade);
}

.graphite {
  background: linear-gradient(160deg, var(--graphite-top), var(--graphite-bot));
  -webkit-backdrop-filter: blur(34px) saturate(150%);
  backdrop-filter: blur(34px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 24px 64px rgba(0, 0, 0, 0.45);
}

/* Browsers without backdrop-filter get a solid that still reads. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .chrome { background: linear-gradient(155deg, #8d9099, #5c5f67); }
  .graphite { background: #17181e; }
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--edge);
  cursor: pointer;
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: default; transform: none; }

.btn.solid {
  background: linear-gradient(180deg, #ffffff, #d9dde4);
  color: #111216;
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 #fff, 0 8px 22px rgba(0, 0, 0, 0.35);
}

.icon-btn { width: 40px; padding: 0; justify-content: center; }

/* ------------------------------------------------------------ the top bar */

.bar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
}
.bar-group .btn { border-color: transparent; background: transparent; box-shadow: none; }
.bar-group .btn:hover { background: rgba(255, 255, 255, 0.12); }
.bar-group .btn[aria-current="page"] { background: rgba(255, 255, 255, 0.18); }

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: var(--t-sm);
  padding: 0 10px 0 6px;
  color: var(--ink-2);
  text-decoration: none;
}

/* The archive folder: a flat 2D folder, in glass. */
.folder-ico { width: 22px; height: 18px; }

@media (max-width: 640px) {
  .bar { top: 12px; left: 12px; right: 12px; }
  .bar .label { display: none; }
  .bar .btn:not(.keep-label) { width: 40px; padding: 0; justify-content: center; }
  .brand { display: none; }
}

/* ------------------------------------------------------------ pages */

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 104px 16px 72px;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.page-head h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, var(--t-h1));
  line-height: 1;
  letter-spacing: -0.035em;
  font-weight: 700;
  text-wrap: balance;
}
.page-head p { margin: 10px 0 0; color: var(--ink-2); max-width: 60ch; }

.panel { border-radius: var(--r-lg); padding: 22px; }

/* ------------------------------------------------------------ popovers & sheets */

.pop {
  position: fixed;
  z-index: 50;
  border-radius: var(--r-lg);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.pop.open { opacity: 1; transform: none; pointer-events: auto; }

.sheet {
  position: fixed;
  z-index: 60;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100% - 32px));
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 32px));
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { transform: none; }

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 6, 9, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.modal-scrim.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: var(--r-lg);
  padding: 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: var(--t-sm);
  font-weight: 600;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* The pill that says a page opened from disk is showing sample numbers. */
.preview-pill {
  position: fixed;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--t-cap);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
  color: #1a1408;
  background: var(--warn);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------ fields */

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--t-lead);
  color: var(--ink);
}
.field input::placeholder { color: var(--ink-3); }
.field:focus-within { border-color: rgba(169, 212, 255, 0.6); }

/* ------------------------------------------------------------ stat tiles */

.tiles { display: grid; gap: 12px; }
.tile {
  border-radius: var(--r-md);
  padding: 14px 16px;
  min-width: 0;
}
.tile .cap { display: block; margin-bottom: 6px; }
.tile .val {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.good { color: var(--good); background: rgba(48, 209, 88, 0.14); }
.pill.bad { color: var(--bad); background: rgba(255, 69, 58, 0.14); }
.pill.idle { color: var(--ink-3); background: rgba(255, 255, 255, 0.08); }

/* ------------------------------------------------------------ charts */

.chart-card { border-radius: var(--r-lg); padding: 18px 18px 12px; min-width: 0; }
.chart-card h3 { margin: 0; font-size: var(--t-lead); font-weight: 600; letter-spacing: -0.01em; }
.chart-card .sub { margin: 3px 0 10px; color: var(--ink-3); font-size: var(--t-sm); }
.chart-card svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-card .axis { fill: var(--ink-3); font-family: var(--mono); font-size: 9px; }
.chart-card .grid { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.chart-card .empty { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }

/* ------------------------------------------------------------ motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ========================================================================
   LOGIN — the glass box, the head that moves into it, the tall card.
   ======================================================================== */

.login { width: min(380px, calc(100vw - 32px)); padding: 14px; max-height: calc(100vh - 96px); overflow: auto; }
.login-row { display: flex; gap: 8px; }
.login-row .field { flex: 1; }

.login-slot {
  width: 0;
  height: 28px;
  border-radius: 7px;
  image-rendering: pixelated;
  opacity: 0;
  margin-right: -10px;
  transition: width 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
}
.login-slot.seated { width: 28px; opacity: 1; margin-right: 0; }

.login-preview { display: grid; place-items: center; gap: 8px; padding: 18px 0 6px; }
.login-head {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  image-rendering: pixelated;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.login-head.on { opacity: 1; transform: none; }
.login-hint { margin: 0; color: var(--ink-3); font-size: var(--t-sm); text-align: center; }

.login-card {
  overflow: hidden;
  margin-top: 12px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: max-height 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.skin-box {
  height: 290px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 55% at 50% 58%, rgba(169, 212, 255, 0.22), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent);
}
.skin-box canvas { width: 200px; height: 266px; }
.skin-box canvas[hidden] { display: none; }
.skin-fallback { width: 200px; height: 266px; object-fit: contain; image-rendering: pixelated; }

.login-stats { padding: 4px 16px 14px; }
.login-stats .stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.login-stats .stat:first-of-type { border-top: 0; }
.login-stats .v { font-size: var(--t-lead); font-weight: 600; }
.presence {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 4px;
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.presence::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.presence.on { color: var(--good); }
.presence.off { color: var(--ink-3); }
.never, .loading { margin: 0; padding: 22px 6px; text-align: center; color: var(--ink-2); }
.never { font-size: var(--t-lead); font-weight: 600; color: var(--ink); }

.who-chip img { border-radius: 5px; image-rendering: pixelated; }

/* ========================================================================
   SUPPORT — the chat sheet.
   ======================================================================== */

.sup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sup-head strong { font-size: var(--t-lead); letter-spacing: -0.01em; }
.sup-left { color: var(--ink-3); font-size: var(--t-sm); }
.sup-head .btn { background: rgba(255, 255, 255, 0.08); border-color: transparent; }

.sup-log {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble.me {
  align-self: flex-end;
  background: linear-gradient(180deg, #ffffff, #dfe3ea);
  color: #111216;
  border-bottom-right-radius: 6px;
}
.bubble.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: 6px;
}
.bubble.note {
  align-self: center;
  max-width: 100%;
  color: var(--ink-3);
  font-size: var(--t-sm);
  text-align: center;
  padding: 4px 8px;
}
.bubble.typing { animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

.sup-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sup-form .field { flex: 1; height: 44px; }
.sup-form .field input { font-size: var(--t-body); }
.sup-form .btn { height: 44px; }

/* The charts have no subtitle any more: the title sits right on the plot. */
.chart-card h3 + svg { margin-top: 12px; }


/* The docked card arriving on the front page: up out of a blur. */
.login.dock-in { animation: dock-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes dock-in {
  from { opacity: 0; transform: translateY(-14px) scale(0.96); filter: blur(10px); }
  to { opacity: 1; transform: none; filter: none; }
}
