/* Appearance shared by the desktop, H5 and account-facing web pages. */
html.alchemy-web {
  color-scheme: light;
  --ui-font: "PingFang SC", "PingFang HK", "苹方-简", "Noto Sans SC", "Microsoft YaHei UI", system-ui, sans-serif;
  --ui-canvas: #e9f0f9;
  --ui-wash: #f8fbff;
  --ui-glow: #fff;
  --ui-sky: radial-gradient(ellipse 74% 70vh at 50% 38vh, var(--ui-glow), var(--ui-wash) 35%, transparent);
  --ui-orbit-ink: #698cbd20;
  --ui-orbit-planet: #698cbd62;
  --ui-ink: #1d2938;
  --ui-muted: #4c5e75;
  --ui-quiet-text: #5c6d80;
  --ui-rim: #ffffffde;
  --ui-edge: #788da94d;
  --ui-edge-strong: #5a759070;
  --ui-glass: #ffffffac;
  --ui-reflection: #ffffff55;
  --ui-header: #f3f7fce6;
  --ui-dialog: #f8fafdf5;
  --ui-dialog-veil: #47648a20;
  --ui-solid: #fff;
  --ui-field: #ffffffee;
  --ui-tile: #ffffffb8;
  --ui-inset: #f3f6fa;
  --ui-accent: #285a9e;
  --ui-accent-hover: #204b84;
  --ui-on-accent: #fff;
  --ui-selected: #e0edfd;
  --ui-focus: #2868b7;
  --ui-success: #256044;
  --ui-success-bg: #e7f5ec;
  --ui-warning: #775016;
  --ui-warning-bg: #fff2d9;
  --ui-danger: #9a333b;
  --ui-danger-bg: #fae9ec;
  --ui-overlay: #18263882;
  --ui-shadow: 0 10px 28px #233a5c14;
}

/* The defaults follow the system until a visitor picks a theme. */
html.alchemy-web[data-alchemy-theme="dark"] {
  color-scheme: dark;
  --ui-canvas: #0b0e13;
  --ui-wash: #211c33;
  --ui-glow: #1b304b;
  --ui-sky: radial-gradient(ellipse 65% 57vh at 74% 25vh, var(--ui-glow), transparent),
    radial-gradient(ellipse 52% 57vh at 10% 67vh, var(--ui-wash), transparent);
  --ui-orbit-ink: #a7bef323;
  --ui-orbit-planet: #d2c4f263;
  --ui-ink: #f0f3f7;
  --ui-muted: #b0bece;
  --ui-quiet-text: #9dacc0;
  --ui-rim: #d8e6fc22;
  --ui-edge: #bdcee24d;
  --ui-edge-strong: #bdcee280;
  --ui-glass: #171e29d6;
  --ui-reflection: #b8cfff0d;
  --ui-header: #131c2af0;
  --ui-dialog: #1a2432f5;
  --ui-dialog-veil: #02060c59;
  --ui-solid: #1a222e;
  --ui-field: #101722;
  --ui-tile: #202a38;
  --ui-inset: #253141;
  --ui-accent: #d8b967;
  --ui-accent-hover: #edd088;
  --ui-on-accent: #21190b;
  --ui-selected: #39301f;
  --ui-focus: #f0cd7a;
  --ui-success: #9edab8;
  --ui-success-bg: #1d362b;
  --ui-warning: #f1cd85;
  --ui-warning-bg: #3b2d1b;
  --ui-danger: #ffb2b9;
  --ui-danger-bg: #41252d;
  --ui-overlay: #070a0dbe;
  --ui-shadow: 0 12px 32px #00000042;
}

