:root {
  --bg: #f3efff;
  --surface: rgb(255 255 255 / .62);
  --surface-strong: rgb(255 255 255 / .82);
  --ink: #17141f;
  --muted: #625d6e;
  --line: rgb(40 20 80 / .1);
  --ring-track: rgb(40 20 80 / .09);
  --fresh: #0fa672;
  --due: #de8a00;
  --overdue: #e5244a;
  --face: rgb(255 255 255 / .45);
  --face-hi: rgb(255 255 255 / .7);
  --housing-top: rgb(255 255 255 / .5);
  --housing-bottom: rgb(236 230 252 / .66);
  --odo-bg: rgb(20 10 40 / .06);
  --youtube: #ff0033;
  --tiktok: #00c2c7;
  --tiktok-cyan: #25f4ee;
  --tiktok-red: #fe2c55;
  --instagram: #d62f8f;
  --instagram-gradient: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
  --radius: 20px;
  --backdrop:
    radial-gradient(60vmax 50vmax at 8% -10%, rgb(255 0 51 / .22), transparent 60%),
    radial-gradient(55vmax 45vmax at 105% 15%, rgb(37 244 238 / .26), transparent 60%),
    radial-gradient(70vmax 55vmax at 55% 115%, rgb(214 36 159 / .24), transparent 62%),
    radial-gradient(45vmax 40vmax at 20% 80%, rgb(40 90 235 / .16), transparent 60%),
    linear-gradient(160deg, #f7f3ff 0%, #efe9ff 45%, #fdf0f6 100%);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a16;
    --surface: rgb(24 21 36 / .55);
    --surface-strong: rgb(24 21 36 / .78);
    --ink: #f3f0fa;
    --muted: #a7a1b6;
    --line: rgb(255 255 255 / .09);
    --ring-track: rgb(255 255 255 / .1);
    --fresh: #3be8a8;
    --due: #ffb638;
    --overdue: #ff4f6e;
    --face: rgb(8 6 16 / .42);
    --face-hi: rgb(255 255 255 / .05);
    --housing-top: rgb(34 30 50 / .55);
    --housing-bottom: rgb(8 6 16 / .72);
    --odo-bg: rgb(0 0 0 / .32);
    --backdrop:
      radial-gradient(60vmax 50vmax at 8% -10%, rgb(255 0 51 / .28), transparent 60%),
      radial-gradient(55vmax 45vmax at 105% 15%, rgb(37 244 238 / .2), transparent 60%),
      radial-gradient(70vmax 55vmax at 55% 115%, rgb(214 36 159 / .3), transparent 62%),
      radial-gradient(45vmax 40vmax at 15% 85%, rgb(40 90 235 / .22), transparent 60%),
      linear-gradient(160deg, #120d24 0%, #0c0a16 50%, #1a0b1f 100%);
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--backdrop);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---- Logo sprite + badges ------------------------------------------------ */
/* Kept in layout (not display:none) so <use> references always resolve. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.badge {
  --badge: 22px;
  --glyph: .64; /* glyph size as a fraction of the badge */
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--badge);
  height: var(--badge);
  border-radius: 28%;
  color: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / .18), inset 0 0 0 1px rgb(255 255 255 / .14);
}
/* Explicit size: a percentage height would fall back to SVG's default 150px and push the glyph out. */
.badge svg { width: calc(var(--badge) * var(--glyph)); height: calc(var(--badge) * var(--glyph)); display: block; overflow: visible; }
.badge-youtube { background: linear-gradient(180deg, #ff2a4f, #e0002b); --glyph: .78; }
.badge-tiktok { background: #0b0b10; }
.badge-tiktok svg { filter: drop-shadow(-1.2px -1px 0 var(--tiktok-cyan)) drop-shadow(1.2px 1px 0 var(--tiktok-red)); }
.badge-instagram { background: var(--instagram-gradient); --glyph: .7; }

/* ---- Slow-motion logo rain ------------------------------------------------- */
.rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  contain: strict;
}
.drop {
  position: absolute;
  top: 0;
  left: var(--x);
  animation: fall var(--fall) linear var(--delay) infinite;
  will-change: transform;
}
.drop-sway {
  animation: sway var(--sway-time) ease-in-out var(--sway-delay) infinite alternate;
}
.drop-body {
  --badge: var(--size);
  box-shadow: none;
}
@keyframes fall {
  from { transform: translate3d(0, calc(-1 * var(--size) - 12vh), 0); }
  to { transform: translate3d(0, 112vh, 0); }
}
@keyframes sway {
  from { transform: translateX(calc(-1 * var(--sway))) rotate(var(--rot-a)); }
  to { transform: translateX(var(--sway)) rotate(var(--rot-b)); }
}

/* ---- Layout -------------------------------------------------------------- */
.shell { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 48px 20px 64px; }

.masthead h1 {
  margin: 0;
  font-size: clamp(30px, 4.4vw, 44px);
  letter-spacing: -0.03em;
  background: linear-gradient(95deg, var(--ink) 30%, #ff2a6d 65%, #7a5cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  width: fit-content;
}
.masthead p { margin: 6px 0 28px; color: var(--muted); }
.masthead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

/* Help link: available but out of the way */
.help-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 5px 11px 5px 5px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.help-link:hover { color: var(--ink); border-color: var(--line); background: var(--surface); }
.help-link:focus-visible { outline: 2px solid #9d7bff; outline-offset: 2px; }
.help-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font: 600 11px/1 "Martian Mono", ui-monospace, monospace;
}

/* ---- Credit line at the bottom of every page ------------------------------ */
.site-credit {
  margin-top: 40px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.site-credit a { color: var(--ink); font-weight: 600; text-decoration: none; }
.site-credit a:hover { text-decoration: underline; }
.site-credit a:focus-visible { outline: 2px solid #9d7bff; outline-offset: 2px; border-radius: 4px; }

.masthead-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- Offer to install the extension (website only) ------------------------ */
.install-offer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--instagram) 35%, transparent);
  background: color-mix(in srgb, var(--instagram) 10%, var(--surface));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 14px;
}
.install-text { margin: 0; flex: 1; min-width: 14ch; }
.install-link {
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 650;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(100deg, #ff1f4b, #d6249f 55%, #6a4dff);
  white-space: nowrap;
}
.install-link:hover { filter: brightness(1.08); }
.install-dismiss { padding: 7px 10px; background: none; color: var(--muted); font-size: 13px; }
.install-dismiss:hover { color: var(--ink); }

/* ---- Saved profiles ------------------------------------------------------ */
.profiles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: -8px 0 20px;
}
.profiles-label {
  font-family: "Martian Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 300;
  font-stretch: 112.5%;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--muted);
}
.profile-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}
.profile-chip:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--ink) 25%, transparent); }
.profile-chip:focus-visible { outline: 2px solid #9d7bff; outline-offset: 2px; }
.profile-chip[aria-pressed="true"] {
  border-color: transparent;
  background:
    linear-gradient(var(--surface-strong), var(--surface-strong)) padding-box,
    linear-gradient(100deg, #ff1f4b, #d6249f 55%, #6a4dff) border-box;
  border: 1.5px solid transparent;
  box-shadow: 0 6px 20px -10px rgb(214 36 159 / .7);
}
/* Which platforms the profile covers, as three mini logo dots */
.chip-platforms { display: inline-flex; }
.chip-platforms .badge { --badge: 18px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface-strong); }
.chip-platforms .badge + .badge { margin-left: -5px; }
.chip-platforms .badge.off { filter: grayscale(1); opacity: .3; }

.profile-manage { color: var(--muted); padding: 7px 14px; border-style: dashed; }
.profile-manage span { font-weight: 400; }

/* ---- Manage profiles dialog (extension) ------------------------------------ */
.profile-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 30px 80px -30px rgb(10 0 30 / .7);
}
.profile-dialog::backdrop { background: rgb(8 4 20 / .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.profile-dialog h2 { margin: 0 0 4px; font-size: 20px; }
.profile-dialog h3 { margin: 20px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.dialog-hint { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.dialog-field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 13px; font-weight: 650; }
.dialog-message { min-height: 1.2em; margin: 4px 0 8px; font-size: 13px; color: var(--overdue); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .primary { padding: 10px 18px; color: #fff; background: linear-gradient(100deg, #ff1f4b, #d6249f 55%, #6a4dff); }
.dialog-actions .secondary { padding: 10px 16px; color: var(--ink); background: var(--ring-track); }
.custom-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.custom-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.custom-list li.empty { color: var(--muted); }
.link-button { padding: 0; background: none; color: var(--overdue); font-size: 13px; }
.link-button:hover { text-decoration: underline; }

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 28px;
}

.field { display: grid; gap: 7px; font-size: 13px; font-weight: 650; color: var(--ink); }
.field-label { display: inline-flex; align-items: center; gap: 8px; }
.field-label .badge { --badge: 20px; }
.field[data-platform="youtube"], .card[data-platform="youtube"] { --accent: var(--youtube); }
.field[data-platform="tiktok"], .card[data-platform="tiktok"] { --accent: var(--tiktok); }
.field[data-platform="instagram"], .card[data-platform="instagram"] { --accent: var(--instagram); }

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

button {
  font: inherit;
  font-weight: 650;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
#track-btn {
  padding: 12px 26px;
  min-width: 116px;
  color: #fff;
  background: linear-gradient(100deg, #ff1f4b, #d6249f 55%, #6a4dff);
  box-shadow: 0 6px 20px -6px rgb(214 36 159 / .6);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
#track-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px -8px rgb(214 36 159 / .75); }
#track-btn:active { transform: translateY(0); filter: brightness(.95); }
#track-btn:disabled { opacity: .7; cursor: progress; transform: none; }

/* ---- Instrument cluster ---------------------------------------------------
   YouTube is the centre speedometer; TikTok and Instagram are the flanking dials.
   Each .card is display:contents so its dial joins the cluster row and its
   details panel sits directly beneath, while state selectors still work. */
.cards {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  grid-template-areas:
    "tiktok-pod youtube-pod instagram-pod"
    "tiktok-info youtube-info instagram-info";
  column-gap: 16px;
  row-gap: 18px;
}
.card { display: contents; }

.cluster-housing {
  grid-area: 1 / 1 / 2 / -1;
  /* Arched binnacle: wide elliptical top corners, tight bottom corners */
  border-radius: 50% 50% 30px 30px / 46% 46% 30px 30px;
  background: linear-gradient(180deg, var(--housing-top), var(--housing-bottom));
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .1),
    inset 0 -40px 60px -40px rgb(0 0 0 / .45),
    0 40px 80px -50px rgb(10 0 30 / .7);
}

.pod {
  position: relative;
  z-index: 1;
  display: grid;
  align-items: end;
  padding: 34px 0 26px;
  min-width: 0;
}
.card[data-platform="youtube"] .pod { grid-area: youtube-pod; z-index: 2; align-items: center; padding-top: 26px; }
.card[data-platform="tiktok"] .pod { grid-area: tiktok-pod; }
.card[data-platform="instagram"] .pod { grid-area: instagram-pod; }
.card[data-platform="youtube"] .card-info { grid-area: youtube-info; }
.card[data-platform="tiktok"] .card-info { grid-area: tiktok-info; }
.card[data-platform="instagram"] .card-info { grid-area: instagram-info; }

/* Flanking dials sit lower and tuck slightly behind the speedometer */
.card[data-platform="youtube"] .gauge { width: min(100%, 430px); }
.card:not([data-platform="youtube"]) .gauge { width: min(112%, 300px); }
.card[data-platform="tiktok"] .gauge { justify-self: end; margin-right: -12%; }
.card[data-platform="instagram"] .gauge { justify-self: start; margin-left: -12%; }

.card-info {
  position: relative;
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px -30px rgb(20 0 50 / .45);
  overflow: hidden;
}
/* Accent line along the top edge */
.card-info::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
}
.card[data-platform="instagram"] .card-info::before { background: linear-gradient(90deg, #fdc468, #fd5949, #d6249f, #285aeb); }
.card[data-platform="tiktok"] .card-info::before { background: linear-gradient(90deg, var(--tiktok-cyan), #0b0b10 50%, var(--tiktok-red)); }

.card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Platform "button": logo + name, links to the tracked profile */
.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  flex: none;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.platform-pill .badge { --badge: 28px; border-radius: 50%; }
.platform-pill[href]:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 6px 16px -8px var(--accent);
}
.platform-pill:not([href]) { cursor: default; }
.platform-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-title { margin: 0; font-size: 15px; font-weight: 700; }
.card-handle { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Cockpit gauge ------------------------------------------------------- */
.gauge {
  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --z: var(--muted);
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 1;
  margin: 2px auto 0;
  container-type: inline-size;
}
.gauge[data-zone="fresh"] { --z: var(--fresh); }
.gauge[data-zone="due"] { --z: var(--due); }
.gauge[data-zone="overdue"] { --z: var(--overdue); }

/* Instrument face: a recessed disc behind the scale */
.gauge::before {
  content: "";
  position: absolute;
  inset: 1.5%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, var(--face-hi), transparent 62%),
    var(--face);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 -18px 36px -12px rgb(0 0 0 / .28);
}
.gauge > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.g-track { fill: none; stroke: var(--ring-track); stroke-width: 2; stroke-linecap: round; }
.g-sweep {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 0 1;
  opacity: .45;
  transition: stroke-dasharray .8s ease-out;
}

.tick { stroke-linecap: round; opacity: .2; transition: opacity .35s ease, stroke-width .35s ease; }
.tick.minor { stroke-width: 1.3; }
.tick.major { stroke-width: 2.6; }
.tick.z-fresh { stroke: var(--fresh); }
.tick.z-due { stroke: var(--due); }
.tick.z-overdue { stroke: var(--overdue); }
.tick.lit { opacity: 1; }
.tick.major.lit { filter: drop-shadow(0 0 2.5px currentColor); stroke-width: 3; }
.tick.z-fresh.lit { color: var(--fresh); }
.tick.z-due.lit { color: var(--due); }
.tick.z-overdue.lit { color: var(--overdue); }

.g-label {
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
  font-stretch: 75%;
  letter-spacing: .02em;
  fill: var(--muted);
  text-anchor: middle;
  dominant-baseline: central;
  opacity: .55;
  transition: opacity .35s ease, fill .35s ease;
}
.g-label.lit { fill: var(--ink); opacity: 1; font-weight: 700; }

.g-pointer {
  transform-box: view-box;
  transform-origin: 120px 120px;
  transform: rotate(-135deg);
  transition: transform .8s ease-out;
}
.g-pointer line {
  stroke: var(--ink);
  stroke-width: 3.2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px var(--accent)) drop-shadow(0 0 1px var(--accent));
}

/* Start-up sweep when a result arrives */
.gauge.reveal .g-pointer { transition: transform 1.4s cubic-bezier(.16, .84, .24, 1); }
.gauge.reveal .g-sweep { transition: stroke-dasharray 1.4s cubic-bezier(.16, .84, .24, 1); }
.gauge.reveal .tick, .gauge.reveal .g-label { transition-duration: .18s; }
.gauge.no-anim, .gauge.no-anim * { transition: none !important; }

/* Readout */
.g-readout {
  position: absolute;
  inset: 25% 18% 27%;
  display: grid;
  place-items: center;
  text-align: center;
}
.g-live { display: none; justify-items: center; }
.g-days {
  font-family: var(--mono);
  font-size: 27cqi;
  font-weight: 800;
  font-stretch: 75%;
  line-height: .86;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 22px color-mix(in srgb, var(--z) 35%, transparent);
}
.g-unit {
  margin-top: 2.2cqi;
  padding-left: .38em; /* balances the trailing letter-spacing */
  font-family: var(--mono);
  font-size: 3.5cqi;
  font-weight: 300;
  font-stretch: 112.5%;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: var(--z);
}
.g-clock {
  margin-top: 3.6cqi;
  font-family: var(--mono);
  font-size: 6.4cqi;
  font-weight: 450;
  font-stretch: 87.5%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.g-clock i { font-style: normal; font-weight: 200; color: var(--muted); margin: 0 .04em; }
.g-sec { font-weight: 250; color: var(--muted); }

/* Odometer strip in the open bottom of the dial: telltale lamp + week/day count */
.g-odo {
  position: absolute;
  left: 50%;
  bottom: 5%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: .55em;
  padding: .38em .95em .38em .55em;
  border-radius: 999px;
  background: var(--odo-bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--z) 32%, transparent);
  font-family: var(--mono);
  font-size: 4.3cqi;
  white-space: nowrap;
}
.g-odo b { font-weight: 700; font-stretch: 87.5%; }
.g-odo small { font-size: .74em; font-weight: 300; font-stretch: 112.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 .3em 0 .12em; }
.g-odo small:last-child { margin-right: 0; }

.g-lamp {
  width: 1.55em;
  height: 1.55em;
  flex: none;
  overflow: visible;
  color: var(--z);
  filter: drop-shadow(0 0 .18em var(--z)) drop-shadow(0 0 .55em color-mix(in srgb, var(--z) 70%, transparent));
}
/* Overdue lamps blink like a dashboard warning light: a fast warm-up, a slower fade */
.gauge[data-zone="overdue"] .g-lamp { animation: telltale 1.2s infinite; }
@keyframes telltale {
  0% { opacity: .15; filter: none; }
  6%, 46% { opacity: 1; filter: drop-shadow(0 0 .18em var(--z)) drop-shadow(0 0 .7em var(--z)); }
  62%, 100% { opacity: .15; filter: none; }
}
/* Loading: bulb check, every lamp lit in the platform colour */
.card[data-state="loading"] .g-odo { display: inline-flex; --z: var(--accent); }
.card[data-state="loading"] .g-odo-text::after { content: "SYNC"; font-weight: 300; font-stretch: 112.5%; letter-spacing: .22em; color: var(--muted); }
.card[data-state="loading"] .g-odo-text > * { display: none; }

/* ---- Engine feel -------------------------------------------------------- */
/* Constant idle flutter on the needle */
.g-needle {
  transform-box: view-box;
  transform-origin: 120px 120px;
  animation: idle-rev var(--rev, 2.5s) linear infinite;
}
@keyframes idle-rev {
  0% { rotate: 0deg; } 8% { rotate: .9deg; } 15% { rotate: -.35deg; } 24% { rotate: .6deg; }
  35% { rotate: -.75deg; } 44% { rotate: .25deg; } 55% { rotate: .85deg; } 63% { rotate: -.5deg; }
  76% { rotate: .4deg; } 86% { rotate: -.8deg; } 100% { rotate: 0deg; }
}
/* Occasional throttle blip: the needle kicks and settles, the dial rumbles */
.g-blip { transform-box: view-box; transform-origin: 120px 120px; }
.gauge.revving .g-blip { animation: rev-blip 1s cubic-bezier(.3, .7, .3, 1); }
.gauge.revving > svg { animation: rumble .45s linear; }
@keyframes rev-blip {
  0% { rotate: 0deg; } 16% { rotate: 7deg; } 36% { rotate: -2.2deg; }
  56% { rotate: 1.1deg; } 76% { rotate: -.4deg; } 100% { rotate: 0deg; }
}
@keyframes rumble {
  0%, 100% { translate: 0 0; } 12% { translate: .7px -.5px; } 25% { translate: -.6px .6px; }
  37% { translate: .5px .4px; } 50% { translate: -.7px -.3px; } 62% { translate: .4px -.6px; }
  75% { translate: -.4px .5px; } 87% { translate: .3px -.2px; }
}
.card:not([data-state="success"]) .g-needle { animation: none; }

.g-caption { display: none; max-width: 22ch; font-size: 13px; line-height: 1.35; color: var(--muted); }
.g-caption-loading { font-family: var(--mono); font-size: 3.6cqi; font-stretch: 112.5%; letter-spacing: .2em; text-transform: uppercase; }
.g-caption-error { color: var(--overdue); }

.card[data-state="success"] .g-live { display: grid; }
.card[data-state="success"] .g-odo { display: inline-flex; }
.card[data-state="idle"] .g-caption-idle,
.card[data-state="loading"] .g-caption-loading,
.card[data-state="error"] .g-caption-error { display: block; }
.card:not([data-state="success"]) :is(.g-pointer, .g-sweep) { visibility: hidden; }

/* Loading: a scanning light runs along the scale */
.card[data-state="loading"] .tick { animation: scan 1.5s ease-in-out infinite; animation-delay: calc(var(--f) * 1.1s); }
@keyframes scan { 0%, 100% { opacity: .14; } 12% { opacity: 1; } 34% { opacity: .14; } }
.card[data-state="error"] .tick { opacity: .1; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.card-foot { display: flex; align-items: center; gap: 12px; min-height: 84px; font-size: 13px; }
.foot-text { display: grid; gap: 2px; min-width: 0; flex: 1; }

/* Thumbnail: 16:9 for YouTube, portrait for TikTok/Instagram, same row height. */
.thumb {
  --thumb-h: 84px;
  position: relative;
  flex: none;
  height: var(--thumb-h);
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ring-track);
  display: none;
}
.card[data-platform="tiktok"] .thumb,
.card[data-platform="instagram"] .thumb { aspect-ratio: 3 / 4; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.card[data-thumb="ready"] .thumb img { opacity: 1; }
.card[data-thumb="loading"] .thumb,
.card[data-thumb="ready"] .thumb,
.card[data-state="loading"] .thumb { display: block; }
.card[data-state="loading"] .thumb img { display: none; }
.card[data-state="loading"] .thumb,
.card[data-thumb="loading"] .thumb {
  background: linear-gradient(100deg, var(--ring-track) 30%, var(--line) 50%, var(--ring-track) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

.play {
  position: absolute; inset: 0; margin: auto;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgb(0 0 0 / .55);
  opacity: 0; transition: opacity .2s, transform .2s;
}
.play::after {
  content: ""; position: absolute; left: 11px; top: 8px;
  border-style: solid; border-width: 6px 0 6px 9px; border-color: transparent transparent transparent #fff;
}
.card[data-thumb="ready"] .play { opacity: 1; }
.thumb:hover .play { transform: scale(1.12); background: var(--accent); }
.thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.post-link { color: var(--ink); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-link:hover { text-decoration: underline; }
.meta { color: var(--muted); }
.retry { justify-self: start; padding: 6px 14px; background: var(--ring-track); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  /* Keep the logos as a still, scattered backdrop */
  .drop, .drop-sway { animation-play-state: paused; }
  .card[data-state="loading"] .tick { animation: none; opacity: .35; }
  .gauge .g-pointer, .gauge .g-sweep, .gauge .tick, .gauge .g-label { transition: none !important; }
  .g-needle, .gauge.revving .g-blip, .gauge.revving > svg { animation: none !important; }
  .gauge[data-zone="overdue"] .g-lamp { animation: none; }
  .thumb { animation: none !important; }
}

@media (max-width: 860px) {
  .controls { grid-template-columns: 1fr; }
  #track-btn { width: 100%; }
  .cards {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "youtube-pod youtube-pod"
      "tiktok-pod instagram-pod"
      "youtube-info youtube-info"
      "tiktok-info tiktok-info"
      "instagram-info instagram-info";
    column-gap: 8px;
  }
  .cluster-housing { grid-area: 1 / 1 / 3 / -1; border-radius: 48% 48% 28px 28px / 22% 22% 28px 28px; }
  .pod { padding: 10px 0 14px; }
  .card[data-platform="youtube"] .pod { padding: 24px 12px 0; }
  .card:not([data-platform="youtube"]) .gauge { width: 100%; margin: -18px 0 0; justify-self: center; }
}
