/* =====================================================================
   SMART-CORE · Water Quality Intelligence
   Visual system: "Abyssal Clarity" — deep water, refracted light, glass.
   ===================================================================== */

:root {
  --bg: #010810;
  --ink: #ecf9ff;
  --ink-2: rgba(222, 243, 255, 0.74);
  --ink-3: rgba(196, 228, 248, 0.6);
  --ink-4: rgba(196, 228, 248, 0.38);
  --hair: rgba(160, 222, 255, 0.11);
  --hair-2: rgba(160, 222, 255, 0.2);

  --cyan: 94 231 255;
  --aqua: 70 236 206;
  --azure: 124 168 255;
  --mint: 92 255 200;
  --amber: 255 196 107;
  --danger: 255 77 94;
  --red: #ff3448;

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.7, 0, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --mx: 0;
  --my: 0;
  --gutter: clamp(20px, 4vw, 56px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-intro {
  overflow: hidden;
}

img,
svg,
canvas {
  display: block;
}

button,
textarea {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgb(var(--cyan) / 0.3);
  color: #fff;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ---------------------------------------------------------------------
   Intro gating: elements start hidden; JS choreographs them in.
   If JS never runs, a CSS failsafe reveals everything.
   --------------------------------------------------------------------- */
[data-intro] {
  opacity: 0;
}

[data-intro].is-in {
  opacity: 1;
}

html:not(.intro-ctl) [data-intro] {
  animation: failsafe-in 1s var(--ease-out) 2.4s forwards;
}

html:not(.intro-ctl) .intro {
  animation: failsafe-out 1s ease 2.2s forwards;
}

@keyframes failsafe-in {
  to {
    opacity: 1;
  }
}

@keyframes failsafe-out {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* =====================================================================
   OCEAN BACKGROUND
   ===================================================================== */
.ocean {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--bg);
}

.ocean__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.no-webgl .ocean__canvas {
  display: none;
}

.no-webgl .ocean__vignette {
  display: block;
}

/* Shown when WebGL is unavailable (or before JS) */
.ocean__fallback {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(30, 150, 200, 0.35), transparent 70%),
    radial-gradient(40% 35% at 20% 30%, rgba(20, 110, 170, 0.22), transparent 70%),
    radial-gradient(45% 40% at 80% 35%, rgba(30, 90, 190, 0.2), transparent 70%),
    linear-gradient(180deg, #06263a 0%, #031627 40%, #010810 100%);
}

/* Only animate the CSS fallback when it is actually visible */
.no-webgl .ocean__fallback {
  animation: ocean-drift 24s ease-in-out infinite alternate;
}

@keyframes ocean-drift {
  to {
    transform: translate3d(3%, 2%, 0) scale(1.06);
  }
}

/* Vignette is rendered inside the WebGL shader; this overlay is only for the fallback */
.ocean__vignette {
  display: none;
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 35%, transparent 55%, rgba(0, 3, 8, 0.65) 100%),
    linear-gradient(180deg, transparent 70%, rgba(1, 6, 12, 0.55) 100%);
}

/* =====================================================================
   INTRO SEQUENCE
   ===================================================================== */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  --ix: 50vw;
  --iy: 38vh;
}

.intro.is-done {
  display: none;
}

.intro__veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 70% at 50% 40%, #020b16 0%, #00040a 70%);
}

.intro__drop,
.intro__flash {
  position: absolute;
  left: var(--ix);
  top: var(--iy);
  transform: translate(-50%, -50%);
  opacity: 0;
  will-change: transform, opacity;
}

.intro__drop {
  width: 12px;
  height: 18px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 40% 65%, #ffffff 0%, #c9f7ff 30%, #45c8f0 75%, #1584b8 100%);
  box-shadow:
    0 0 14px 2px rgba(140, 235, 255, 0.85),
    0 0 46px 8px rgba(60, 190, 255, 0.35);
}

.intro__drop::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 70%;
  width: 2px;
  height: 160px;
  transform: translateX(-50%);
  background: linear-gradient(to top, rgba(170, 240, 255, 0.7), transparent);
  filter: blur(0.6px);
}

.intro__flash {
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 250, 255, 0.95) 0%, rgba(110, 220, 255, 0.45) 18%, rgba(40, 150, 220, 0.12) 45%, transparent 70%);
}

/* =====================================================================
   TOP BAR
   ===================================================================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px var(--gutter);
  padding-top: max(18px, env(safe-area-inset-top));
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(1, 7, 14, 0.9) 0%, rgba(1, 7, 14, 0.6) 55%, rgba(1, 7, 14, 0) 100%);
}

.topbar a,
.topbar button {
  pointer-events: auto;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.topbar__sep {
  width: 1px;
  height: 12px;
  background: var(--hair-2);
}

.topbar__clock {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.topbar__settings {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--hair);
  background: rgba(4, 20, 36, 0.55);
  color: var(--ink-2);
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}

.topbar__settings svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: transform 0.6s var(--ease-out);
}

.topbar__settings:hover,
.topbar__settings:focus-visible {
  outline: none;
  color: #fff;
  border-color: rgb(var(--cyan) / 0.4);
  background: rgb(var(--cyan) / 0.1);
}

.topbar__settings:hover svg {
  transform: rotate(60deg);
}

/* ---- Live status (station reachability) ---- */
.live-status {
  --tone: var(--amber);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 9px 18px 9px 14px;
  border-radius: 999px;
  background: rgba(3, 16, 30, 0.6);
  box-shadow:
    inset 0 0 0 1px rgb(var(--tone) / 0.28),
    0 0 28px -8px rgb(var(--tone) / 0.45);
  transition: box-shadow 0.5s var(--ease-soft);
  white-space: nowrap;
}

