/* @ambasada/ui 0.8.19: fonts, tokens and components in one stylesheet. MIT, CENTYSO. https://ambasada.id */
/*
 * Inter and JetBrains Mono, self-hosted (variable, SIL Open Font License 1.1: fonts/OFL-*.txt). Latin and
 * Latin Extended, so Romanian ț and ș render. The URLs are relative to this file: bundlers copy the files,
 * and the CDN build (dist/ambasada-ui.css) finds them in dist/fonts/. Already serving the fonts yourself?
 * Import tokens.css and components.css instead of the whole package.
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-variable-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-variable-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-variable-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./fonts/jetbrains-mono-variable-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/*
 * @ambasada/ui design tokens: the Ambasada look as CSS custom properties.
 *
 * Source of truth is the Ambasada hub (repo ambasada-landing, hub.ambasada.id / ambasada.pro):
 *   - src/app/globals.css        the @theme block ("V5 light + brand red")
 *   - src/app/layout.tsx         Inter + JetBrains Mono via next/font
 *   - src/lib/member/card-style.ts  wallet pass palettes (Apple / Google Wallet)
 *   - src/app/card/frames.tsx    WalletCard, the on-screen copy of the pass
 * Light only: the Ambasada app is light, and so are its mini apps (docs/MINI-APPS.md §9).
 * Usage and rules: docs/DESIGN-SYSTEM.md. The fonts themselves are in fonts.css.
 */

