/* ==========================================================================
   Avan design system - components (round 4)
   Load after tokens.css. Class names are short and unprefixed except for the
   root .av scope. Directions use logical properties, so RTL just works.
   ========================================================================== */

/* ---------- Base ---------- */
/* resets use :where() so every component class wins over them */
:where(.av, .av *, .av *::before, .av *::after) { box-sizing: border-box; }
.av {
  font-family: var(--font-sans); font-size: 15px; line-height: 26px; font-weight: 400;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
:where(.av) :where(h1, h2, h3, h4, p, figure, ul, ol) { margin: 0; padding: 0; }
:where(.av) :where(ul, ol) { list-style: none; }
:where(.av) :where(a) { color: inherit; text-decoration: none; }
:where(.av) :where(button) { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(.av) :where(img, video) { display: block; max-width: 100%; }
:where(.av) ::selection { background: var(--tide-5); color: #fff; }
:where(.av) :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:where(.av) .ltr { direction: ltr; unicode-bidi: isolate; }
:where(.av) .muted { color: var(--text-muted); }
:where(.av) .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:where(.av) .num { font-variant-numeric: tabular-nums; }
.av [hidden] { display: none !important; }

/* ---------- Scrollbars ---------- */
html { scrollbar-width: thin; scrollbar-color: rgba(128,145,150,.38) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,145,150,.38); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(128,145,150,.6); }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- Icons ---------- */
.ico { width: 20px; height: 20px; flex: none; fill: currentColor; display: inline-block; vertical-align: middle; }
.ico--16 { width: 16px; height: 16px; }
.ico--18 { width: 18px; height: 18px; }
.ico--24 { width: 24px; height: 24px; }
.ico--28 { width: 28px; height: 28px; }
.ico--flip { transform: scaleX(-1); }

/* ---------- Liquid ----------
   The approved recipe: deep teals moving like thick liquid, lit from the
   top-left by the galaxy glow, with faint stars. Text sits on the deep right. */
.liquid {
  position: relative; isolation: isolate; overflow: hidden;
  color: var(--on-liquid);
  background: linear-gradient(140deg, var(--liq-2) 0%, var(--liq-1) 38%, var(--liq-3) 100%);
}
.liquid::before, .liquid::after { content: ""; position: absolute; z-index: -1; pointer-events: none; }
.liquid::before {
  inset: -45%;
  background:
    radial-gradient(22% 26% at 25% 27%, rgba(34,199,220,.7) 0%, rgba(34,199,220,0) 72%),
    radial-gradient(34% 38% at 22% 30%, var(--liq-4) 0%, transparent 74%),
    radial-gradient(30% 34% at 34% 78%, var(--liq-4) 0%, transparent 76%),
    radial-gradient(44% 48% at 70% 40%, var(--liq-3) 0%, transparent 78%);
  filter: blur(14px);
  animation: liquid-drift 26s var(--ease-liquid) infinite alternate;
}
.liquid::after {
  inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, rgba(255,255,255,.95) 50%, transparent 52%),
    radial-gradient(1px 1px at 27% 62%, rgba(255,255,255,.7) 50%, transparent 52%),
    radial-gradient(1.2px 1.2px at 41% 30%, rgba(255,255,255,.8) 50%, transparent 52%),
    radial-gradient(1px 1px at 55% 78%, rgba(255,255,255,.55) 50%, transparent 52%),
    radial-gradient(1.6px 1.6px at 63% 14%, rgba(255,255,255,.9) 50%, transparent 52%),
    radial-gradient(1px 1px at 72% 52%, rgba(255,255,255,.6) 50%, transparent 52%),
    radial-gradient(1.2px 1.2px at 84% 28%, rgba(255,255,255,.75) 50%, transparent 52%),
    radial-gradient(1px 1px at 91% 70%, rgba(255,255,255,.5) 50%, transparent 52%),
    radial-gradient(1px 1px at 8% 84%, rgba(255,255,255,.6) 50%, transparent 52%),
    radial-gradient(1.2px 1.2px at 35% 90%, rgba(255,255,255,.5) 50%, transparent 52%),
    radial-gradient(1px 1px at 48% 8%, rgba(255,255,255,.7) 50%, transparent 52%),
    radial-gradient(1px 1px at 78% 88%, rgba(255,255,255,.45) 50%, transparent 52%);
  animation: twinkle 6s ease-in-out infinite alternate;
}
.liquid--calm::before { animation-duration: 40s; }
.liquid--nostars::after { display: none; }
/* small surfaces (buttons, chips, coins): same light, tighter */
.liquid--sm::before { inset: -60%; filter: blur(6px); }
.liquid .muted, .liquid .on-2 { color: var(--on-liquid-2); }
@keyframes liquid-drift {
  0%   { transform: translate3d(-4%, -3%, 0) rotate(-3deg) scale(1); }
  50%  { transform: translate3d(1%, 2%, 0) rotate(1deg) scale(1.06); }
  100% { transform: translate3d(5%, 4%, 0) rotate(4deg) scale(1.1); }
}
@keyframes twinkle { from { opacity: .45; } to { opacity: 1; } }

/* .glow-top used to add a light at the top of the page; removed in round 4 (no decorative light). */
.glow-top { position: relative; }

/* ---------- Buttons ---------- */
.btn {
  --h: 48px;
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--h); padding-inline: 22px; border-radius: var(--radius-pill);
  font-family: var(--font-sans); font-size: 15px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-slow) var(--ease),
              background-color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease), filter var(--dur-slow) var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn--sm { --h: 38px; padding-inline: 16px; font-size: 13.5px; gap: 8px; }
