/* ==========================================================================
   AI API Gateway — USER PANEL DESIGN SYSTEM ("pv")
   ==========================================================================
   Same language as the admin panel (admin-scale.css), plus the person's own
   appearance settings (AIAPI_Panel_Prefs). Rules:
     1. Tinted boxes: flat tint + ONE thin full border + dark same-hue text.
     2. No accent borders, no gradients, no glows.
     3. Everything is a token: the shell root carries data-pv-* attributes
        printed by the server (no flash), the tokens below react to them.
     4. Logical properties only (works in LTR and RTL).
   Settings -> attributes on .aiapi-shell:
     data-aiapi-theme  light|dark (resolved)   data-pv-preset   accent preset
     data-pv-radius    none|sm|md|lg|xl        data-pv-density  compact|default|comfortable
     data-pv-font-en   data-pv-font-fa         data-aiapi-lang  fa|en|ru
   Inter / Geist @font-face rules are printed by AIAPI_Panel_Prefs::font_face_css() only when the files exist.
   ========================================================================== */


/* ---------- 1. Tokens -------------------------------------------------- */

.aiapi-shell {
	/* neutral scale */
	--pv-bg: #f7f6f2; --pv-surface: #ffffff; --pv-soft: #f3f2ee; --pv-line: #e8e6df; --pv-ink: #171717; --pv-mute: #6f6c66;
	/* accent (preset) */
	--pv-accent: #2563eb; --pv-on-accent: #ffffff;
	/* tones: bg / border / text */
	--pv-green-bg: #e1f5e8; --pv-green-bd: #a4d9b6; --pv-green-tx: #0f4d27;
	--pv-blue-bg: #e2edff; --pv-blue-bd: #aac8f4; --pv-blue-tx: #1b3a85;
	--pv-violet-bg: #ede7ff; --pv-violet-bd: #c5b5f4; --pv-violet-tx: #45198c;
	--pv-rose-bg: #ffe6ea; --pv-rose-bd: #f2b0bc; --pv-rose-tx: #80102f;
	--pv-orange-bg: #ffebd9; --pv-orange-bd: #f2c197; --pv-orange-tx: #7a3400;
	--pv-slate-bg: #f3f2ee; --pv-slate-bd: #e0ddd5; --pv-slate-tx: #3a3834;
	/* shape + rhythm */
	--pv-r: 14px;
	--pv-d: 1;
	--pv-font-en: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--pv-font-fa: Vazirmatn, Sahel, "Yekan Bakh", Tahoma, sans-serif;
	--pv-header-h: calc(56px * var(--pv-d));
	background: var(--pv-bg);
	color: var(--pv-ink);
}
.aiapi-shell[data-aiapi-theme="dark"] {
	--pv-bg: #131312; --pv-surface: #1b1b19; --pv-soft: #242320; --pv-line: #2c2b28; --pv-ink: #f3f2ee; --pv-mute: #9c9a93;
	--pv-on-accent: #1a1405;
	--pv-green-bg: #0f2a1a; --pv-green-bd: #235a38; --pv-green-tx: #9be0b4;
	--pv-blue-bg: #10213f; --pv-blue-bd: #27487f; --pv-blue-tx: #a9c8ff;
	--pv-violet-bg: #221a3d; --pv-violet-bd: #43348a; --pv-violet-tx: #cdbfff;
	--pv-rose-bg: #3a1620; --pv-rose-bd: #7a2e40; --pv-rose-tx: #ffb9c6;
	--pv-orange-bg: #3a2108; --pv-orange-bd: #7a4a1a; --pv-orange-tx: #ffcfa0;
	--pv-slate-bg: #242320; --pv-slate-bd: #3a3935; --pv-slate-tx: #d6d3cb;
}