:root {
  color-scheme: light;

  /* Brand */
  --color-accent: #ff002e; /* hub --color-accent, the logo red; "Ambasada red" pass palette rgb(255,0,46) */
  --color-accent-hover: #e5002a; /* hub .prose-ambasada a:hover */
  --color-accent-text: #e5002a; /* red for small text on light: #ff002e is 3.8:1 on bg, this is 4.6:1 (AA) */
  --color-accent-press: #b30020; /* hub tier-theme "Active" gradient end */
  --color-accent-2: #ff6b00; /* hub --color-accent-2, used sparingly (warm highlights) */
  --color-accent-soft: #ffe9ec; /* hub --color-accent-soft, tinted backgrounds */
  --color-accent-ring: rgba(255, 0, 46, 0.45); /* hub .card-hover:hover border */
  --color-on-accent: #ffffff; /* hub primary button text, pass foreground */

  /* Neutrals */
  --color-bg: #fafaf9; /* hub --color-bg (stone-50) */
  --color-surface: #ffffff; /* hub --color-surface */
  --color-surface-2: #f5f5f4; /* stone-100, hub Clerk card footer and row hover */
  --color-ink: #0c0a09; /* hub --color-ink (stone-950) */
  --color-ink-2: #57534e; /* hub --color-ink-2 (stone-600), secondary text */
  --color-ink-3: #78716c; /* hub --color-ink-3 (stone-500), labels, WCAG AA on bg */
  --color-line: #e7e5e4; /* hub --color-line (stone-200), borders and dividers */
  --color-line-strong: #d6d3d1; /* stone-300, input borders on hover */
  --color-backdrop: rgba(12, 10, 9, 0.5); /* behind bottom sheets: ink at 50% */

  /* Status */
  --color-success: #16a34a; /* hub --color-success */
  --color-warn: #f59e0b; /* hub --color-warn */
  --color-danger: #dc2626; /* red-600: distinct from the brand red so errors never read as branding */
  --color-info: #2563eb; /* hub --color-info */
  --color-success-soft: #ecfdf3; /* tint of success for notices */
  --color-warn-soft: #fff8eb; /* tint of warn for notices */
  --color-danger-soft: #fef2f2; /* tint of danger for notices */
  --color-warn-line: #fcd9a0;
  --color-danger-line: #fecaca;
  --color-success-line: #bbf7d0;

  /* The member card (wallet pass, "Ambasada red" palette, src/lib/member/card-style.ts) */
  --card-bg: #ff002e; /* pass backgroundColor rgb(255,0,46) */
  --card-fg: #ffffff; /* pass foregroundColor rgb(255,255,255) */
  --card-label: #ffc8d2; /* pass labelColor rgb(255,200,210) */
  --card-divider: rgba(255, 255, 255, 0.28);
  /* The dark card ("Midnight" palette, also the hub's .card-dark / terminal surface) */
  --card-dark-bg: #0c0a09; /* pass Midnight rgb(12,10,9), hub --color-terminal-bg */
  --card-dark-fg: #ffffff;
  --card-dark-label: #a5a09b; /* pass Midnight labelColor rgb(165,160,155) */

  /* Typography */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; /* hub layout.tsx Inter */
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; /* hub layout.tsx JetBrains_Mono 400/500/700 */
  --font-native: -apple-system, BlinkMacSystemFont, system-ui, sans-serif; /* hub .native-shell body */

  --text-label: 0.6875rem; /* 11px, hub .section-label (mono, uppercase, 0.1em): the mono label, .ui-label */
  --text-micro: 0.625rem; /* 10px, hub card labels ("membership", business card rows) */
  --text-xs: 0.75rem; /* 12px, hub nav links */
  --text-sm: 0.875rem; /* 14px, hub body small / buttons */
  --text-base: 1rem; /* 16px */
  --text-lg: 1.0625rem; /* 17px, pass "Name" value */
  --text-xl: 1.375rem; /* 22px, business card name */
  --text-2xl: 1.75rem; /* 28px, page titles on mobile */
  --text-display: 2.75rem; /* 44px, wallet balance (hub card numbers, text-3xl and up) */
  --tracking-label: 0.1em; /* hub .section-label */
  --tracking-tight: -0.02em; /* hub headings, tracking-tight */
  --weight-regular: 400;
  --weight-medium: 500; /* hub headings are font-medium */
  --weight-semibold: 600; /* hub card names */
  --weight-bold: 700; /* hub numbers (events count) */

  /* Radii */
  --radius-xs: 4px; /* hub QR plate on the wallet card */
  --radius-sm: 8px; /* hub --radius-sm, Clerk borderRadius 0.5rem: buttons and inputs */
  --radius-md: 12px; /* hub article images, notices */
  --radius-card: 16px; /* hub --radius-card, WalletCard rounded-2xl */
  --radius-hero: 28px; /* hub MemberCard and BusinessCard rounded-[28px], bottom sheets */
  --radius-pill: 9999px; /* hub --radius-pill */

  /* Shadows */
  --shadow-card: 0 1px 2px rgba(12, 10, 9, 0.04); /* hub cards are flat: border first, barely any shadow */
  --shadow-raised: 0 12px 40px -20px rgba(0, 0, 0, 0.35); /* hub BusinessCard */
  --shadow-pass: 0 30px 60px -30px rgba(0, 0, 0, 0.55); /* hub WalletCard */
  --shadow-glow: 0 0 0 1px rgba(255, 0, 46, 0.25), 0 12px 40px -8px rgba(255, 0, 46, 0.18); /* hub .glow-red */
  --focus-ring: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-accent); /* hub: 2px accent outline, offset 2px */

  /* Spacing (4px grid, as Tailwind in the hub) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px; /* hub WalletCard horizontal padding (px-5) */
  --space-6: 24px; /* hub MemberCard padding (p-6), page gutter (px-6) */
  --space-8: 32px;
  --space-10: 40px;
  --page-max: 480px; /* the mini-app column; the hub's member pages use max-w-md..lg */
  --tap: 44px; /* minimum touch target */

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration: 200ms; /* hub .card transitions */

  /*
   * The Ambasada app's shell (docs/MINI-APPS.md §6). Inside the app, @ambasada/miniapp (applyCssVars, run by
   * ready()) sets these on <html> from the shell context, which wins over :root. On the web the safe areas
   * fall back to the browser's own insets (non-zero only with viewport-fit=cover) and there is no host bar.
   */
  --ambasada-safe-area-top: env(safe-area-inset-top, 0px);
  --ambasada-safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --ambasada-safe-area-left: env(safe-area-inset-left, 0px);
  --ambasada-safe-area-right: env(safe-area-inset-right, 0px);
  --ambasada-host-bar: 0px; /* height of the shell's top bar (close, app name, "…" menu) */

  /*
   * What a page actually keeps clear, per side: the larger of the shell's report and the browser's own inset.
   * A shell that reports 0 while its WebView runs under the home indicator, and a browser that knows nothing of
   * the shell, both come out right, and an inset is never counted twice (docs/MINI-APPS.md §15, decision 11).
   * Use these (plus --ambasada-host-bar at the top), never env() or the raw --ambasada-safe-area-* directly.
   */
  --ambasada-inset-top: max(var(--ambasada-safe-area-top), env(safe-area-inset-top, 0px));
  --ambasada-inset-bottom: max(var(--ambasada-safe-area-bottom), env(safe-area-inset-bottom, 0px));
  --ambasada-inset-left: max(var(--ambasada-safe-area-left), env(safe-area-inset-left, 0px));
  --ambasada-inset-right: max(var(--ambasada-safe-area-right), env(safe-area-inset-right, 0px));
}