/* Let the existing module styles consume the shared palette. */
html.alchemy-web {
  --ink: var(--ui-ink);
  --ink-soft: var(--ui-muted);
  --muted: var(--ui-muted);
  --quiet: var(--ui-quiet-text);
  --black: var(--ui-ink);
  --black-soft: var(--ui-inset);
  --paper: var(--ui-solid);
  --paper-deep: var(--ui-inset);
  --panel: var(--ui-glass);
  --panel-strong: var(--ui-field);
  --surface: var(--ui-glass);
  --surface-strong: var(--ui-solid);
  --line: var(--ui-edge);
  --line-strong: var(--ui-edge-strong);
  --blue: var(--ui-accent);
  --brass: var(--ui-accent);
  --sage: var(--ui-accent);
  --sage-deep: var(--ui-accent);
  --sage-dark: var(--ui-accent);
  --green: var(--ui-success);
  --success: var(--ui-success);
  --warning: var(--ui-warning);
  --red: var(--ui-danger);
  --danger: var(--ui-danger);
  --wine: var(--ui-danger);
  --champagne: var(--ui-inset);
  --champagne-soft: var(--ui-tile);
  --shadow: var(--ui-shadow);
  --shadow-soft: var(--ui-shadow);
  --radius: 12px;
  --radius-sm: 8px;
  min-height: 100%;
  background: var(--ui-canvas);
}