.live-status[data-state="live"] {
  --tone: var(--mint);
}

.live-status[data-state="offline"] {
  --tone: var(--danger);
}

.live-status__dot {
  position: relative;
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 50%;
  background: rgb(var(--tone));
  box-shadow: 0 0 14px rgb(var(--tone) / 0.95);
  transition: background 0.4s, box-shadow 0.4s;
}

.live-status__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgb(var(--tone) / 0.85);
  animation: live-ping 2.2s var(--ease-out) infinite;
}

.live-status[data-state="offline"] .live-status__dot::after {
  animation: none;
  opacity: 0;
}

.live-status[data-state="offline"] .live-status__dot {
  animation: offline-blink 1.6s steps(2, jump-none) infinite;
}

.live-status[data-state="checking"] .live-status__dot::after,
.live-status[data-state="reconnecting"] .live-status__dot::after {
  animation-duration: 1.2s;
}

.live-status__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1;
}

.live-status__label {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgb(var(--tone));
  text-shadow: 0 0 18px rgb(var(--tone) / 0.5);
  transition: color 0.4s;
}

.live-status__meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

@keyframes offline-blink {
  50% {
    opacity: 0.35;
  }
}

@keyframes live-ping {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(3.2);
    opacity: 0;
  }
}

/* =====================================================================
   PAGE / HERO
   ===================================================================== */
.page {
  position: relative;
  z-index: 1;
}

.hero {
  position: relative;
  padding: clamp(104px, 15vh, 160px) var(--gutter) 0;
  overflow-x: clip;
}

.hero__stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  isolation: isolate;
}

/* ---- Halo: sonar / lens rings behind the logo ---- */
.halo {
  position: absolute;
  left: 50%;
  top: var(--halo-y, 170px);
  width: min(880px, 135vw);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: -1;
  will-change: translate;
}

.halo__glow {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(70, 200, 255, 0.19) 0%, rgba(30, 130, 210, 0.09) 38%, transparent 70%);
  animation: halo-breathe 7s ease-in-out infinite;
  will-change: transform, opacity;
}

@keyframes halo-breathe {
  50% {
    transform: scale(1.06);
    opacity: 0.8;
  }
}

/* Whole-SVG rotation = GPU compositor only (no per-frame repaint) */
.halo__layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  will-change: transform;
}

.halo__layer circle {
  fill: none;
  stroke-width: 1;
}

.halo__layer--ticks {
  animation: spin 160s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 60%, transparent 100%);
  mask: radial-gradient(circle, #000 60%, transparent 100%);
}

.halo__layer--ticks circle {
  stroke: rgba(160, 230, 255, 0.16);
  stroke-width: 7;
  stroke-dasharray: 1.2 9;
}

.halo__layer--a {
  animation: spin 90s linear infinite reverse;
}

.halo__layer--a circle {
  stroke: rgba(150, 225, 255, 0.12);
  stroke-dasharray: 220 40 6 40;
}

.halo__layer--b {
  animation: spin 120s linear infinite;
}

.halo__layer--b circle {
  stroke: rgba(94, 231, 255, 0.16);
  stroke-dasharray: 2 6;
}

.halo__layer--c {
  will-change: auto;
}

.halo__layer--c circle {
  stroke: rgba(124, 168, 255, 0.1);
}