/*
 * @ambasada/ui components, in plain CSS: page, card, buttons, list rows, pill, bottom sheet, stepper,
 * empty state, skeleton, the mono label; for desktop tools the app shell, sidebar nav, tabs, fields and tables.
 * Tokens only (tokens.css): no raw colours.
 * Markup for each one: packages/ui/README.md, or the React wrappers in @ambasada/ui/react.
 */

/* ── base ───────────────────────────────────────────────────────────────────
 * Zero specificity, so any rule of the app's own wins. Enough for a plain HTML page to look right. */

*,
*::before,
*::after {
  box-sizing: border-box;
}
:where(html) {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
:where(body) {
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.5;
}

/* ── page ───────────────────────────────────────────────────────────────────
 * The mini-app column, clear of the shell's host bar and the safe areas (docs/MINI-APPS.md §6). */

.ui-page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding:
    calc(var(--space-4) + var(--ambasada-inset-top) + var(--ambasada-host-bar, 0px))
    calc(var(--space-4) + var(--ambasada-inset-right))
    calc(var(--space-8) + var(--ambasada-inset-bottom))
    calc(var(--space-4) + var(--ambasada-inset-left));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* The mono label: the hub's .section-label. For small captions, never for sentences. */
.ui-label {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-ink-3);
}

/* ── card ───────────────────────────────────────────────────────────────────
 * The hub's .card: white, hairline border, 16px radius, flat. */

.ui-card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}
.ui-card-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.2;
}

/* ── buttons ────────────────────────────────────────────────────────────────
 * The hub's Button. Primary: brand red, white text (one per screen). Secondary: surface, hairline, red on hover. */

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: var(--weight-medium);
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: filter var(--duration) var(--ease), background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.ui-button:hover {
  filter: brightness(0.92);
  color: var(--color-on-accent);
}
.ui-button:active {
  filter: brightness(0.85);
}
.ui-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.ui-button:disabled,
.ui-button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
  filter: none;
}
.ui-button.secondary {
  background: var(--color-surface);
  color: var(--color-ink);
  border-color: var(--color-line);
}
.ui-button.secondary:hover {
  filter: none;
  border-color: var(--color-accent-ring);
  color: var(--color-accent-text);
}
.ui-button.block {
  width: 100%;
}

/* ── list: a group of rows ──────────────────────────────────────────────── */

.ui-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.ui-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-1);
}
.ui-group-head h2 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-ink-2);
}
.ui-group-body {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.ui-group-body > .ui-row + .ui-row {
  border-top: 1px solid var(--color-line);
}
.ui-group-body > .pad {
  padding: var(--space-4);
}

/* List row: icon, title and subtitle, a value or a chevron. A <button> or <a> when tappable. */
.ui-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--color-ink);
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-weight: var(--weight-regular);
}
.ui-row.tappable {
  cursor: pointer;
  transition: background-color var(--duration) var(--ease);
}
.ui-row.tappable:hover,
.ui-row.tappable:active {
  background: var(--color-surface-2);
  filter: none;
}
.ui-row.danger .row-title {
  color: var(--color-danger);
}
.ui-row.muted {
  opacity: 0.55;
}
.row-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-ink-2);
}
.row-icon.accent {
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
}
.row-icon.good {
  background: var(--color-success-soft);
  color: var(--color-success);
}
.row-icon.bad {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}
.row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-title {
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}
.row-sub {
  font-size: var(--text-sm);
  color: var(--color-ink-3);
  overflow-wrap: anywhere;
}
.row-right {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  text-align: right;
}
.row-right.plus { color: var(--color-success); }
.row-chev {
  flex: none;
  color: var(--color-ink-3);
}