/* accent presets */
.aiapi-shell[data-pv-preset="yellow"] { --pv-accent: #f5b800; --pv-on-accent: #1a1405; }
.aiapi-shell[data-pv-preset="blue"]   { --pv-accent: #2563eb; --pv-on-accent: #ffffff; }
.aiapi-shell[data-pv-preset="purple"] { --pv-accent: #7c3aed; --pv-on-accent: #ffffff; }
.aiapi-shell[data-pv-preset="green"]  { --pv-accent: #059669; --pv-on-accent: #ffffff; }
.aiapi-shell[data-pv-preset="teal"]   { --pv-accent: #0d9488; --pv-on-accent: #ffffff; }
.aiapi-shell[data-pv-preset="rose"]   { --pv-accent: #e11d48; --pv-on-accent: #ffffff; }
.aiapi-shell[data-pv-preset="amber"]  { --pv-accent: #d97706; --pv-on-accent: #1a1405; }
.aiapi-shell[data-pv-preset="default"] { --pv-accent: #222222; --pv-on-accent: #ffffff; }
.aiapi-shell[data-pv-preset="default"][data-aiapi-theme="dark"] { --pv-accent: #e8e6df; --pv-on-accent: #171717; }
.aiapi-shell[data-pv-preset="custom"] { --pv-accent: var(--pv-custom, #f5b800); --pv-on-accent: var(--pv-custom-on, #1a1405); }
/* the accent as a tinted box (derived, so a custom colour just works) */
.aiapi-shell {
	--pv-accent-bg: color-mix(in srgb, var(--pv-accent) 15%, var(--pv-surface));
	--pv-accent-bd: color-mix(in srgb, var(--pv-accent) 42%, var(--pv-surface));
	--pv-accent-tx: color-mix(in srgb, var(--pv-accent) 38%, var(--pv-ink));
}
.aiapi-shell[data-aiapi-theme="dark"] {
	--pv-accent-bg: color-mix(in srgb, var(--pv-accent) 18%, var(--pv-surface));
	--pv-accent-bd: color-mix(in srgb, var(--pv-accent) 40%, var(--pv-surface));
	--pv-accent-tx: color-mix(in srgb, var(--pv-accent) 62%, var(--pv-ink));
}

/* corner radius / density */
.aiapi-shell[data-pv-radius="none"] { --pv-r: 0px; }
.aiapi-shell[data-pv-radius="sm"]   { --pv-r: 7px; }
.aiapi-shell[data-pv-radius="md"]   { --pv-r: 11px; }
.aiapi-shell[data-pv-radius="lg"]   { --pv-r: 14px; }
.aiapi-shell[data-pv-radius="xl"]   { --pv-r: 22px; }
.aiapi-shell { --pv-r-md: calc(var(--pv-r) * .85); --pv-r-sm: calc(var(--pv-r) * .6); --pv-r-pill: 999px; }
.aiapi-shell[data-pv-radius="none"] { --pv-r-pill: 0px; }
.aiapi-shell[data-pv-density="compact"]     { --pv-d: .84; }
.aiapi-shell[data-pv-density="comfortable"] { --pv-d: 1.16; }

/* fonts: Persian panel puts the Persian font first (it carries Latin too); other languages put the English font first */
.aiapi-shell[data-pv-font-en="inter"]  { --pv-font-en: Inter, system-ui, "Segoe UI", Roboto, sans-serif; }
.aiapi-shell[data-pv-font-en="geist"]  { --pv-font-en: Geist, system-ui, "Segoe UI", Roboto, sans-serif; }
.aiapi-shell[data-pv-font-en="system"] { --pv-font-en: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.aiapi-shell[data-pv-font-en="serif"]  { --pv-font-en: Georgia, "Times New Roman", serif; }
.aiapi-shell[data-pv-font-en="mono"]   { --pv-font-en: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.aiapi-shell[data-pv-font-fa="vazir"]  { --pv-font-fa: Vazirmatn, Sahel, Tahoma, sans-serif; }
.aiapi-shell[data-pv-font-fa="yekan"]  { --pv-font-fa: "Yekan Bakh", Vazirmatn, Tahoma, sans-serif; }
.aiapi-shell[data-pv-font-fa="sahel"]  { --pv-font-fa: Sahel, Vazirmatn, Tahoma, sans-serif; }
.aiapi-shell[data-pv-font-fa="system"] { --pv-font-fa: Tahoma, "Segoe UI", system-ui, sans-serif; }
.aiapi-shell { --pv-font: var(--pv-font-en), var(--pv-font-fa); }
.aiapi-shell[data-aiapi-lang="fa"] { --pv-font: var(--pv-font-fa), var(--pv-font-en); }
.aiapi-shell { font-family: var(--pv-font); }

/* ---------- 2. Bridge: the older tabs (wallet, plans, keys, chat …) follow the same tokens ------------------------- */
/* Each tab renders its own .aiapi-panel that re-declares the old --aiapi-* tokens, so the bridge targets both the shell
   and every nested panel, with higher specificity than the old dark/preset blocks. */

.aiapi-shell[data-pv-preset], .aiapi-shell[data-pv-preset] .aiapi-panel {
	--aiapi-font-family: var(--pv-font);
	--aiapi-background: var(--pv-bg);
	--aiapi-foreground: var(--pv-ink);
	--aiapi-foreground-secondary: var(--pv-mute);
	--aiapi-card: var(--pv-surface);
	--aiapi-card-border: var(--pv-line);
	--aiapi-card-border-strong: color-mix(in srgb, var(--pv-line) 70%, var(--pv-mute));
	--aiapi-muted: var(--pv-soft);
	--aiapi-muted-foreground: var(--pv-mute);
	--aiapi-muted-foreground-soft: color-mix(in srgb, var(--pv-mute) 70%, var(--pv-surface));
	--aiapi-input-bg: var(--pv-surface);
	--aiapi-primary: var(--pv-accent);
	--aiapi-primary-hover: color-mix(in srgb, var(--pv-accent) 86%, var(--pv-ink));
	--aiapi-primary-soft: var(--pv-accent-bg);
	--aiapi-primary-foreground: var(--pv-on-accent);
	--aiapi-focus-ring: 0 0 0 3px var(--pv-accent-bg);
	--aiapi-radius: var(--pv-r);
	--aiapi-radius-sm: var(--pv-r-md);
	--aiapi-radius-xs: var(--pv-r-sm);
	--aiapi-density-scale: var(--pv-d);
	--aiapi-shadow-xs: none; --aiapi-shadow-sm: none;
	--aiapi-shadow-md: 0 12px 32px -12px rgba(0,0,0,.28);
	--aiapi-success: var(--pv-green-tx); --aiapi-success-bg: var(--pv-green-bg); --aiapi-success-border: var(--pv-green-bd);
	--aiapi-danger: var(--pv-rose-tx);   --aiapi-danger-bg: var(--pv-rose-bg);   --aiapi-danger-border: var(--pv-rose-bd);
	--aiapi-info: var(--pv-blue-tx);     --aiapi-info-bg: var(--pv-blue-bg);     --aiapi-info-border: var(--pv-blue-bd);
	--aiapi-warning: var(--pv-orange-tx); --aiapi-warning-bg: var(--pv-orange-bg); --aiapi-warning-border: var(--pv-orange-bd);
}
.aiapi-shell[data-pv-preset] .aiapi-shell-header { background: var(--pv-surface); }
.aiapi-shell[data-pv-preset] .aiapi-sidebar { background: transparent; }
.aiapi-shell[data-pv-preset] .aiapi-tabs-nav .aiapi-tab-btn { border-radius: var(--pv-r-md); border: 1px solid transparent; box-shadow: none; }
.aiapi-shell[data-pv-preset] .aiapi-tabs-nav .aiapi-tab-btn.is-active { background: var(--pv-accent-bg); border-color: var(--pv-accent-bd); color: var(--pv-accent-tx); font-weight: 650; }
.aiapi-shell[data-pv-preset] .aiapi-tabs-nav .aiapi-tab-btn.is-active svg { color: var(--pv-accent-tx); }
.aiapi-shell[data-pv-preset] .aiapi-tabs-nav-group-title { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 11.5px; }
.aiapi-shell[data-pv-preset] .aiapi-btn-primary { background: var(--pv-accent); border-color: var(--pv-accent); color: var(--pv-on-accent); }
.aiapi-shell[data-pv-preset] .aiapi-avatar { border-radius: var(--pv-r-pill); }

/* the currency pair: show only the chosen one before any script runs */
.aiapi-shell[data-aiapi-currency="IRT"] [data-currency-group="USD"],
.aiapi-shell[data-aiapi-currency="USD"] [data-currency-group="IRT"] { display: none !important; }

/* ---------- 3. Shared components -------------------------------------- */

.pv-ov, .pv-drawer, .pv-modal { --pv-gap: calc(16px * var(--pv-d)); --pv-s1: calc(4px * var(--pv-d)); --pv-s2: calc(8px * var(--pv-d)); --pv-s3: calc(12px * var(--pv-d)); --pv-s4: calc(16px * var(--pv-d)); --pv-s5: calc(20px * var(--pv-d)); --pv-s6: calc(24px * var(--pv-d)); }
.pv-ov { display: block; min-width: 0; color: var(--pv-ink); font-family: var(--pv-font); transition: opacity .15s; }
/* Every block (header, alerts, tiles, KPIs, chart, lists) is a direct child of the mount, so the vertical rhythm lives HERE. */
.pv-ov > [data-pv-root] { display: flex; flex-direction: column; gap: var(--pv-gap); min-width: 0; }
.pv-ov.is-loading { opacity: .6; pointer-events: none; }
.pv-ov *, .pv-ov *::before, .pv-ov *::after, .pv-drawer *, .pv-modal * { box-sizing: border-box; }
.pv-ov h1, .pv-ov h2, .pv-ov h3, .pv-ov p { margin: 0; padding: 0; }
.pv-ov svg, .pv-drawer svg, .pv-modal svg { flex: none; }
.pv-ov bdi, .pv-num { unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.pv-ov small { font-size: 11.5px; color: var(--pv-mute); }
.pv-ov em { font-style: normal; font-size: .8em; opacity: .7; margin-inline-start: 3px; font-weight: 500; }

.pv-card { display: flex; flex-direction: column; background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-r); min-width: 0; }
.pv-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--pv-s3); flex-wrap: wrap; min-height: calc(var(--pv-s5) * 2 + 22px); padding: var(--pv-s4) var(--pv-s5) var(--pv-s3); }
.pv-ov .pv-card-head h2 { font-size: 14.5px; font-weight: 700; line-height: 1.35; }
.pv-sub { margin-top: 2px; font-size: 12px; color: var(--pv-mute); line-height: 1.6; }
.pv-card-bar { padding: 0 var(--pv-s5) var(--pv-s2); }

.pv-t-accent { --b: var(--pv-accent-bg); --d: var(--pv-accent-bd); --x: var(--pv-accent-tx); }
.pv-t-green  { --b: var(--pv-green-bg);  --d: var(--pv-green-bd);  --x: var(--pv-green-tx); }
.pv-t-blue   { --b: var(--pv-blue-bg);   --d: var(--pv-blue-bd);   --x: var(--pv-blue-tx); }
.pv-t-violet { --b: var(--pv-violet-bg); --d: var(--pv-violet-bd); --x: var(--pv-violet-tx); }
.pv-t-rose   { --b: var(--pv-rose-bg);   --d: var(--pv-rose-bd);   --x: var(--pv-rose-tx); }
.pv-t-orange { --b: var(--pv-orange-bg); --d: var(--pv-orange-bd); --x: var(--pv-orange-tx); }
.pv-t-slate  { --b: var(--pv-slate-bg);  --d: var(--pv-slate-bd);  --x: var(--pv-slate-tx); }
.pv-box { background: var(--b, var(--pv-slate-bg)); border: 1px solid var(--d, var(--pv-slate-bd)); color: var(--x, var(--pv-slate-tx)); border-radius: var(--pv-r); min-width: 0; }
.pv-box small { color: inherit; opacity: .78; }

.pv-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: var(--pv-r-pill); font-size: 11.5px; font-weight: 650; line-height: 1.7; white-space: nowrap; background: var(--b, var(--pv-slate-bg)); border: 1px solid var(--d, var(--pv-slate-bd)); color: var(--x, var(--pv-slate-tx)); }
.pv-pill > i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.pv-tabs { display: inline-flex; gap: 3px; padding: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); }
.pv-tabs::-webkit-scrollbar { display: none; }
.pv-tabs button { appearance: none; font: inherit; font-size: 12.5px; font-weight: 500; line-height: 1.6; padding: 4px 12px; border-radius: var(--pv-r-sm); border: 1px solid transparent; background: none; color: var(--pv-mute); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s; }
.pv-tabs button:hover { color: var(--pv-ink); }
.pv-tabs button.is-active { background: var(--pv-accent-bg); border-color: var(--pv-accent-bd); color: var(--pv-accent-tx); font-weight: 650; }
.pv-tabs.is-soft { background: var(--pv-soft); }
.pv-tabs.is-soft button.is-active { background: var(--pv-surface); border-color: var(--pv-line); color: var(--pv-ink); }

.pv-btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 12.5px; font-weight: 650; line-height: 1.6; padding: 5px 14px; border-radius: var(--pv-r-sm); border: 1px solid var(--pv-line); background: var(--pv-surface); color: var(--pv-ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: filter .12s, border-color .12s; }
.pv-btn:hover { border-color: color-mix(in srgb, var(--pv-line) 55%, var(--pv-mute)); }
.pv-btn.is-primary { background: var(--pv-accent); border-color: var(--pv-accent); color: var(--pv-on-accent); }
.pv-btn.is-primary:hover { filter: brightness(.96); }
.pv-btn.is-tint { background: var(--pv-accent-bg); border-color: var(--pv-accent-bd); color: var(--pv-accent-tx); }
.pv-btn[disabled] { opacity: .55; cursor: default; }
.pv-btn svg { width: 14px; height: 14px; }
.pv-icon-btn { appearance: none; width: 28px; height: 28px; display: inline-grid; place-items: center; padding: 0; border-radius: var(--pv-r-sm); border: 1px solid transparent; background: none; color: inherit; cursor: pointer; opacity: .75; }
.pv-icon-btn:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }
.pv-icon-btn svg { width: 15px; height: 15px; }
.pv-ov :focus-visible, .pv-drawer :focus-visible, .pv-modal :focus-visible { outline: 2px solid var(--pv-accent); outline-offset: 2px; }

.pv-ico { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--pv-r-sm); background: var(--pv-surface); border: 1px solid var(--d, var(--pv-line)); color: var(--x, var(--pv-ink)); }
.pv-ico svg { width: 16px; height: 16px; }

.pv-bar { height: 7px; overflow: hidden; background: var(--pv-soft); border: 1px solid var(--pv-line); border-radius: var(--pv-r-pill); }
.pv-bar > i { display: block; height: 100%; min-width: 3px; border-radius: var(--pv-r-pill); background: var(--pv-accent); transition: width .35s ease; }
.pv-bar.is-green > i { background: var(--pv-green-bd); } .pv-bar.is-orange > i { background: var(--pv-orange-bd); } .pv-bar.is-rose > i { background: var(--pv-rose-bd); }
.pv-bar.is-thin { height: 5px; border: 0; }

.pv-empty { padding: 26px var(--pv-s5); text-align: center; font-size: 13px; color: var(--pv-mute); }
.pv-skel { border-radius: var(--pv-r); background: var(--pv-soft); min-height: 96px; animation: pv-pulse 1.3s ease-in-out infinite; }
@keyframes pv-pulse { 50% { opacity: .55; } }

/* ---------- 4. Overview ------------------------------------------------ */

.pv-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--pv-s3) var(--pv-s5); padding: var(--pv-s1) 0 var(--pv-s1); }
.pv-ov .pv-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.pv-ov .pv-head p { margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--pv-mute); }

.pv-strips { display: flex; flex-direction: column; gap: var(--pv-s2); }
.pv-strips:empty { display: none; }
.pv-strip { display: flex; align-items: center; gap: var(--pv-s3); padding: 9px 12px; font-size: 13px; }
.pv-strip .pv-ico { width: 28px; height: 28px; }
.pv-strip-t { flex: 1; min-width: 0; line-height: 1.55; }
.pv-strip-t b { font-weight: 650; }
.pv-strip .pv-btn { padding: 2px 11px; }
.pv-plan { align-items: flex-start; }
.pv-plan .pv-strip-t { font-size: 13px; }
.pv-plan-sub { display: inline-block; margin-top: 2px; font-size: 12px; color: var(--pv-mute); }
.pv-ov .pv-notice.aiapi-nl-item { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: var(--pv-s3); padding: 9px 12px; cursor: pointer; font: inherit; font-size: 13px; width: 100%; background: var(--pv-blue-bg); border: 1px solid var(--pv-blue-bd); color: var(--pv-blue-tx); border-radius: var(--pv-r); }
.pv-ov .pv-notice.aiapi-nl-item:focus-visible { outline: 2px solid var(--pv-accent); outline-offset: 2px; }
.pv-notice .pv-strip-t { text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pv-money { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--pv-gap); }
.pv-money > .pv-skel, .pv-kpis > .pv-skel { min-height: 148px; }
.pv-money[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pv-money[data-n="1"] { grid-template-columns: minmax(0, 1fr); }
.pv-tile { display: flex; flex-direction: column; gap: 4px; padding: var(--pv-s5); }
.pv-tile-top { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.pv-tile-label { flex: 1; min-width: 0; font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-tile-val { margin-top: var(--pv-s2); font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-tile-val.is-text { font-size: 18px; white-space: normal; }
.pv-tile-val small { font-size: 12px; font-weight: 500; opacity: .7; margin-inline-start: 4px; color: inherit; }
.pv-tile-sub { font-size: 12px; opacity: .85; line-height: 1.55; min-height: 18px; }
.pv-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--pv-s2); flex-wrap: wrap; margin-top: auto; padding-top: var(--pv-s3); min-height: calc(var(--pv-s3) + 30px); }
.pv-tile .pv-bar { margin-top: var(--pv-s2); background: var(--pv-surface); border-color: var(--d); }
.pv-ov .pv-unit { margin-inline-start: 4px; font-size: 12px; font-weight: 500; opacity: .7; color: inherit; white-space: nowrap; }
.pv-ov .pv-dot { margin-inline: .45em; opacity: .5; }
.pv-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pv-chip { display: inline-flex; align-items: center; gap: 5px; padding-block: 1px; padding-inline: 4px 9px; border-radius: var(--pv-r-pill); background: var(--pv-surface); border: 1px solid var(--d, var(--pv-line)); font-size: 11.5px; max-width: 100%; }
.pv-chip img { width: 15px; height: 15px; object-fit: contain; border-radius: 4px; }
.pv-chip.is-more { padding-inline: 9px; }
.pv-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }

/* ---------- Finance cards: Wallet + Free allowance (Overview) ---------------
   Tinted card surface + a faint line-art SVG watermark; flat colour only (no gradients, no side rails). Every colour is a token, so light/dark, the accent preset,
   radius, density, font and RTL/LTR all apply on their own. Free allowance has its own hue (emerald),
   which swaps to violet when the accent preset is itself green/teal so the two cards never blend. */
.pv-ov { --pv-free-bg: #e4f6ee; --pv-free-bd: #a8dcc3; --pv-free-tx: #0d5138; --pv-free-solid: #12915f; }
.aiapi-shell[data-pv-preset="green"] .pv-ov, .aiapi-shell[data-pv-preset="teal"] .pv-ov { --pv-free-bg: #ede7ff; --pv-free-bd: #c5b5f4; --pv-free-tx: #45198c; --pv-free-solid: #7c4ddb; }
.aiapi-shell[data-aiapi-theme="dark"] .pv-ov { --pv-free-bg: #0f2b21; --pv-free-bd: #25604a; --pv-free-tx: #9ee3c4; --pv-free-solid: #3fc99a; }
.aiapi-shell[data-pv-preset="green"][data-aiapi-theme="dark"] .pv-ov, .aiapi-shell[data-pv-preset="teal"][data-aiapi-theme="dark"] .pv-ov { --pv-free-bg: #221a3d; --pv-free-bd: #43348a; --pv-free-tx: #cdbfff; --pv-free-solid: #a78bfa; }

.pv-fin { --c-bg: var(--pv-slate-bg); --c-bd: var(--pv-slate-bd); --c-tx: var(--pv-slate-tx); --c-solid: var(--pv-mute); position: relative; display: flex; flex-direction: column; gap: var(--pv-s4); padding: var(--pv-s5); min-width: 0; overflow: hidden; isolation: isolate; background: var(--c-bg); border: 1px solid var(--c-bd); border-radius: var(--pv-r); color: var(--pv-ink); }
.pv-fin > :not(.pv-fin-art) { position: relative; z-index: 1; }
.pv-fin-art { position: absolute; z-index: 0; inset-inline-end: calc(var(--pv-s4) * -.5); top: 54px; width: 170px; height: 170px; color: var(--c-tx); opacity: .11; pointer-events: none; }
.pv-fin-art svg { display: block; width: 100%; height: 100%; }
.pv-fin-wallet.is-ok  { --c-bg: var(--pv-accent-bg); --c-bd: var(--pv-accent-bd); --c-tx: var(--pv-accent-tx); --c-solid: var(--pv-accent); }
.pv-fin-free.is-ok    { --c-bg: var(--pv-free-bg);   --c-bd: var(--pv-free-bd);   --c-tx: var(--pv-free-tx);   --c-solid: var(--pv-free-solid); }
.pv-fin.is-low        { --c-bg: var(--pv-orange-bg); --c-bd: var(--pv-orange-bd); --c-tx: var(--pv-orange-tx); --c-solid: color-mix(in srgb, var(--pv-orange-tx) 55%, var(--pv-orange-bd)); }
.pv-fin.is-empty      { --c-bg: var(--pv-rose-bg);   --c-bd: var(--pv-rose-bd);   --c-tx: var(--pv-rose-tx);   --c-solid: color-mix(in srgb, var(--pv-rose-tx) 55%, var(--pv-rose-bd)); }

.pv-fin-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pv-fin-ico { flex: none; width: 36px; height: 36px; display: grid; place-items: center; background: var(--pv-surface); border: 1px solid var(--c-bd); border-radius: var(--pv-r-md); color: var(--c-tx); }
.pv-fin-ico svg { width: 18px; height: 18px; }
.pv-fin-title { flex: 1; min-width: 0; margin: 0; font-size: 13.5px; font-weight: 650; line-height: 1.4; color: var(--pv-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-fin-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; background: var(--pv-surface); border: 1px solid var(--c-bd); border-radius: var(--pv-r-pill); color: var(--c-tx); font-size: 11.5px; font-weight: 650; line-height: 1.7; white-space: nowrap; }
.pv-fin-pill > i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pv-fin-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pv-fin-val { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-fin-val .pv-unit { margin-inline-start: 6px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--c-tx); opacity: .75; }
.pv-fin-of { margin-inline-start: 6px; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--c-tx); opacity: .75; }
.pv-fin-meta { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; line-height: 1.5; color: var(--c-tx); }
.pv-fin-meta > span { opacity: .8; }
.pv-fin-meta svg { flex: none; width: 14px; height: 14px; }
.pv-fin-pct { margin-inline-start: auto; padding-inline-start: var(--pv-s2); font-weight: 650; font-variant-numeric: tabular-nums; color: var(--pv-ink); }
.pv-meter { height: 8px; margin-top: 6px; overflow: hidden; background: var(--pv-surface); border: 1px solid var(--c-bd); border-radius: var(--pv-r-pill); }
.pv-meter > i { display: block; height: 100%; min-width: 6px; background: var(--c-solid); border-radius: inherit; transition: width .35s ease; }

.pv-fin-foot { display: flex; align-items: center; margin-top: auto; padding-top: var(--pv-s4); gap: var(--pv-s2); min-height: calc(var(--pv-s4) + 42px); box-sizing: content-box; border-top: 1px solid var(--c-bd); }
.pv-fin-btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1 1 0; min-width: 0; padding: 9px 16px; font: inherit; font-size: 13px; font-weight: 650; line-height: 1.5; background: var(--pv-accent); border: 1px solid var(--pv-accent); border-radius: var(--pv-r-sm); color: var(--pv-on-accent); cursor: pointer; transition: filter .12s, transform .06s; }
.pv-fin-btn:hover { filter: brightness(.94); }
.pv-fin-btn:active { transform: translateY(1px); }
.pv-fin-btn svg { width: 15px; height: 15px; }
.pv-fin-btn.is-ghost { background: var(--pv-surface); border-color: var(--c-bd); color: var(--pv-ink); }
.pw-top.is-solo .pv-fin-val { font-size: 36px; }
.pw-top.is-solo .pv-fin-btn { flex: 0 0 auto; min-width: 180px; }
.pw-top .pv-fin { height: 100%; }
@media (max-width: 720px) { .pw-top.is-solo .pv-fin-btn { flex: 1 1 0; min-width: 0; } }
.pv-fin .pv-chips { gap: 8px; padding-block: 2px; }
.pv-fin .pv-chip { appearance: none; margin: 0; font: inherit; font-size: 12px; font-weight: 650; line-height: 1.4; padding-block: 4px; padding-inline: 5px 13px; background: var(--c-bg); border: 1px solid var(--c-bd); color: var(--c-tx); cursor: pointer; transition: background-color .12s, transform .06s; }
.pv-fin .pv-chip:hover { background: color-mix(in srgb, var(--c-tx) 9%, var(--c-bg)); }
.pv-fin .pv-chip:focus-visible { outline: 2px solid var(--c-tx); outline-offset: 2px; }
.pv-fin .pv-chip:active { transform: translateY(1px); }
.pv-chip-ico { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; background: #fff; border: 1px solid var(--c-bd, var(--pv-line)); border-radius: 50%; box-sizing: border-box; }
.pv-fin .pv-chip .pv-chip-ico img { width: 14px; height: 14px; padding: 0; background: none; border: 0; border-radius: 0; }
.pv-fin .pv-chip.is-more { padding-inline: 13px; }

/* Free models dialog */
.pv-fm { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--pv-s2); }
.pv-fm-row { display: flex; align-items: center; gap: var(--pv-s3); padding: var(--pv-s2) var(--pv-s3); background: var(--pv-soft); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); }
.pv-fm-logo { flex: none; width: 34px; height: 34px; display: grid; place-items: center; background: #fff; border: 1px solid var(--pv-line); border-radius: var(--pv-r-sm); }
.pv-fm-logo img { width: 22px; height: 22px; object-fit: contain; }
.pv-fm-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pv-fm-t b { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-fm-t small { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }

.pv-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--pv-gap); }
.pv-kpi { display: flex; flex-direction: column; gap: 2px; padding: var(--pv-s5) var(--pv-s5) 0; overflow: hidden; background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-r); }
.pv-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pv-kpi-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 650; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pv-kpi-label svg { width: 15px; height: 15px; color: var(--pv-mute); }
.pv-kpi-val { margin-top: var(--pv-s2); font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-kpi-sub { min-height: 18px; font-size: 12px; color: var(--pv-mute); }
.pv-spark { height: 44px; margin: auto calc(var(--pv-s5) * -1) 0; padding-top: var(--pv-s3); box-sizing: content-box; }
.pv-spark svg { width: 100%; height: 44px; display: block; }
.pv-spark path.l { fill: none; stroke: var(--pv-ink); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.pv-spark path.a { fill: var(--pv-ink); opacity: .07; }
.pv-delta { display: inline-flex; align-items: center; gap: 3px; padding: 0 8px; border-radius: var(--pv-r-pill); font-size: 11px; font-weight: 700; line-height: 1.7; white-space: nowrap; background: var(--b, var(--pv-slate-bg)); border: 1px solid var(--d, var(--pv-slate-bd)); color: var(--x, var(--pv-slate-tx)); }
.pv-delta svg { width: 11px; height: 11px; }

.pv-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--pv-gap); align-items: stretch; }
.pv-side { display: flex; flex-direction: column; gap: var(--pv-gap); min-width: 0; }
/* When the chart card is taller than the side cards, the last side card grows to the same bottom edge instead of leaving a gap. */
.pv-side > .pv-card:last-child { flex: 1 1 auto; }
.pv-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pv-gap); align-items: stretch; }
/* The chart card is as tall as the side column next to it; the chart itself takes all the room that is left. */
.pv-card-chart { align-self: stretch; }
.pv-chart-wrap { flex: 1; display: flex; min-height: 300px; padding: var(--pv-s1) var(--pv-s5) var(--pv-s5); }
.pv-chart { position: relative; flex: 1; min-width: 0; min-height: 260px; max-height: 640px; }
.pv-chart svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }
.pv-chart .g { stroke: var(--pv-line); stroke-dasharray: 3 5; }
.pv-chart .g.is-base { stroke-dasharray: none; }
.pv-chart .t { fill: var(--pv-mute); font-size: 11px; font-family: var(--pv-font); }
.pv-chart .area { fill: var(--pv-accent); opacity: .14; }
.pv-chart .line { fill: none; stroke: var(--pv-accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pv-chart .cur { stroke: var(--pv-mute); stroke-dasharray: 2 3; opacity: 0; }
.pv-chart .dot { fill: var(--pv-surface); stroke: var(--pv-accent); stroke-width: 2; opacity: 0; }
.pv-chart.is-hover .cur, .pv-chart.is-hover .dot { opacity: 1; }
.pv-tip { position: absolute; z-index: 2; pointer-events: none; min-width: 120px; padding: 7px 10px; font-size: 12px; line-height: 1.5; background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-r-sm); box-shadow: 0 8px 24px -10px rgba(0,0,0,.3); opacity: 0; transition: opacity .1s; }
.pv-chart.is-hover .pv-tip { opacity: 1; }
.pv-tip b { display: block; font-size: 13px; }
.pv-tip span { color: var(--pv-mute); }
.pv-chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--pv-mute); font-size: 13px; pointer-events: none; }

.pv-rows { list-style: none; flex: 1; margin: 0; padding: 0 var(--pv-s5) var(--pv-s2); }
.pv-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; column-gap: var(--pv-s3); row-gap: 6px; padding: var(--pv-s3) 0; }
.pv-row + .pv-row { border-top: 1px solid var(--pv-line); }
.pv-logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--pv-r-sm); background: var(--pv-soft); border: 1px solid var(--pv-line); overflow: hidden; }
.pv-logo img { width: 21px; height: 21px; object-fit: contain; }
.pv-logo.is-ok { background: var(--pv-green-bg); border-color: var(--pv-green-bd); color: var(--pv-green-tx); }
.pv-logo.is-bad { background: var(--pv-rose-bg); border-color: var(--pv-rose-bd); color: var(--pv-rose-tx); }
.pv-logo svg { width: 15px; height: 15px; }
.pv-row-t { min-width: 0; display: flex; flex-direction: column; text-align: start; }
.pv-row-t b { font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-row-t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-row-v { font-size: 13px; font-weight: 700; white-space: nowrap; text-align: end; }
.pv-row-v .pv-unit { font-size: 11px; margin-inline-start: 3px; }
.pv-row-v small { display: block; font-weight: 500; }
.pv-row .pv-bar { grid-column: 2 / -1; }
.pv-foot { padding: 0 var(--pv-s5) var(--pv-s4); display: flex; justify-content: flex-end; }

.pv-list { list-style: none; margin: 0; padding: var(--pv-s2) var(--pv-s3) var(--pv-s3); display: flex; flex-direction: column; gap: 6px; }
/* inset rows: the row's own padding + the list inset add up to the card's padding, so icons line up with the title above */
.pv-step { display: flex; align-items: center; gap: 10px; width: 100%; padding: var(--pv-s2) calc(var(--pv-s5) - var(--pv-s3)); text-align: start; font: inherit; font-size: 13px; color: inherit; background: var(--pv-soft); border: 1px solid transparent; border-radius: var(--pv-r-md); cursor: pointer; appearance: none; }
.pv-step:hover { border-color: var(--pv-line); }
.pv-step .pv-ico { width: 26px; height: 26px; border-radius: var(--pv-r-pill); }
.pv-step.is-done { opacity: .6; }
.pv-step.is-done .pv-ico { background: var(--pv-green-bg); border-color: var(--pv-green-bd); color: var(--pv-green-tx); }
.pv-step.is-done .pv-step-t { text-decoration: line-through; }
.pv-step-t { flex: 1; min-width: 0; font-weight: 600; line-height: 1.4; }
.pv-step small { display: block; font-weight: 400; text-decoration: none; }
.pv-seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--pv-surface); border: 1px solid var(--d, var(--pv-line)); border-radius: var(--pv-r-md); }
.pv-seg button { appearance: none; font: inherit; font-size: 12px; font-weight: 600; padding: 2px 10px; border: 0; border-radius: var(--pv-r-sm); background: none; color: inherit; opacity: .7; cursor: pointer; }
.pv-seg button.is-active { opacity: 1; background: var(--b); box-shadow: inset 0 0 0 1px var(--d); }
.pv-reward { padding: var(--pv-s1) var(--pv-s5) var(--pv-s5); display: flex; flex-direction: column; gap: var(--pv-s3); }
.pv-reward.is-flush { padding-top: 0; padding-inline: var(--pv-s3); padding-bottom: var(--pv-s3); }
.pv-reward + .pv-reward.is-flush { margin-top: calc(var(--pv-s3) * -1); }
.pv-btn-amt { display: inline-flex; align-items: center; margin-inline-start: 2px; padding-inline-start: 10px; border-inline-start: 1px solid color-mix(in srgb, currentColor 32%, transparent); }
.pv-btn .pv-unit { font-size: 11.5px; opacity: .85; margin-inline-start: 3px; }
.pv-reward-top { display: flex; align-items: center; gap: var(--pv-s3); }
.pv-reward-top small { display: block; margin-top: 1px; }
.pv-reward-top strong { display: block; font-size: 14.5px; line-height: 1.35; }
.pv-code { display: flex; direction: ltr; align-items: center; gap: 6px; padding: 5px 5px 5px 12px; background: var(--pv-soft); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); }
.pv-code code { flex: 1; min-width: 0; direction: ltr; text-align: left; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pv-ink); background: none; padding: 0; }
.pv-side-body { padding: var(--pv-s1) var(--pv-s5) var(--pv-s5); display: flex; flex-direction: column; gap: var(--pv-s3); }
.pv-side-body > div > small { display: block; margin-bottom: 6px; }
.pv-side-body .pv-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 5. Modal ---------------------------------------------------- */