/* Glow baked into a soft mask instead of a drop-shadow filter (keeps rotation on the compositor) */
.halo__sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 250deg, rgba(94, 231, 255, 0.35) 350deg, rgba(225, 252, 255, 0.95) 360deg);
  -webkit-mask: radial-gradient(circle closest-side, transparent 77.6%, rgba(0, 0, 0, 0.25) 78.6%, #000 79.3%, #000 79.9%, rgba(0, 0, 0, 0.25) 80.6%, transparent 81.6%);
  mask: radial-gradient(circle closest-side, transparent 77.6%, rgba(0, 0, 0, 0.25) 78.6%, #000 79.3%, #000 79.9%, rgba(0, 0, 0, 0.25) 80.6%, transparent 81.6%);
  animation: spin 11s linear infinite;
  opacity: 0.8;
  will-change: transform;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Brand (hero logo) ---- */
.brand {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: translate;
}

.brand__liquid {
  position: relative;
}

.fx-liquid .brand__liquid.is-distorting {
  filter: url(#fx-liquid-logo);
}

.brand__mark {
  position: relative;
  display: grid;
  place-items: center;
  filter: blur(0px) drop-shadow(0 0 26px rgba(94, 231, 255, 0.3));
}

.brand__logo {
  display: block;
  width: auto;
  height: auto;
  max-width: min(560px, 84vw);
  max-height: clamp(150px, 34vh, 370px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.brand__fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2vh, 22px);
}

.brand.is-fallback .brand__logo {
  display: none;
}

.brand.is-fallback .brand__fallback {
  display: flex;
}

.brand__fallback-drop {
  width: clamp(40px, 5vw, 62px);
  height: auto;
  filter: drop-shadow(0 0 18px rgba(94, 231, 255, 0.6));
}

.brand__fallback-word {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 8.2vw, 112px);
  line-height: 1;
  letter-spacing: 0.14em;
  margin-right: -0.14em;
  white-space: nowrap;
  background:
    linear-gradient(100deg, transparent 40%, rgba(255, 255, 255, 0.95) 50%, transparent 60%) 160% 0 / 300% 100% no-repeat,
    linear-gradient(180deg, #ffffff 0%, #d4f7ff 42%, #6fd8f6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand__fallback-word b {
  font-weight: 200;
  margin: 0 0.06em;
}

.is-awake .brand__fallback-word {
  animation: text-shine 9s var(--ease-io) 1s infinite;
}

@keyframes text-shine {
  0% {
    background-position: 160% 0, 0 0;
  }
  22%,
  100% {
    background-position: -60% 0, 0 0;
  }
}

/* Light sweep across the logo, masked by the logo's own alpha (set via JS).
   The band moves with transform so the sweep runs on the compositor. */
.brand__shine {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  -webkit-mask: var(--logo-mask, none) center / contain no-repeat;
  mask: var(--logo-mask, none) center / contain no-repeat;
}

.brand__shine::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 55%;
  background: linear-gradient(100deg, transparent 15%, rgba(255, 255, 255, 0.6) 50%, transparent 85%);
  transform: translateX(-120%);
  will-change: transform;
}

.brand.has-mask .brand__shine {
  opacity: 1;
}

.brand.is-fallback .brand__shine {
  display: none;
}

.is-awake .brand.has-mask .brand__shine::before {
  animation: logo-shine 9s var(--ease-io) 0.4s infinite;
}

@keyframes logo-shine {
  0% {
    transform: translateX(-120%);
  }
  22%,
  100% {
    transform: translateX(200%);
  }
}

.brand__waterline {
  width: min(780px, 88vw);
  height: 1px;
  margin-top: 6px; /* the logo sits just above the line */
  background: linear-gradient(90deg, transparent, rgba(94, 231, 255, 0.15) 18%, rgba(200, 248, 255, 0.85) 50%, rgba(94, 231, 255, 0.15) 82%, transparent);
  box-shadow: 0 0 18px rgba(94, 231, 255, 0.45);
  transform-origin: center;
}

.brand__reflection {
  position: relative;
  height: clamp(36px, 8vh, 96px);
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
  opacity: 0;
  transition: opacity 2.4s var(--ease-out);
  -webkit-mask: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 92%);
  mask: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 92%);
}

.is-awake .brand__reflection {
  opacity: 0.42;
}

/* The ripple filter is static (rasterised once); a gentle compositor-only sway keeps it alive. */
.brand__reflection-inner {
  transform: scaleY(-1);
  transform-origin: center;
  align-self: flex-start;
  will-change: transform;
}

.is-awake .brand__reflection-inner {
  animation: reflect-sway 7s ease-in-out infinite;
}

@keyframes reflect-sway {
  0%,
  100% {
    transform: scaleY(-1) translateX(0) skewX(0deg);
  }
  50% {
    transform: scaleY(-1.04) translateX(3px) skewX(-1.2deg);
  }
}

.brand__reflection-inner > * {
  filter: blur(1.2px);
}

.fx-liquid .brand__reflection-inner > * {
  filter: url(#fx-reflect) blur(1px);
}

.brand__reflection-inner .brand__fallback {
  display: flex;
}

.brand__reflection-inner .brand__fallback-word {
  animation: none;
}

/* ---- Hero copy ---- */
.hero__copy {
  margin-top: clamp(-40px, -3vh, -18px);
  display: grid;
  gap: 14px;
  justify-items: center;
}

.hero__kicker {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(11px, 1.1vw, 14px);
  letter-spacing: 0.52em;
  margin-right: -0.52em;
  text-transform: uppercase;
  color: rgba(214, 244, 255, 0.86);
}

.hero__kicker::before,
.hero__kicker::after {
  content: "";
  width: clamp(24px, 5vw, 64px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(94, 231, 255, 0.6));
}

.hero__kicker::after {
  transform: scaleX(-1);
  margin-left: -0.52em;
}

.hero__lede {
  margin: 0;
  max-width: 46ch;
  font-size: clamp(14px, 1.2vw, 16.5px);
  font-weight: 300;
  line-height: 1.7;
  color: var(--ink-3);
}

/* =====================================================================
   READINGS
   ===================================================================== */
.readings {
  max-width: 1260px;
  margin: clamp(48px, 7vh, 88px) auto 0;
  padding: 0 var(--gutter);
}

.readings__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(20px, 3vh, 32px);
}

.eyebrow {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgb(var(--cyan) / 0.85);
}

.readings__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(24px, 2.7vw, 36px);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.readings__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}

.readings__sync time {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.chip {
  --tone: var(--amber);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgb(var(--tone) / 0.24);
  background: rgb(var(--tone) / 0.06);
  color: rgb(var(--tone));
  transition: color 0.4s, border-color 0.4s, background 0.4s;
}

.chip[data-state="live"] {
  --tone: var(--mint);
}

.chip[data-state="offline"] {
  --tone: var(--danger);
}

.chip__dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.chip[data-state="live"] .chip__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid currentColor;
  animation: live-ping 2.4s var(--ease-out) infinite;
}

.readings__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 26px);
}

/* Station unreachable: readings are stale — dim card contents (not the card itself,
   which would break its backdrop blur) */
.reading__head,
.reading__vessel,
.scale,
.reading__desc {
  transition: opacity 0.8s var(--ease-soft), filter 0.8s var(--ease-soft);
}