/* ── pill ───────────────────────────────────────────────────────────────── */

.ui-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  background: var(--color-surface-2);
  color: var(--color-ink-2);
}
.ui-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.ui-pill.good { background: var(--color-success-soft); color: var(--color-success); }
.ui-pill.bad { background: var(--color-danger-soft); color: var(--color-danger); }
.ui-pill.warn { background: var(--color-warn-soft); color: var(--color-warn); }
.ui-pill.accent { background: var(--color-accent-soft); color: var(--color-accent-text); }
.ui-pill.pulse i {
  animation: ui-pulse 1.6s ease-in-out infinite;
}
@keyframes ui-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ── bottom sheet ───────────────────────────────────────────────────────────
 * Anything that opens over a page is a bottom sheet, at every width: never a centred dialog (docs/MINI-APPS.md
 * §15, decision 12). A grip and a head you can drag down, a body that scrolls, a foot with the one primary
 * action. The React Sheet portals it to <body> (so no transformed ancestor can trap it) and sizes the backdrop
 * to the visual viewport (--ui-vv-top, --ui-vv-height, --ui-keyboard), so the foot stays above the keyboard. */

body.ui-sheet-open { overflow: hidden; }
.ui-sheet-backdrop {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--ui-vv-top, 0px);
  height: var(--ui-vv-height, 100%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-top: calc(var(--ambasada-inset-top) + var(--ambasada-host-bar, 0px) + var(--space-2));
  background: var(--color-backdrop);
  animation: ui-fade var(--duration) var(--ease);
}
.ui-sheet {
  width: 100%;
  max-width: var(--page-max);
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border-radius: var(--radius-hero) var(--radius-hero) 0 0;
  box-shadow: var(--shadow-raised);
  animation: ui-rise 320ms var(--ease);
  /* The home indicator stays clear; with the keyboard up it is covered anyway, so the inset goes. */
  padding-bottom: max(0px, calc(var(--ambasada-inset-bottom) - var(--ui-keyboard, 0px)));
  padding-left: var(--ambasada-inset-left);
  padding-right: var(--ambasada-inset-right);
  will-change: transform;
}
.ui-sheet-backdrop.leaving { animation: ui-fade-out 200ms var(--ease) both; }
.ui-sheet-backdrop.leaving .ui-sheet { animation: ui-sink 200ms var(--ease) both; }
/* Grip and head: the drag handle. touch-action none so a drag moves the sheet, not the page. */
.ui-sheet-handle {
  flex: none;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.ui-sheet-grip {
  width: 36px;
  height: 5px;
  margin: var(--space-2) auto 0;
  border-radius: 3px;
  background: var(--color-line-strong);
}
.ui-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-5);
}
.ui-sheet-head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.ui-sheet-head .ui-icon-btn { flex: none; }
.ui-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-3) var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.ui-sheet-body > * { flex: none; }
.ui-sheet-foot {
  flex: none;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-line);
  display: flex;
  gap: var(--space-2);
}
.ui-sheet-foot > button,
.ui-sheet-foot > a,
.ui-sheet-foot > .ui-button { flex: 1; min-height: 48px; }
@keyframes ui-rise { from { transform: translate3d(0, 100%, 0); } to { transform: none; } }
@keyframes ui-sink { from { transform: none; } to { transform: translate3d(0, 100%, 0); } }
@keyframes ui-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-fade-out { from { opacity: 1; } to { opacity: 0; } }

/* Round icon button (the sheet's close): a 36px circle in a 44px target. */
.ui-icon-btn {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: none;
  color: var(--color-ink-2);
  border: 0;
  cursor: pointer;
  isolation: isolate;
}
.ui-icon-btn::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  border-radius: 50%;
  background: var(--color-surface-2);
  transition: background-color var(--duration) var(--ease);
}
.ui-icon-btn:hover { filter: none; color: var(--color-ink); }
.ui-icon-btn:hover::before { background: var(--color-line); }

