/* Shared typography, aligned with tweakcn's Default preview:
 * UI 14/20, card headings 18/28, metrics 30/36, weights 400/500/600.
 * Keep icon fonts and control geometry in their original component styles.
 * rem scales with browser preferences; mobile editable fields use 16px.
 */
:root[data-app-theme="tweakcn"] {
  --type-xs: .75rem;
  --type-sm: .875rem;
  --type-base: 1rem;
  --type-lg: 1.125rem;
  --type-xl: 1.25rem;
  --type-2xl: 1.5rem;
  --type-3xl: 1.875rem;
  --leading-xs: 1rem;
  --leading-sm: 1.25rem;
  --leading-base: 1.5rem;
  --leading-lg: 1.75rem;
  --leading-2xl: 2rem;
  --leading-3xl: 2.25rem;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  /* Explicit CJK fallbacks supplement the exported system sans stack. */
  --app-font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --md-font: var(--app-font-sans);
  --bs-font-sans-serif: var(--app-font-sans);
  --bs-body-font-family: var(--app-font-sans);
}
:root[data-app-theme] body {
  font-family: var(--app-font-sans) !important;
  font-size: var(--type-sm);
  font-weight: var(--weight-normal);
  line-height: calc(20 / 14);
  letter-spacing: normal;
}
:root[data-app-theme] :is(h1, h2, h3, h4, h5, h6) {
  font-family: var(--app-font-sans);
  font-weight: var(--weight-semibold);
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
:root[data-app-theme] h1 { font-size: var(--type-2xl); line-height: calc(32 / 24); }
:root[data-app-theme] h2 { font-size: var(--type-xl); line-height: 1.4; }
:root[data-app-theme] :is(h3, h4) { font-size: var(--type-lg); line-height: calc(28 / 18); }
:root[data-app-theme] :is(h5, h6) { font-size: var(--type-base); line-height: 1.5; }
:root[data-app-theme] :is(b, strong, .fw-bold, .fw-bolder) { font-weight: var(--weight-semibold) !important; }
:root[data-app-theme] .fw-semibold { font-weight: var(--weight-semibold) !important; }
:root[data-app-theme] .fw-medium { font-weight: var(--weight-medium) !important; }

/* Replace inherited Metronic text utilities without resizing font icons. */
:root[data-app-theme] :is(h1, h2, h3, h4, h5, h6, p, div, span, a, label):not([class*="material-icons"]):is(.fs-6, .fs-7) {
  font-size: var(--type-sm) !important;
}
:root[data-app-theme] :is(p, div, span, a, label):not([class*="material-icons"]):is(.fs-8, .fs-9) {
  font-size: var(--type-xs) !important;
}

/* Brand, page and card headings use separate, predictable levels. */
:root[data-app-theme] :is(.shop-brand, .shop-drawer__brand, .uc-brand__name, .logo,
  .uc-plan__name, .uc-mstatus__name, .uc-promo__title, .shipment-title, .uc-subhead) {
  font-size: var(--type-base) !important;
  font-weight: var(--weight-semibold) !important;
  line-height: 1.5;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.panel-title, .section-title, .card-title, .uc-card__title,
  .dash-card__title, .uc-welcome__hi, .md-settings__title) {
  font-size: var(--type-lg) !important;
  font-weight: var(--weight-semibold) !important;
  line-height: calc(28 / 18);
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.dash-panel__title, .uc-ticket-toolbar__title strong,
  .uc-ticket-form__heading strong) {
  font-size: var(--type-base) !important;
  font-weight: var(--weight-semibold) !important;
  line-height: 1.5;
}
:root[data-app-theme] #kt_aside .menu-title {
  font-size: var(--type-sm) !important;
  line-height: calc(20 / 14);
}
:root[data-app-theme] #kt_aside :is(.menu-section, .menu-title.latest-update) {
  font-size: var(--type-xs) !important;
  line-height: 1.5;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.uc-pagehead__title, .auth-title, .item-buy > h4,
  .uc-ticket-page h1, .uc-ticket-create-head h1, .uc-ticket-detail-head h1,
  #kt_toolbar h1) {
  font-size: var(--type-2xl) !important;
  font-weight: var(--weight-semibold) !important;
  line-height: calc(32 / 24);
  letter-spacing: normal !important;
}

/* UI text. Avoid a universal font rule: Font Awesome / Material Icons must
 * retain their own typefaces, including icon-only buttons and pseudo-elements. */