.pv-modal { position: fixed; inset: 0; z-index: 100000; display: none; align-items: center; justify-content: center; padding: var(--pv-s4); font-family: var(--pv-font); color: var(--pv-ink); }
.pv-modal.is-open { display: flex; }
.pv-modal-bg { position: absolute; inset: 0; background: rgba(15,15,14,.5); }
.pv-modal-box { position: relative; width: min(560px, 100%); max-height: min(86vh, 720px); display: flex; flex-direction: column; background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: calc(var(--pv-r) * 1.15); box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); overflow: hidden; animation: pv-pop .16s ease-out; }
@keyframes pv-pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }
.pv-modal-head { display: flex; align-items: center; gap: 10px; padding: var(--pv-s4) var(--pv-s5); border-bottom: 1px solid var(--pv-line); }
.pv-modal-head h3 { flex: 1; margin: 0; font-size: 15px; font-weight: 700; }
.pv-modal-body { padding: var(--pv-s4) var(--pv-s5) var(--pv-s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--pv-s3); }
.pv-modal pre { margin: 0; padding: 12px 14px; direction: ltr; text-align: left; overflow-x: auto; font: 12px/1.65 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--pv-soft); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); color: var(--pv-ink); white-space: pre; }

/* ---------- 6. Theme drawer -------------------------------------------- */

