/* ==========================================================================
   Ferri UI — the one design system for every app on FerriCloud.
   Load:  <link rel="stylesheet" href="/assets/ui/ferri-ui.css?v=1">
          <script defer src="/assets/ui/ferri-ui.js?v=1"></script>
   Docs + live component gallery: /assets/ui/  (README.md next to this file)

   Rules that keep the server coherent (see README for the full list):
   - One accent (oxide). State colours (ok/warn/danger/info) only mean state.
   - Radius rule: controls 10px, surfaces 16px, tags 6px, chips/avatars full.
   - Theme follows the OS unless html[data-theme] is set (ferri-ui.js sets it
     from localStorage 'ferri-theme' = light | dark | auto).
   - Everything is prefixed .fx-* so it never collides with app CSS.
   ========================================================================== */

/* ---------- Fonts (self-hosted, so the tailnet works offline) ---------- */
@font-face {
  font-family: "Geist";
  src: url("./fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("./fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
/* Thai glyphs come from IBM Plex Sans Thai; unicode-range means Latin pages never download it. */
@font-face { font-family: "Geist"; src: url("./fonts/ibm-plex-sans-thai-thai-400-normal.woff2") format("woff2"); font-weight: 100 449; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Geist"; src: url("./fonts/ibm-plex-sans-thai-thai-500-normal.woff2") format("woff2"); font-weight: 450 549; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Geist"; src: url("./fonts/ibm-plex-sans-thai-thai-600-normal.woff2") format("woff2"); font-weight: 550 649; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Geist"; src: url("./fonts/ibm-plex-sans-thai-thai-700-normal.woff2") format("woff2"); font-weight: 650 900; font-display: swap; unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }

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

  /* neutrals: one family, faintly warm graphite */
  --fx-bg: #F5F5F3;
  --fx-surface: #FDFDFC;
  --fx-surface-2: #EFEFEC;
  --fx-surface-3: #E7E7E3;
  --fx-sunken: #ECECE8;
  --fx-line: #E1E1DC;
  --fx-line-strong: #CBCBC4;
  --fx-fg: #18181A;
  --fx-fg-2: #56565C;
  --fx-fg-3: #6B6B72;
  --fx-overlay: rgb(24 24 26 / .42);

  /* the one accent: oxide (Ferri = iron) */
  --fx-accent: #B8471F;
  --fx-accent-hover: #A33E1A;
  --fx-accent-fg: #FFFFFF;
  --fx-accent-ink: #A8421D;           /* accent used as text on bg */
  --fx-accent-soft: rgb(184 71 31 / .10);
  --fx-accent-line: rgb(184 71 31 / .32);

  /* state (never decorative) */
  --fx-ok: #2F7D4F;      --fx-ok-soft: rgb(47 125 79 / .11);
  --fx-warn: #95600A;    --fx-warn-soft: rgb(176 118 16 / .13);
  --fx-danger: #BF3434;  --fx-danger-soft: rgb(191 52 52 / .10);
  --fx-info: #3A6597;    --fx-info-soft: rgb(58 101 151 / .10);

  /* type */
  --fx-font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  --fx-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fx-t-xs: .75rem;     /* 12 */
  --fx-t-sm: .8125rem;   /* 13 */
  --fx-t-base: .9375rem; /* 15 */
  --fx-t-md: 1.0625rem;  /* 17 */
  --fx-t-lg: 1.25rem;    /* 20 */
  --fx-t-xl: 1.625rem;   /* 26 */
  --fx-t-2xl: 2.125rem;  /* 34 */
  --fx-t-3xl: clamp(2.25rem, 1.6rem + 2.6vw, 3.25rem);

  /* space (4px grid) */
  --fx-1: 4px; --fx-2: 8px; --fx-3: 12px; --fx-4: 16px; --fx-5: 20px;
  --fx-6: 24px; --fx-8: 32px; --fx-10: 40px; --fx-12: 48px; --fx-16: 64px;

  /* shape */
  --fx-r-tag: 6px;
  --fx-r-ctl: 10px;
  --fx-r-surface: 16px;
  --fx-r-full: 999px;

  /* depth: shadows tinted to the neutral, one light source from above */
  --fx-shadow-1: 0 1px 2px rgb(40 36 30 / .06), 0 1px 1px rgb(40 36 30 / .04);
  --fx-shadow-2: 0 2px 6px rgb(40 36 30 / .06), 0 8px 24px rgb(40 36 30 / .08);
  --fx-shadow-3: 0 12px 40px rgb(40 36 30 / .16), 0 2px 8px rgb(40 36 30 / .08);
  --fx-ring: 0 0 0 3px rgb(184 71 31 / .28);

  /* motion */
  --fx-ease: cubic-bezier(.2, .8, .2, 1);
  --fx-fast: 140ms;
  --fx-med: 220ms;

  /* layout */
  --fx-appbar-h: 56px;
  --fx-max: 1200px;
  --fx-max-narrow: 720px;

  /* z-index scale (the only z-indexes allowed) */
  --fx-z-sticky: 20;
  --fx-z-appbar: 30;
  --fx-z-popover: 40;
  --fx-z-dialog: 50;
  --fx-z-toast: 60;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fx-bg: #121214;
    --fx-surface: #19191C;
    --fx-surface-2: #212125;
    --fx-surface-3: #2A2A2F;
    --fx-sunken: #0E0E10;
    --fx-line: #2A2A2F;
    --fx-line-strong: #3B3B42;
    --fx-fg: #EDEDEF;
    --fx-fg-2: #A8A8B0;
    --fx-fg-3: #8A8A93;
    --fx-overlay: rgb(0 0 0 / .56);
    --fx-accent: #F0784C;
    --fx-accent-hover: #F48A62;
    --fx-accent-fg: #1A0E08;
    --fx-accent-ink: #F4926B;
    --fx-accent-soft: rgb(240 120 76 / .13);
    --fx-accent-line: rgb(240 120 76 / .38);
    --fx-ok: #5CC98A;      --fx-ok-soft: rgb(92 201 138 / .12);
    --fx-warn: #E7A93B;    --fx-warn-soft: rgb(231 169 59 / .13);
    --fx-danger: #F07070;  --fx-danger-soft: rgb(240 112 112 / .12);
    --fx-info: #82A9DB;    --fx-info-soft: rgb(130 169 219 / .12);
    --fx-shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --fx-shadow-2: 0 2px 6px rgb(0 0 0 / .3), 0 10px 28px rgb(0 0 0 / .32);
    --fx-shadow-3: 0 16px 48px rgb(0 0 0 / .5), 0 2px 8px rgb(0 0 0 / .3);
    --fx-ring: 0 0 0 3px rgb(240 120 76 / .34);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fx-bg: #121214;
  --fx-surface: #19191C;
  --fx-surface-2: #212125;
  --fx-surface-3: #2A2A2F;
  --fx-sunken: #0E0E10;
  --fx-line: #2A2A2F;
  --fx-line-strong: #3B3B42;
  --fx-fg: #EDEDEF;
  --fx-fg-2: #A8A8B0;
  --fx-fg-3: #8A8A93;
  --fx-overlay: rgb(0 0 0 / .56);
  --fx-accent: #F0784C;
  --fx-accent-hover: #F48A62;
  --fx-accent-fg: #1A0E08;
  --fx-accent-ink: #F4926B;
  --fx-accent-soft: rgb(240 120 76 / .13);
  --fx-accent-line: rgb(240 120 76 / .38);
  --fx-ok: #5CC98A;      --fx-ok-soft: rgb(92 201 138 / .12);
  --fx-warn: #E7A93B;    --fx-warn-soft: rgb(231 169 59 / .13);
  --fx-danger: #F07070;  --fx-danger-soft: rgb(240 112 112 / .12);
  --fx-info: #82A9DB;    --fx-info-soft: rgb(130 169 219 / .12);
  --fx-shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --fx-shadow-2: 0 2px 6px rgb(0 0 0 / .3), 0 10px 28px rgb(0 0 0 / .32);
  --fx-shadow-3: 0 16px 48px rgb(0 0 0 / .5), 0 2px 8px rgb(0 0 0 / .3);
  --fx-ring: 0 0 0 3px rgb(240 120 76 / .34);
}

/* ---------- Base (applies only inside .fx or on body.fx) ---------- */
.fx, .fx *, .fx *::before, .fx *::after { box-sizing: border-box; }
html:has(body.fx) { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body.fx {
  margin: 0;
  min-height: 100dvh;
  background: var(--fx-bg);
  color: var(--fx-fg);
  font-family: var(--fx-font);
  font-size: var(--fx-t-base);
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
.fx :where(h1, h2, h3, h4, h5, h6) { margin: 0; font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; text-wrap: balance; color: var(--fx-fg); }
.fx :where(h1) { font-size: var(--fx-t-2xl); letter-spacing: -0.028em; }
.fx :where(h2) { font-size: var(--fx-t-xl); letter-spacing: -0.022em; }
.fx :where(h3) { font-size: var(--fx-t-lg); }
.fx :where(h4) { font-size: var(--fx-t-md); }
.fx :where(p) { margin: 0; text-wrap: pretty; }
.fx :where(a) { color: var(--fx-accent-ink); text-decoration: none; text-underline-offset: 3px; }
.fx :where(a:hover) { text-decoration: underline; }
.fx :where(img, svg, video, canvas) { max-width: 100%; }
.fx .leaflet-container :is(img, canvas, svg) { max-width: none; } /* map tiles and vector layers size themselves */
.fx :where(button, input, select, textarea) { font: inherit; color: inherit; }
.fx :where(code, kbd, samp, pre) { font-family: var(--fx-mono); font-size: .92em; }
.fx :where(hr) { border: 0; border-top: 1px solid var(--fx-line); margin: var(--fx-6) 0; }
.fx :where(ul, ol) { margin: 0; padding-left: 1.2em; }
.fx :where(table) { border-collapse: collapse; }
.fx ::selection { background: var(--fx-accent-soft); color: var(--fx-fg); }
.fx :where(:focus-visible) { outline: 2px solid var(--fx-accent); outline-offset: 2px; }
.fx [hidden] { display: none !important; }
/* Thai tone marks and vowels stack above and below the line: give them room. */
body.fx:lang(th), .fx :lang(th) { line-height: 1.65; }
.fx :lang(th) :where(h1, h2, h3, h4, h5, h6), .fx :where(h1, h2, h3, h4, h5, h6):lang(th) { line-height: 1.4; }
.fx :lang(th) :where(.fx-btn, .fx-chip, .fx-tag, .fx-seg > *, .fx-nav a) { line-height: 1.3; }

/* ---------- Layout ---------- */
.fx-container { width: 100%; max-width: var(--fx-max); margin-inline: auto; padding-inline: var(--fx-4); }
.fx-container--narrow { max-width: var(--fx-max-narrow); }
.fx-container--wide { max-width: 1440px; }
@media (min-width: 768px) { .fx-container { padding-inline: var(--fx-6); } }
.fx-main { padding-block: var(--fx-6) var(--fx-16); }
@media (min-width: 768px) { .fx-main { padding-block: var(--fx-8) var(--fx-16); } }

.fx-stack { display: flex; flex-direction: column; gap: var(--gap, var(--fx-4)); }
.fx-row { display: flex; align-items: center; gap: var(--gap, var(--fx-3)); }
.fx-row--wrap { flex-wrap: wrap; }
.fx-row--between { justify-content: space-between; }
.fx-row--end { justify-content: flex-end; }
.fx-spacer { flex: 1 1 auto; }
.fx-grid { display: grid; gap: var(--gap, var(--fx-4)); grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 240px), 100%), 1fr)); }
.fx-split { display: grid; gap: var(--fx-6); grid-template-columns: 1fr; }
.fx-split > *, .fx-grid > *, .fx-form__row > * { min-width: 0; }
@media (min-width: 960px) {
  .fx-split { grid-template-columns: minmax(0, 1fr) var(--aside, 340px); align-items: start; }
  .fx-split--left { grid-template-columns: var(--aside, 280px) minmax(0, 1fr); }
}
.fx-sticky { position: sticky; top: calc(var(--fx-appbar-h) + var(--fx-4)); }

