/* ==========================================================================
   zUI — shared design system for zSuite ("soft glass + depth")
   Loaded AFTER each app's own stylesheet so its tokens and base components
   win; app-specific layout rules (more specific selectors) still apply.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* Core palette */
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eceef5;
  --text: #0f1220;
  --text-2: #3c4257;
  --text-3: #6b7186;
  --text-4: #a3a8b8;
  --border: rgba(15, 18, 32, 0.09);
  --border-strong: rgba(15, 18, 32, 0.16);
  --fill: rgba(15, 18, 32, 0.045);
  --fill-2: rgba(15, 18, 32, 0.08);

  --accent: #6d4aff;
  --accent-2: #1fa6e8;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #5b7bff 50%, #1fb6f0 100%);
  --accent-soft: rgba(109, 74, 255, 0.14);
  --accent-text: #5a37f0;
  --on-accent: #ffffff;

  --positive: #12a36b;
  --negative: #e5484d;
  --warning: #c27c0e;
  --info: #2f6fe4;
  --positive-bg: rgba(18, 163, 107, 0.11);
  --negative-bg: rgba(229, 72, 77, 0.10);
  --warning-bg: rgba(194, 124, 14, 0.11);
  --info-bg: rgba(47, 111, 228, 0.10);

  /* "Solid" = selected / inverted chips (formerly ink-on-paper) */
  --solid: var(--accent);
  --on-solid: #ffffff;

  /* Glass */
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --blur: blur(22px) saturate(160%);

  /* Aurora */
  --aurora-1: rgba(124, 92, 255, 0.22);
  --aurora-2: rgba(31, 182, 240, 0.18);
  --aurora-3: rgba(255, 120, 200, 0.12);

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(15, 18, 32, 0.06), 0 2px 8px -2px rgba(15, 18, 32, 0.06);
  --shadow-2: 0 2px 4px rgba(15, 18, 32, 0.04), 0 12px 32px -8px rgba(15, 18, 32, 0.14);
  --shadow-3: 0 4px 8px rgba(15, 18, 32, 0.05), 0 32px 80px -16px rgba(15, 18, 32, 0.28);
  --glow: 0 8px 24px -8px rgba(109, 74, 255, 0.55);

  /* Shape */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Type */
  --font-ui: 'Geist', 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.2%, 1);
  --t-fast: 120ms;
  --t-med: 220ms;
  --t-slow: 380ms;

  /* ---- Legacy aliases (every app's CSS + inline styles use these) ---- */
  --desk: var(--bg);
  --paper: #ffffff;
  --paper-card: #ffffff;
  --ink: #0f1220;
  --mid: #3c4257;
  --muted: #6b7186;
  --soft: #a3a8b8;
  --rule: rgba(15, 18, 32, 0.09);
  --rule-light: rgba(15, 18, 32, 0.06);
  --stamp: #e5484d;
  --field: rgba(15, 18, 32, 0.045);
  --field-active: rgba(15, 18, 32, 0.08);
  --input-bg: rgba(15, 18, 32, 0.045);
  --font: var(--font-ui);
  --font-mono: var(--font-num);

  --ink-blue: #2f6fe4;
  --ink-green: #12a36b;
  --ink-gold: #c27c0e;
  --ink-purple: #6d4aff;
  --ink-cyan: #0e9fb6;
  --ink-red: #e5484d;
  --amber: #c27c0e;
  --success: #12a36b;
  --bg-blue: rgba(47, 111, 228, 0.10);
  --bg-green: rgba(18, 163, 107, 0.11);
  --bg-gold: rgba(194, 124, 14, 0.11);
  --bg-purple: rgba(109, 74, 255, 0.10);
  --bg-red: rgba(229, 72, 77, 0.10);

  --text-main: var(--text);
  --text-muted: var(--text-3);
  --text-dim: var(--text-4);
  --border-subtle: var(--border);
  --border-highlight: var(--border-strong);
  --primary: var(--accent);
  --danger: var(--negative);
  --bg-base: var(--bg);
  --bg-surface: var(--surface);

  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --shadow-sm: var(--shadow-1);
  --shadow-md: var(--shadow-2);
  --shadow-lg: var(--shadow-3);
  --shadow-subtle: var(--shadow-1);
  --shadow-card: var(--shadow-2);
  --ease-out-gentle: var(--ease-out);
  --ease-gentle: var(--ease-out);
  --ease: var(--ease-out);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #08090d;
  --surface: #12141b;
  --surface-2: #181b24;
  --surface-3: #1f2330;
  --text: #eef0f6;
  --text-2: #b9becc;
  --text-3: #868c9c;
  --text-4: #575d6c;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --fill: rgba(255, 255, 255, 0.045);
  --fill-2: rgba(255, 255, 255, 0.08);

  --accent: #8b6dff;
  --accent-2: #3ec6ff;
  --accent-grad: linear-gradient(135deg, #8b6dff 0%, #6a7dff 50%, #3ec6ff 100%);
  --accent-soft: rgba(139, 109, 255, 0.18);
  --accent-text: #b4a2ff;

  --positive: #3ddc97;
  --negative: #ff6b6b;
  --warning: #ffb547;
  --info: #6ea8ff;
  --positive-bg: rgba(61, 220, 151, 0.12);
  --negative-bg: rgba(255, 107, 107, 0.12);
  --warning-bg: rgba(255, 181, 71, 0.12);
  --info-bg: rgba(110, 168, 255, 0.12);

  --glass: rgba(20, 23, 32, 0.58);
  --glass-strong: rgba(22, 25, 35, 0.86);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --aurora-1: rgba(124, 92, 255, 0.20);
  --aurora-2: rgba(40, 170, 255, 0.13);
  --aurora-3: rgba(255, 90, 180, 0.08);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px -2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 16px 40px -8px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 4px 8px rgba(0, 0, 0, 0.3), 0 40px 100px -20px rgba(0, 0, 0, 0.8);
  --glow: 0 8px 28px -8px rgba(139, 109, 255, 0.7);

  --paper: #12141b;
  --paper-card: #181b24;
  --ink: #eef0f6;
  --mid: #b9becc;
  --muted: #868c9c;
  --soft: #575d6c;
  --rule: rgba(255, 255, 255, 0.075);
  --rule-light: rgba(255, 255, 255, 0.05);
  --stamp: #ff6b6b;
  --field: rgba(255, 255, 255, 0.045);
  --field-active: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.045);

  --ink-blue: #6ea8ff;
  --ink-green: #3ddc97;
  --ink-gold: #ffb547;
  --ink-purple: #a78bfa;
  --ink-cyan: #4dd4e6;
  --ink-red: #ff6b6b;
  --amber: #ffb547;
  --success: #3ddc97;
  --bg-blue: rgba(110, 168, 255, 0.12);
  --bg-green: rgba(61, 220, 151, 0.12);
  --bg-gold: rgba(255, 181, 71, 0.12);
  --bg-purple: rgba(167, 139, 250, 0.13);
  --bg-red: rgba(255, 107, 107, 0.12);
}

