:root {
  --bg-0: #060a12;
  --bg-1: #0b111a;
  --bg-2: #131c2a;
  --panel: rgba(13, 19, 28, 0.72);
  --panel-inner: rgba(6, 10, 18, 0.6);
  --panel-border: rgba(0, 154, 168, 0.28);
  --panel-border-strong: rgba(0, 184, 199, 0.6);
  --hairline: rgba(255, 255, 255, 0.06);
  --hairline-strong: rgba(255, 255, 255, 0.12);
  --text: #f1f6fc;
  --text-dim: #a8b8cc;
  --text-faint: #6f8094;
  --teal: #009aa8;
  --teal-bright: #00b8c7;
  --teal-glow: rgba(0, 154, 168, 0.5);
  --teal-glow-soft: rgba(0, 154, 168, 0.18);
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --slate: #94a3b8;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --max-w: 980px;
  --ease-out: cubic-bezier(0.32, 0.72, 0.24, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Light theme
   ========================================================================== */
:root[data-theme="light"] {
  --bg-0: #ffffff;
  --bg-1: #f4f7fa;
  --bg-2: #e9eff5;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-inner: rgba(244, 247, 250, 0.72);
  --panel-border: rgba(0, 154, 168, 0.30);
  --panel-border-strong: rgba(0, 154, 168, 0.55);
  --hairline: rgba(11, 31, 36, 0.10);
  --hairline-strong: rgba(11, 31, 36, 0.16);
  --text: #0b1f24;
  --text-dim: #3f5560;
  --text-faint: #6b7f89;
  --teal: #009aa8;
  --teal-bright: #00818f;
  --teal-glow: rgba(0, 154, 168, 0.35);
  --teal-glow-soft: rgba(0, 154, 168, 0.12);
  --green: #0b8043;
  --amber: #b45309;
  --red: #dc2626;
  --slate: #64748b;
}

/* Page background: light gradient with a faint teal wash top and bottom. */
[data-theme="light"] body {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0, 154, 168, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 50% at 50% 110%, rgba(0, 154, 168, 0.06), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, var(--bg-1) 60%, var(--bg-2) 100%);
  background-attachment: fixed;
}

/* Card shadow: soften the heavy dark drop shadow for a light surface. */
[data-theme="light"] .calc-card {
  box-shadow:
    0 20px 50px rgba(11, 31, 36, 0.10),
    0 0 0 1px rgba(11, 31, 36, 0.03) inset,
    0 1px 0 rgba(255, 255, 255, 0.60) inset;
}

/* Hover / surface tints that were white-on-dark become dark-on-light. */
[data-theme="light"] .mode-btn:hover { background: rgba(11, 31, 36, 0.04); }
[data-theme="light"] .switch:hover { background: rgba(11, 31, 36, 0.03); }
[data-theme="light"] .switch-track { background: rgba(11, 31, 36, 0.14); }

/* Inputs: dark fields become white on a light background. */
[data-theme="light"] .select-wrap,
[data-theme="light"] .input-wrap,
[data-theme="light"] .login-bar { background: rgba(255, 255, 255, 0.90); }
[data-theme="light"] .select-wrap:hover,
[data-theme="light"] .input-wrap:hover,
[data-theme="light"] .select-wrap:focus-within,
[data-theme="light"] .input-wrap:focus-within,
[data-theme="light"] .login-bar:hover,
[data-theme="light"] .login-bar:focus-within { background: #ffffff; }
[data-theme="light"] .login-bar { box-shadow: 0 4px 16px rgba(11, 31, 36, 0.08); }
[data-theme="light"] .login-bar.is-invalid { background: rgba(254, 242, 242, 0.92); }

/* Table header + inset data rows. */
[data-theme="light"] .tactic-table thead th { background: rgba(11, 31, 36, 0.04); }
[data-theme="light"] .reverse-rate-row { background: rgba(11, 31, 36, 0.05); }

/* Secondary CTA: near-invisible white overlay becomes a subtle white card. */
[data-theme="light"] .cta--secondary { background: rgba(255, 255, 255, 0.70); }

/* The interactive Vanta dots are dark-theme only — never show them on light. */
[data-theme="light"] .vanta-bg { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }

::selection { background: rgba(0, 154, 168, 0.45); color: #fff; }
::-moz-selection { background: rgba(0, 154, 168, 0.45); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 154, 168, 0.25); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 154, 168, 0.5); border: 2px solid transparent; background-clip: padding-box; }

body {
  margin: 0;
  font-family: "helvetica-neue-lt-pro", -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0, 154, 168, 0.14), transparent 60%),
    radial-gradient(ellipse 60% 50% at 50% 110%, rgba(0, 154, 168, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 50%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.vanta-bg { position: fixed; inset: 0; z-index: 0; opacity: 0.5; }
.vanta-bg canvas { display: block; }

/* ---------- Header ---------- */
.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 22px 32px;
}

/* Wordmark inherits theme text color (currentColor); icon stays teal. */
.ft-logo { width: 100%; height: auto; display: block; color: var(--text); }

.header-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 200ms var(--ease-out), color 200ms var(--ease-out), background 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.header-link:hover {
  color: var(--text);
  border-color: var(--panel-border-strong);
  background: rgba(0, 154, 168, 0.06);
}
.header-link:active { transform: scale(0.98); }

/* ---------- Layout ---------- */
.site-main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 24px 48px;
}