/* ---------- Page header ---------- */
.fx-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--fx-4); margin-bottom: var(--fx-6); }
.fx-pagehead__title { display: flex; flex-direction: column; gap: var(--fx-1); min-width: 0; }
.fx-pagehead h1 { font-size: var(--fx-t-2xl); }
.fx-pagehead p { color: var(--fx-fg-2); max-width: 60ch; }
.fx-pagehead__actions { display: flex; flex-wrap: wrap; gap: var(--fx-2); }
.fx-section { display: flex; flex-direction: column; gap: var(--fx-3); }
.fx-section + .fx-section { margin-top: var(--fx-10); }
.fx-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--fx-3); }
.fx-section__head h2 { font-size: var(--fx-t-md); letter-spacing: -0.01em; }
.fx-section__head a, .fx-section__head .fx-link { font-size: var(--fx-t-sm); }

/* ---------- Text helpers ---------- */
.fx-muted { color: var(--fx-fg-2); }
.fx-faint { color: var(--fx-fg-3); }
.fx-small { font-size: var(--fx-t-sm); }
.fx-xs { font-size: var(--fx-t-xs); }
.fx-mono { font-family: var(--fx-mono); }
.fx-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.fx-label { font-size: var(--fx-t-xs); font-weight: 500; color: var(--fx-fg-3); letter-spacing: .02em; }
.fx-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fx-prose { max-width: 65ch; line-height: 1.65; color: var(--fx-fg-2); }
.fx-prose > * + * { margin-top: .9em; }
.fx-sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.fx-skip { position: absolute; left: var(--fx-3); top: -60px; z-index: var(--fx-z-toast); padding: var(--fx-2) var(--fx-3); border-radius: var(--fx-r-ctl); background: var(--fx-fg); color: var(--fx-bg) !important; transition: top var(--fx-fast) var(--fx-ease); }
.fx-skip:focus { top: var(--fx-3); }