/* ---------- Base ---------- */
@view-transition { navigation: auto; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text);
  background: transparent !important;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
}

/* Aurora + film grain behind everything. Both stay static: the glass shell
   blurs whatever is behind it, so a moving backdrop would force a
   full-screen re-blur on every frame. */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
body::before {
  inset: -20%;
  background:
    radial-gradient(38% 42% at 18% 22%, var(--aurora-1), transparent 70%),
    radial-gradient(34% 38% at 82% 18%, var(--aurora-2), transparent 70%),
    radial-gradient(40% 40% at 70% 88%, var(--aurora-3), transparent 70%);
}
body::after {
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent-soft); color: var(--text); }

* { scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

h1, h2, h3, h4 {
  font-family: var(--font-ui);
  font-weight: 650;
  letter-spacing: -0.022em;
  color: var(--text);
}
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 18px; line-height: 1.25; }
h3 { font-size: 15px; }
p.subtitle { color: var(--text-3); font-size: 13px; }

/* Numbers, money, codes */
.num, .mono, code, kbd {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums slashed-zero;
  letter-spacing: -0.02em;
}

/* ---------- Shell ---------- */
.container {
  background: var(--glass) !important;
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-color: var(--glass-border) !important;
  box-shadow: var(--glass-hi), var(--shadow-3) !important;
}
@media (min-width: 768px) {
  .container { border-radius: var(--r-xl) !important; }
}