.station-offline .reading__vessel,
.station-offline .scale,
.station-offline .reading__desc,
.reading.is-waiting .reading__vessel,
.reading.is-waiting .scale,
.reading.is-stale .reading__vessel,
.reading.is-stale .scale {
  opacity: 0.55;
  filter: saturate(0.4);
}

/* ---- Reading card ---- */
.reading {
  --accent: var(--cyan);
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 24px 24px 22px;
  border-radius: 30px;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, rgb(var(--accent) / 0.09), transparent 60%),
    linear-gradient(165deg, rgba(170, 228, 255, 0.085) 0%, rgba(120, 200, 255, 0.025) 42%, rgba(3, 16, 30, 0.46) 100%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -60px 90px -60px rgb(var(--accent) / 0.22),
    0 40px 90px -40px rgba(0, 0, 0, 0.75);
  transform: perspective(1100px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.7s var(--ease-out);
}

.reading--a {
  --accent: var(--cyan);
}

.reading--b {
  --accent: var(--aqua);
}

.reading--c {
  --accent: var(--azure);
}

.reading::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.05) 32%, rgba(255, 255, 255, 0.02) 60%, rgb(var(--accent) / 0.32));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
  z-index: 2;
}

/* Spotlight moves via transform (compositor) instead of repainting a gradient on every mouse move */
.reading__spot {
  position: absolute;
  left: 0;
  top: 0;
  width: 520px;
  height: 520px;
  margin: -260px 0 0 -260px;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(var(--accent) / 0.2) 0%, rgb(var(--accent) / 0.07) 35%, transparent 65%);
  transform: translate(50%, 30%);
  transition: opacity 0.5s var(--ease-soft);
  will-change: transform, opacity;
}

.reading:hover .reading__spot {
  opacity: 1;
}

.reading__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.reading__index {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.08em;
}

.reading__label {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.reading__status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(var(--accent));
  background: rgb(var(--accent) / 0.08);
  border: 1px solid rgb(var(--accent) / 0.22);
  transition: color 0.4s, background 0.4s, border-color 0.4s;
}

.reading__status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: status-glow 2.6s ease-in-out infinite;
}

@keyframes status-glow {
  50% {
    opacity: 0.35;
  }
}

.reading.is-warn .reading__status {
  color: #ffc46b;
  background: rgba(255, 196, 107, 0.08);
  border-color: rgba(255, 196, 107, 0.28);
}

.reading.is-waiting .reading__status,
.reading.is-stale .reading__status {
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--hair-2);
}

.reading.is-waiting .reading__status i,
.reading.is-stale .reading__status i {
  animation: none;
  box-shadow: none;
}

/* Keep long values (two decimals, e.g. 2,300.00) inside the gauge while staying large */
/* (data-len counts digits only: 55.50 → 4, 874.52 → 5, 2,300.00 → 6) */
.reading__number[data-len="5"] {
  font-size: clamp(38px, 3.5vw, 48px);
}

.reading__number[data-len="6"] {
  font-size: clamp(31px, 2.8vw, 38px);
}

.reading__number[data-len="7"],
.reading__number[data-len="8"],
.reading__number[data-len="9"] {
  font-size: clamp(27px, 2.4vw, 32px);
}

/* The beam and thermometer cards have less room for the number */
.reading:is([data-gauge="beam"], [data-gauge="thermo"]) .reading__number[data-len="5"] {
  font-size: clamp(34px, 3vw, 42px);
}

.reading:is([data-gauge="beam"], [data-gauge="thermo"]) .reading__number[data-len="6"] {
  font-size: clamp(28px, 2.5vw, 34px);
}

.reading:is([data-gauge="beam"], [data-gauge="thermo"]) .reading__number:is([data-len="7"], [data-len="8"], [data-len="9"]) {
  font-size: clamp(25px, 2.2vw, 29px);
}

.reading__vessel {
  position: relative;
  width: min(230px, 100%);
  aspect-ratio: 1;
  margin: clamp(18px, 2.6vh, 26px) auto clamp(16px, 2.2vh, 22px);
}

.reading__value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
  text-shadow: 0 2px 24px rgba(0, 10, 20, 0.6);
}