/* ---------- App bar ---------- */
.fx-appbar {
  position: sticky; top: 0; z-index: var(--fx-z-appbar);
  height: var(--fx-appbar-h);
  background: color-mix(in srgb, var(--fx-bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--fx-line);
}
.fx-appbar__inner { height: 100%; display: flex; align-items: center; gap: var(--fx-3); }
.fx-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--fx-fg) !important; text-decoration: none !important; font-weight: 600; letter-spacing: -0.01em; }
.fx-brand__mark {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--fx-fg); color: var(--fx-bg);
  font-size: 13px; font-weight: 700; letter-spacing: -0.04em;
}
.fx-brand__mark::after { content: ""; }
/* FerriCloud logo (2026-10-08, was the geometric F of 2026-09-29): every app's
   "F" tile draws the shared Cloud Badge (logo.svg) instead of a text letter,
   so the mark is identical everywhere and follows light/dark (tile uses
   --fx-fg, cloud --fx-bg; the F cut into the cloud shows the tile through).
   Two mask layers: mark-glyph.svg = the cloud, mark-accent.svg = the orange
   poles. The letter stays in the markup for screen readers and as a fallback
   where masks are unsupported. */
@supports ((-webkit-mask-image: url("")) or (mask-image: url(""))) {
  .fx-brand__mark { position: relative; font-size: 0; color: transparent; overflow: hidden; }
  .fx-brand__mark::after {
    position: absolute; inset: 0; background: var(--fx-bg);
    -webkit-mask: url("/assets/ui/mark-glyph.svg") center / 100% 100% no-repeat; mask: url("/assets/ui/mark-glyph.svg") center / 100% 100% no-repeat;
  }
  .fx-brand__mark::before {
    content: ""; position: absolute; inset: 0; background: #F0784C; z-index: 1;
    -webkit-mask: url("/assets/ui/mark-accent.svg") center / 100% 100% no-repeat; mask: url("/assets/ui/mark-accent.svg") center / 100% 100% no-repeat;
  }
}
.fx-brand__name { font-size: var(--fx-t-base); white-space: nowrap; }
.fx-brand__sep { color: var(--fx-line-strong); font-weight: 400; }
.fx-brand__app { color: var(--fx-fg-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-nav { display: flex; align-items: center; gap: 2px; margin-left: var(--fx-4); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.fx-nav::-webkit-scrollbar { display: none; }
.fx-nav a, .fx-nav button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 0; background: none; border-radius: 8px; cursor: pointer;
  color: var(--fx-fg-2); font-size: var(--fx-t-sm); font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background var(--fx-fast) var(--fx-ease), color var(--fx-fast) var(--fx-ease);
}
.fx-nav a:hover, .fx-nav button:hover { background: var(--fx-surface-2); color: var(--fx-fg); text-decoration: none; }
.fx-nav [aria-current="page"], .fx-nav .is-active { color: var(--fx-fg); background: var(--fx-surface-2); }
.fx-appbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--fx-2); }
@media (max-width: 767px) {
  .fx-appbar .fx-nav--desktop { display: none; }
  .fx-brand__sep, .fx-brand__name--hide-sm { display: none; }
}