.view {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  animation: fadeUp 480ms var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.hero--compact { padding-top: 8px; }

.hero-logo {
  width: clamp(240px, 36vw, 380px);
  margin: 0 auto 12px;
  filter: drop-shadow(0 6px 24px rgba(0, 154, 168, 0.32)) drop-shadow(0 0 60px rgba(0, 154, 168, 0.12));
}

.tagline {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin: 0 0 14px;
  text-shadow: 0 0 24px rgba(0, 184, 199, 0.35);
}

.hero-blurb {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0 auto;
  max-width: 580px;
}

/* ---------- Calc card ---------- */
.calc-card {
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 1px 0 rgba(255, 255, 255, 0.05) inset;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- CTA row ---------- */
.cta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 540px) { .cta-row { grid-template-columns: 1fr; } }

.cta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  text-decoration: none;
  position: relative;
  transition: transform 180ms var(--ease-out), box-shadow 240ms var(--ease-out), border-color 200ms var(--ease-out), background 200ms var(--ease-out), filter 200ms var(--ease-out);
  border: 1px solid transparent;
  overflow: hidden;
}
.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 50%);
  pointer-events: none;
}
.cta:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 3px; }
.cta svg {
  position: absolute;
  top: 16px;
  right: 16px;
  opacity: 0.65;
  transition: opacity 200ms var(--ease-out), transform 220ms var(--ease-out);
}
.cta:hover svg { opacity: 1; transform: translate(2px, -2px); }
.cta-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.78;
}
.cta-main { font-size: 15px; font-weight: 600; }
.cta--primary {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  color: #ffffff;
  box-shadow: 0 6px 22px rgba(0, 154, 168, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.cta--primary:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 154, 168, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.22); filter: brightness(1.06); }
.cta--primary:active { transform: translateY(-1px); filter: brightness(0.98); }
.cta--secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-color: var(--hairline-strong);
}
.cta--secondary:hover { border-color: var(--panel-border-strong); background: rgba(0, 154, 168, 0.1); transform: translateY(-2px); }
.cta--secondary:active { transform: translateY(-1px); background: rgba(0, 154, 168, 0.06); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: rgba(0, 154, 168, 0.94);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 154, 168, 0.4);
  z-index: 50;
  opacity: 0;
  transition: opacity 220ms var(--ease-out), transform 240ms var(--ease-out);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Footer ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* live dot (shared) */