:root[data-app-theme] :is(.shop-nav__item, .shop-menu__item, .shop-drawer__link,
  .shop-user__name, .uc-nav__item, .uc-nav__link, .uc-subitem, .uc-drawer__link,
  .uc-user__lv, .menu-title, .dropdown-item, .md-theme-opt, .md-lang-opt,
  .md-nodesel__name, .md-nodesel__item,
  .uc-info__k, .uc-info__v, .uc-plan__feat,
  .uc-list__name, .uc-list__amount, .order-basic, .goods-name, .card-loading,
  .auth-subtitle, .auth-card .text-link, .lk-row--pair, .lk-menu__item,
  .uc-ticket-row__title, .uc-ticket-row__excerpt, .uc-empty p, .uc-blank p,
  .dash-flow, .dash-bars, .dash-todo__label, .dash-mini > dt, .dash-mini > dd,
  .dash-panel__empty) {
  font-size: var(--type-sm) !important;
  line-height: calc(20 / 14);
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.shop-nav__item, .shop-menu__item, .shop-drawer__link,
  .shop-user__name, .uc-nav__item, .uc-nav__link, .uc-subitem, .uc-drawer__link,
  .menu-title, .dropdown-item, .md-theme-opt, .md-lang-opt, .uc-user__lv) {
  font-weight: var(--weight-medium) !important;
}
:root[data-app-theme] .goods-title {
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-medium);
  line-height: calc(20 / 14);
}
:root[data-app-theme] :is(.btn, .shop-btn, .layui-btn, .mui-btn, .uc-cta,
  .uc-minibtn, .uc-quick, .uc-more, .btn-search, .btn-reset, .btn-gradient,
  .btn-ghost, .btn-passkey, .chip, .sku, .optional-card, .uc-tab, .uc-subtab a,
  .dash-seg__btn, .dash-trend__tab-label, .lk-submit, .lk-passkey,
  .uc-ticket-pagination button, .pay-list .pay, .pay-list .button-click,
  .uc-topup-methods .btn-pay, .page-link) {
  font-family: var(--app-font-sans);
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-medium) !important;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.btn, .shop-btn, .btn-gradient, .btn-ghost,
  .btn-passkey, .uc-cta, .chip, .sku, .lk-submit, .lk-passkey) { line-height: calc(20 / 14); }

/* Forms: native single-line inputs center text themselves. Fixed-height Layui
 * wrappers keep their centering rules; floating-label transforms stay intact. */
:root[data-app-theme] :is(input:not([type="checkbox"]):not([type="radio"]),
  textarea, select, .form-control, .form-select, .layui-input, .layui-textarea,
  .lk-input, .select2-selection__rendered, .xm-option-content) {
  font-family: var(--app-font-sans) !important;
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-normal) !important;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.form-control, textarea, .lk-input) { line-height: 1.5; }
:root[data-app-theme] :is(.form-label, .col-form-label, .form-check-label,
  .layui-form-label, .form-header, .form-floating > label,
  .layui-form-checkbox > span, .layui-form-radio > div, .uc-ticket-field-label) {
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-medium) !important;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.form-label, .col-form-label, .form-check-label) { line-height: calc(20 / 14); }
:root[data-app-theme][data-theme] .uc-card .form-body :is(.layui-input, .layui-select, select),
:root[data-app-theme][data-admin-layout="mobile"] body .admin-mobile-overlay :is(input, textarea, select) {
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-normal) !important;
}
/* Outlined fields render compact labels in a border notch. */
:root[data-app-theme] :is(.mui-sf__label, .uc-outline legend,
  .uc-outline legend > span, .mui-float > .layui-form-label) {
  font-size: var(--type-xs) !important;
  font-weight: var(--weight-medium) !important;
  letter-spacing: normal !important;
}
:root[data-app-theme] .uc-card .uc-field > .form-header { font-size: var(--type-sm) !important; }
:root[data-app-theme] .uc-card .uc-field:has(input:focus, input:not(:placeholder-shown), select) > .form-header {
  font-size: var(--type-xs) !important;
}