/* mobile bottom tab bar (only for apps with 2-5 primary views) */
.fx-tabbar {
  position: fixed; inset: auto 0 0 0; z-index: var(--fx-z-appbar);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--fx-surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--fx-line);
}
.fx-tabbar a, .fx-tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px;
  border: 0; background: none; border-radius: var(--fx-r-ctl); cursor: pointer;
  color: var(--fx-fg-3); font-size: 11px; font-weight: 500; text-decoration: none;
}
.fx-tabbar .ph { font-size: 22px; }
.fx-tabbar [aria-current="page"], .fx-tabbar .is-active { color: var(--fx-accent-ink); }
body.fx.has-tabbar { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { .fx-tabbar { display: none; } body.fx.has-tabbar { padding-bottom: 0; } }

/* ---------- Buttons ---------- */
.fx-btn {
  --_bg: var(--fx-surface); --_fg: var(--fx-fg); --_bd: var(--fx-line-strong); --_hover: var(--fx-surface-2);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--fx-r-ctl);
  border: 1px solid var(--_bd); background: var(--_bg); color: var(--_fg) !important;
  font-size: var(--fx-t-sm); font-weight: 550; line-height: 1; white-space: nowrap; text-decoration: none !important;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  box-shadow: var(--fx-shadow-1);
  transition: background var(--fx-fast) var(--fx-ease), border-color var(--fx-fast) var(--fx-ease), transform var(--fx-fast) var(--fx-ease), box-shadow var(--fx-fast) var(--fx-ease), color var(--fx-fast);
}
.fx-btn:hover { background: var(--_hover); }
.fx-btn:active { transform: translateY(1px) scale(.985); }
.fx-btn:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.fx-btn:disabled, .fx-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.fx-btn .ph { font-size: 1.15em; }
.fx-btn--primary { --_bg: var(--fx-accent); --_fg: var(--fx-accent-fg); --_bd: transparent; --_hover: var(--fx-accent-hover); }
.fx-btn--dark { --_bg: var(--fx-fg); --_fg: var(--fx-bg); --_bd: transparent; --_hover: color-mix(in srgb, var(--fx-fg) 86%, var(--fx-bg)); }
.fx-btn--ghost { --_bg: transparent; --_bd: transparent; --_hover: var(--fx-surface-2); box-shadow: none; color: var(--fx-fg-2) !important; }
.fx-btn--ghost:hover { color: var(--fx-fg) !important; }
.fx-btn--danger { --_bg: var(--fx-surface); --_fg: var(--fx-danger); --_bd: color-mix(in srgb, var(--fx-danger) 35%, transparent); --_hover: var(--fx-danger-soft); }
.fx-btn--danger-solid { --_bg: var(--fx-danger); --_fg: #fff; --_bd: transparent; --_hover: color-mix(in srgb, var(--fx-danger) 88%, #000); }
.fx-btn--sm { height: 30px; padding: 0 10px; font-size: var(--fx-t-xs); border-radius: 8px; gap: 6px; }
.fx-btn--lg { height: 46px; padding: 0 20px; font-size: var(--fx-t-base); }
.fx-btn--block { width: 100%; }
.fx-btn--icon { width: 38px; padding: 0; }
.fx-btn--icon.fx-btn--sm { width: 30px; }
.fx-btn--icon.fx-btn--lg { width: 46px; }
.fx-btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.fx-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--_fg); border-right-color: transparent; animation: fx-spin .7s linear infinite;
}
.fx-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--fx-accent-ink); font-weight: 500; text-decoration: none; }
.fx-link:hover { text-decoration: underline; }
.fx-btngroup { display: inline-flex; gap: var(--fx-2); flex-wrap: wrap; }