.live-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-bright);
  box-shadow: 0 0 0 3px rgba(0, 184, 199, 0.18);
  animation: liveDotPulse 2.2s ease-out infinite;
}
@keyframes liveDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 184, 199, 0.45); }
  60%      { box-shadow: 0 0 0 6px rgba(0, 184, 199, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .live-dot { animation: none; }
}

/* ==========================================================================
   OPS APP MARKETPLACE — layout, filter bar, cards, stars, live feed
   Marketplace-specific styles. All colors use design-system tokens so the
   theme flip (dark/light) still works if the shell is ever switched back.
   ========================================================================== */

/* Wider canvas than the calculator apps — this is a gallery. */
.view--marketplace { max-width: 1240px; gap: 28px; }

/* ---------- Marketplace hero ---------- */
.market-hero { text-align: center; display: flex; flex-direction: column; align-items: center; }
.market-hero .hero-logo { width: clamp(200px, 28vw, 300px); margin: 0 auto 14px; }
.market-heading {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--text);
  margin: 2px 0 12px;
  max-width: 720px;
}
.market-heading .accent { color: var(--teal-bright); }

/* ---------- Marketplace body: main gallery + live-feed rail ---------- */
.market-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1080px) {
  .market-body { grid-template-columns: 1fr; }
}

/* ---------- Toolbar: count + filter tags ---------- */
.market-toolbar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.toolbar-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.result-count {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.result-count strong { color: var(--text); font-weight: 700; }

/* ---------- Sort control (segmented) ---------- */
.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--panel-inner);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
}
.sort-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 8px 0 10px;
}
.sort-btn {
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: color 160ms var(--ease-out), background 160ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.sort-btn:hover { color: var(--text); background: rgba(0, 154, 168, 0.08); }
.sort-btn:active { transform: scale(0.97); }
.sort-btn:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }
.sort-btn.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  box-shadow: 0 4px 14px rgba(0, 154, 168, 0.30);
}
@media (max-width: 640px) {
  .sort-label { display: none; }
  .sort-btn { padding: 6px 10px; font-size: 12px; }
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: color 180ms var(--ease-out), border-color 180ms var(--ease-out), background 180ms var(--ease-out), transform 160ms var(--ease-out), box-shadow 200ms var(--ease-out);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.filter-tag:hover {
  color: var(--text);
  border-color: var(--panel-border-strong);
  background: rgba(0, 154, 168, 0.08);
}
.filter-tag:active { transform: scale(0.97); }
.filter-tag:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }
.filter-tag .tag-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.filter-tag.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(0, 154, 168, 0.32);
}
.filter-tag.is-active .tag-count { color: rgba(255, 255, 255, 0.85); }

.filter-tag--clear {
  color: var(--text-faint);
  background: transparent;
  border-style: dashed;
}
.filter-tag--clear:hover { color: var(--red); border-color: rgba(220, 38, 38, 0.4); background: rgba(220, 38, 38, 0.05); }

/* ---------- App card grid ---------- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  /* smooth height reflow as cards are filtered out */
  transition: none;
}
@media (max-width: 520px) {
  .app-grid { grid-template-columns: 1fr; }
}

/* ---------- Fader animation (jQuery-style smart fade/scale) ----------
   Cards animate opacity + translate + scale. A `.is-hidden` card fades
   and scales down, then is removed from layout via `.is-collapsed`
   (display:none) AFTER the transition finishes — driven by script.js —
   so the grid re-flows only once the fade-out has visually completed. */
.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 12px 34px rgba(11, 31, 36, 0.08), 0 1px 0 rgba(255, 255, 255, 0.5) inset;
  transform: translateY(0) scale(1);
  opacity: 1;
  transition:
    opacity 340ms var(--ease-out),
    transform 420ms var(--ease-spring),
    box-shadow 240ms var(--ease-out),
    border-color 200ms var(--ease-out);
  will-change: opacity, transform;
}
.app-card:hover {
  transform: translateY(-5px) scale(1.012);
  border-color: var(--panel-border-strong);
  box-shadow: 0 22px 48px rgba(0, 154, 168, 0.18), 0 0 0 1px rgba(0, 154, 168, 0.12);
}
.app-card.is-hidden {
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  pointer-events: none;
}
.app-card.is-collapsed { display: none; }
/* entrance stagger handled inline via animation-delay in JS-free fallback */
.app-card.is-entering {
  animation: cardIn 460ms var(--ease-out) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Clickable card region wraps thumb + body; footer (with star buttons)
   lives outside it so rating clicks never trigger navigation. */
.card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-decoration: none;
  color: inherit;
}
.card-link:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: -2px; }