/* Supporting text has a 12px floor; functional descriptions remain 14px. */
:root[data-app-theme] :is(.small, small, .meta, .stat-bottom, .acg-tag, .badge,
  .badge-soft, .badge-money, .soldout-ribbon, .goods-sku, .shipment-badge,
  .shop-user__balance, .uc-card__sub, .uc-stat__unit, .uc-stat__value .cur,
  .uc-tag, .uc-count, .uc-plan__badge, .uc-plan__sub, .uc-list__time,
  .uc-list__gain, .uc-list__state, .uc-spark__label, .uc-ticket-pill,
  .uc-ticket-row__time, .uc-ticket-row__context, .uc-ticket-row__unread,
  .uc-ticket-row__number, .uc-ticket-detail-number, .uc-ticket-pagination__meta,
  .uc-topup-level > em, .uc-topup-summary__hero em, .menu-section,
  .dash-card__caption,
  .dash-earn__delta, .dash-earn__aside, .dash-earn__meta, .dash-kpi__sub,
  .dash-data__note, .dash-panel__note, .dash-todo__sub, .lk-date, .lk-menu__title,
  footer, .pagination-info, .pagination-detail) {
  font-size: var(--type-xs) !important;
  line-height: 1.5;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.form-text, .uc-hint, .uc-card__sub, .uc-welcome__sub,
  .uc-card .elem-quote, .uc-card .elem-tips, .uc-domain-hint, .uc-promo__rule,
  .uc-plan__feat--fee, .uc-benefit div, .uc-ticket-field-help,
  .uc-topup-limit, .uc-topup-bonus, .uc-topup-balance__hint,
  .uc-cash-balance__hint, .md-settings .form-text) {
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-normal) !important;
  line-height: 1.5;
  letter-spacing: normal !important;
}
:root[data-app-theme] .auth-card :is(p, .auth-subtitle, .text-link, .form-check label) {
  font-size: var(--type-sm) !important;
  line-height: calc(20 / 14);
}

/* Finance and statistics use the UI font with aligned digits, not a code font. */
:root[data-app-theme] :is(.dash-num, .price, .amount-value, .uc-stat__value,
  .md-stat__value, .uc-plan__price, .uc-cash-balance__value,
  .uc-topup-balance__value, .uc-cash-metric strong, .uc-strip__v,
  .uc-topup-summary__hero strong, .uc-cash-receipt__hero strong) {
  font-family: var(--app-font-sans) !important;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: normal !important;
}
:root[data-app-theme] :is(.dash-earn__value, .uc-stat__value, .md-stat__value,
  .uc-plan__price, .uc-cash-balance__value, .uc-topup-balance__value,
  .uc-topup-summary__hero strong, .uc-cash-receipt__hero strong) {
  font-size: var(--type-3xl) !important;
  font-weight: var(--weight-semibold) !important;
  line-height: calc(36 / 30);
}
:root[data-app-theme] :is(.dash-kpi__value, .dash-trend__tab-value,
  .amount-value, .abacus .price, .uc-cash-metric strong,
  .uc-topup-progress__head strong, .uc-ticket-stat__copy strong) {
  font-size: var(--type-2xl) !important;
  font-weight: var(--weight-semibold) !important;
  line-height: calc(32 / 24);
}
:root[data-app-theme] :is(.price, .uc-strip__v) {
  font-size: var(--type-lg);
  font-weight: var(--weight-semibold);
  line-height: calc(28 / 18);
}
:root[data-app-theme] :is(.price .unit, .abacus .price .unit) {
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-medium) !important;
  line-height: calc(20 / 14);
}
:root[data-app-theme] :is(.dash-earn__label, .dash-kpi__label,
  .md-stat__label, .uc-stat__label, .uc-strip__k,
  .uc-cash-balance__label, .uc-topup-balance__label) {
  font-size: var(--type-sm) !important;
  font-weight: var(--weight-normal) !important;
  line-height: calc(20 / 14);
  letter-spacing: normal !important;
}