/* ---------- Forms ---------- */
.fx-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fx-field > label, .fx-field__label { font-size: var(--fx-t-sm); font-weight: 550; color: var(--fx-fg); }
.fx-field__hint { font-size: var(--fx-t-xs); color: var(--fx-fg-3); }
.fx-field__error { font-size: var(--fx-t-xs); color: var(--fx-danger); font-weight: 500; }
.fx-field__error:empty { display: none; }
.fx-field:has(.fx-field__error:not(:empty)) .fx-field__hint { display: none; }
.fx-input, .fx-select, .fx-textarea {
  width: 100%; min-width: 0; height: 40px; padding: 0 12px;
  border-radius: var(--fx-r-ctl); border: 1px solid var(--fx-line-strong);
  background: var(--fx-surface); color: var(--fx-fg);
  font-size: var(--fx-t-base); line-height: 1.3;
  transition: border-color var(--fx-fast) var(--fx-ease), box-shadow var(--fx-fast) var(--fx-ease), background var(--fx-fast);
  -webkit-appearance: none; appearance: none;
}
.fx-textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.fx-select {
  padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fx-fg-3) 50%), linear-gradient(135deg, var(--fx-fg-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.fx-input::placeholder, .fx-textarea::placeholder { color: var(--fx-fg-3); opacity: 1; }
.fx-input:hover, .fx-select:hover, .fx-textarea:hover { border-color: color-mix(in srgb, var(--fx-fg) 30%, var(--fx-line-strong)); }
.fx-input:focus, .fx-select:focus, .fx-textarea:focus { outline: none; border-color: var(--fx-accent); box-shadow: var(--fx-ring); }
.fx-input[type="file"] { height: auto; padding: 6px; }
.fx-input::file-selector-button { margin-right: 10px; height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--fx-line-strong); background: var(--fx-surface-2); color: var(--fx-fg); font: inherit; font-size: var(--fx-t-sm); font-weight: 550; cursor: pointer; }
.fx-input:disabled, .fx-select:disabled, .fx-textarea:disabled { background: var(--fx-surface-2); color: var(--fx-fg-3); cursor: not-allowed; }
.fx-input[aria-invalid="true"], .fx-select[aria-invalid="true"], .fx-textarea[aria-invalid="true"] { border-color: var(--fx-danger); }
.fx-input--sm, .fx-select--sm { height: 32px; font-size: var(--fx-t-sm); border-radius: 8px; }
.fx-select--sm { background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px; padding-right: 28px; }
.fx-input--lg { height: 48px; font-size: var(--fx-t-md); }
.fx-input--mono { font-family: var(--fx-mono); letter-spacing: .02em; }
@media (max-width: 767px) { .fx-input, .fx-select, .fx-textarea { font-size: 16px; } } /* stops iOS zoom-on-focus */
.fx-inputgroup { position: relative; display: flex; align-items: center; }
.fx-inputgroup > .ph { position: absolute; left: 12px; color: var(--fx-fg-3); pointer-events: none; font-size: 16px; }
.fx-inputgroup > .ph ~ .fx-input { padding-left: 36px; }
.fx-inputgroup > .fx-btn { position: absolute; right: 4px; height: 32px; }
.fx-inputgroup > .fx-btn ~ .fx-input, .fx-inputgroup > .fx-input:has(~ .fx-btn) { padding-right: 90px; }
.fx-form { display: flex; flex-direction: column; gap: var(--fx-4); }
.fx-form__row { display: grid; gap: var(--fx-4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .fx-form__row { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); } }
.fx-form__actions { display: flex; gap: var(--fx-2); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--fx-2); }

.fx-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fx-t-sm); user-select: none; }
.fx-check input[type="checkbox"], .fx-check input[type="radio"] {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0;
  width: 18px; height: 18px; border: 1.5px solid var(--fx-line-strong); background: var(--fx-surface);
  border-radius: 5px; display: grid; place-items: center; cursor: pointer;
  transition: background var(--fx-fast), border-color var(--fx-fast);
}
.fx-check input[type="radio"] { border-radius: 50%; }
.fx-check input:checked { background: var(--fx-accent); border-color: var(--fx-accent); }
.fx-check input[type="checkbox"]:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--fx-accent-fg); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.fx-check input[type="radio"]:checked::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--fx-accent-fg); }
.fx-check input:focus-visible { outline: none; box-shadow: var(--fx-ring); }

.fx-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fx-t-sm); user-select: none; }
.fx-switch input {
  -webkit-appearance: none; appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 38px; height: 22px; border-radius: 999px; background: var(--fx-surface-3); position: relative;
  border: 1px solid var(--fx-line-strong);
  transition: background var(--fx-med) var(--fx-ease), border-color var(--fx-med);
}
.fx-switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform var(--fx-med) var(--fx-ease);
}
.fx-switch input:checked { background: var(--fx-accent); border-color: var(--fx-accent); }
.fx-switch input:checked::after { transform: translateX(16px); }
.fx-switch input:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.fx-switch input:disabled { opacity: .5; cursor: not-allowed; }

/* segmented control / view switcher */
.fx-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--fx-r-ctl); background: var(--fx-surface-2); border: 1px solid var(--fx-line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.fx-seg::-webkit-scrollbar { display: none; }
.fx-seg > button, .fx-seg > a, .fx-seg > label {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 7px;
  border: 0; background: none; color: var(--fx-fg-2); font-size: var(--fx-t-sm); font-weight: 500; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--fx-fast), color var(--fx-fast), box-shadow var(--fx-fast);
}
.fx-seg > :hover { color: var(--fx-fg); text-decoration: none; }
.fx-seg > [aria-selected="true"], .fx-seg > [aria-pressed="true"], .fx-seg > [aria-checked="true"], .fx-seg > [aria-current="page"], .fx-seg > .is-active, .fx-seg > label:has(input:checked) {
  background: var(--fx-surface); color: var(--fx-fg); box-shadow: var(--fx-shadow-1);
}
.fx-seg > label input { position: absolute; opacity: 0; pointer-events: none; }
.fx-seg--block { display: flex; }
.fx-seg--block > * { flex: 1; justify-content: center; }

/* underline tabs (for in-page sections) */
.fx-tabs { display: flex; gap: var(--fx-5); border-bottom: 1px solid var(--fx-line); overflow-x: auto; scrollbar-width: none; }
.fx-tabs::-webkit-scrollbar { display: none; }
.fx-tabs > button, .fx-tabs > a {
  position: relative; padding: 10px 0; border: 0; background: none; cursor: pointer; white-space: nowrap;
  color: var(--fx-fg-2); font-size: var(--fx-t-sm); font-weight: 500; text-decoration: none;
}
.fx-tabs > :hover { color: var(--fx-fg); text-decoration: none; }
.fx-tabs > [aria-selected="true"], .fx-tabs > [aria-current="page"], .fx-tabs > .is-active { color: var(--fx-fg); }
.fx-tabs > [aria-selected="true"]::after, .fx-tabs > [aria-current="page"]::after, .fx-tabs > .is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--fx-accent);
}