.reading__number {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: clamp(46px, 4.4vw, 60px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.reading__unit {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ---- Vessel (liquid gauge) ----
   Static frame = SVG (repaints only when the value changes).
   Liquid = HTML layers animated with transform/opacity only (GPU compositor). */
.vessel {
  position: absolute;
  inset: 0;
}

.vessel__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.v-ticks {
  fill: none;
  stroke: rgba(180, 230, 255, 0.2);
  stroke-width: 6;
  stroke-dasharray: 1 4.4;
}

.v-track {
  fill: none;
  stroke: rgba(160, 220, 255, 0.08);
  stroke-width: 2.5;
}

.v-arc {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 2.2s var(--ease-out);
}

.v-stop-arc-a {
  stop-color: rgb(var(--accent));
}

.v-stop-arc-b {
  stop-color: #ffffff;
}

.v-dot {
  transform-box: view-box;
  transform-origin: 110px 110px;
  transform: rotate(0deg);
  transition: transform 2.2s var(--ease-out);
}

.v-dot circle:first-child {
  fill: #fff;
}

.v-dot-glow {
  fill: rgb(var(--accent) / 0.28);
}

.vessel__liquid {
  position: absolute;
  inset: 11.818%; /* glass radius 84 of a 220 viewBox */
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(65% 65% at 50% 38%, rgba(12, 53, 87, 0.35), rgba(2, 12, 24, 0.82));
}

.vessel__liquid::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 50%;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgb(var(--accent) / 0.06) 50%, rgb(var(--accent) / 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.vessel__level {
  position: absolute;
  inset: 0;
  transform: translateY(104%);
  transition: transform 2.6s var(--ease-out);
  will-change: transform;
}

.vessel__wave {
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 14' preserveAspectRatio='none'%3E%3Cpath d='M0 7 Q30 0 60 7 T120 7 V14 H0Z'/%3E%3C/svg%3E");
  position: absolute;
  top: 0;
  left: 0;
  width: 300%;
  height: 100%;
  background: linear-gradient(to bottom, rgb(var(--accent) / 0.8) 0%, rgb(var(--accent) / 0.36) 50%, rgba(4, 41, 74, 0.85) 100%);
  -webkit-mask: var(--wave) 0 0 / 25% 14px repeat-x, linear-gradient(#000 0 0) 0 13px / 100% 100% no-repeat;
  mask: var(--wave) 0 0 / 25% 14px repeat-x, linear-gradient(#000 0 0) 0 13px / 100% 100% no-repeat;
  animation: wave-x 5.5s linear infinite;
  will-change: transform;
}

.vessel__wave--back {
  top: 4px;
  opacity: 0.55;
  -webkit-mask-position: 40% 0, 0 13px;
  mask-position: 40% 0, 0 13px;
  animation-duration: 8.5s;
  animation-direction: reverse;
}

.reading--b .vessel__wave {
  background: linear-gradient(to bottom, rgb(var(--accent) / 0.8) 0%, rgba(170, 240, 225, 0.32) 50%, rgba(4, 41, 74, 0.85) 100%);
}

@keyframes wave-x {
  to {
    transform: translateX(-25%);
  }
}

/* Bubbles are clipped at the surface so they never float in the "air" */
.vessel__bubbles {
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  bottom: 0;
  overflow: hidden;
}

.vessel__bubbles i {
  position: absolute;
  bottom: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(230, 250, 255, 0.6);
  opacity: 0;
  animation: bubble-rise 6s ease-in infinite;
  will-change: transform, opacity;
}

.vessel__bubbles i:nth-child(1) { left: 22%; bottom: 18%; animation-delay: 0s; }
.vessel__bubbles i:nth-child(2) { left: 38%; bottom: 6%; width: 3px; height: 3px; animation-delay: 1.6s; }
.vessel__bubbles i:nth-child(3) { left: 58%; bottom: 14%; width: 5px; height: 5px; animation-delay: 3.1s; }
.vessel__bubbles i:nth-child(4) { left: 72%; bottom: 4%; width: 3px; height: 3px; animation-delay: 0.8s; }
.vessel__bubbles i:nth-child(5) { left: 48%; bottom: 2%; animation-delay: 4.4s; }

@keyframes bubble-rise {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  15% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-120px);
    opacity: 0;
  }
}

.vessel__spec {
  position: absolute;
  left: 12%;
  top: 10%;
  width: 46%;
  height: 18%;
  z-index: 2;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(-32deg);
  pointer-events: none;
}

/* ---- Range scale ---- */
.scale__track {
  position: relative;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
}

.scale__optimal {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--opt-l, 0%);
  width: var(--opt-w, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, rgb(var(--accent) / 0.15), rgb(var(--accent) / 0.45), rgb(var(--accent) / 0.15));
}

.scale__marker {
  position: absolute;
  top: 50%;
  left: var(--pos, 0%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  box-shadow:
    0 0 0 3px rgb(var(--accent) / 0.25),
    0 0 14px rgb(var(--accent) / 0.9);
  transition: left 2.2s var(--ease-out);
}

.scale__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}

.scale__range {
  color: var(--ink-3);
}

.reading__desc {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-3);
}

/* =====================================================================
   FOOTER
   ===================================================================== */
.footer {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: clamp(56px, 9vh, 96px) var(--gutter) max(40px, env(safe-area-inset-bottom));
}

.footer__legal {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}

.footer__legal a {
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1px solid var(--hair-2);
  transition: color 0.3s, border-color 0.3s;
}

.footer__legal a:hover,
.footer__legal a:focus-visible {
  outline: none;
  color: #fff;
  border-color: rgb(var(--cyan) / 0.6);
}

/* =====================================================================
   AI LAUNCHER
   ===================================================================== */
.ai-launcher {
  position: fixed;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  padding: 5px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(160deg, rgba(160, 225, 255, 0.12), rgba(8, 30, 50, 0.5));
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 0 1px rgba(150, 220, 255, 0.14),
    0 20px 50px -14px rgba(0, 0, 0, 0.7),
    0 0 40px -8px rgba(60, 190, 255, 0.35);
  transition: box-shadow 0.5s var(--ease-soft), transform 0.5s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.ai-launcher:hover,
.ai-launcher:focus-visible {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 0 1px rgba(150, 230, 255, 0.3),
    0 24px 60px -14px rgba(0, 0, 0, 0.75),
    0 0 60px -6px rgba(60, 200, 255, 0.55);
  outline: none;
}

.ai-launcher__label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  padding: 0;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  transition:
    max-width 0.6s var(--ease-out),
    opacity 0.4s var(--ease-soft),
    padding 0.6s var(--ease-out);
}

.ai-launcher__label b {
  font-weight: 600;
  color: #fff;
}

.ai-launcher:hover .ai-launcher__label,
.ai-launcher:focus-visible .ai-launcher__label {
  max-width: 170px;
  opacity: 1;
  padding: 0 12px 0 16px;
}

.ai-launcher__orb {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
}

.ai-launcher__liquid,
.ai-avatar::before,
.msg__avatar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), transparent 32%),
    conic-gradient(from 0deg, #0b5f9c, #39d5ff, #a8f2ff, #3a7dff, #0b3f7a, #19b6e8, #0b5f9c);
  animation: spin 7s linear infinite;
  will-change: transform;
}