.btn--lg { --h: 56px; padding-inline: 28px; font-size: 16px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

/* primary: a small piece of Liquid */
.btn--primary { color: #fff; background: linear-gradient(140deg, var(--liq-3) 0%, var(--liq-1) 55%, var(--liq-3) 100%); }
.btn--primary::before {
  content: ""; position: absolute; inset: -60% -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 70% at 18% 30%, rgba(34,199,220,.75) 0%, rgba(34,199,220,0) 70%),
    radial-gradient(45% 80% at 30% 85%, var(--liq-4) 0%, transparent 72%),
    radial-gradient(50% 80% at 85% 40%, var(--tide-4) 0%, transparent 75%);
  filter: blur(8px);
  transition: transform 1.2s var(--ease);
}
.btn--primary::after { /* soft rim of light */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  display: none;
}
.btn--primary:hover { filter: brightness(1.1); }
.btn--primary:hover::before { transform: translateX(-8%) scale(1.08); }
.btn--primary .cost { color: var(--on-liquid-2); font-weight: 500; }

.btn--secondary { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--secondary:hover { box-shadow: inset 0 0 0 1px var(--control-line); }
.btn--ghost { color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--soft { color: var(--text); background: var(--surface-2); }
.btn--soft:hover { background: var(--surface-3); }
.btn--white { color: var(--liq-2); background: #fff; }
.btn--white:hover { background: #e6f2f4; }
.btn--glass { color: #fff; background: rgba(255,255,255,.14); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.btn--glass:hover { background: rgba(255,255,255,.22); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.liquid .btn--secondary { background: transparent; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }

/* round icon button */
.iconbtn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
}
.iconbtn:hover { box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--surface-2); }
.iconbtn:active { transform: scale(.96); }
.iconbtn--sm { width: 36px; height: 36px; }
.iconbtn--bare { background: transparent; box-shadow: none; }
.iconbtn--glass { color: #fff; background: rgba(8,24,24,.32); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
.iconbtn--glass:hover { background: rgba(8,24,24,.5); }
.iconbtn .dot { position: absolute; top: 9px; inset-inline-end: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--glow); box-shadow: 0 0 0 2px var(--surface); }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative; isolation: isolate; overflow: hidden; flex: none;
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding-inline: 16px;
  border-radius: var(--radius-pill); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  color: var(--text-2); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  transition: color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease);
}
.chip:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip .ico { width: 16px; height: 16px; }
.chip.is-on { color: #fff; box-shadow: none; background: linear-gradient(140deg, var(--liq-3), var(--liq-1) 60%, var(--liq-3)); }
.chip.is-on::before { content: ""; position: absolute; inset: -40%; z-index: -1; background: radial-gradient(40% 70% at 20% 30%, rgba(34,199,220,.6), transparent 70%), radial-gradient(50% 80% at 40% 90%, var(--liq-4), transparent 72%); filter: blur(6px); }
.chip--dark { background: rgba(255,255,255,.06); color: rgba(255,255,255,.78); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }
.chip--dark:hover { color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }

/* ---------- Token: coin, cost, balance ---------- */
/* The token coin: always a white disc with the teal spark, on every surface.
   A hairline keeps it visible on white cards; it disappears on dark and Liquid. */
.coin {
  flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  color: var(--liq-3); background: #fff; box-shadow: inset 0 0 0 1px rgba(6,35,40,.14);
}
.coin svg { width: 60%; height: 60%; fill: currentColor; }
.coin--lg { width: 40px; height: 40px; }
.coin--xl { width: 64px; height: 64px; }

.cost { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cost--pill { height: 30px; padding-inline: 6px 12px; border-radius: var(--radius-pill); background: rgba(8,24,24,.5); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 13px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.cost--pill .coin { width: 20px; height: 20px; }

.balance {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding-inline: 6px 14px;
  border-radius: var(--radius-pill); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px;
  transition: box-shadow var(--dur-base) var(--ease);
}
.balance:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.balance .coin { width: 32px; height: 32px; }
.balance__add { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-inline-start: 2px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding-inline: 8px 10px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge .ico { width: 14px; height: 14px; }
.badge--glass { background: rgba(8,24,24,.45); color: #fff; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.badge--hot .ico { color: #ffb37a; }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--success { background: color-mix(in oklab, var(--success) 14%, transparent); color: var(--success); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: inset 0 0 0 1px var(--line); }
[data-theme="dark"] .card { box-shadow: inset 0 0 0 1px var(--line); }
.card--pad { padding: 24px; }
.card--xl { border-radius: var(--radius-xl); }
.card__hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 18px; }
.card__title { font-family: var(--font-display); font-size: 20px; line-height: 30px; font-weight: 700; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 8px; }
.field__label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--text); }
.field__label .opt { font-weight: 400; color: var(--text-muted); font-size: 12.5px; }
.field__hint { font-size: 12.5px; line-height: 20px; color: var(--text-muted); }
.field__error { display: flex; gap: 6px; align-items: center; font-size: 12.5px; line-height: 20px; color: var(--danger); }
.field__error .ico { width: 16px; height: 16px; }
.input, .textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 0; border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  padding: 0 16px; height: 52px; outline: none;
  transition: box-shadow var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease);
}
.textarea { height: auto; min-height: 104px; padding: 14px 16px; line-height: 26px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); opacity: .8; }
.input:hover, .textarea:hover { box-shadow: inset 0 0 0 1px var(--control-line); }
.input:focus, .textarea:focus, .input.is-focus { box-shadow: inset 0 0 0 1.5px var(--tide-5); }
.input.is-error { box-shadow: inset 0 0 0 1.5px var(--danger); }
.input--ltr { direction: ltr; text-align: left; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-inline-end: 72px; }
.input-group__affix { position: absolute; inset-inline-end: 14px; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 14px; direction: ltr; pointer-events: none; }
.input-group__affix::before { content: ""; width: 1px; height: 20px; background: var(--line-strong); order: 2; }
.input-group__affix span { order: 1; }

/* OTP: five boxes, LTR */
.otp { display: flex; gap: 10px; direction: ltr; justify-content: center; }
.otp__cell {
  width: 52px; height: 60px; border-radius: var(--radius-md); display: grid; place-items: center;
  font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: box-shadow var(--dur-base) var(--ease);
}
.otp__cell.is-focus { box-shadow: inset 0 0 0 1.5px var(--tide-5); }
.otp__cell.is-focus::after { content: ""; width: 2px; height: 26px; background: var(--tide-5); animation: caret 1.1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* switch */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); transition: background var(--dur-base) var(--ease); pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: inset-inline-start var(--dur-slow) var(--ease); }
.switch input:checked + span { background: linear-gradient(140deg, var(--liq-4), var(--liq-3)); box-shadow: none; }
.switch input:checked + span::after { inset-inline-start: 21px; }
.row-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row-switch__txt b { display: block; font-size: 14px; font-weight: 600; }
.row-switch__txt small { display: block; font-size: 12.5px; line-height: 20px; color: var(--text-muted); }