/* filter chips */
.fx-chips { display: flex; gap: var(--fx-2); flex-wrap: wrap; }
.fx-chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.fx-chips--scroll::-webkit-scrollbar { display: none; }
.fx-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; flex: none;
  border-radius: var(--fx-r-full); border: 1px solid var(--fx-line-strong); background: var(--fx-surface);
  color: var(--fx-fg-2); font-size: var(--fx-t-sm); font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--fx-fast), color var(--fx-fast), border-color var(--fx-fast), transform var(--fx-fast);
}
.fx-chip:hover { color: var(--fx-fg); border-color: color-mix(in srgb, var(--fx-fg) 28%, var(--fx-line-strong)); text-decoration: none; }
.fx-chip:active { transform: scale(.97); }
.fx-chip[aria-pressed="true"], .fx-chip[aria-selected="true"], .fx-chip.is-active { background: var(--fx-fg); border-color: var(--fx-fg); color: var(--fx-bg); }

/* ---------- Surfaces ---------- */
.fx-panel { background: var(--fx-surface); border: 1px solid var(--fx-line); border-radius: var(--fx-r-surface); }
.fx-panel--pad { padding: var(--fx-5); }
@media (min-width: 768px) { .fx-panel--pad { padding: var(--fx-6); } }
.fx-panel--raised { box-shadow: var(--fx-shadow-2); border-color: transparent; }
.fx-panel--sunken { background: var(--fx-sunken); border-color: transparent; }
.fx-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--fx-3); padding: var(--fx-4) var(--fx-5); border-bottom: 1px solid var(--fx-line); }
.fx-panel__head h2, .fx-panel__head h3 { font-size: var(--fx-t-base); font-weight: 600; letter-spacing: -0.005em; }
.fx-panel__body { padding: var(--fx-5); }
.fx-panel__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--fx-2); padding: var(--fx-3) var(--fx-5); border-top: 1px solid var(--fx-line); background: color-mix(in srgb, var(--fx-surface-2) 50%, transparent); border-radius: 0 0 var(--fx-r-surface) var(--fx-r-surface); }

/* clickable tile (launchers, pickers) */
.fx-tile {
  position: relative; display: flex; flex-direction: column; gap: var(--fx-2); padding: var(--fx-4);
  background: var(--fx-surface); border: 1px solid var(--fx-line); border-radius: var(--fx-r-surface);
  color: var(--fx-fg) !important; text-decoration: none !important; cursor: pointer; text-align: left;
  transition: border-color var(--fx-fast) var(--fx-ease), box-shadow var(--fx-med) var(--fx-ease), transform var(--fx-med) var(--fx-ease);
}
.fx-tile:hover { border-color: var(--fx-line-strong); box-shadow: var(--fx-shadow-2); transform: translateY(-1px); }
.fx-tile:active { transform: translateY(0) scale(.99); }
.fx-tile:focus-visible { outline: none; box-shadow: var(--fx-ring); }
.fx-tile[aria-pressed="true"], .fx-tile[aria-selected="true"], .fx-tile.is-active { border-color: var(--fx-accent); box-shadow: inset 0 0 0 1px var(--fx-accent); }
.fx-tile__icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--fx-surface-2); color: var(--fx-fg); font-size: 20px; flex: none; }
.fx-tile__title { font-weight: 600; font-size: var(--fx-t-base); letter-spacing: -0.005em; }
.fx-tile__desc { font-size: var(--fx-t-sm); color: var(--fx-fg-2); }

/* list rows */
.fx-list { display: flex; flex-direction: column; background: var(--fx-surface); border: 1px solid var(--fx-line); border-radius: var(--fx-r-surface); overflow: hidden; }
.fx-list--plain { background: none; border: 0; border-radius: 0; }
.fx-list > * + * { border-top: 1px solid var(--fx-line); }
.fx-item { display: flex; align-items: center; gap: var(--fx-3); padding: var(--fx-3) var(--fx-4); min-height: 56px; color: var(--fx-fg); text-decoration: none !important; }
a.fx-item, button.fx-item { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; transition: background var(--fx-fast); font: inherit; }
a.fx-item:hover, button.fx-item:hover { background: var(--fx-surface-2); }
.fx-item__lead { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--fx-surface-2); font-size: 18px; color: var(--fx-fg-2); }
.fx-item__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fx-item__title { font-weight: 550; font-size: var(--fx-t-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-item__meta { font-size: var(--fx-t-sm); color: var(--fx-fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-item__trail { flex: none; display: flex; align-items: center; gap: var(--fx-2); color: var(--fx-fg-3); font-size: var(--fx-t-sm); }

/* stat / KPI */
/* Hairlines are drawn by each cell's shadow, so a short last row leaves clean surface instead of grey gaps. */
.fx-stats { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); background: var(--fx-surface); border: 1px solid var(--fx-line); border-radius: var(--fx-r-surface); overflow: hidden; }
.fx-stat { display: flex; flex-direction: column; gap: 4px; padding: var(--fx-4); background: var(--fx-surface); min-width: 0; box-shadow: 1px 0 0 var(--fx-line), 0 1px 0 var(--fx-line); }
.fx-stat__label { font-size: var(--fx-t-xs); color: var(--fx-fg-3); font-weight: 500; }
.fx-stat__value { font-size: var(--fx-t-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fx-stat__meta { font-size: var(--fx-t-xs); color: var(--fx-fg-2); }
.fx-stat__meta.is-up { color: var(--fx-ok); } .fx-stat__meta.is-down { color: var(--fx-danger); }

/* table */
.fx-tablewrap { overflow-x: auto; border: 1px solid var(--fx-line); border-radius: var(--fx-r-surface); background: var(--fx-surface); }
.fx-table { width: 100%; border-collapse: collapse; font-size: var(--fx-t-sm); }
.fx-table th { text-align: left; font-weight: 500; font-size: var(--fx-t-xs); color: var(--fx-fg-3); padding: 10px var(--fx-4); border-bottom: 1px solid var(--fx-line); white-space: nowrap; background: color-mix(in srgb, var(--fx-surface-2) 50%, var(--fx-surface)); }
.fx-table td { padding: 12px var(--fx-4); border-bottom: 1px solid var(--fx-line); vertical-align: middle; }
.fx-table tr:last-child td { border-bottom: 0; }
.fx-table tbody tr { transition: background var(--fx-fast); }
.fx-table tbody tr:hover { background: color-mix(in srgb, var(--fx-surface-2) 55%, transparent); }
.fx-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }

/* tags + badges */
.fx-tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border-radius: var(--fx-r-tag);
  font-size: 11.5px; font-weight: 550; line-height: 1; white-space: nowrap;
  background: var(--fx-surface-2); color: var(--fx-fg-2); border: 1px solid var(--fx-line);
}
.fx-tag--accent { background: var(--fx-accent-soft); color: var(--fx-accent-ink); border-color: var(--fx-accent-line); }
.fx-tag--ok { background: var(--fx-ok-soft); color: var(--fx-ok); border-color: color-mix(in srgb, var(--fx-ok) 28%, transparent); }
.fx-tag--warn { background: var(--fx-warn-soft); color: var(--fx-warn); border-color: color-mix(in srgb, var(--fx-warn) 28%, transparent); }
.fx-tag--danger { background: var(--fx-danger-soft); color: var(--fx-danger); border-color: color-mix(in srgb, var(--fx-danger) 28%, transparent); }
.fx-tag--info { background: var(--fx-info-soft); color: var(--fx-info); border-color: color-mix(in srgb, var(--fx-info) 28%, transparent); }
/* a status light: ONLY for real live state (service up/down, online) */
.fx-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fx-t-xs); color: var(--fx-fg-2); font-weight: 500; }
.fx-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fx-fg-3); }
.fx-status--ok::before { background: var(--fx-ok); box-shadow: 0 0 0 3px var(--fx-ok-soft); }
.fx-status--warn::before { background: var(--fx-warn); box-shadow: 0 0 0 3px var(--fx-warn-soft); }
.fx-status--danger::before { background: var(--fx-danger); box-shadow: 0 0 0 3px var(--fx-danger-soft); }