.ai-launcher__core,
.ai-avatar span,
.msg__avatar::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.0) 26%),
    radial-gradient(circle at 50% 120%, rgba(0, 20, 40, 0.0) 40%, rgba(0, 20, 40, 0.45) 100%),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(2, 18, 34, 0.55) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    inset 0 -6px 14px rgba(0, 30, 60, 0.45);
}

.ai-launcher__icon {
  position: relative;
  width: 22px;
  height: 22px;
  fill: #fff;
  filter: drop-shadow(0 0 6px rgba(200, 245, 255, 0.9));
  animation: icon-float 4s ease-in-out infinite;
}

@keyframes icon-float {
  50% {
    transform: scale(0.88) rotate(45deg);
  }
}

.ai-launcher__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(140, 230, 255, 0.6);
  animation: orb-pulse 3.6s var(--ease-out) infinite;
  pointer-events: none;
}

.ai-launcher__pulse:nth-of-type(2) {
  animation-delay: 1.8s;
}

@keyframes orb-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70%,
  100% {
    transform: scale(1.9);
    opacity: 0;
  }
}

/* =====================================================================
   AI CHAT PANEL
   ===================================================================== */
.ai-chat {
  position: fixed;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 50;
  width: min(420px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 56px));
  height: min(680px, calc(100svh - 56px));
  --r: 30px;
}

.ai-chat[hidden] {
  display: none;
}

.ai-chat__backdrop {
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  background: rgba(3, 15, 27, 0.6);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
}

.ai-chat__lens {
  position: absolute;
  inset: 0;
}

.fx-liquid .ai-chat__lens.is-distorting {
  filter: url(#fx-liquid-chat);
}

.ai-chat__body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 50% at 50% 0%, rgba(80, 200, 255, 0.14), transparent 60%),
    linear-gradient(172deg, rgba(140, 215, 255, 0.08), rgba(8, 36, 64, 0.1) 30%, rgba(2, 12, 22, 0.4));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(150, 222, 255, 0.1),
    0 50px 120px -30px rgba(0, 0, 0, 0.8),
    0 0 90px -20px rgba(60, 190, 255, 0.28);
}

.ai-chat__caustic {
  position: absolute;
  inset: -30%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  background:
    radial-gradient(30% 22% at 30% 20%, rgba(90, 210, 255, 0.16), transparent 70%),
    radial-gradient(26% 20% at 75% 40%, rgba(124, 168, 255, 0.12), transparent 70%),
    radial-gradient(34% 26% at 40% 85%, rgba(70, 236, 206, 0.08), transparent 70%);
  animation: caustic-drift 18s ease-in-out infinite alternate;
}

@keyframes caustic-drift {
  to {
    transform: translate3d(8%, -6%, 0) rotate(8deg) scale(1.1);
  }
}

.ai-chat__grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background-image:
    linear-gradient(rgba(120, 225, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 225, 255, 0.16) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask: radial-gradient(90% 70% at 50% 50%, #000, transparent);
  mask: radial-gradient(90% 70% at 50% 50%, #000, transparent);
}

.ai-chat__scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 140px;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-140px);
  background: linear-gradient(to bottom, transparent, rgba(94, 231, 255, 0.06) 60%, rgba(94, 231, 255, 0.22) 94%, rgba(230, 252, 255, 0.95) 99%, transparent);
}

.ai-chat__flood {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  transform: translateY(105%);
  background: linear-gradient(to bottom, rgba(90, 210, 255, 0.55), rgba(30, 120, 210, 0.45) 60%, rgba(10, 60, 140, 0.4));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.ai-chat__flood svg {
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 100%;
  height: 34px;
  margin-bottom: -1px;
}

.ai-chat__flood path {
  fill: rgba(90, 210, 255, 0.55);
}

/* Border light: a static ring mask with a rotating conic layer inside
   (transform rotation = compositor; no per-frame repaint). */
.ai-chat__edge {
  position: absolute;
  inset: 0;
  z-index: 6;
  border-radius: inherit;
  padding: 1px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.45;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.ai-chat__edge i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 180%;
  aspect-ratio: 1;
  margin-left: -90%;
  translate: 0 -50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(150, 240, 255, 0.95) 40deg, transparent 100deg, transparent 180deg, rgba(124, 168, 255, 0.8) 230deg, transparent 290deg);
  animation: spin 9s linear infinite;
  will-change: transform;
}

/* ---- Header ---- */
.ai-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 16px 18px;
  border-bottom: 1px solid var(--hair);
}

.ai-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(60, 200, 255, 0.45);
}

.ai-chat__titles {
  flex: 1;
  min-width: 0;
}

.ai-chat__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.ai-chat__status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ai-chat__status [data-ai-status] {
  color: rgb(var(--mint));
}