.aiapi-shell .aiapi-theme-drawer, .aiapi-shell .aiapi-theme-drawer-overlay { display: none !important; }
.pv-drawer-bg { position: fixed; inset: 0; z-index: 99998; background: rgba(15,15,14,.45); opacity: 0; pointer-events: none; transition: opacity .18s; }
.pv-drawer { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 99999; width: min(380px, 100vw); display: flex; flex-direction: column; background: var(--pv-surface); color: var(--pv-ink); font-family: var(--pv-font); border-inline-start: 1px solid var(--pv-line); transform: translateX(105%); transition: transform .2s ease; visibility: hidden; }
.pv-drawer[dir="rtl"] { transform: translateX(-105%); }
body.pv-drawer-open .pv-drawer { transform: none; visibility: visible; }
body.pv-drawer-open .pv-drawer-bg { opacity: 1; pointer-events: auto; }
.pv-drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: var(--pv-s4) var(--pv-s5); border-bottom: 1px solid var(--pv-line); }
.pv-drawer-head div { flex: 1; min-width: 0; }
.pv-drawer-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.pv-drawer-head p { margin: 2px 0 0; font-size: 12px; color: var(--pv-mute); line-height: 1.55; }
.pv-drawer-body { flex: 1; overflow-y: auto; padding: var(--pv-s4) var(--pv-s5); display: flex; flex-direction: column; gap: var(--pv-s5); }
.pv-drawer-foot { padding: var(--pv-s3) var(--pv-s5); border-top: 1px solid var(--pv-line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pv-set > label, .pv-set-title { display: block; margin-bottom: 8px; font-size: 12.5px; font-weight: 650; }
.pv-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; }
.pv-opt { appearance: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 52px; padding: 8px 6px; font: inherit; font-size: 12px; font-weight: 600; color: var(--pv-ink); background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); cursor: pointer; text-align: center; transition: border-color .12s, background .12s; }
.pv-opt:hover { border-color: color-mix(in srgb, var(--pv-line) 50%, var(--pv-mute)); }
.pv-opt[aria-checked="true"] { background: var(--pv-accent-bg); border-color: var(--pv-accent-bd); color: var(--pv-accent-tx); }
.pv-opt svg { width: 17px; height: 17px; }
.pv-opt .g { font-size: 17px; line-height: 1; }
.pv-sw { width: 22px; height: 22px; border-radius: 50%; background: var(--c); border: 1px solid rgba(0,0,0,.12); }
.pv-opt-r { width: 26px; height: 26px; border: 2px solid currentColor; border-inline-end: 0; border-block-end: 0; border-start-start-radius: var(--rr); opacity: .8; }
.pv-opt-d { display: flex; flex-direction: column; gap: var(--g); width: 26px; }
.pv-opt-d i { height: 4px; border-radius: 2px; background: currentColor; opacity: .75; }
/* Custom colour card — --cc / --cc-on are set by pv-theme.js (and printed by pv-drawer.php) so the swatch, the
   hex field and the live preview all follow the picked colour. */