.card {
  background: transparent;
  animation: zuiRise 0.55s var(--ease-out) both;
}
.card::before { display: none !important; }

.nav-breadcrumbs {
  border-bottom: 1px solid var(--border) !important;
  font-size: 13px;
}
.nav-back-link {
  font-family: var(--font-ui);
  font-weight: 500;
  color: var(--text-3);
  padding: 4px 10px;
  margin-left: -10px;
  border-radius: var(--r-pill);
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-back-link:hover { color: var(--text); background: var(--fill); }

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---------- Controls ---------- */
.btn {
  font-family: var(--font-ui);
  font-weight: 560;
  font-size: 13px;
  letter-spacing: -0.005em;
  text-transform: none;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--fill);
  color: var(--text);
  box-shadow: var(--glass-hi);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast),
              box-shadow var(--t-med), transform var(--t-slow) var(--ease-spring), filter var(--t-fast);
  position: relative;
  isolation: isolate;
}
.btn:hover { background: var(--fill-2); border-color: var(--border-strong); opacity: 1; }
.btn:active { transform: scale(0.97); transition-duration: 80ms; }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent-grad) !important;
  color: var(--on-accent) !important;
  border-color: transparent !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), var(--glow);
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.7s var(--ease-out);
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:hover::after { transform: translateX(120%); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-outline:hover { background: var(--fill); }

.btn-sm { border-radius: var(--r-sm); font-size: 12px; }

.btn-theme-toggle {
  border-radius: var(--r-md) !important;
  border: 1px solid var(--border) !important;
  background: var(--fill) !important;
  color: var(--text-2) !important;
  min-width: 34px;
  min-height: 34px;
  transition: background var(--t-fast), transform var(--t-slow) var(--ease-spring) !important;
}
.btn-theme-toggle:hover { background: var(--fill-2) !important; color: var(--text) !important; transform: rotate(180deg); }

.tag {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border) !important;
  border-style: solid !important;
  background: var(--fill);
  color: var(--text-2);
}

label {
  font-family: var(--font-ui);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.01em;
  color: var(--text-3);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not(.zui-bare):not(.editor-title-input),
select,
textarea:not(.zui-bare):not(.writing-textarea) {
  font-family: var(--font-ui);
  background: var(--fill);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md);
  color: var(--text);
  box-shadow: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-med);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not(.zui-bare):not(.editor-title-input):hover,
select:hover,
textarea:not(.zui-bare):not(.writing-textarea):hover { border-color: var(--border-strong) !important; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not(.zui-bare):not(.editor-title-input):focus,
select:focus,
textarea:not(.zui-bare):not(.writing-textarea):focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px var(--accent-soft) !important;
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }

/* ---------- Overlays ---------- */
.modal-overlay {
  background: rgba(6, 8, 14, 0.5) !important;
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  animation: zuiFade var(--t-med) var(--ease-out) both;
}
.modal-overlay > div,
.modal-overlay > .modal,
.modal-overlay > .modal-content {
  border-radius: var(--r-xl) !important;
  border: 1px solid var(--glass-border) !important;
  background: var(--glass-strong) !important;
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glass-hi), var(--shadow-3) !important;
  animation: zuiPop var(--t-slow) var(--ease-spring) both;
}

.toast-banner {
  font-family: var(--font-ui) !important;
  font-weight: 500;
  border-radius: var(--r-pill) !important;
  border: 1px solid var(--glass-border) !important;
  background: var(--glass-strong) !important;
  color: var(--text) !important;
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--glass-hi), var(--shadow-2) !important;
  animation: zuiDrop var(--t-slow) var(--ease-spring) both;
}

/* ---------- Utilities ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-hi), var(--shadow-2);
  border-radius: var(--r-lg);
}

/* Cursor-tracked spotlight (zui.js sets --mx / --my) */
.zui-spot {
  background-image: radial-gradient(260px circle at var(--mx, 50%) var(--my, -200px), var(--accent-soft), transparent 65%);
}