/* Table cells and prose need breathing room, especially for Chinese text. */
:root[data-app-theme] :is(.table, .bootstrap-table, .layui-table, .wholesale-table) {
  font-size: var(--type-sm) !important;
  line-height: 1.5;
}
:root[data-app-theme] :is(.table, .layui-table) :is(th, td) {
  font-size: var(--type-sm) !important;
  line-height: 1.5;
}
:root[data-app-theme] :is(.table, .layui-table) th { font-weight: var(--weight-medium) !important; }
:root[data-app-theme] :is(.panel-body, .item-detail .panel-body,
  .uc-ticket-markdown, .protocol-text, .protocol-summary) {
  font-size: var(--type-base);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
:root[data-app-theme] :is(code, pre, kbd, .card-display, .uc-chip,
  .uc-promo__url, .uc-ticket-row__number, .uc-ticket-detail-number) {
  font-family: var(--font-mono) !important;
  font-size: var(--type-sm);
  line-height: 1.6;
}
:root[data-app-theme]:has(#agreeBtn) .content { font-size: var(--type-base); line-height: 1.75; }
:root[data-app-theme]:has(#agreeBtn) :is(.subtitle, .checkbox-container label) {
  font-size: var(--type-sm);
  font-weight: var(--weight-normal);
  line-height: 1.5;
}
:root[data-app-theme]:has(#agreeBtn) .update-time { font-size: var(--type-xs); line-height: 1.5; }

@media (max-width: 767px) {
  :root[data-app-theme] :is(input:not([type="checkbox"]):not([type="radio"]),
    textarea, select, .form-control, .form-select, .layui-input, .layui-textarea,
    .lk-input, .select2-selection__rendered, .xm-option-content) {
    font-size: var(--type-base) !important;
  }
  :root[data-app-theme][data-theme] .uc-card .form-body :is(.layui-input, .layui-select, select),
  :root[data-app-theme][data-admin-layout="mobile"] body .admin-mobile-overlay :is(input, textarea, select) {
    font-size: var(--type-base) !important;
  }
  :root[data-app-theme] :is(.uc-pagehead__title, .auth-title, .item-buy > h4,
    .uc-ticket-page h1, .uc-ticket-create-head h1, #kt_toolbar h1) {
    font-size: var(--type-xl) !important;
    line-height: 1.4;
  }
  /* Compact admin cards have their own high-specificity legacy rules. Keep
   * these overrides scoped to text; do not enlarge navigation icons. */
  :root[data-app-theme][data-admin-layout="mobile"] body :is(
    .admin-mobile-appbar__heading strong, .admin-mobile-card-heading strong,
    .admin-mobile-empty strong, .admin-mobile-load-state strong) {
    font-size: var(--type-base) !important;
    font-weight: var(--weight-semibold) !important;
    line-height: 1.5 !important;
    letter-spacing: normal !important;
  }
  :root[data-app-theme][data-admin-layout="mobile"] body .admin-mobile-context-tab {
    font-size: var(--type-sm) !important;
    font-weight: var(--weight-medium) !important;
    line-height: calc(20 / 14);
    letter-spacing: normal !important;
  }
  :root[data-app-theme][data-admin-layout="mobile"] body .admin-mobile-context-tab.is-active {
    font-weight: var(--weight-semibold) !important;
  }
  :root[data-app-theme][data-admin-layout="mobile"] body .admin-mobile-bottom-nav :is(a, button) > span:not([class*="material-icons"]) {
    font-size: var(--type-xs) !important;
    font-weight: var(--weight-medium) !important;
    line-height: 1.5;
  }
  :root[data-app-theme][data-admin-layout="mobile"] body :is(
    .admin-mobile-card-heading small, .admin-mobile-card-subtitle-line,
    .admin-mobile-status-chip, .admin-mobile-card-metrics dt,
    .admin-mobile-pagination span, .admin-mobile-detail-list dt,
    .admin-mobile-nav__label, .admin-mobile-state-filter span,
    .admin-mobile-selection-dock__summary > strong,
    .admin-mobile-settings-details > summary small) {
    font-size: var(--type-xs) !important;
    line-height: 1.5 !important;
    font-weight: var(--weight-medium) !important;
    letter-spacing: normal !important;
  }
  :root[data-app-theme][data-admin-layout="mobile"] body :is(
    .admin-mobile-card-metrics dd, .admin-mobile-detail-list dd,
    .admin-mobile-popup-form .layui-form-label, .admin-mobile-form-help,
    .admin-mobile-toolbar button, .admin-mobile-selection-dock button,
    .admin-mobile-popup-tabs button, .admin-mobile-settings-nav a) {
    font-size: var(--type-sm) !important;
    font-weight: var(--weight-medium) !important;
    line-height: 1.5 !important;
    letter-spacing: normal !important;
  }
  :root[data-app-theme][data-admin-layout="mobile"] .md-stat-grid[data-admin-mobile-stats="mini"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  :root[data-app-theme][data-admin-layout="mobile"] .md-stat-grid[data-admin-mobile-stats="mini"] .md-stat__label {
    font-size: var(--type-xs) !important;
    line-height: 1.5;
  }
  :root[data-app-theme][data-admin-layout="mobile"] .md-stat-grid[data-admin-mobile-stats="mini"] .md-stat__value {
    font-size: var(--type-lg) !important;
    line-height: calc(28 / 18);
  }
}
