/* ============================================================================
   iWallet design system — v3
   HF atmosphere (yellow signature) + shadcn-flavoured semantic tokens.
   Weight register: 300 light / 400 regular / 500 medium. 600 reserved for headings.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------------------------------------------------------------- tokens -- */
:root {
  /* Brand — the one thing that must never drift */
  --wo-yellow: 47 100% 56%;          /* #FFD21E */
  --wo-yellow-ink: 32 81% 24%;
  --wo-orange: 37 100% 50%;          /* #FF9D00 */

  /* Semantic surface scale (shadcn shape, HF temperature) */
  --background: 0 0% 98%;
  --foreground: 0 0% 11%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 11%;
  --popover: 0 0% 100%;
  --popover-foreground: 0 0% 11%;
  --muted: 30 6% 96%;
  --muted-foreground: 25 5% 40%;
  --subtle-foreground: 25 5% 58%;
  --accent: 47 100% 94%;
  --accent-foreground: 32 81% 24%;
  --primary: 0 0% 11%;
  --primary-foreground: 0 0% 100%;
  --border: 20 6% 90%;
  --border-strong: 20 6% 83%;
  --input: 20 6% 83%;
  --ring: 0 0% 11%;
  --destructive: 0 72% 45%;
  --destructive-soft: 0 86% 96%;
  --success: 142 69% 29%;
  --success-soft: 141 79% 92%;
  --info: 217 91% 52%;
  --info-soft: 214 95% 93%;

  /* Decorative tag ramp — kept from v2 so partner avatars stay recognisable */
  --tag-blue: 214 95% 93%;      --tag-blue-ink: 224 64% 33%;
  --tag-purple: 271 91% 95%;    --tag-purple-ink: 272 52% 39%;
  --tag-pink: 327 73% 94%;      --tag-pink-ink: 336 74% 35%;
  --tag-green: 141 79% 92%;     --tag-green-ink: 142 64% 24%;
  --tag-orange: 33 100% 91%;    --tag-orange-ink: 21 83% 34%;

  /* Type */
  --font-sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* Radius — shadcn convention: one root value, everything derives */
  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: calc(var(--radius) - 2px);   /* 6px — buttons, inputs */
  --radius-xs: calc(var(--radius) - 4px);   /* 4px — pills-on-cards */

  /* Control metrics — visually compact, hit area enforced separately */
  --control-h: 32px;
  --control-h-sm: 26px;
  --control-h-lg: 38px;
  --control-px: 11px;

  /* Elevation — one consistent scale, no ad-hoc shadows */
  --elev-0: none;
  --elev-1: 0 1px 2px hsl(0 0% 0% / 0.04);
  --elev-2: 0 2px 8px hsl(0 0% 0% / 0.06), 0 1px 2px hsl(0 0% 0% / 0.04);
  --elev-3: 0 12px 32px hsl(0 0% 0% / 0.12), 0 2px 8px hsl(0 0% 0% / 0.06);

  /* Motion — 150–300ms band, spatial continuity */
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 300ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Layered z-index scale */
  --z-base: 0;
  --z-raised: 10;
  --z-sticky: 20;
  --z-nav: 40;
  --z-overlay: 100;
  --z-toast: 1000;

  /* Safe areas */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --bottom-nav-h: 58px;
}

/* Dark mode is a first-class variant: desaturated tonal shifts, not inversion. */
@media (prefers-color-scheme: dark) {
  :root.theme-auto {
    --background: 0 0% 6%;
    --foreground: 0 0% 96%;
    --card: 0 0% 10%;
    --card-foreground: 0 0% 96%;
    --popover: 0 0% 12%;
    --popover-foreground: 0 0% 96%;
    --muted: 0 0% 14%;
    --muted-foreground: 0 0% 66%;
    --subtle-foreground: 0 0% 50%;
    --accent: 45 40% 16%;
    --accent-foreground: 47 100% 72%;
    --primary: 0 0% 96%;
    --primary-foreground: 0 0% 8%;
    --border: 0 0% 18%;
    --border-strong: 0 0% 26%;
    --input: 0 0% 26%;
    --ring: 47 100% 56%;
    --destructive: 0 72% 62%;
    --destructive-soft: 0 40% 16%;
    --success: 142 60% 55%;
    --success-soft: 142 34% 14%;
    --info: 217 91% 68%;
    --info-soft: 217 40% 17%;

    --tag-blue: 217 40% 20%;    --tag-blue-ink: 213 94% 78%;
    --tag-purple: 272 30% 22%;  --tag-purple-ink: 270 95% 82%;
    --tag-pink: 336 30% 22%;    --tag-pink-ink: 327 87% 80%;
    --tag-green: 142 30% 17%;   --tag-green-ink: 141 70% 70%;
    --tag-orange: 25 40% 20%;   --tag-orange-ink: 33 100% 72%;

    --elev-2: 0 2px 8px hsl(0 0% 0% / 0.4);
    --elev-3: 0 12px 32px hsl(0 0% 0% / 0.6);
  }
}