.fx-kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--fx-line-strong); border-bottom-width: 2px; background: var(--fx-surface); font-family: var(--fx-mono); font-size: 11px; color: var(--fx-fg-2); }
.fx-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--fx-surface-3); color: var(--fx-fg); font-size: 13px; font-weight: 600; }
.fx-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fx-avatar--sm { width: 24px; height: 24px; font-size: 11px; }
.fx-avatar--lg { width: 56px; height: 56px; font-size: 20px; }
.fx-divider { height: 1px; background: var(--fx-line); border: 0; margin: 0; }
.fx-progress { height: 6px; border-radius: 999px; background: var(--fx-surface-3); overflow: hidden; }
.fx-progress > span { display: block; height: 100%; width: var(--value, 0%); background: var(--fx-accent); border-radius: inherit; transition: width var(--fx-med) var(--fx-ease); }
.fx-progress--indeterminate > span { width: 35%; animation: fx-indet 1.2s var(--fx-ease) infinite; }
@keyframes fx-indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.fx-progress--ok > span { background: var(--fx-ok); }
.fx-progress--warn > span { background: var(--fx-warn); }
.fx-progress--danger > span { background: var(--fx-danger); }

/* ---------- Feedback: banners, empty, skeleton, errors ---------- */
.fx-banner { display: flex; gap: var(--fx-3); align-items: flex-start; padding: var(--fx-3) var(--fx-4); border-radius: var(--fx-r-ctl); background: var(--fx-surface-2); border: 1px solid var(--fx-line); font-size: var(--fx-t-sm); color: var(--fx-fg); }
.fx-banner > .ph { font-size: 18px; flex: none; margin-top: 1px; }
.fx-banner__body { flex: 1; min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.fx-banner__title { font-weight: 600; }
.fx-banner--info { background: var(--fx-info-soft); border-color: color-mix(in srgb, var(--fx-info) 25%, transparent); } .fx-banner--info > .ph { color: var(--fx-info); }
.fx-banner--ok { background: var(--fx-ok-soft); border-color: color-mix(in srgb, var(--fx-ok) 25%, transparent); } .fx-banner--ok > .ph { color: var(--fx-ok); }
.fx-banner--warn { background: var(--fx-warn-soft); border-color: color-mix(in srgb, var(--fx-warn) 25%, transparent); } .fx-banner--warn > .ph { color: var(--fx-warn); }
.fx-banner--danger { background: var(--fx-danger-soft); border-color: color-mix(in srgb, var(--fx-danger) 25%, transparent); } .fx-banner--danger > .ph { color: var(--fx-danger); }

.fx-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--fx-2); padding: var(--fx-12) var(--fx-6); }
.fx-empty__icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--fx-surface-2); color: var(--fx-fg-2); font-size: 24px; margin-bottom: var(--fx-2); }
.fx-empty__title { font-weight: 600; font-size: var(--fx-t-md); }
.fx-empty__text { color: var(--fx-fg-2); font-size: var(--fx-t-sm); max-width: 42ch; }
.fx-empty .fx-btn { margin-top: var(--fx-3); }
.fx-empty--compact { padding: var(--fx-8) var(--fx-4); }