/* ── fields ─────────────────────────────────────────────────────────────────
 * A label, the control, one line of hint or error (.bad) under it, 8px apart. Inputs are 16px so iOS does not zoom into them. */

.ui-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.ui-field-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-ink);
  line-height: 1.3;
}
.ui-field-hint {
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  line-height: 1.45;
}
.ui-field-hint.bad { color: var(--color-danger); }
.ui-field-hint.good { color: var(--color-success); }
.ui-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 12px 14px;
  font: inherit;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  letter-spacing: normal;
  line-height: 1.4;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.ui-input::placeholder { color: var(--color-ink-3); opacity: 1; }
.ui-input:hover { border-color: var(--color-line-strong); }
.ui-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.ui-input:disabled { background: var(--color-surface-2); color: var(--color-ink-2); border-color: var(--color-line); }
.ui-input.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.ui-input.code { font-family: var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; }
textarea.ui-input { resize: vertical; min-height: 104px; }

/* ── stepper ────────────────────────────────────────────────────────────────
 * − value + for amounts, with optional preset chips underneath. */

.ui-stepper-wrap { display: flex; flex-direction: column; gap: var(--space-2); }
.ui-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 3px;
}
.ui-stepper button {
  width: 52px;
  height: 40px;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-ink);
  border: 0;
  cursor: pointer;
}
.ui-stepper button:hover { filter: none; background: var(--color-line); }
.ui-stepper button:disabled { opacity: 0.45; cursor: default; }
.ui-stepper-value {
  font-size: 1.25rem;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}
.ui-stepper-value small { font-size: var(--text-xs); color: var(--color-ink-3); font-weight: var(--weight-regular); }
.ui-presets { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.ui-presets button {
  min-width: 48px;
  min-height: 36px;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-ink-2);
  border: 1px solid var(--color-line);
  font-family: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}
.ui-presets button:hover { filter: none; border-color: var(--color-line-strong); }
.ui-presets button.on { background: var(--color-ink); color: var(--color-bg); border-color: var(--color-ink); }

/* ── empty state ────────────────────────────────────────────────────────── */

.ui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-ink-2);
}
.ui-empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-ink-3);
  margin-bottom: var(--space-2);
}
.ui-empty strong { color: var(--color-ink); font-size: var(--text-lg); }
.ui-empty > button, .ui-empty > a.button, .ui-empty > .ui-button { margin-top: var(--space-3); }

/* ── skeleton ───────────────────────────────────────────────────────────────
 * Grey bars where the content will be: skeletons, not spinners. */

.ui-skeleton { display: flex; flex-direction: column; gap: 10px; padding: var(--space-4); }
.ui-skeleton span {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-line) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: ui-shimmer 1.4s linear infinite;
}
@keyframes ui-shimmer { to { background-position: -200% 0; } }

/* ── app shell (desktop tools) ──────────────────────────────────────────────
 * For apps built for the laptop that still open in the Ambasada app: a sidebar, a top bar, the content. Under
 * 900 px the sidebar becomes a drawer behind the top bar's menu button. Clears the host bar and the safe areas
 * once: the top bar takes the top, the content the bottom (docs/MINI-APPS.md §15 decision 11). */