* { box-sizing: border-box; }

html {
  /* Never block pinch-zoom; honour the user's system text size. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  /* 16px floor on mobile: prevents iOS auto-zoom on input focus. */
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

@media (min-width: 769px) { body { font-size: 15px; } }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Focus is always visible — never removed, only restyled. */
:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: hsl(var(--wo-yellow) / 0.35); }

/* Skip link for keyboard users */
.wo-skip {
  position: absolute; left: 8px; top: -60px;
  background: hsl(var(--card)); color: hsl(var(--foreground));
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border-strong));
  z-index: var(--z-toast); transition: top var(--dur-fast) var(--ease-out);
}
.wo-skip:focus { top: calc(8px + var(--safe-t)); }

/* --------------------------------------------------------------- utility -- */
.wo-mono { font-family: var(--font-mono); font-size: 0.9em; font-weight: 400; }
.wo-muted { color: hsl(var(--muted-foreground)); }
.wo-faint { color: hsl(var(--subtle-foreground)); font-size: 13px; }
.wo-bold { font-weight: 500; }
.wo-hstack { display: flex; align-items: center; gap: 8px; }
.wo-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Lucide icons: one set, one stroke language. */
.wo-i {
  width: 18px; height: 18px;
  stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
  fill: none; flex-shrink: 0;
  vertical-align: -0.18em;
}
.wo-i--sm { width: 15px; height: 15px; stroke-width: 1.9; }
.wo-i--lg { width: 22px; height: 22px; stroke-width: 1.6; }
.wo-i--xl { width: 30px; height: 30px; stroke-width: 1.35; }

/* ------------------------------------------------------------------ card -- */
.wo-card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--elev-1);
}
.wo-card--hover {
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.wo-card--hover:hover {
  border-color: hsl(var(--border-strong));
  box-shadow: var(--elev-2);
}
.wo-card--hover:active { transform: scale(0.994); }

.wo-card-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin: 0 0 6px;
}
.wo-card-value {
  font-size: 27px;
  font-weight: 300;          /* light register for the big numbers */
  letter-spacing: -0.022em;
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
}
.wo-card-value .unit {
  font-size: 13px; font-weight: 400;
  color: hsl(var(--muted-foreground)); letter-spacing: 0;
}
.wo-card-sub { font-size: 13px; color: hsl(var(--muted-foreground)); margin-top: 3px; }

/* ------------------------------------------------------------------ pill -- */
.wo-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500; letter-spacing: 0.01em;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.wo-pill .wo-i { width: 12px; height: 12px; stroke-width: 2.1; }
.wo-pill--yellow { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); border-color: transparent; }
.wo-pill--orange { background: hsl(var(--tag-orange)); color: hsl(var(--tag-orange-ink)); border-color: transparent; }
.wo-pill--blue   { background: hsl(var(--tag-blue));   color: hsl(var(--tag-blue-ink));   border-color: transparent; }
.wo-pill--purple { background: hsl(var(--tag-purple)); color: hsl(var(--tag-purple-ink)); border-color: transparent; }
.wo-pill--green  { background: hsl(var(--tag-green));  color: hsl(var(--tag-green-ink));  border-color: transparent; }
.wo-pill--pink   { background: hsl(var(--tag-pink));   color: hsl(var(--tag-pink-ink));   border-color: transparent; }