.fx-skeleton { display: block; border-radius: 8px; background: var(--fx-surface-2); position: relative; overflow: hidden; min-height: 12px; }
.fx-skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--fx-surface) 70%, transparent), transparent);
  animation: fx-shimmer 1.4s var(--fx-ease) infinite;
}
.fx-skeleton--text { height: 12px; width: var(--w, 100%); }
.fx-skeleton--title { height: 20px; width: var(--w, 40%); }
.fx-skeleton--block { height: var(--h, 96px); border-radius: var(--fx-r-surface); }
.fx-spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fx-line-strong); border-top-color: var(--fx-accent); animation: fx-spin .7s linear infinite; vertical-align: middle; }

/* ---------- Overlays: dialog, sheet, popover, menu, toast ---------- */
dialog.fx-dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; margin: auto;
  border: 1px solid var(--fx-line); border-radius: var(--fx-r-surface); background: var(--fx-surface); color: var(--fx-fg);
  box-shadow: var(--fx-shadow-3); overflow: auto;
}
dialog.fx-dialog[open] { animation: fx-pop var(--fx-med) var(--fx-ease); }
dialog.fx-dialog::backdrop { background: var(--fx-overlay); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.fx-dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--fx-3); padding: var(--fx-5) var(--fx-5) 0; }
.fx-dialog__head h2 { font-size: var(--fx-t-lg); }
.fx-dialog__body { padding: var(--fx-4) var(--fx-5); display: flex; flex-direction: column; gap: var(--fx-4); }
.fx-dialog__foot { display: flex; justify-content: flex-end; gap: var(--fx-2); padding: 0 var(--fx-5) var(--fx-5); flex-wrap: wrap; }
dialog.fx-dialog--wide { width: min(800px, calc(100vw - 32px)); }
@media (max-width: 639px) {
  dialog.fx-dialog.fx-dialog--sheet { width: 100vw; max-width: 100vw; margin: auto 0 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; max-height: 88dvh; padding-bottom: env(safe-area-inset-bottom); }
  dialog.fx-dialog.fx-dialog--sheet[open] { animation: fx-sheet var(--fx-med) var(--fx-ease); }
}

.fx-popover {
  position: absolute; z-index: var(--fx-z-popover); min-width: 220px; padding: 6px;
  background: var(--fx-surface); border: 1px solid var(--fx-line); border-radius: 12px; box-shadow: var(--fx-shadow-3);
  animation: fx-pop var(--fx-fast) var(--fx-ease);
}
.fx-menu { display: flex; flex-direction: column; }
.fx-menu > a, .fx-menu > button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--fx-fg); font-size: var(--fx-t-sm); text-align: left; cursor: pointer; text-decoration: none;
}
.fx-menu > a:hover, .fx-menu > button:hover, .fx-menu > .is-focus { background: var(--fx-surface-2); text-decoration: none; }
.fx-menu > [aria-current="page"] { color: var(--fx-accent-ink); }
.fx-menu .ph { font-size: 17px; color: var(--fx-fg-2); }
.fx-menu__sep { height: 1px; margin: 6px 4px; background: var(--fx-line); }
.fx-menu__label { padding: 8px 10px 4px; font-size: var(--fx-t-xs); color: var(--fx-fg-3); font-weight: 500; }

.fx-toasts { position: fixed; z-index: var(--fx-z-toast); left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(420px, calc(100vw - 32px)); }
body.has-tabbar .fx-toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
.fx-toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--fx-fg); color: var(--fx-bg); box-shadow: var(--fx-shadow-3); font-size: var(--fx-t-sm); font-weight: 500;
  animation: fx-toast-in var(--fx-med) var(--fx-ease);
}
.fx-toast .ph { font-size: 18px; flex: none; }
.fx-toast--ok .ph { color: color-mix(in srgb, var(--fx-ok) 70%, var(--fx-bg)); }
.fx-toast--danger .ph { color: color-mix(in srgb, var(--fx-danger) 70%, var(--fx-bg)); }
.fx-toast--warn .ph { color: color-mix(in srgb, var(--fx-warn) 70%, var(--fx-bg)); }
.fx-toast__action { margin-left: auto; background: none; border: 0; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; font-size: inherit; }
.fx-toast.is-leaving { animation: fx-toast-out var(--fx-fast) var(--fx-ease) forwards; }

/* app switcher (rendered by ferri-ui.js into any [data-fx-apps] button) */
.fx-apps { width: min(360px, calc(100vw - 24px)); max-height: min(70dvh, 560px); overflow: auto; padding: 8px; }
.fx-apps__search { margin: 2px 2px 8px; }
.fx-apps__group { padding: 6px 8px 4px; font-size: var(--fx-t-xs); font-weight: 500; color: var(--fx-fg-3); }
.fx-apps__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-bottom: 4px; }
.fx-apps__grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 10px; color: var(--fx-fg) !important; text-decoration: none !important; font-size: 12px; font-weight: 500; text-align: center; }
.fx-apps__grid a:hover, .fx-apps__grid a.is-focus { background: var(--fx-surface-2); }
.fx-apps__grid a[aria-current="page"] .fx-apps__icon { background: var(--fx-accent-soft); color: var(--fx-accent-ink); }
.fx-apps__icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--fx-surface-2); font-size: 20px; color: var(--fx-fg); transition: background var(--fx-fast); }

/* ---------- Auth / centered card pages ---------- */
.fx-center { min-height: 100dvh; display: grid; place-items: center; padding: var(--fx-6) var(--fx-4); }
.fx-card-narrow { width: min(400px, 100%); }

/* ---------- Motion ---------- */
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-shimmer { to { transform: translateX(100%); } }
@keyframes fx-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fx-sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fx-toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fx-toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes fx-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fx-rise { animation: fx-rise 420ms var(--fx-ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@media (prefers-reduced-motion: reduce) {
  .fx *, .fx *::before, .fx *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .fx-appbar, .fx-tabbar { background: var(--fx-surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