/* range */
.range { display: grid; gap: 10px; }
.range__head { display: flex; justify-content: space-between; font-size: 13.5px; font-weight: 600; }
.range__head output { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.range input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; direction: ltr; margin: 0; --v: 50%; }
.range input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--liq-4) 0 var(--v), var(--surface-3) var(--v) 100%); }
.range input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
.range input[type=range]::-moz-range-progress { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--liq-3), var(--liq-4)); }
.range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 2px solid var(--liq-4); }
.range input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border: 2px solid var(--liq-4); border-radius: 50%; background: #fff; }
.range__scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* segmented choice (quality) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--radius-md); background: var(--surface-2); }
.seg__opt { display: grid; gap: 2px; justify-items: center; padding: 10px 6px; border-radius: 12px; text-align: center; color: var(--text-2); transition: background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), color var(--dur-base) var(--ease); }
.seg__opt b { font-size: 14px; font-weight: 600; }
.seg__opt small { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.seg__opt:hover { color: var(--text); }
.seg__opt.is-on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--tide-5); }
.seg__opt.is-on b { color: var(--accent); }
[data-theme="dark"] .seg__opt.is-on { background: var(--surface-3); }

/* disclosure */
.more { border-radius: var(--radius-md); }
.more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.more > summary::-webkit-details-marker { display: none; }
.more > summary .ico { transition: transform var(--dur-slow) var(--ease); color: var(--text-muted); }
.more[open] > summary .ico { transform: rotate(180deg); }
.more__body { display: grid; gap: 18px; padding-block: 14px 4px; }