.zui-lift {
  transition: transform var(--t-slow) var(--ease-spring), box-shadow var(--t-med), border-color var(--t-fast), background-color var(--t-fast);
}
.zui-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.zui-lift:active { transform: scale(0.98); }

.stagger > * { animation: zuiRise 0.5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms + 60ms); }

.skeleton {
  color: transparent !important;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 37%, var(--fill) 63%) 0 0 / 400% 100%;
  animation: zuiShimmer 1.4s ease infinite;
}

.zui-flash-up { animation: zuiFlashUp 0.9s var(--ease-out); }
.zui-flash-down { animation: zuiFlashDown 0.9s var(--ease-out); }

.gradient-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- App lobby: brand mark, hero, tile grid ----------
   Shared by the app lobbies so they read as one suite. --h is the app's
   hue (same as its row in the zSuite hub). The brand icon + name are what
   the hub's row flies into on navigation (see Page-to-page transitions). */
.zui-brand { display: flex; align-items: center; gap: 12px; }
.zui-brand-icon {
  --tint: hsl(var(--h, 260) 85% 64%);
  display: grid;
  place-items: center;
  flex: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  color: var(--tint);
  background: color-mix(in oklab, var(--tint) 15%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tint) 25%, transparent);
  view-transition-name: zapp-icon;
}
.zui-brand-icon svg { width: 20px; height: 20px; }
.zui-brand-name { width: fit-content; view-transition-name: zapp-name; }

.zui-app-hero { margin: 6px 0 22px; text-align: left; animation: zuiRise .6s var(--ease-out) .05s both; }
.zui-app-hero .zui-brand { margin-bottom: 10px; }
.zui-app-hero .zui-brand-icon { width: 48px; height: 48px; border-radius: 14px; }
.zui-app-hero .zui-brand-icon svg { width: 24px; height: 24px; }
.zui-app-hero h1 {
  margin: 0;
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.04em;
  text-align: left;
  background: linear-gradient(110deg, var(--text) 20%, hsl(var(--h, 260) 85% 66%) 60%, hsl(calc(var(--h, 260) - 62) 85% 70%));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.zui-app-hero .subtitle { margin: 0; text-align: left; font-size: 14.5px; color: var(--text-3); }

.zui-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 10px;
  margin-bottom: 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--fill);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
}
.zui-live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--positive); animation: zuiLivePulse 2.2s ease-out infinite; }
@keyframes zuiLivePulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--positive) 60%, transparent); }
  70%, 100% { box-shadow: 0 0 0 8px transparent; }
}
.zui-section-head { margin: 4px 0 10px; animation: zuiRise .5s var(--ease-out) .1s both; }

.zui-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
@media (min-width: 640px) {
  .zui-tiles { grid-template-columns: repeat(auto-fill, minmax(var(--tile-min, 160px), 1fr)); }
}
.zui-tile {
  --tint: hsl(var(--h, 260) 85% 64%);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 140px;
  padding: 16px;
  text-align: left;
  color: inherit;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background-color: var(--fill);
  box-shadow: var(--glass-hi);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  animation: zuiRise .5s var(--ease-out) calc(.12s + var(--i, 0) * .03s) both;
  transition: transform var(--t-slow) var(--ease-spring), border-color var(--t-med), background-color var(--t-med), box-shadow var(--t-med);
}
.zui-tile.zui-spot {
  background-image: radial-gradient(220px circle at var(--mx, 50%) var(--my, -300px), color-mix(in oklab, var(--tint) 22%, transparent), transparent 70%);
}
.zui-tile:hover {
  transform: translateY(-3px);
  border-color: color-mix(in oklab, var(--tint) 45%, transparent);
  background-color: color-mix(in oklab, var(--tint) 8%, var(--fill));
  box-shadow: var(--glass-hi), var(--shadow-2), 0 12px 40px -18px var(--tint);
}
.zui-tile:active { transform: scale(.98); }
.zui-tile-icon {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 13px;
  color: var(--tint);
  background: color-mix(in oklab, var(--tint) 15%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--tint) 25%, transparent);
  transition: transform var(--t-slow) var(--ease-spring);
}
.zui-tile-icon svg { width: 22px; height: 22px; stroke-width: 1.75px; }
.zui-tile:hover .zui-tile-icon { transform: scale(1.08) rotate(-6deg); }
.zui-tile-title { margin-top: 14px; font-size: 15px; font-weight: 640; letter-spacing: -0.015em; color: var(--text); }
.zui-tile-desc { font-size: 12.5px; line-height: 1.4; color: var(--text-3); }
.zui-tile-badge {
  position: absolute;
  top: 14px; right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--positive);
  background: var(--positive-bg);
}
.zui-tile-badge svg { width: 12px; height: 12px; }
.zui-tile-go {
  position: absolute;
  right: 16px; bottom: 16px;
  color: var(--tint);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--t-med), transform var(--t-slow) var(--ease-spring);
}
.zui-tile-go svg { width: 17px; height: 17px; }
.zui-tile:hover .zui-tile-go { opacity: 1; transform: none; }