/* ---------- Card thumbnail (screenshot / generated placeholder) ---------- */
.card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--panel-inner);
  border-bottom: 1px solid var(--hairline);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 520ms var(--ease-out);
}
.app-card:hover .card-thumb img { transform: scale(1.04); }

/* Generated placeholder thumbnail: teal gradient + big monogram.
   Used when an app has no real screenshot yet. */
.thumb-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.22), transparent 55%),
    linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
}
.thumb-placeholder .monogram {
  font-size: clamp(40px, 8vw, 62px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
  opacity: 0.95;
}
.thumb-placeholder .grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(circle at 70% 80%, #000, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 70% 80%, #000, transparent 75%);
}

/* Small "live" domain chip on the thumbnail */
.card-domain {
  position: absolute;
  bottom: 10px;
  left: 12px;
  max-width: calc(100% - 24px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(6, 10, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-domain .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.card-domain .dot--service { background: var(--amber); }
.card-domain .dot--test { background: var(--slate); }

/* Status badge (top-right of thumbnail) for non-live projects. */
.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  color: #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.card-badge--service { background: rgba(180, 83, 9, 0.92); }
.card-badge--test { background: rgba(100, 116, 139, 0.92); }

/* Featured badge sits top-LEFT so it never collides with service/test. */
.card-badge--featured {
  left: 10px;
  right: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  box-shadow: 0 4px 14px rgba(0, 154, 168, 0.35);
}
.card-badge--featured svg { margin-top: -1px; }

/* ---------- Card body ---------- */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
  flex: 1;
}
.card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.card-title {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
.card-open {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--teal-bright);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.app-card:hover .card-open { opacity: 1; transform: translateX(0); }
.card-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.card-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-inner);
  border: 1px solid var(--hairline);
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out), background 160ms var(--ease-out);
}
.card-tag.is-matched {
  color: var(--teal-bright);
  border-color: var(--panel-border);
  background: rgba(0, 154, 168, 0.08);
}

/* ---------- Card footer: rating ---------- */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--panel-inner);
}
.rating {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.stars {
  display: inline-flex;
  gap: 2px;
}
.star {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--hairline-strong);
  transition: color 140ms var(--ease-out), transform 140ms var(--ease-spring);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.star svg { width: 18px; height: 18px; display: block; }
.star:hover { transform: scale(1.18); }
.star.is-on { color: var(--amber); }
.star:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; border-radius: 4px; }
/* Hover preview (JS-driven): while previewing, saved fill is muted and only
   the hovered range lights up. */
.stars.previewing .star { color: var(--hairline-strong); }
.stars.previewing .star.hover-on { color: var(--amber); }

.rating-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.rating-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rating-note {
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 500;
}
.rating.is-rated .rating-note { color: var(--teal); }

/* Last-updated (last Vercel deploy) — subtle meta line at the bottom of the
   card body, above the footer. `margin-top:auto` pins it to the body bottom so
   it lines up across cards regardless of description length. */