/* ---------- Upload slot ---------- */
.upload {
  position: relative; overflow: hidden; display: grid; place-items: center; align-content: center; gap: 6px;
  min-height: 168px; padding: 18px; border-radius: var(--radius-lg); text-align: center;
  background: var(--surface-2); border: 1.5px dashed var(--line-strong); color: var(--text-2);
  transition: border-color var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease);
  cursor: pointer;
}
.upload:hover, .upload.is-drag { border-color: var(--tide-5); background: color-mix(in oklab, var(--accent-soft) 70%, var(--surface-2)); }
.upload__ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--surface); color: var(--accent); margin-block-end: 6px; }
.upload__ic .ico { width: 24px; height: 24px; }
.upload b { font-size: 14.5px; font-weight: 600; color: var(--text); }
.upload small { font-size: 12.5px; line-height: 19px; color: var(--text-muted); }
.upload--req .upload__ic { color: #fff; background: linear-gradient(140deg, var(--liq-4), var(--liq-3) 60%, var(--liq-1)); }
.upload.is-filled { padding: 0; border: 0; background: var(--ink, #000); cursor: default; }
.upload.is-filled img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload__bar { position: absolute; inset-inline: 10px; bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.upload__tag { display: inline-flex; gap: 6px; align-items: center; height: 30px; padding-inline: 10px; border-radius: 99px; background: rgba(8,24,24,.5); color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.upload__tag .ico { width: 15px; height: 15px; color: #7fe3ef; }
.upload.is-loading::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--glow), transparent); animation: sweep 1.4s var(--ease-in-out) infinite; }

/* ---------- Trend tile (the video wall) ---------- */
.trend {
  position: relative; isolation: isolate; display: block; overflow: hidden;
  aspect-ratio: 9 / 16; border-radius: var(--radius-md); background: #0a1416;
  transform: translateZ(0);
}
.trend__media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 1.4s var(--ease), filter var(--dur-slow) var(--ease); }
.trend:hover .trend__media { transform: scale(1.05); }
.trend::after { /* scrim */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(3,14,16,.34) 0%, rgba(3,14,16,0) 22%, rgba(3,14,16,0) 52%, rgba(3,14,16,.86) 100%);
}
.trend__top { position: absolute; z-index: 2; inset-inline: 10px; top: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.trend__body { position: absolute; z-index: 2; inset-inline: 12px; bottom: 12px; display: grid; gap: 8px; color: #fff; }
.trend__name { font-family: var(--font-display); font-size: 16px; line-height: 22px; font-weight: 700; text-shadow: 0 1px 12px rgba(0,0,0,.35); }
.trend__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trend__cat { font-size: 12px; line-height: 16px; color: rgba(255,255,255,.72); }
.trend__stats { display: flex; gap: 10px; font-size: 11.5px; color: rgba(255,255,255,.78); font-variant-numeric: tabular-nums; }
.trend__stats span { display: inline-flex; gap: 4px; align-items: center; }
.trend__stats .ico { width: 13px; height: 13px; }
/* reference -> output: the input photo as a small inset, like the brief's reference */
.trend__ref { position: relative; width: 34px; height: 46px; flex: none; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 1.5px rgba(255,255,255,.85); }
.trend__ref img { width: 100%; height: 100%; object-fit: cover; }
/* hover CTA */
.trend__cta {
  position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.trend__cta .btn { opacity: 0; transform: translateY(10px) scale(.97); transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease); }
.trend:hover .trend__cta .btn, .trend:focus-visible .trend__cta .btn { opacity: 1; transform: none; }
.trend--placeholder { background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface-3) 10px 20px); }

/* masonry tile (videos people made) */
.mz { columns: 6; column-gap: var(--masonry-gap); }
.mz__tile { position: relative; overflow: hidden; break-inside: avoid; margin-block-end: var(--masonry-gap); border-radius: 12px; background: #0a1416; display: block; }
.mz__tile video, .mz__tile img { width: 100%; height: auto; display: block; transition: transform 1.4s var(--ease); }
.mz__tile:hover video, .mz__tile:hover img { transform: scale(1.04); }
.mz__by { position: absolute; inset-inline: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; color: #fff; font-size: 11.5px; opacity: 0; transform: translateY(4px); transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease); }
.mz__tile:hover .mz__by { opacity: 1; transform: none; }
.mz__tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 60%, rgba(3,14,16,.7)); opacity: 0; transition: opacity var(--dur-slow) var(--ease); pointer-events: none; }
.mz__tile:hover::after { opacity: 1; }
.mz__by { z-index: 1; }

/* ---------- Progress ---------- */
.progress { position: relative; height: 6px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden; direction: ltr; }
.progress--on-surface { background: var(--surface-3); }
.progress__fill { position: absolute; inset-block: 0; left: 0; width: var(--p, 40%); border-radius: inherit; background: linear-gradient(90deg, var(--liq-4), var(--glow)); transition: width 1.2s var(--ease); }
.progress__fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: sweep 2.2s var(--ease-in-out) infinite; }
.liquid .progress__fill { background: #fff; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- Generation card (My videos) ---------- */
.gen { position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 9 / 16; border-radius: var(--radius-md); background: #0a1416; color: #fff; display: block; }
.gen video, .gen > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 1.4s var(--ease); }
.gen:hover video { transform: scale(1.04); }
.gen::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(3,14,16,.3), transparent 25%, transparent 55%, rgba(3,14,16,.85)); }
.gen__top { position: absolute; z-index: 2; inset-inline: 10px; top: 10px; display: flex; justify-content: space-between; gap: 6px; }
.gen__body { position: absolute; z-index: 2; inset-inline: 12px; bottom: 12px; display: grid; gap: 10px; }
.gen__name { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; line-height: 22px; }
.gen__sub { font-size: 12px; color: rgba(255,255,255,.72); }
.gen__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gen--progress, .gen--queued { display: grid; place-items: center; }
.gen--progress::after, .gen--queued::after { display: none; }
.gen__center { position: relative; z-index: 2; display: grid; justify-items: center; gap: 12px; text-align: center; padding: 16px; }
.gen--queued { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.gen--queued .gen__sub { color: var(--text-muted); }
.gen--failed { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); display: grid; place-items: center; }
.gen--failed::after { display: none; }
.gen--failed .gen__sub { color: var(--text-muted); }
.gen__ref { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .22; filter: blur(14px) saturate(.8); transform: scale(1.1); }