.ai-chat__status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(var(--mint));
  box-shadow: 0 0 10px rgb(var(--mint));
  animation: status-glow 2s ease-in-out infinite;
}

.ai-chat__controls {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--hair);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, transform 0.3s var(--ease-out);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  outline: none;
  background: rgba(150, 225, 255, 0.1);
  border-color: rgba(150, 225, 255, 0.3);
  transform: scale(1.06);
}

/* ---- Messages ---- */
.ai-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 18px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(150, 220, 255, 0.2) transparent;
  -webkit-mask: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 12px), transparent);
  mask: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 12px), transparent);
}

.ai-chat__messages::-webkit-scrollbar {
  width: 6px;
}

.ai-chat__messages::-webkit-scrollbar-thumb {
  background: rgba(150, 220, 255, 0.18);
  border-radius: 99px;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: msg-in 0.7s var(--ease-out) both;
}

.msg--ai {
  align-self: flex-start;
}

.msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    filter: blur(6px);
  }
}

.msg__avatar {
  position: relative;
  width: 26px;
  height: 26px;
  flex: none;
  margin-top: 2px;
  border-radius: 50%;
}

.msg__avatar::after {
  content: "";
}

.msg__content {
  min-width: 0;
}

.msg__bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg--ai .msg__bubble {
  border-top-left-radius: 6px;
  color: rgba(232, 247, 255, 0.92);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 0 0 1px rgba(160, 222, 255, 0.1);
}

.msg--user .msg__bubble {
  border-top-right-radius: 6px;
  color: #fff;
  background: linear-gradient(135deg, rgba(60, 195, 255, 0.42), rgba(50, 110, 255, 0.32));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 0 0 1px rgba(150, 225, 255, 0.28),
    0 10px 30px -12px rgba(40, 150, 255, 0.55);
}

.msg__bubble strong {
  font-weight: 600;
  color: #fff;
}

.msg__meta {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.msg--user .msg__meta {
  text-align: right;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: rgb(var(--cyan));
  box-shadow: 0 0 8px rgb(var(--cyan));
  animation: caret-blink 0.9s steps(2) infinite;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 2px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: rgb(var(--cyan));
  box-shadow: 0 0 8px rgb(var(--cyan) / 0.8);
  animation: droplet-bounce 1.2s var(--ease-soft) infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes droplet-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-6px) scale(1.1, 0.9);
    opacity: 1;
  }
}

/* ---- Suggestions ---- */
.ai-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 18px 14px;
}

.ai-chat__suggestions.is-gone {
  display: none;
}

.suggestion {
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgb(var(--cyan) / 0.2);
  background: rgb(var(--cyan) / 0.05);
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, color 0.3s, transform 0.4s var(--ease-out);
}

.suggestion:hover,
.suggestion:focus-visible {
  outline: none;
  color: #fff;
  background: rgb(var(--cyan) / 0.12);
  border-color: rgb(var(--cyan) / 0.45);
  transform: translateY(-1px);
}

/* ---- Composer ---- */
.ai-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 14px;
  padding: 6px 6px 6px 16px;
  border-radius: 24px;
  background: rgba(1, 10, 20, 0.55);
  box-shadow: inset 0 0 0 1px rgba(150, 220, 255, 0.14);
  transition: box-shadow 0.4s var(--ease-soft);
}

.ai-chat__composer:focus-within {
  box-shadow:
    inset 0 0 0 1px rgb(var(--cyan) / 0.45),
    0 0 30px -6px rgb(var(--cyan) / 0.35);
}