.card-updated {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.card-updated svg { opacity: 0.7; flex: 0 0 auto; }

/* ---------- Empty state ---------- */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty-state h3 { font-size: 17px; color: var(--text-dim); margin: 0 0 6px; font-weight: 700; }
.empty-state p { font-size: 13.5px; margin: 0; }

/* ---------- Live feed rail ---------- */
.live-feed {
  position: sticky;
  top: 24px;
  background: var(--panel);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 12px 34px rgba(11, 31, 36, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.live-feed-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}
.live-feed-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0;
}
.live-feed-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow-y: auto;
}
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--hairline);
}
.feed-item:last-child { border-bottom: none; }
.feed-item.is-new { animation: feedIn 520ms var(--ease-out) both; }
@keyframes feedIn {
  from { opacity: 0; transform: translateY(-8px); background: rgba(0, 154, 168, 0.10); }
  to   { opacity: 1; transform: translateY(0); background: transparent; }
}
.feed-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  box-shadow: 0 2px 8px rgba(0, 154, 168, 0.25);
}
.feed-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-dim);
  min-width: 0;
}
.feed-text .who { font-weight: 700; color: var(--text); }
.feed-text .what { font-weight: 600; color: var(--teal); }
.feed-time {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Shown when nothing has been opened recently. Real activity is quiet outside
   working hours, so the rail needs something to say rather than a blank gap. */
.feed-empty {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  margin: 4px 0 0;
}

.feed-note {
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .site-header { padding: 18px 20px; }
  .app-grid { gap: 16px; }
}

/* ==========================================================================
   Sign-in gate (one-time code) — see api/auth.py
   ========================================================================== */
.view--auth {
  max-width: 430px;
  margin-top: clamp(4px, 5vh, 56px);
}

.auth-card { gap: 20px; padding: 32px 30px; }

.auth-brand { text-align: center; }
.auth-brand .hero-logo { width: clamp(180px, 52%, 230px); margin: 0 auto 12px; }
.auth-brand .tagline { margin: 0; font-size: 11px; }

.auth-copy { text-align: center; }
.auth-heading {
  font-size: clamp(20px, 4vw, 25px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: var(--text);
}
.auth-heading .accent { color: var(--teal-bright); }
.auth-blurb {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0;
}
.auth-blurb strong { color: var(--text); font-weight: 600; }

/* ---------- Form ---------- */
.auth-form { display: flex; flex-direction: column; gap: 10px; }

.auth-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.auth-field {
  background: var(--panel-inner);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  transition: border-color 200ms var(--ease-out), background 200ms var(--ease-out),
              box-shadow 200ms var(--ease-out);
}
.auth-field:hover { border-color: var(--panel-border); }
.auth-field:focus-within {
  border-color: var(--panel-border-strong);
  box-shadow: 0 0 0 3px var(--teal-glow-soft);
}

.auth-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 13px 15px;
  border-radius: inherit;
}
.auth-input::placeholder { color: var(--text-faint); }

/* The code field: wide tracking and tabular figures so eight digits stay
   readable and don't reflow as they're typed. */
.auth-input--code {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 15px 12px;
}

/* .cta is built for anchors; reset what a <button> brings with it. */
.auth-submit {
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  margin-top: 2px;
  gap: 3px;
}
.auth-submit .cta-main { font-size: 15px; }

/* ---------- Notes and secondary actions ---------- */
.auth-note {
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.auth-note--error {
  color: var(--red);
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.28);
}
.auth-note--ok {
  color: var(--green);
  background: rgba(11, 128, 67, 0.08);
  border-color: rgba(11, 128, 67, 0.26);
}

.auth-hint {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-faint);
  margin: 0;
  text-align: center;
}

.auth-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.auth-alt-sep { color: var(--text-faint); font-size: 12px; }

/* Buttons that need to read as links: the secondary actions are POSTs, because
   resending a code and switching address both change server state. */
.auth-inline-form { display: contents; }

.auth-link {
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--teal-bright);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--teal-glow);
  transition: color 180ms var(--ease-out), text-decoration-color 180ms var(--ease-out);
}
.auth-link:hover { text-decoration-color: var(--teal-bright); }
.auth-link:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 3px; border-radius: 3px; }
.auth-link:disabled {
  color: var(--text-faint);
  text-decoration-color: transparent;
  cursor: not-allowed;
}

/* ---------- Signed-in identity in the header ---------- */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(0, 154, 168, 0.05);
  max-width: min(52vw, 340px);
}
.header-user-email {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-signout {
  flex: 0 0 auto;
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--teal-bright);
  cursor: pointer;
  transition: color 180ms var(--ease-out);
}
.header-signout:hover { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.header-signout:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 3px; border-radius: 3px; }

@media (max-width: 600px) {
  .site-header { flex-wrap: wrap; gap: 8px; }
  .auth-card { padding: 26px 20px; }
  .auth-input--code { font-size: 20px; letter-spacing: 0.16em; }
}