/* ---------- Pack (token packs) ---------- */
.pack { position: relative; display: grid; gap: 6px; padding: 20px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); text-align: start; transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease); cursor: pointer; }
.pack:hover { box-shadow: inset 0 0 0 1px var(--line-strong); }
.pack__amt { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 30px; line-height: 40px; font-weight: 800; }
.pack__note { font-size: 13px; color: var(--text-muted); }
.pack__price { display: flex; justify-content: space-between; align-items: baseline; margin-block-start: 12px; padding-block-start: 14px; border-top: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.pack__price small { font-weight: 500; font-size: 12.5px; color: var(--text-muted); }
.pack__flag { position: absolute; top: 14px; inset-inline-end: 14px; }
.pack.liquid .pack__note, .pack.liquid .pack__price small { color: var(--on-liquid-2); }
.pack.liquid .pack__price { border-top-color: rgba(255,255,255,.2); }
.pack__check { position: absolute; top: 16px; inset-inline-end: 16px; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); display: grid; place-items: center; }
.pack.is-on .pack__check { background: #fff; color: var(--liq-3); box-shadow: none; }

/* ---------- Navigation ---------- */
.side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 4px; height: calc(100dvh - 32px); padding: 18px 14px; border-radius: var(--radius-xl); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; }
.side__group { display: grid; gap: 2px; }
.side__label { padding: 14px 12px 6px; font-size: 11.5px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.side__link { position: relative; display: flex; align-items: center; gap: 12px; height: 46px; padding-inline: 12px; border-radius: 14px; font-size: 14.5px; font-weight: 500; color: var(--text-2); transition: background-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease); }
.side__link .ico { width: 22px; height: 22px; color: var(--text-muted); transition: color var(--dur-base) var(--ease); }
.side__link:hover { background: var(--surface-2); color: var(--text); }
.side__link.is-on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.side__link.is-on .ico { color: var(--accent); }
.side__link.is-on::before { content: ""; position: absolute; inset-inline-start: 0; top: 13px; bottom: 13px; width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--glow), var(--liq-4)); }
.side__link .badge { margin-inline-start: auto; }
.side__foot { margin-block-start: auto; display: grid; gap: 10px; }
.side__balance { padding: 16px; border-radius: var(--radius-lg); display: grid; gap: 12px; }
.side__balance b { font-family: var(--font-display); font-size: 28px; line-height: 34px; font-weight: 800; display: flex; align-items: center; gap: 10px; }