/* ---------------------------------------------------------------- button -- */
.wo-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  position: relative;
  height: var(--control-h);
  padding: 0 var(--control-px);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1;
  cursor: pointer;
  border: 1px solid hsl(var(--border-strong));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  text-decoration: none !important;
  touch-action: manipulation;   /* kills the 300ms tap delay */
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}
/* Hit area is always >=44px even when the control looks smaller. */
.wo-btn::after {
  content: '';
  position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: max(100%, 44px);
}
.wo-btn:hover { background: hsl(var(--muted)); }
.wo-btn:active { transform: scale(0.97); }
.wo-btn[disabled], .wo-btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.wo-btn--primary {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}
.wo-btn--primary:hover { background: hsl(var(--primary) / 0.88); }

.wo-btn--accent {
  background: hsl(var(--wo-yellow)); color: hsl(var(--wo-yellow-ink));
  border-color: hsl(var(--wo-yellow)); font-weight: 500;
}
.wo-btn--accent:hover { background: hsl(var(--wo-yellow) / 0.85); }

.wo-btn--ghost { border-color: transparent; background: transparent; }
.wo-btn--ghost:hover { background: hsl(var(--muted)); }

/* Destructive stays visually subordinate and is placed out of the thumb arc. */
.wo-btn--danger { color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.35); background: transparent; }
.wo-btn--danger:hover { background: hsl(var(--destructive-soft)); }

.wo-btn--sm { height: var(--control-h-sm); font-size: 12.5px; padding: 0 9px; border-radius: var(--radius-xs); }
.wo-btn--lg { height: var(--control-h-lg); font-size: 14.5px; padding: 0 16px; }
.wo-btn--block { width: 100%; }
.wo-btn--icon { width: var(--control-h); padding: 0; }
.wo-btn--icon.wo-btn--lg { width: var(--control-h-lg); }

/* Coarse pointers get real 44px controls, not just a phantom hit area. */
@media (pointer: coarse) {
  .wo-btn { height: 40px; font-size: 14.5px; padding: 0 14px; }
  .wo-btn--sm { height: 34px; font-size: 13.5px; padding: 0 11px; }
  .wo-btn--lg { height: 46px; font-size: 15.5px; }
  .wo-btn--icon { width: 44px; height: 44px; }
}

/* Async state: disable + spinner, never a dead-looking button. */
.wo-btn[data-loading="true"] { pointer-events: none; opacity: 0.7; }
.wo-btn[data-loading="true"] .wo-btn-label { opacity: 0.45; }

/* ----------------------------------------------------------------- input -- */
.wo-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.wo-label {
  font-size: 13px; font-weight: 500;
  color: hsl(var(--foreground));
}
.wo-hint { font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.wo-input, .wo-textarea, .wo-select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 16px;              /* 16px = no iOS zoom-on-focus */
  line-height: 1.4;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
@media (min-width: 769px) { .wo-input, .wo-textarea, .wo-select { font-size: 14px; min-height: 36px; padding: 7px 11px; } }
.wo-input:focus, .wo-textarea:focus, .wo-select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
.wo-textarea { resize: vertical; min-height: 84px; }

/* Inline validation — live, next to the field, never only at the top. */
.wo-input[aria-invalid="true"], .wo-textarea[aria-invalid="true"] {
  border-color: hsl(var(--destructive));
}
.wo-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px hsl(var(--destructive) / 0.14); }
.wo-error {
  display: none;
  align-items: center; gap: 5px;
  font-size: 12.5px; color: hsl(var(--destructive));
}
.wo-error.is-shown { display: flex; }
.wo-ok-mark { color: hsl(var(--success)); display: none; }
.wo-ok-mark.is-shown { display: inline-flex; }

/* Section grouping in long forms */
.wo-fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.wo-fieldset legend {
  font-size: 12px; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding: 0 0 8px; margin-bottom: 12px;
  border-bottom: 1px solid hsl(var(--border)); width: 100%;
}