.alchemy-web body {
  min-height: 100vh;
  color: var(--ui-ink);
  font-family: var(--ui-font);
  font-synthesis: none;
  isolation: isolate;
  background: var(--ui-sky), var(--ui-canvas);
}
.alchemy-web body::before {
  --orbit-center-x: 50%;
  --orbit-center-y: 50%;
  --orbit-x: max(14rem, 53vw);
  --orbit-y: max(14rem, 55vh);
  --orbit-stroke: transparent calc(100% - 1px), var(--ui-orbit-ink) calc(100% - .8px) calc(100% - .2px), transparent 100%;
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* Each planet sits on one of the three concentric paths. */
  background:
    radial-gradient(circle 3.5px at calc(var(--orbit-center-x) + var(--orbit-x) * .8) calc(var(--orbit-center-y) + var(--orbit-y) * .6), var(--ui-orbit-planet) 75%, transparent),
    radial-gradient(circle 2.5px at calc(var(--orbit-center-x) - var(--orbit-x) * .36) calc(var(--orbit-center-y) - var(--orbit-y) * .6235), var(--ui-orbit-planet) 68%, transparent),
    radial-gradient(circle 1.75px at calc(var(--orbit-center-x) + var(--orbit-x) * .276) calc(var(--orbit-center-y) - var(--orbit-y) * .368), var(--ui-orbit-planet) 65%, transparent),
    radial-gradient(ellipse var(--orbit-x) var(--orbit-y) at var(--orbit-center-x) var(--orbit-center-y), var(--orbit-stroke)),
    radial-gradient(ellipse calc(var(--orbit-x) * .72) calc(var(--orbit-y) * .72) at var(--orbit-center-x) var(--orbit-center-y), var(--orbit-stroke)),
    radial-gradient(ellipse calc(var(--orbit-x) * .46) calc(var(--orbit-y) * .46) at var(--orbit-center-x) var(--orbit-center-y), var(--orbit-stroke));
}
html.alchemy-web[data-alchemy-theme="dark"] body::before {
  --orbit-center-x: 56%;
  --orbit-center-y: 44%;
  --orbit-x: max(14rem, 56vw);
  --orbit-y: max(14rem, 54vh);
}
.alchemy-web .app-shell { background: transparent; }
.alchemy-web body :is(h1, h2, h3, h4, .access-brand) { font-family: var(--ui-font); }
.alchemy-web :is(.brand-mark, .brand-lockup h1, .access-brand) { color: var(--ui-ink); }
.alchemy-web .alchemy-brand-logo { display: block; flex: none; }
.alchemy-web .brand-wordmark { display: grid; gap: 3px; }
.alchemy-web .brand-wordmark h1 { margin: 0; font-weight: 650; line-height: 1.1; }
.alchemy-web .brand-wordmark p {
  margin: 0;
  color: var(--ui-muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.alchemy-web .brand-mark {
  font-family: var(--ui-font);
  font-weight: 620;
  background: var(--ui-tile);
  border-color: var(--ui-rim);
}
.alchemy-web .hero-copy h2 { color: var(--ui-ink); letter-spacing: -.03em; font-weight: 650; }

.alchemy-web :is(.lux-header, .access-header, .account-center-head, .mobile-view-head, .mobile-sheet-head, .hero-card,
  .studio-panel, .panel, .gallery-wrap, .mode-switch-row, .flow-section,
  .account-center-panel, .v3-workspace-header, .access-card, .v3-page-loading-overlay) {
  color: var(--ui-ink);
  background: linear-gradient(145deg, var(--ui-reflection), transparent 60%), var(--ui-glass);
  border-color: var(--ui-rim);
  box-shadow: var(--ui-shadow);
}
.alchemy-web :is(.lux-header, .access-header, .mobile-view-head, .mobile-view-footer,
  .mobile-sheet-head, .mobile-sheet-footer) {
  background: var(--ui-header);
  border-color: var(--ui-edge);
  backdrop-filter: blur(14px);
}
.alchemy-web :is(.account-center-dialog, .account-access-dialog, .access-dialog, .sample-dialog, .lightbox-panel,
  .mobile-view, .mobile-sheet, .lab-nav-dropdown, .v3-project-history-dialog, .v3-brand-memory-dialog,
  .v3-visual-asset-binding-dialog, .v3-mobile-full-prompt-dialog) {
  color: var(--ui-ink);
  background: var(--ui-dialog);
  border-color: var(--ui-rim);
  box-shadow: var(--ui-shadow);
}
.alchemy-web .account-center-overlay {
  background: var(--ui-dialog-veil);
  backdrop-filter: blur(8px);
}
.alchemy-web .account-center-head {
  background: transparent;
  border-color: var(--ui-edge);
  box-shadow: none;
}
.alchemy-web .account-center-nav { background: transparent; border-color: var(--ui-edge); }
.alchemy-web .hero-band { border-color: var(--ui-rim); }
.alchemy-web :is(.panel, .studio-panel, .gallery-wrap, .flow-section):where(:not(.billing-admin-page > .panel)) {
  border-radius: var(--radius);
}
.alchemy-web .state-pill { white-space: nowrap; }
.alchemy-web body.h5-simplified .hero-card {
  background: linear-gradient(145deg, var(--ui-reflection), transparent 60%), var(--ui-glass);
  border-color: var(--ui-rim);
}
.alchemy-web :is(.case-slide div, .case-slide strong, .case-slide span) {
  color: #fff;
  font-family: var(--ui-font);
}
.alchemy-web :is(.hero-card .case-source, .v2-facet) { background: var(--ui-tile); color: var(--ui-ink); border-color: var(--ui-edge); }
.alchemy-web .v2-facet.active { background: var(--ui-accent); color: var(--ui-on-accent); border-color: var(--ui-accent); }
.alchemy-web .mode-switch-row { border-radius: var(--radius); }
.alchemy-web .module-tabs { border-color: var(--ui-edge); }
.alchemy-web :is(.tab.active, .tab[aria-selected="true"]) {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
}
.alchemy-web :is(.segmented, .mobile-summary-grid > button, .sample-step) {
  background: var(--ui-tile);
  border-color: var(--ui-edge);
  color: var(--ui-ink);
}

.alchemy-web :is(.surface-switch-link, .alchemy-theme-toggle, .button.secondary, .button.ghost, .access-button.secondary,
  .mobile-back-button, .mobile-v2-asset-thumb.empty, .v2-reference-title-row em,
  .v3-result-download, .v3-mobile-output-actions button, .segment, .account-center-nav-button, .modal-close) {
  background: var(--ui-tile);
  color: var(--ui-ink);
  border-color: var(--ui-edge);
}
.alchemy-web .alchemy-theme-toggle {
  min-width: max-content;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--ui-edge);
  border-radius: 999px;
  font: 600 12px/1.2 var(--ui-font);
  cursor: pointer;
}
.alchemy-web :is(.button.primary, .segment.active, .access-button:not(.secondary, .danger)) {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: var(--ui-on-accent);
  box-shadow: inset 0 1px 0 #ffffff22;
}
.alchemy-web :is(.button.primary, .segment.active, .access-button:not(.secondary, .danger)):hover:not(:disabled) {
  background: var(--ui-accent-hover);
}
.alchemy-web :is(.access-button.danger, .button.danger) {
  color: var(--ui-danger);
  background: var(--ui-danger-bg);
  border-color: var(--ui-danger);
}
.alchemy-web .v2-favorite-reference-card.has-selection .v2-reference-title-row em {
  color: var(--ui-success);
  background: var(--ui-success-bg);
}
.alchemy-web .account-center-nav-button {
  border-radius: 8px;
  font-weight: 600;
}
.alchemy-web .account-center-nav-button:not(.active):hover { background: var(--ui-inset); }
.alchemy-web .account-center-nav-button.active {
  color: var(--ui-accent);
  border-color: var(--ui-accent);
  background: var(--ui-selected);
}

.alchemy-web :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="hidden"]),
  textarea, select) {
  color: var(--ui-ink);
  background: var(--ui-field);
  border-color: var(--ui-edge);
}
.alchemy-web :is(input, textarea)::placeholder { color: var(--ui-quiet-text); opacity: 1; }
.alchemy-web :is(input[type="checkbox"], input[type="radio"], input[type="range"]) { accent-color: var(--ui-accent); }
.alchemy-web :is(button, a, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 2px;
}