.tabbar {
  position: fixed; z-index: 40; inset-inline: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; height: 68px; padding-inline: 6px;
  border-radius: 26px; background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tabbar__link { display: grid; justify-items: center; gap: 3px; font-size: 10.5px; font-weight: 500; color: var(--text-muted); }
.tabbar__link .ico { width: 24px; height: 24px; }
.tabbar__link.is-on { color: var(--text); font-weight: 600; }
.tabbar__link.is-on .ico { color: var(--accent); }
.tabbar__make { justify-self: center; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 20px; padding: 0; margin-top: -4px; }
.tabbar__make .ico { width: 26px; height: 26px; }

/* ---------- Sheet / modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--scrim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity var(--dur-slow) var(--ease); }
.overlay.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 61; left: 50%; top: 50%; width: min(440px, calc(100vw - 32px));
  transform: translate(-50%, -46%) scale(.98); opacity: 0; pointer-events: none;
  border-radius: var(--radius-2xl); overflow: hidden; background: var(--surface);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.sheet.is-open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.sheet__hero { padding: 26px 24px 24px; display: grid; gap: 6px; }
.sheet__hero h2 { font-family: var(--font-display); font-size: 24px; line-height: 34px; font-weight: 800; }
.sheet__hero p { font-size: 14px; line-height: 23px; }
.sheet__close { position: absolute; top: 16px; inset-inline-end: 16px; z-index: 2; }
.sheet__body { padding: 22px 24px 24px; display: grid; gap: 18px; }
.sheet__grab { display: none; }
@media (max-width: 640px) {
  .sheet { left: 0; right: 0; top: auto; bottom: 0; width: 100%; transform: translateY(100%); border-radius: var(--radius-2xl) var(--radius-2xl) 0 0; }
  .sheet.is-open { transform: none; }
  .sheet__grab { display: block; position: absolute; z-index: 2; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: rgba(255,255,255,.4); }
  .sheet__body { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ---------- Toast ---------- */
.toast { display: inline-flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 12px 10px 18px; border-radius: 18px; background: var(--text); color: var(--bg); font-size: 14px; }
.toast .ico { color: var(--glow); }

/* ---------- Lists / tables ---------- */
.rows { display: grid; }
.rows__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.rows__row:last-child { border-bottom: 0; }
.rows__ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; background: var(--surface-2); color: var(--text-2); }
.rows__main b { display: block; font-size: 14.5px; font-weight: 600; }
.rows__main small { display: block; font-size: 12.5px; color: var(--text-muted); }
.rows__end { font-weight: 700; font-variant-numeric: tabular-nums; text-align: end; }
.rows__end.plus { color: var(--success); }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 56px 24px; }
.empty__art { position: relative; width: 120px; height: 120px; border-radius: 36px; display: grid; place-items: center; margin-block-end: 8px; }
.empty__art svg { width: 54px; height: 54px; fill: #fff; }
.empty h3 { font-family: var(--font-display); font-size: 22px; line-height: 32px; font-weight: 700; }
.empty p { max-width: 340px; font-size: 14.5px; line-height: 24px; color: var(--text-muted); }

/* ---------- Avatar ---------- */
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 72px; height: 72px; font-size: 24px; }