.pv-custom { --cc: var(--pv-accent); --cc-on: #fff; display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 12px; background: var(--pv-soft); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); transition: border-color .15s, background .15s, box-shadow .15s; }
.pv-custom[hidden] { display: none; }
@keyframes pv-custom-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pv-custom:not([hidden]) { animation: pv-custom-in .18s ease-out; }
@media (prefers-reduced-motion: reduce) { .pv-custom:not([hidden]) { animation: none; } }
.pv-custom.is-on { background: color-mix(in srgb, var(--cc) 8%, var(--pv-surface)); border-color: color-mix(in srgb, var(--cc) 55%, var(--pv-line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cc) 14%, transparent); }
.pv-custom-pick { position: relative; flex: none; display: block; width: 46px; height: 46px; cursor: pointer; }
.pv-custom-pick input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.pv-custom-sw { display: grid; place-items: center; width: 100%; height: 100%; border-radius: var(--pv-r-sm); background: var(--cc); color: var(--cc-on); box-shadow: inset 0 0 0 1px rgba(0,0,0,.14), inset 0 -10px 16px -10px rgba(0,0,0,.28), 0 1px 2px rgba(0,0,0,.12); transition: transform .12s, background .1s; pointer-events: none; }
.pv-custom-pick:hover .pv-custom-sw { transform: scale(1.04); }
.pv-custom-pick:focus-within .pv-custom-sw { outline: 2px solid var(--cc); outline-offset: 3px; }
.pv-custom-body { flex: 1; min-width: 0; }
.pv-custom-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.pv-custom-head b { font-size: 12.5px; font-weight: 700; }
.pv-custom .pv-custom-hex { width: 88px; height: 26px; margin: 0; padding: 0 8px; box-sizing: border-box; text-align: center; text-transform: uppercase; letter-spacing: .04em; font: 600 12px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--pv-ink); background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: calc(var(--pv-r-sm) * .8); box-shadow: none; outline: 0; }
.pv-custom .pv-custom-hex:focus { border-color: var(--cc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cc) 22%, transparent); }
.pv-custom .pv-custom-hex.is-bad { border-color: var(--pv-rose-bd); background: var(--pv-rose-bg); color: var(--pv-rose-tx); }
.pv-custom-body p { margin: 0; font-size: 11.5px; line-height: 1.6; color: var(--pv-mute); }
.pv-custom-prev { flex: none; display: flex; flex-direction: column; gap: 4px; }
.pv-custom-prev i { display: grid; place-items: center; min-width: 38px; height: 20px; padding: 0 8px; font: 700 11px/1 var(--pv-font); font-style: normal; border-radius: 999px; transition: background .1s, color .1s; }
.pv-custom-prev .is-solid { background: var(--cc); color: var(--cc-on); }
.pv-custom-prev .is-soft { background: color-mix(in srgb, var(--cc) 16%, var(--pv-surface)); color: color-mix(in srgb, var(--cc) 45%, var(--pv-ink)); border: 1px solid color-mix(in srgb, var(--cc) 40%, var(--pv-surface)); }
@media (max-width: 360px) { .pv-custom-prev { display: none; } }