.alchemy-web :is(.output-card, .v2-output-card, .v2-history-card, .v2-template-card, .v2-case-tile,
  .v2-asset-panel, .v2-brain-panel, .v2-progress-panel, .mobile-entry-card,
  .lab-style-panel, .lab-style-card, .lab-history-card, .lab-style-result, .lab-reference-panel, .lab-library-panel,
  .v3-composer-panel, .v3-progress-panel, .v3-result-card, .v3-artifact-card, .v3-history-card,
  .v3-history-project-card, .v3-project-card, .v3-project-snapshot-card, .v3-project-reference-panel,
  .v3-mobile-project-card, .v3-mobile-template-card, .v3-mobile-output-card, .v3-mobile-progress,
  .v3-mobile-snapshot-card, .v3-mobile-reference-card, .v3-mobile-professional-panel, .v3-mobile-full-prompt-card,
  .v3-visual-asset-card, .v3-visual-asset-dialog-card, .v3-character-card-slot, .v3-character-card-module,
  .bridge-reward-stat, .bridge-node-card, .access-stat, :where(#v2-template-guide) pre, .access-key,
  .account-access-hero, .account-access-card, .account-access-endpoint, .account-access-explain article,
  .account-access-key-row, .account-data-notice, .account-kpi, .account-history-card,
  .account-usage-row, .account-empty-state, .node-rewards-node) {
  color: var(--ui-ink);
  background: var(--ui-tile);
  border-color: var(--ui-edge);
}

.alchemy-web :is(.tuning-card, .advanced-asset-panel, .asset-preview, .file-drop, .role-check, .revision-selected-card,
  .favorite-filter, .history-load-more, .v2-composer, .v2-side-controls, .control-block, .v2-result-block,
  .v2-prompt-plan, .v2-context-chip.idle, .lab-module-card, .v3-template-create-panel,
  .status-strip > div, .asset-preview span) {
  color: var(--ui-ink);
  background: var(--ui-tile);
  border-color: var(--ui-edge);
}
.alchemy-web :is(.gallery, .history-gallery, .v2-template-grid, .v2-history-grid, .v2-output-grid) {
  background: var(--ui-glass);
  border-color: var(--ui-edge);
}
.alchemy-web :is(.output-preview, .v2-template-preview, .v2-live-preview, .lab-style-preview, .v3-result-preview,
  .v3-history-preview, .v3-mobile-output-preview, .v3-mobile-empty-thumb, .v3-history-empty-thumb,
  .empty-v3-list, .empty-v2-list) {
  color: var(--ui-muted);
  background-color: var(--ui-inset);
  border-color: var(--ui-edge);
}
.alchemy-web :is(.state-pill, .session-code, .access-status, .v2-route-badge.unknown, .v2-review-badge, .bridge-node-status.is-offline, .bridge-node-status.is-unknown) {
  color: var(--ui-muted);
  background: var(--ui-inset);
  border-color: var(--ui-edge);
}
.alchemy-web .notice-bar {
  color: var(--ui-ink);
  background: var(--ui-selected);
  border-color: var(--ui-edge);
}
.alchemy-web :is(.global-toast, .notice-bar.success, .v3-inline-notice.success, .bridge-node-status.is-online) {
  color: var(--ui-success);
  background: var(--ui-success-bg);
  border-color: currentColor;
}
.alchemy-web :is(.access-alert, .notice-bar.warning, .v3-inline-notice.warning, .v3-review-hold-card, .v3-mobile-review-hold, .bridge-node-status.is-busy) {
  color: var(--ui-warning);
  background: var(--ui-warning-bg);
  border-color: currentColor;
}
.alchemy-web :is(.global-toast.error, .notice-bar.error, .v3-inline-notice.error, .v2-output-error, .lab-error-tile, .v3-mobile-template-state.error, .bridge-node-status.is-attention) {
  color: var(--ui-danger);
  background: var(--ui-danger-bg);
  border-color: currentColor;
}
.alchemy-web :is(.v3-inline-notice, .v3-mobile-template-state, .v2-progress-detail, .run-progress-detail) { overflow-wrap: anywhere; }
.alchemy-web :is(.sample-dialog, .access-dialog, .v3-visual-asset-binding-dialog)::backdrop { background: var(--ui-overlay); }
.alchemy-web .account-access-dialog::backdrop { background: var(--ui-dialog-veil); }
.alchemy-web :is(.account-history-grid, .account-template-list, .account-usage-list) > .account-empty-state {
  grid-column: 1 / -1;
}
.alchemy-web .account-access-panel :is(.account-access-endpoint-actions input, .account-access-create-form input, .account-access-create-form select) {
  min-height: 40px;
  padding-inline: 11px;
  border: 1px solid var(--ui-edge);
  border-radius: 8px;
}
.alchemy-web #veyraAccountEmail { font-size: clamp(15px, 1.45vw, 19px); }
.alchemy-web .account-kpi strong { font-size: clamp(16px, 1.8vw, 22px); font-weight: 600; }
.alchemy-web .balance-kpi strong {
  color: var(--ui-accent);
  font: 650 clamp(25px, 3vw, 38px)/1.1 var(--ui-font);
  font-variant-numeric: tabular-nums;
}

.alchemy-web .access-body :is(a:not(.access-button), summary) { color: var(--ui-accent); }
.alchemy-web .access-body :is(label, p, small, .access-key code, .access-status, .access-step, .access-eyebrow, .access-empty, .access-footer, #accountLabel) { color: var(--ui-muted); }
.alchemy-web .access-body :is(.access-card h2, .access-stat strong) { color: var(--ui-ink); }
.alchemy-web .access-body :is(.access-brand span, .access-button) { font-family: var(--ui-font); }
.alchemy-web .access-body .access-download-note { color: var(--ui-muted) !important; }

@media (min-width: 1100px) {
  .alchemy-web .header-status { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .alchemy-web body.h5-simplified .lux-header {
    gap: 10px;
    padding: 9px 10px 0;
    border-radius: 16px;
  }
  .alchemy-web body.h5-simplified .module-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
  }
  .alchemy-web body.h5-simplified .module-tabs .tab {
    width: auto;
    min-width: 0;
    max-width: none;
    min-height: 36px;
    padding: 0 2px;
    font-size: 12px;
  }
  .alchemy-web .mobile-header-actions { gap: 5px; }
  .alchemy-web .mobile-header-actions .alchemy-theme-toggle { min-height: 32px; padding-inline: 8px; font-size: 11px; }
  .alchemy-web .access-header { gap: 8px 12px; }
}
@media (prefers-reduced-transparency: reduce) {
  .alchemy-web body { background: var(--ui-canvas); }
  .alchemy-web body::before { display: none; }
  .alchemy-web :is(.lux-header, .access-header, .lab-nav-dropdown, .lightbox-panel, .sample-dialog, .access-dialog,
    .panel, .flow-section, .account-center-dialog, .account-access-dialog, .mobile-view, .mobile-view-head,
    .mobile-view-footer, .mobile-sheet, .mobile-sheet-head, .mobile-sheet-footer) {
    background: var(--ui-solid);
    backdrop-filter: none;
  }
  .alchemy-web .account-center-overlay, .alchemy-web .account-access-dialog::backdrop {
    backdrop-filter: none;
  }
}