/* ---------- Skeleton ---------- */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-md); }
.skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--surface) 70%, transparent), transparent); animation: sweep 1.6s var(--ease-in-out) infinite; }

/* ---------- Wordmark ---------- */
.wordmark { font-family: var(--font-display); font-weight: 800; letter-spacing: .01em; direction: ltr; line-height: 1; }

/* ---------- Motion: arrival ---------- */
.rise { animation: rise var(--dur-enter) var(--ease) both; }
.stagger > * { animation: rise var(--dur-enter) var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }   .stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; } .stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; } .stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 360ms; } .stagger > *:nth-child(8) { animation-delay: 420ms; }
.stagger > *:nth-child(9) { animation-delay: 480ms; } .stagger > *:nth-child(10) { animation-delay: 540ms; }
.stagger > *:nth-child(n+11) { animation-delay: 600ms; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .liquid::before, .liquid::after, .progress__fill::after, .skel::after, .upload.is-loading::after { animation: none; }
  .rise, .stagger > * { animation: none; }
  .trend:hover .trend__media, .mz__tile:hover video, .gen:hover video { transform: none; }
}

/* Liquid wins over any component's own background */
.liquid:is(.pack, .card, .gen, .side__balance, .empty__art, .upload, .stage, .rule__n) { background: linear-gradient(140deg, var(--liq-2) 0%, var(--liq-1) 38%, var(--liq-3) 100%); }
.wordmark, .t-display, .t-h1, .t-h2, .t-h3 { font-variant-numeric: normal; }

/* ---------- Prototype-only: theme switch ---------- */
.devbar { position: fixed; z-index: 90; left: 0; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 4px; padding: 5px; border-radius: 0 14px 14px 0; background: rgba(8,24,24,.72); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); opacity: .55; transition: opacity var(--dur-base) var(--ease); }
.devbar:hover { opacity: 1; }
.devbar button, .devbar a { appearance: none; border: 0; background: none; cursor: pointer; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: rgba(255,255,255,.85); }
.devbar button:hover, .devbar a:hover { background: rgba(255,255,255,.14); color: #fff; }
.devbar .ico { width: 16px; height: 16px; }