/* ----------------------------------------------------------------- table -- */
.wo-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wo-table th {
  text-align: left; font-weight: 500; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  padding: 9px 15px;
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
}
.wo-table td { padding: 11px 15px; border-bottom: 1px solid hsl(var(--border)); }
.wo-table tr:last-child td { border-bottom: none; }
.wo-table tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
.wo-table tbody tr:hover td { background: hsl(var(--muted) / 0.6); }
.wo-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- avatar -- */
.wo-avatar {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, hsl(var(--wo-yellow)), hsl(var(--wo-orange)));
  flex-shrink: 0;
}
.wo-avatar--blue   { background: linear-gradient(135deg, #60A5FA, #2563EB); }
.wo-avatar--purple { background: linear-gradient(135deg, #C084FC, #7C3AED); }
.wo-avatar--green  { background: linear-gradient(135deg, #4ADE80, #16A34A); }
.wo-avatar--pink   { background: linear-gradient(135deg, #F472B6, #DB2777); }
.wo-avatar--orange { background: linear-gradient(135deg, #FDBA74, #F97316); }
.wo-avatar--sm { width: 27px; height: 27px; font-size: 11px; border-radius: var(--radius-xs); }
.wo-avatar--lg { width: 50px; height: 50px; font-size: 17px; border-radius: var(--radius); }

/* ==========================================================================
   SIGNATURE — circling glow
   Draws attention to profile steps the user hasn't completed. One rotating
   conic sweep + a slow halo. Nothing else in the UI animates like this.
   ========================================================================== */
@property --wo-glow-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.wo-glow { position: relative; isolation: isolate; }
.wo-glow::before {
  content: '';
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(
    from var(--wo-glow-angle),
    hsl(var(--border)) 0deg,
    hsl(var(--border)) 190deg,
    hsl(var(--wo-orange)) 268deg,
    hsl(var(--wo-yellow)) 310deg,
    hsl(var(--wo-yellow) / 0.15) 344deg,
    hsl(var(--border)) 360deg
  );
  /* Mask keeps only the 1.5px rim — the card face stays clean. */
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: wo-glow-spin 4s linear infinite;
  z-index: -1;
  pointer-events: none;
}
.wo-glow::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 hsl(var(--wo-yellow) / 0.4);
  animation: wo-glow-halo 4s var(--ease-in-out) infinite;
  z-index: -1;
  pointer-events: none;
}
@keyframes wo-glow-spin { to { --wo-glow-angle: 360deg; } }
@keyframes wo-glow-halo {
  0%, 70%, 100% { box-shadow: 0 0 0 0 hsl(var(--wo-yellow) / 0); }
  35%           { box-shadow: 0 0 0 5px hsl(var(--wo-yellow) / 0.14); }
}

/* Browsers without @property: no rotation, but the rim still reads as "act here". */
@supports not (background: conic-gradient(from var(--wo-glow-angle), red, blue)) {
  .wo-glow::before {
    background: linear-gradient(120deg, hsl(var(--wo-yellow)), hsl(var(--wo-orange)));
    animation: none;
  }
}

/* Progress ring used on the profile summary */
.wo-ring { --pct: 0; position: relative; width: 52px; height: 52px; flex-shrink: 0; }
.wo-ring::before {
  content: '';
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(
    hsl(var(--wo-yellow)) calc(var(--pct) * 1%),
    hsl(var(--muted)) 0
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  transition: background var(--dur-slow) var(--ease-out);
}
.wo-ring-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   MOTION — page slide + card reveal
   ========================================================================== */

/* Cards rise as the screen settles. Auto-staggered so templates stay clean. */
.wo-stagger > * { animation: wo-rise var(--dur-slow) var(--ease-out) backwards; }
.wo-stagger > *:nth-child(1) { animation-delay: 20ms; }
.wo-stagger > *:nth-child(2) { animation-delay: 55ms; }
.wo-stagger > *:nth-child(3) { animation-delay: 90ms; }
.wo-stagger > *:nth-child(4) { animation-delay: 125ms; }
.wo-stagger > *:nth-child(5) { animation-delay: 160ms; }
.wo-stagger > *:nth-child(6) { animation-delay: 195ms; }
.wo-stagger > *:nth-child(n+7) { animation-delay: 225ms; }

.wo-rise { animation: wo-rise var(--dur-slow) var(--ease-out) backwards; }
@keyframes wo-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* --- Page transition: current screen exits left, next enters from right --- */
@keyframes wo-page-out-left  { to   { opacity: 0; transform: translateX(-22%); } }
@keyframes wo-page-in-right  { from { opacity: 0; transform: translateX(100%); } }
@keyframes wo-page-out-right { to   { opacity: 0; transform: translateX(22%); } }
@keyframes wo-page-in-left   { from { opacity: 0; transform: translateX(-100%); } }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(page) {
    animation: wo-page-out-left var(--dur) var(--ease-in-out) both;
  }
  ::view-transition-new(page) {
    animation: wo-page-in-right var(--dur) var(--ease-in-out) both;
  }
  /* Back navigation mirrors the gesture. */
  html[data-nav="back"] ::view-transition-old(page) {
    animation: wo-page-out-right var(--dur) var(--ease-in-out) both;
  }
  html[data-nav="back"] ::view-transition-new(page) {
    animation: wo-page-in-left var(--dur) var(--ease-in-out) both;
  }
}
::view-transition-group(page) { animation-duration: var(--dur); }
.wo-view { view-transition-name: page; }

/* Fallback for engines without the View Transitions API. */
.wo-view.is-leaving  { animation: wo-page-out-left var(--dur) var(--ease-in-out) both; }
.wo-view.is-entering { animation: wo-page-in-right var(--dur) var(--ease-in-out) both; }
html[data-nav="back"] .wo-view.is-leaving  { animation-name: wo-page-out-right; }
html[data-nav="back"] .wo-view.is-entering { animation-name: wo-page-in-left; }

/* Sheets rise from the thumb, backdrops fade. */
@keyframes wo-sheet-up   { from { transform: translateY(100%); } }
@keyframes wo-sheet-down { to   { transform: translateY(100%); } }
@keyframes wo-fade-in    { from { opacity: 0; } }
@keyframes wo-fade-out   { to   { opacity: 0; } }

/* Anyone who asks for less motion gets none of it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .wo-glow::before { animation: none; background: linear-gradient(120deg, hsl(var(--wo-yellow)), hsl(var(--wo-orange))); }
  .wo-glow::after { animation: none; }
}

/* ==========================================================================
   SKELETONS — perceived speed for anything over ~1s
   ========================================================================== */
.wo-skel {
  border-radius: var(--radius-xs);
  background: linear-gradient(90deg,
    hsl(var(--muted)) 25%,
    hsl(var(--border)) 37%,
    hsl(var(--muted)) 63%);
  background-size: 400% 100%;
  animation: wo-shimmer 1.35s ease-in-out infinite;
}
@keyframes wo-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.wo-skel-line { height: 11px; margin-bottom: 8px; }
.wo-skel-line:last-child { width: 62%; margin-bottom: 0; }
.wo-skel-title { height: 22px; width: 45%; margin-bottom: 12px; }
.wo-skel-avatar { width: 38px; height: 38px; border-radius: var(--radius-sm); }

/* Space reservation so async content never shifts layout (CLS). */
.wo-reserve { min-height: var(--reserve, 120px); }

/* ==========================================================================
   LAYOUT — desktop shell
   ========================================================================== */
.wo-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.wo-sidebar {
  width: 232px; flex-shrink: 0;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 18px 10px;
  display: flex; flex-direction: column;
}
.wo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wo-topbar {
  height: 52px; flex-shrink: 0;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.wo-content { padding: 22px 20px 32px; max-width: 1200px; margin: 0 auto; width: 100%; }
.wo-content h1 {
  font-size: 23px; font-weight: 600; margin: 0 0 3px;
  letter-spacing: -0.022em; line-height: 1.2;
}
.wo-page-sub { color: hsl(var(--muted-foreground)); margin: 0 0 20px; font-size: 14.5px; }

.wo-nav-link {
  display: flex; align-items: center; gap: 9px;
  min-height: 34px; padding: 6px 9px;
  border-radius: var(--radius-sm);
  color: hsl(var(--foreground));
  font-size: 14px; font-weight: 400;
  text-decoration: none !important;
  margin-bottom: 1px;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.wo-nav-link:hover { background: hsl(var(--muted)); }
.wo-nav-link.active { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); font-weight: 500; }
.wo-nav-link .wo-i { opacity: 0.72; }
.wo-nav-link.active .wo-i { opacity: 1; }
.wo-nav-section {
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  color: hsl(var(--subtle-foreground));
  padding: 15px 9px 5px;
}

.wo-logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 16px; letter-spacing: -0.015em;
  color: hsl(var(--foreground));
  text-decoration: none !important;
  padding: 3px 9px 14px;
}
.wo-logo-mark {
  width: 26px; height: 26px;
  background: hsl(var(--wo-yellow));
  color: hsl(var(--wo-yellow-ink));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.wo-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}
.wo-section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 11px;
}
.wo-section-h h2 { font-size: 15.5px; font-weight: 600; margin: 0; letter-spacing: -0.012em; }

/* ==========================================================================
   MOBILE — thumb-zone first
   ========================================================================== */
.wo-mobile-shell {
  display: flex; flex-direction: column;
  height: 100dvh;
  background: hsl(var(--background));
}
.wo-mobile-topbar {
  height: 50px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 10px;
  padding-top: var(--safe-t);
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
}
.wo-mobile-title { font-size: 15.5px; font-weight: 600; letter-spacing: -0.012em; }

.wo-mobile-balance {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 30px;
  background: hsl(var(--accent));
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: hsl(var(--accent-foreground));
  font-variant-numeric: tabular-nums;
  text-decoration: none !important;
  touch-action: manipulation;
}

/* --- Bottom tab bar: 5 destinations max, icon + label, always visible ----- */
.wo-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: hsl(var(--card) / 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid hsl(var(--border));
  padding-bottom: var(--safe-b);
}
.wo-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 6px 2px 5px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.005em;
  color: hsl(var(--muted-foreground));
  text-decoration: none !important;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-fast) var(--ease-out);
}
.wo-tab .wo-i { width: 21px; height: 21px; stroke-width: 1.7; }
.wo-tab:active { background: hsl(var(--muted)); }
.wo-tab.active { color: hsl(var(--foreground)); }
.wo-tab.active .wo-i { stroke-width: 2.1; }
/* Active state is never colour alone — a bar marks the current destination. */
.wo-tab.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: hsl(var(--wo-yellow));
}
.wo-tab-badge {
  position: absolute; top: 5px; left: calc(50% + 7px);
  min-width: 7px; height: 7px; border-radius: 999px;
  background: hsl(var(--wo-orange));
  border: 1.5px solid hsl(var(--card));
}

/* Any scrollable page must clear the fixed bar. */
.wo-has-tabbar { padding-bottom: calc(var(--bottom-nav-h) + var(--safe-b) + 14px); }

/* --- Bottom sheet: replaces top-anchored modals ---------------------------*/
.wo-sheet-backdrop {
  position: fixed; inset: 0;
  background: hsl(0 0% 0% / 0.42);
  backdrop-filter: blur(2px);
  z-index: var(--z-overlay);
  animation: wo-fade-in var(--dur) var(--ease-out) both;
}
.wo-sheet-backdrop.is-closing { animation: wo-fade-out var(--dur-fast) var(--ease-out) both; }
.wo-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: calc(var(--z-overlay) + 1);
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid hsl(var(--border));
  box-shadow: var(--elev-3);
  padding: 8px 16px calc(18px + var(--safe-b));
  max-height: 88dvh; overflow-y: auto;
  animation: wo-sheet-up var(--dur) var(--ease-out) both;
}
.wo-sheet.is-closing { animation: wo-sheet-down var(--dur-fast) var(--ease-in-out) both; }
.wo-sheet-grip {
  width: 34px; height: 4px; border-radius: 999px;
  background: hsl(var(--border-strong));
  margin: 4px auto 12px;
}
.wo-sheet-title { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
@media (min-width: 769px) {
  .wo-sheet {
    left: 50%; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 40px));
    border-radius: var(--radius-lg);
    animation: wo-fade-in var(--dur) var(--ease-out) both;
  }
  .wo-sheet-grip { display: none; }
}

/* --- Drawer (secondary nav only; primary lives in the tab bar) ----------- */
.wo-drawer-backdrop {
  position: fixed; inset: 0;
  background: hsl(0 0% 0% / 0.4);
  z-index: var(--z-overlay);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
}
.wo-drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.wo-drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(284px, 82vw);
  background: hsl(var(--card));
  z-index: calc(var(--z-overlay) + 1);
  transform: translateX(-100%);
  transition: transform var(--dur) var(--ease-out);
  display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) 10px calc(14px + var(--safe-b));
  border-right: 1px solid hsl(var(--border));
  overflow-y: auto;
}
.wo-drawer.open { transform: translateX(0); }

/* --- Offline banner ------------------------------------------------------ */
.wo-offline-bar {
  display: none;
  align-items: center; justify-content: center; gap: 7px;
  padding: 7px 12px;
  background: hsl(var(--tag-orange));
  color: hsl(var(--tag-orange-ink));
  font-size: 13px; font-weight: 500;
  flex-shrink: 0;
}
html[data-online="false"] .wo-offline-bar { display: flex; }
html[data-online="false"] .wo-needs-network { opacity: 0.5; pointer-events: none; }

/* Queued-while-offline marker on a chat message */
.wo-queued { opacity: 0.62; }
.wo-queued-tag {
  font-size: 11px; color: hsl(var(--muted-foreground));
  display: inline-flex; align-items: center; gap: 4px; margin-top: 3px;
}

/* ==========================================================================
   CHAT
   ========================================================================== */
.wo-chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 14px 12px 6px;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
}
.wo-chat-scroll::-webkit-scrollbar { width: 4px; }
.wo-chat-scroll::-webkit-scrollbar-thumb { background: hsl(var(--border-strong)); border-radius: 2px; }