.ai-chat__input {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 10px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

.ai-chat__input::placeholder {
  color: var(--ink-4);
}

.ai-chat__send {
  position: relative;
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  background: radial-gradient(circle at 30% 25%, #e6fcff 0%, #7fe4ff 30%, #2b9bff 100%);
  box-shadow: 0 6px 22px -6px rgba(60, 190, 255, 0.8);
  transition: transform 0.4s var(--ease-out), opacity 0.3s, filter 0.3s;
}

.ai-chat__send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #02223a;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ai-chat__send:hover:not(:disabled),
.ai-chat__send:focus-visible {
  outline: none;
  transform: scale(1.07);
  filter: brightness(1.1);
}

.ai-chat__send:disabled {
  opacity: 0.35;
  cursor: default;
  filter: saturate(0.5);
}

.ai-chat__note {
  margin: 0;
  padding: 10px 0 14px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* Shared FX canvas (intro shockwaves, assistant materialisation).
   Hidden while idle so the compositor can skip it entirely. */
.fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  pointer-events: none;
  visibility: hidden;
}

.fx-canvas.is-active {
  visibility: visible;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1080px) {
  .reading {
    padding: 20px 18px 18px;
  }
}

@media (max-width: 960px) {
  .readings__grid {
    grid-template-columns: minmax(0, 1fr);
    max-width: 520px;
    margin: 0 auto;
  }

  .readings__head {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 640px) {
  .topbar__date,
  .topbar__meta .topbar__sep {
    display: none;
  }

  .live-status {
    gap: 11px;
    padding: 8px 14px 8px 12px;
  }

  .live-status__label {
    font-size: 13px;
  }

  .readings__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero__kicker {
    letter-spacing: 0.34em;
    margin-right: -0.34em;
  }

  .ai-launcher {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .ai-chat {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    height: min(640px, 82vh);
    height: min(640px, 82svh);
    --r: 26px;
  }

  .ai-chat__status-sub {
    display: none;
  }
}

@media (hover: none) {
  .ai-launcher:hover .ai-launcher__label {
    max-width: 0;
    opacity: 0;
    padding: 0;
  }
}

/* =====================================================================
   EXPERIENCE SETTINGS (classes applied by js/settings.js)
   ===================================================================== */

/* Reduced motion: calm the decorative loops, keep the scene alive */
.m-reduced .halo__layer,
.m-reduced .halo__glow,
.m-reduced .ai-launcher__pulse,
.m-reduced .ai-launcher__icon,
.m-reduced .ai-chat__caustic,
.m-reduced .brand__reflection-inner,
.m-reduced .brand__shine::before,
.m-reduced .brand__fallback-word,
.m-reduced .reading__status i,
.m-reduced .ai-chat__status-dot {
  animation: none !important;
}

.m-reduced .halo__sweep,
.m-reduced .vessel__bubbles {
  display: none;
}

.m-reduced .vessel__wave {
  animation-duration: 14s;
}

.m-reduced .vessel__wave--back {
  animation-duration: 20s;
}

.m-reduced .ai-launcher__liquid,
.m-reduced .ai-avatar::before,
.m-reduced .msg__avatar::before {
  animation-duration: 24s;
}

.m-reduced .ai-chat__edge i {
  animation-duration: 30s;
}

/* Still: nothing moves on its own */
.m-still *,
.m-still *::before,
.m-still *::after {
  animation: none !important;
}

.m-still .halo__sweep,
.m-still .vessel__bubbles,
.m-still .live-status__dot::after,
.m-still .chip__dot::after {
  display: none;
}

/* Interface transitions off: state changes are instant */
.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
  transition: none !important;
}

.no-transitions .msg {
  animation: none;
}

/* Gauges without liquid motion */
.no-gauge-motion .vessel__wave {
  animation: none !important;
}

.no-gauge-motion .vessel__bubbles {
  display: none;
}

/* Card tilt & spotlight off */
.no-card-fx .reading__spot {
  display: none;
}

/* Frosted glass off: opaque surfaces, no per-frame backdrop blur */
.no-glass .reading,
.no-glass .ai-launcher,
.no-glass .ai-chat__backdrop,
.no-glass .ai-chat__flood,
.no-glass .settings-panel,
.no-glass .preset {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

.no-glass .reading {
  background:
    radial-gradient(120% 70% at 50% 0%, rgb(var(--accent) / 0.1), transparent 60%),
    linear-gradient(165deg, #0c2a44 0%, #071a2d 45%, #04111f 100%);
}

.no-glass .ai-launcher {
  background: linear-gradient(160deg, #123553, #06182a);
}

.no-glass .ai-chat__backdrop {
  background: rgba(4, 17, 31, 0.96);
}

/* =====================================================================
   ACCOUNT MENU (js/account.js)
   ===================================================================== */
.account {
  position: relative;
  pointer-events: auto;
}

.account__button {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px 0 4px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: rgba(4, 20, 36, 0.55);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: none;
  cursor: pointer;
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}

.account__button:hover,
.account__button:focus-visible,
.account.is-open .account__button {
  outline: none;
  color: #fff;
  border-color: rgb(var(--cyan) / 0.4);
  background: rgb(var(--cyan) / 0.1);
}

.account__avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #022033;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  background: radial-gradient(circle at 35% 30%, #ffffff, rgb(var(--cyan)) 55%, rgb(43 155 255));
  box-shadow: 0 0 14px rgb(var(--cyan) / 0.45);
}

.account__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account__chevron {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s var(--ease-out);
}

.account.is-open .account__chevron {
  transform: rotate(180deg);
}

.account__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 70;
  display: grid;
  min-width: 220px;
  padding: 8px;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(14, 50, 78, 0.96), rgba(3, 16, 30, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px var(--hair-2),
    0 30px 60px -20px rgba(0, 0, 0, 0.8);
  text-transform: none;
  letter-spacing: 0;
  animation: account-in 0.35s var(--ease-out);
}

.account__menu[hidden] {
  display: none;
}

@keyframes account-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.account__who {
  display: grid;
  gap: 3px;
  padding: 10px 12px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--hair);
}

.account__who b {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.account__who span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgb(var(--cyan) / 0.85);
}

.account__menu a,
.account__menu button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}

.account__menu a:hover,
.account__menu a:focus-visible,
.account__menu button:hover,
.account__menu button:focus-visible {
  outline: none;
  color: #fff;
  background: rgb(var(--cyan) / 0.1);
}

.account__menu a[aria-current="page"] {
  color: rgb(var(--cyan));
}

.account__menu [data-signout] {
  margin-top: 4px;
  border-top: 1px solid var(--hair);
  border-radius: 0 0 11px 11px;
  color: rgb(var(--danger) / 0.9);
}

.account__menu [data-signout]:hover {
  color: #fff;
  background: rgb(var(--danger) / 0.14);
}

@media (max-width: 640px) {
  .account__name,
  .account__chevron {
    display: none;
  }

  .account__button {
    padding: 0 4px;
  }
}

/* AI chat: a quiet note that the assistant is still in development */
.ai-chat__notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 18px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.45;
  background: rgb(var(--amber) / 0.07);
  box-shadow: inset 0 0 0 1px rgb(var(--amber) / 0.28);
}
.ai-chat__notice svg {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  fill: none;
  stroke: rgb(var(--amber));
  stroke-width: 1.8;
  stroke-linecap: round;
}