.ui-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}
.ui-shell-side {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding:
    calc(var(--space-3) + var(--ambasada-safe-area-top, 0px) + var(--ambasada-host-bar, 0px))
    var(--space-3)
    calc(var(--space-3) + var(--ambasada-safe-area-bottom, 0px))
    calc(var(--space-3) + var(--ambasada-safe-area-left, 0px));
  background: var(--color-surface);
  border-right: 1px solid var(--color-line);
  overflow-y: auto;
}
.ui-shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ui-shell-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: calc(56px + var(--ambasada-safe-area-top, 0px) + var(--ambasada-host-bar, 0px));
  padding:
    calc(var(--ambasada-safe-area-top, 0px) + var(--ambasada-host-bar, 0px))
    calc(var(--space-6) + var(--ambasada-safe-area-right, 0px))
    0
    var(--space-6);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-line);
}
.ui-shell-menu {
  display: none;
}
.ui-shell-content {
  flex: 1;
  width: 100%;
  max-width: 1088px;
  padding:
    var(--space-6)
    calc(var(--space-6) + var(--ambasada-safe-area-right, 0px))
    calc(var(--space-10) + var(--ambasada-safe-area-bottom, 0px))
    var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.ui-shell-scrim {
  display: none;
}
@media (max-width: 899px) {
  .ui-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .ui-shell-side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    transition: transform var(--duration) var(--ease);
    box-shadow: var(--shadow-raised);
  }
  .ui-shell.open .ui-shell-side {
    transform: none;
  }
  .ui-shell.open .ui-shell-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--color-backdrop);
  }
  .ui-shell-menu {
    display: inline-grid;
    margin-left: calc(-1 * var(--space-2));
  }
  .ui-shell-top {
    padding-left: calc(var(--space-4) + var(--ambasada-safe-area-left, 0px));
    padding-right: calc(var(--space-4) + var(--ambasada-safe-area-right, 0px));
  }
  .ui-shell-content {
    padding-left: calc(var(--space-4) + var(--ambasada-safe-area-left, 0px));
    padding-right: calc(var(--space-4) + var(--ambasada-safe-area-right, 0px));
    padding-top: var(--space-4);
    gap: var(--space-5);
  }
}

/* Sidebar navigation: a title, then items (icon, label, a value on the right). The current one is marked. */
.ui-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ui-nav-title {
  margin: 0;
  padding: var(--space-2) var(--space-2) var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-ink-3);
}
.ui-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 6px var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-ink-2);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.ui-nav-item:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
}
.ui-nav-item.on {
  background: var(--color-surface-2);
  color: var(--color-ink);
  font-weight: var(--weight-medium);
}
.ui-nav-item.on::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--space-3));
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--color-accent);
}
.ui-nav-item:focus-visible,
.ui-tabs a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
.ui-nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-nav-right {
  flex: none;
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

/* Tabs: a row of links under a page title; scrolls sideways when it doesn't fit. */
.ui-tabs {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  border-bottom: 1px solid var(--color-line);
  overflow-x: auto;
  scrollbar-width: none;
}
.ui-tabs::-webkit-scrollbar {
  display: none;
}
.ui-tabs a {
  flex: none;
  padding: 10px var(--space-3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--color-ink-3);
  font-size: var(--text-sm);
  text-decoration: none;
}
.ui-tabs a:hover {
  color: var(--color-ink);
}
.ui-tabs a.on {
  color: var(--color-ink);
  font-weight: var(--weight-medium);
  border-bottom-color: var(--color-ink);
}

/* Fields inside a desktop tool are compact with a mouse. On a phone they stay 48 px and 16 px, so iOS does not zoom. */
@media (pointer: fine) {
  .ui-shell .ui-field {
    gap: 6px;
  }
  .ui-shell .ui-input {
    min-height: 40px;
    padding: 8px 12px;
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
  }
  .ui-shell .ui-input:focus {
    border-color: var(--color-ink);
    box-shadow: 0 0 0 3px var(--color-surface-2);
  }
}

/* Data table: hairline rows, numbers right-aligned in tabular figures (`.num`). */
.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.ui-table th {
  padding: 10px var(--space-4);
  text-align: left;
  font-weight: var(--weight-medium);
  color: var(--color-ink-3);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-line);
  white-space: nowrap;
}
.ui-table td {
  padding: 12px var(--space-4);
  border-bottom: 1px solid var(--color-line);
  vertical-align: middle;
}
.ui-table tr:last-child td {
  border-bottom: 0;
}
.ui-table .num {
  text-align: right;
}
.ui-table tbody tr.tappable {
  cursor: pointer;
}
.ui-table tbody tr.tappable:hover td {
  background: var(--color-surface-2);
}

@media (prefers-reduced-motion: reduce) {
  .ui-sheet,
  .ui-sheet-backdrop,
  .ui-sheet-backdrop.leaving,
  .ui-sheet-backdrop.leaving .ui-sheet,
  .ui-pill.pulse i,
  .ui-skeleton span {
    animation: none;
  }
  .ui-shell-side {
    transition: none;
  }
}