.wo-msg { margin-bottom: 13px; display: flex; gap: 8px; max-width: 100%; animation: wo-rise var(--dur) var(--ease-out) backwards; }
.wo-msg--user { justify-content: flex-end; }
.wo-msg--user .wo-msg-bubble {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border-radius: 16px 16px 4px 16px; max-width: 82%;
}
.wo-msg--assistant .wo-msg-bubble {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 16px 16px 16px 4px; max-width: 90%;
}
.wo-msg-bubble { padding: 9px 13px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.wo-msg-bubble p { margin: 0 0 7px; }
.wo-msg-bubble p:last-child { margin-bottom: 0; }
.wo-msg-bubble code {
  background: hsl(var(--foreground) / 0.07);
  padding: 1px 5px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 0.88em;
}
.wo-msg--user .wo-msg-bubble code { background: hsl(0 0% 100% / 0.16); }

.wo-tool-card {
  margin-top: 2px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.65);
  padding: 11px 13px;
  font-size: 14px;
}
.wo-tool-card-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 7px;
}
.wo-tool-card-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dashed hsl(var(--border));
}
.wo-tool-card-row:last-child { border-bottom: none; }
.wo-tool-card-row .lbl { color: hsl(var(--muted-foreground)); font-size: 13px; }
.wo-tool-card-row .val { font-weight: 500; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }

.wo-chips {
  display: flex; gap: 6px;
  padding: 6px 12px 7px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
.wo-chips::-webkit-scrollbar { display: none; }
.wo-chip {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 6px 12px;
  border-radius: 999px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  font-family: inherit; font-size: 13.5px; font-weight: 400;
  color: hsl(var(--foreground));
  white-space: nowrap; cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.wo-chip:hover, .wo-chip:active { background: hsl(var(--accent)); border-color: hsl(var(--wo-yellow)); }

.wo-input-bar {
  flex-shrink: 0;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: hsl(var(--card));
  border-top: 1px solid hsl(var(--border));
  display: flex; gap: 8px; align-items: flex-end;
}
.wo-input-bar textarea {
  flex: 1;
  min-height: 42px; max-height: 122px;
  padding: 10px 14px;
  border: 1px solid hsl(var(--input));
  border-radius: 20px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: inherit; font-size: 16px; line-height: 1.4;
  resize: none; outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.wo-input-bar textarea:focus { border-color: hsl(var(--ring)); }
.wo-input-bar .send-btn {
  width: 44px; height: 44px;      /* thumb target, never shrink this */
  border-radius: 50%;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.wo-input-bar .send-btn:active { transform: scale(0.92); }
.wo-input-bar .send-btn[disabled] { opacity: 0.35; }

.wo-dots { display: inline-flex; gap: 3px; align-items: center; height: 18px; }
.wo-dots span {
  width: 5px; height: 5px; background: currentColor;
  border-radius: 50%; animation: wo-bounce 1.2s infinite; opacity: 0.5;
}
.wo-dots span:nth-child(2) { animation-delay: 0.15s; }
.wo-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes wo-bounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.3; }
  40%         { transform: translateY(-4px); opacity: 1; }
}

/* ------------------------------------------------------------ empty state -- */
.wo-empty { padding: 34px 20px; text-align: center; color: hsl(var(--muted-foreground)); }
.wo-empty .wo-i { color: hsl(var(--subtle-foreground)); margin-bottom: 10px; }
.wo-empty-title { font-weight: 600; color: hsl(var(--foreground)); margin-bottom: 3px; font-size: 16px; }
.wo-empty-sub { font-size: 14px; max-width: 34ch; margin: 0 auto; }

/* ------------------------------------------------------------------ htmx -- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }

/* -------------------------------------------------------------- responsive -- */
@media (max-width: 768px) {
  .wo-sidebar { display: none; }
  .wo-content { padding: 16px 12px calc(var(--bottom-nav-h) + var(--safe-b) + 20px); }
  .wo-topbar { padding: 0 12px; padding-top: var(--safe-t); height: calc(50px + var(--safe-t)); }
  .wo-stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .wo-card-value { font-size: 23px; }
  .wo-content h1 { font-size: 21px; }
  /* Tables reflow rather than scroll sideways. */
  .wo-table thead { display: none; }
  .wo-table, .wo-table tbody, .wo-table tr, .wo-table td { display: block; width: 100%; }
  .wo-table tr {
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius); margin-bottom: 9px; padding: 4px 0;
    background: hsl(var(--card));
  }
  .wo-table td {
    border: none; padding: 6px 13px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  .wo-table td::before {
    content: attr(data-label);
    font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em;
    color: hsl(var(--muted-foreground));
  }
  .wo-table td:empty { display: none; }
}
@media (min-width: 769px) {
  .wo-tabbar { display: none; }
  .wo-has-tabbar { padding-bottom: 0; }
}

@media print {
  .wo-sidebar, .wo-topbar, .wo-input-bar, .wo-tabbar, .wo-offline-bar { display: none !important; }
}

/* --- Chat screen keeps the tab bar reachable, then yields it to the keyboard.
   Focusing the composer collapses the bar so the thumb zone belongs to typing;
   blurring brings navigation straight back. ------------------------------- */
@media (max-width: 768px) {
  .wo-tabbar { transition: transform var(--dur) var(--ease-out); }
  html[data-composing="true"] .wo-tabbar { transform: translateY(100%); }
  .wo-chat-shell .wo-input-bar {
    margin-bottom: calc(var(--bottom-nav-h) + var(--safe-b));
    transition: margin-bottom var(--dur) var(--ease-out);
  }
  html[data-composing="true"] .wo-chat-shell .wo-input-bar { margin-bottom: 0; }
}

/* ==========================================================================
   OPERATOR CONSOLE
   Deliberately not the customer app. An operator holding real money should
   never be a beat unsure which surface they're on, so the rail inverts and
   the accent moves off brand yellow.
   ========================================================================== */
.wo-ops-shell { display: flex; min-height: 100dvh; }
.wo-ops-rail {
  width: 214px; flex-shrink: 0;
  background: hsl(0 0% 10%);
  color: hsl(0 0% 88%);
  padding: 16px 9px;
  display: flex; flex-direction: column;
}
.wo-ops-rail .wo-logo { color: hsl(0 0% 97%); }
.wo-ops-rail .wo-logo-mark { background: hsl(0 0% 22%); color: hsl(0 0% 97%); }
.wo-ops-rail .wo-nav-link { color: hsl(0 0% 82%); }
.wo-ops-rail .wo-nav-link:hover { background: hsl(0 0% 17%); }
.wo-ops-rail .wo-nav-link.active { background: hsl(0 0% 22%); color: #fff; }
.wo-ops-rail .wo-nav-section { color: hsl(0 0% 48%); }

.wo-ops-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase;
  color: hsl(0 0% 62%);
  padding: 0 9px 12px;
}

.wo-ops-main { flex: 1; min-width: 0; }
.wo-ops-topbar {
  height: 50px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky; top: 0; z-index: var(--z-sticky);
}

/* Health states are named as well as coloured. */
.wo-state { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; font-size: 12.5px; }
.wo-state--ok     { color: hsl(var(--success)); }
.wo-state--warn   { color: hsl(var(--tag-orange-ink)); }
.wo-state--danger { color: hsl(var(--destructive)); }

.wo-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.wo-kv dt { color: hsl(var(--muted-foreground)); }
.wo-kv dd { margin: 0; overflow-wrap: anywhere; }

/* A verification result should look different from a mere label. */
.wo-verify {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
}
.wo-verify--ok   { background: hsl(var(--success-soft)); color: hsl(var(--success)); }
.wo-verify--bad  { background: hsl(var(--destructive-soft)); color: hsl(var(--destructive)); }

@media (max-width: 768px) {
  .wo-ops-rail { display: none; }
  .wo-ops-shell .wo-content { padding-bottom: 28px; }
}