/* ---------- 7. Responsive ----------------------------------------------- */

@media (max-width: 1280px) { .pv-main { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 1100px) {
	.pv-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.pv-money { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.pv-main, .pv-cols { grid-template-columns: minmax(0, 1fr); }
	.pv-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--pv-gap); align-items: stretch; }
	.pv-money[data-n="3"] > :last-child { grid-column: 1 / -1; }
	.pv-chart-wrap { min-height: 320px; }
}
@media (max-width: 782px) { .pv-ov .pv-head h1 { font-size: 21px; } .pv-head .pv-tabs { width: 100%; } }
@media (max-width: 720px) {
	/* The [data-n] variants must be listed too: .pv-money[data-n="2"] (0,2,0) otherwise beats a bare .pv-money (0,1,0) and keeps Wallet + Free allowance side by side on phones. */
	.pv-money, .pv-money[data-n], .pv-side { grid-template-columns: minmax(0, 1fr); }
	.pv-money[data-n="3"] > :last-child { grid-column: auto; }
	.pv-chart-wrap { padding-inline: var(--pv-s3); min-height: 260px; }
	.pv-chart { min-height: 220px; }
	.pv-rows { padding-inline: var(--pv-s4); }
	.pv-modal { align-items: flex-end; padding: 0; }
	.pv-modal-box { width: 100%; max-height: 88vh; border-end-start-radius: 0; border-end-end-radius: 0; }
}
@media (max-width: 480px) { .pv-fin { padding: var(--pv-s4); } }
@media (prefers-reduced-motion: reduce) { .pv-ov *, .pv-drawer, .pv-modal *, .pv-drawer-bg { animation: none !important; transition: none !important; } }
[dir="rtl"] .pv-fm-t small { text-align: right; }