/* Not live yet: same tile, locked */
.zui-tile.is-locked { cursor: default; }
.zui-tile.is-locked .zui-tile-icon { filter: saturate(.3); opacity: .7; }
.zui-tile.is-locked :is(.zui-tile-title, .zui-tile-desc) { opacity: .6; }
.zui-tile.is-locked .zui-tile-badge { padding: 4px; color: var(--text-3); background: var(--fill-2); }
.zui-tile.is-locked:hover {
  transform: none;
  border-color: var(--border-strong);
  background-color: var(--fill);
  box-shadow: var(--glass-hi);
}
.zui-tile.is-locked:hover .zui-tile-icon { transform: none; }

/* Sliding tab indicator (zui.tabs) */
.zui-tabs { position: relative; isolation: isolate; }
.zui-tab-pill {
  position: absolute;
  z-index: -1;
  border-radius: var(--r-md);
  background: var(--fill-2);
  box-shadow: var(--glass-hi), var(--shadow-1);
  transition: transform var(--t-slow) var(--ease-spring), width var(--t-slow) var(--ease-spring), height var(--t-slow) var(--ease-spring), opacity var(--t-med);
  pointer-events: none;
}

/* ---------- Keyframes ---------- */
@keyframes zuiRise {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes zuiFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes zuiPop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes zuiDrop {
  from { opacity: 0; transform: translate(-50%, -16px) scale(0.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes zuiShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes zuiFlashUp { 0% { color: var(--positive); text-shadow: 0 0 18px var(--positive); } 100% { text-shadow: none; } }
@keyframes zuiFlashDown { 0% { color: var(--negative); text-shadow: 0 0 18px var(--negative); } 100% { text-shadow: none; } }
@keyframes zuiShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* Mobile: overlays become bottom sheets */
@media (max-width: 600px) {
  .modal-overlay > div,
  .modal-overlay > .modal,
  .modal-overlay > .modal-content {
    animation-name: zuiSheet;
  }
}
@keyframes zuiSheet {
  from { opacity: 0.4; transform: translateY(40px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Page-to-page transitions ----------
   Pages opt in by naming their screen `zui-page`; the glass shell and
   backdrop stay in the root crossfade, which is near-identical between
   apps, so only the content moves. Elements named `zapp-icon` /
   `zapp-name` on both pages fly between them. zui.js tags the
   direction: zui-forward (deeper path) or zui-back. */
::view-transition-group(*) {
  animation-duration: .52s;
  animation-timing-function: var(--ease-out);
}
::view-transition-group(zapp-icon),
::view-transition-group(zapp-name) { animation-duration: .6s; }

::view-transition-old(zui-page) { animation: zuiPageOut .26s var(--ease-in-out) both; }
::view-transition-new(zui-page) { animation: zuiPageIn .5s var(--ease-out) .1s both; }
html:active-view-transition-type(zui-back)::view-transition-old(zui-page) { animation-name: zuiPageOutBack; }
html:active-view-transition-type(zui-back)::view-transition-new(zui-page) { animation-name: zuiPageInBack; }

@keyframes zuiPageOut     { to   { opacity: 0; scale: 1.02; } }
@keyframes zuiPageIn      { from { opacity: 0; scale: .97; translate: 0 10px; } }
@keyframes zuiPageOutBack { to   { opacity: 0; scale: .97; translate: 0 10px; } }
@keyframes zuiPageInBack  { from { opacity: 0; scale: 1.02; } }

/* The transition is the entrance, so the arriving page's own load-in
   animations collapse to their end state (zui.js restores them after).
   Scroll-driven ones (zui-scroll-*, sticky headers) are left alone. */
.zui-vt-in .card:not([class*="zui-scroll"]),
.zui-vt-in .anim-header,
.zui-vt-in .hub-hero,
.zui-vt-in .hub-grid-head,
.zui-vt-in .zui-app-hero,
.zui-vt-in .zui-section-head,
.zui-vt-in .footer-note { animation-duration: 0s !important; animation-delay: 0s !important; }

/* ---------- Day/night switch ----------
   zui.js wraps toggleTheme() in a view transition. Named page elements are
   folded into the root snapshot so the whole page cross-fades as one. */
.zui-theme-vt * { view-transition-name: none !important; }
.zui-theme-vt::view-transition-group(root) { animation-duration: .5s; }
.zui-theme-vt::view-transition-old(root),
.zui-theme-vt::view-transition-new(root) { animation-duration: .5s; animation-timing-function: var(--ease-in-out); }

/* Fallback where view transitions aren't supported: ease the colors instead. */
.zui-theme-fade, .zui-theme-fade *, .zui-theme-fade *::before, .zui-theme-fade *::after {
  transition: background-color .45s var(--ease-in-out), color .45s var(--ease-in-out),
    border-color .45s var(--ease-in-out), outline-color .45s var(--ease-in-out),
    fill .45s var(--ease-in-out), stroke .45s var(--ease-in-out),
    box-shadow .45s var(--ease-in-out) !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  body::before { animation: none !important; }
  @view-transition { navigation: none; }
}

/* Opt-out for inputs that are the page itself (editors, inline titles, palette search) */
.zui-bare, .zui-bare:hover, .zui-bare:focus,
textarea.writing-textarea, textarea.writing-textarea:hover, textarea.writing-textarea:focus,
input.editor-title-input, input.editor-title-input:hover, input.editor-title-input:focus {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0;
}
.zui-bare:focus-visible, textarea.writing-textarea:focus-visible, input.editor-title-input:focus-visible { outline: none !important; }

/* ==========================================================================
   Scroll layer — scroll-driven reveals, collapsing headers, edge fades,
   progress bars and snap carousels. Pure CSS: only active where the
   browser supports scroll timelines and the user allows motion, so
   everything is static (and fully visible) otherwise.
   ========================================================================== */
@property --fade-top { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --fade-bottom { syntax: '<length>'; inherits: false; initial-value: 0px; }

/* Things that only make sense when scroll timelines run */
.zui-scroll-progress, .zui-compact { display: none; }

@supports (animation-timeline: view()) {
@media (prefers-reduced-motion: no-preference) {

  @keyframes zuiFadeOnly { from { opacity: 0; } to { opacity: 1; } }
  @keyframes zuiScrollIn { from { translate: 0 28px; scale: .965; filter: blur(4px); } }
  @keyframes zuiScrollOut { to { opacity: .45; scale: .97; } }
  @keyframes zuiFadeTop { from { --fade-top: 0px; } to { --fade-top: 36px; } }
  @keyframes zuiFadeBottom { from { --fade-bottom: 36px; } to { --fade-bottom: 0px; } }
  @keyframes zuiProgress { from { scale: 0 1; } to { scale: 1 1; } }
  @keyframes zuiHeaderGlass {
    to {
      background-color: color-mix(in oklab, var(--surface) 90%, transparent);
      border-bottom-color: var(--glass-border);
      box-shadow: var(--glass-hi), 0 10px 30px -14px rgba(0, 0, 0, .45);
      -webkit-backdrop-filter: var(--blur);
      backdrop-filter: var(--blur);
    }
  }
  @keyframes zuiHeroOut { to { opacity: 0; translate: 0 -18px; scale: .94; filter: blur(3px); } }
  @keyframes zuiCompactIn { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
  @keyframes zuiSnapFocus {
    0%, 100% { scale: .9; opacity: .5; }
    50% { scale: 1; opacity: 1; }
  }

  /* 1. Reveal-on-scroll: staggered fade on load, then rise/scale/unblur as
     items scroll in and a gentle recede as they leave the top. The scroll
     effects use translate/scale (not transform) so hover lifts still work. */
  .zui-reveal,
  .entity-item, .receipt-accordion, .transfer-item,
  .app-tile, .game-tile, .mode-card, .zui-tile,
  .chart-bar-item, .idea-card, .qa-card,
  .cork-card, .scene-item {
    animation-name: zuiFadeOnly, zuiScrollIn, zuiScrollOut !important;
    animation-duration: .5s, auto, auto !important;
    animation-timing-function: var(--ease-out), linear, linear !important;
    animation-delay: calc(var(--i, 0) * 35ms + 40ms), 0s, 0s !important;
    animation-fill-mode: both !important;
    animation-iteration-count: 1 !important;
    animation-timeline: auto, view(), view() !important;
    animation-range: normal, entry 0% entry min(100%, 160px), exit 25% exit 100% !important;
  }

  /* 2. Edge fades on scroll containers (mask stays fixed to the box) */
  .zui-scroll-fade, .zui-scroll-fade-bottom, .zui-scroll-fade-top {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
  }
  .zui-scroll-fade {
    animation: zuiFadeTop linear both, zuiFadeBottom linear both;
    animation-timeline: scroll(self), scroll(self);
    animation-range: 0px 48px, calc(100% - 48px) 100%;
  }
  .zui-scroll-fade-bottom { animation: zuiFadeBottom linear both; animation-timeline: scroll(self); animation-range: calc(100% - 48px) 100%; }
  .zui-scroll-fade-top { animation: zuiFadeTop linear both; animation-timeline: scroll(self); animation-range: 0px 48px; }

  /* 3. Progress bar (put inside the scroller, or name a timeline) */
  .zui-scroll-progress {
    display: block;
    height: 2px;
    background: var(--accent-grad);
    transform-origin: 0 50%;
    scale: 0 1; /* stays empty if the timeline is inactive (nothing to scroll) */
    animation: zuiProgress linear both;
    animation-timeline: scroll(nearest);
  }

  /* 4. Collapsing glass header: .zui-sticky-head sticks to the top of its
     scroller and turns to glass; .zui-hero children fade away under it and
     .zui-compact (a short title in the header) fades in. The scroller needs
     timeline-scope: --zui-hero. */
  .zui-sticky-head {
    position: sticky;
    top: 0;
    z-index: 20;
    animation: zuiHeaderGlass linear both;
    animation-timeline: scroll(nearest);
    animation-range: 0px 80px;
  }
  .zui-hero { view-timeline: --zui-hero; }
  .zui-hero > * {
    animation: zuiHeroOut linear both !important;
    animation-timeline: --zui-hero !important;
    animation-range: exit 10% exit 90% !important;
  }
  .zui-compact {
    display: inline-block;
    animation: zuiCompactIn linear both;
    animation-timeline: --zui-hero;
    animation-range: exit 55% exit 100%;
  }

  /* 5. Snap carousel on small screens */
  @media (max-width: 639px) {
    .zui-snap-m {
      display: flex !important;
      flex-shrink: 0 !important;
      gap: 12px !important;
      overflow-x: auto !important;
      overscroll-behavior-x: contain;
      scroll-snap-type: x mandatory;
      scroll-padding-inline: var(--snap-bleed, 20px);
      margin-inline: calc(-1 * var(--snap-bleed, 20px)) !important;
      padding: 4px var(--snap-bleed, 20px) 10px !important;
      scrollbar-width: none;
    }
    .zui-snap-m::-webkit-scrollbar { display: none; }
    .zui-snap-m > * {
      flex: 0 0 82% !important;
      scroll-snap-align: center;
      animation-name: zuiSnapFocus !important;
      animation-duration: auto !important;
      animation-delay: 0s !important;
      animation-timing-function: linear !important;
      animation-fill-mode: both !important;
      animation-timeline: view(inline) !important;
      animation-range: cover 0% cover 100% !important;
    }
  }
}
}