/* Logo tiles: white in light mode, dark in dark mode. The auto-dark rule (panel.css) turns flat-black provider logos white
   there, so the tile must be dark or they would be white-on-white. The tile is a wrapper: a filter on the <img> itself
   would invert its own background too. */
.aiapi-shell[data-aiapi-theme="dark"] .pv-chip-ico,
.aiapi-shell[data-aiapi-theme="dark"] .pv-fm-logo { background: var(--pv-soft); }

/* ---------- 8. Polish: empty states, KPI cards without data, reward button ---------- */

/* `.pv-ov p { padding: 0 }` (0,1,1) used to beat `.pv-empty` (0,1,0), so every empty-state <p> lost its padding and the
   message sat against the card's bottom edge. Raise the specificity and let it centre itself in a stretched card. */
.aiapi-shell p.pv-empty { padding: 30px var(--pv-s5) 34px; }
.pv-card > .pv-empty { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; }

/* A brand-new account has no series: no flat baseline glued to the bottom edge, and the text gets real bottom padding. */
.pv-kpi.is-flat { padding-bottom: var(--pv-s5); }

/* Reward button (daily check-in): label on one side, amount chip on the other. */
.pv-btn.pv-claim { width: 100%; justify-content: space-between; gap: var(--pv-s3); padding-block: 7px; padding-inline: 14px 7px; font-size: 13px; }
.pv-claim-t { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.pv-claim-t svg { width: 15px; height: 15px; }
.pv-btn.pv-claim .pv-btn-amt { margin: 0; padding: 2px 11px; border: 0; border-radius: var(--pv-r-pill); background: color-mix(in srgb, var(--pv-on-accent) 18%, transparent); font-weight: 700; white-space: nowrap; }

/* ---------- Code window: the one look for every API quick start (Models, Overview, API Keys) ----------
   Always LTR and left-aligned (code is code, even in an RTL panel), dark in both themes. Copy lives in the top bar,
   never over the code; long lines wrap (hanging under the line number) so nothing scrolls sideways. Markup: pv-code.js. */
.pvc { --c-bg: oklch(0.19 0.025 270); --c-bar: oklch(0.225 0.03 270); --c-line: oklch(0.3 0.03 270); --c-ink: oklch(0.92 0.015 270); --c-dim: oklch(0.58 0.03 270); --c-well: oklch(0.16 0.02 270 / .7); min-width: 0; overflow: hidden; direction: ltr; text-align: left; unicode-bidi: isolate; background: var(--c-bg); border: 1px solid var(--c-line); border-radius: 14px; box-shadow: 0 1px 0 oklch(1 0 0 / .04) inset, 0 12px 28px -16px oklch(0.2 0.05 270 / .5); }
.pvc-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; background: var(--c-bar); border-block-end: 1px solid var(--c-line); }
.pvc .pvc-tabs { display: flex; gap: 2px; padding: 3px; min-width: 0; overflow-x: auto; scrollbar-width: none; background: var(--c-well); border-radius: 10px; }
.pvc .pvc-tabs::-webkit-scrollbar { display: none; }
.pvc .pvc-tab { appearance: none; flex: none; padding: 5px 12px; font: inherit; font-size: 12px; font-weight: 650; line-height: 1.5; color: oklch(0.72 0.02 270); background: transparent; border: 0; border-radius: 7px; cursor: pointer; white-space: nowrap; transition: color .15s, background .15s; }
.pvc .pvc-tab:hover { color: #fff; }
.pvc .pvc-tab.is-active { color: #fff; background: oklch(0.42 0.13 275); box-shadow: 0 1px 6px oklch(0.3 0.12 275 / .5); }
.pvc .pvc-copy { appearance: none; flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 650; line-height: 1.5; color: oklch(0.86 0.02 270); background: oklch(0.3 0.035 270); border: 1px solid oklch(0.42 0.04 270); border-radius: 9px; cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .15s; }
.pvc .pvc-copy:hover { color: #fff; background: oklch(0.4 0.09 275); border-color: oklch(0.55 0.12 275); }
.pvc .pvc-copy:active { transform: scale(.96); }
.pvc .pvc-copy.is-copied { color: oklch(0.9 0.12 152); background: oklch(0.32 0.07 152); border-color: oklch(0.65 0.14 152); }
.pvc .pvc-copy svg, .pvc-url .pvc-copy svg { flex: none; inline-size: 14px; block-size: 14px; }
.pvc :focus-visible { outline: 2px solid oklch(0.75 0.14 275); outline-offset: 2px; }

.pvc .pvc-pre { margin: 0; padding: 14px 0; max-height: min(46vh, 420px); overflow: auto; font: 12.5px/1.75 ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace; color: var(--c-ink); background: transparent; border: 0; border-radius: 0; white-space: normal; direction: ltr; text-align: left; unicode-bidi: isolate; tab-size: 2; scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; }
.pvc .pvc-pre code { display: block; counter-reset: pvcl; padding: 0; font: inherit; color: inherit; background: none; border: 0; }
.pvc-ln { display: flex; min-height: 1.75em; padding-inline-end: 14px; counter-increment: pvcl; }
.pvc-ln::before { content: counter(pvcl); flex: none; inline-size: 2.4em; margin-inline-end: 12px; padding-inline-end: 10px; text-align: right; color: var(--c-dim); opacity: .7; border-inline-end: 1px solid var(--c-line); user-select: none; -webkit-user-select: none; }
.pvc-lc { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pvc .tk-str { color: oklch(0.82 0.13 150); }
.pvc .tk-ph { color: oklch(0.85 0.14 75); background: oklch(0.85 0.14 75 / .14); border-radius: 4px; padding: 0 3px; }
.pvc .tk-url { color: oklch(0.8 0.1 235); }
.pvc .tk-flag { color: oklch(0.8 0.12 320); }
.pvc .tk-kw { color: oklch(0.78 0.14 290); font-weight: 600; }
.pvc .tk-dim { color: var(--c-dim); }

/* Base URL row (label above, address + copy below; follows the panel's direction, the address itself stays LTR). */
.pvc-url { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 3px var(--pv-s2); padding: 8px; padding-inline-start: 12px; background: var(--pv-soft); border: 1px solid var(--pv-line); border-radius: var(--pv-r-md); }
.pvc-url-l { grid-column: 1 / -1; font-size: 11.5px; font-weight: 600; color: var(--pv-mute); }
.pvc-url code { min-width: 0; padding: 0; font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--pv-ink); background: none; border: 0; direction: ltr; text-align: left; unicode-bidi: isolate; overflow-wrap: anywhere; }
.pvc-url .pvc-copy { appearance: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; font: inherit; font-size: 12px; font-weight: 650; line-height: 1.5; color: var(--pv-ink); background: var(--pv-surface); border: 1px solid var(--pv-line); border-radius: var(--pv-r-sm); cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.pvc-url .pvc-copy:hover { color: var(--pv-accent-tx); background: var(--pv-accent-bg); border-color: var(--pv-accent-bd); }
.pvc-url .pvc-copy.is-copied { color: var(--pv-green-tx); background: var(--pv-green-bg); border-color: var(--pv-green-bd); }

@media (max-width: 560px) {
	.pvc-bar { padding: 6px; gap: 6px; }
	.pvc .pvc-tab { padding: 5px 9px; }
	.pvc .pvc-copy { padding: 6px 10px; }
	.pvc .pvc-pre { font-size: 12px; max-height: 40vh; }
	.pvc-ln { padding-inline-end: 10px; }
	.pvc-ln::before { inline-size: 1.8em; margin-inline-end: 9px; padding-inline-end: 7px; }
}
@media (max-width: 360px) { .pvc .pvc-copy span, .pvc-url .pvc-copy span { display: none; } .pvc .pvc-copy, .pvc-url .pvc-copy { padding-inline: 9px; } }
