html {
  background: var(--app-theme-bg, #0b0d12);
}

body {
  position: relative;
  isolation: isolate;
  background: transparent !important;
  color: var(--app-theme-text, inherit);
}

body::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  background-color: var(--app-theme-bg, #0b0d12);
  background-image: linear-gradient(var(--app-theme-overlay, transparent), var(--app-theme-overlay, transparent)), var(--app-theme-wallpaper, none);
  background-position: center;
  background-size: cover;
  content: "";
  pointer-events: none;
}

.shared-theme-wallpaper {
  position: fixed;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(var(--app-theme-video-brightness, .62));
  pointer-events: none;
}

.shared-theme-wallpaper[hidden] { display: none; }
.shared-theme-wallpaper[data-wallpaper-orientation="counterclockwise"] { transform: rotate(-90deg) scale(1.8); }


.store-topbar {
  border-color: var(--app-theme-line, rgba(255,255,255,.1));
  background: var(--app-theme-panel, rgba(15,20,28,.76));
}

.store-tools,
.theme-card,
.theme-details-window,
.theme-details-dialog,
.theme-details-panel,
.studio-form,
.studio-preview,
.theme-details-actions {
  border-color: var(--app-theme-line, rgba(255,255,255,.1));
  background-color: var(--app-theme-panel, rgba(15,20,28,.78));
  color: var(--app-theme-text, #f1f5fa);
}

.store-search,
.price-range-fields input,
.studio-field input,
.studio-field textarea,
.studio-field select,
.theme-details-preview,
.theme-preview,
.preview-window {
  border-color: var(--app-theme-line, rgba(255,255,255,.12));
}

.theme-card-copy,
.theme-card h2,
.theme-card p,
.theme-group-heading,
.store-intro h1,
.studio-heading h2,
.theme-details-dialog h2,
.theme-details-dialog dt,
.theme-details-dialog dd,
.store-filter-heading,
.studio-field,
.store-brand {
  color: var(--app-theme-text, #f1f5fa);
}

.theme-card p,
.studio-description,
.theme-details-description,
.store-intro > p:last-child,
.theme-details-dialog dt {
  color: var(--app-theme-muted, #aab4c0);
}

.auth-card {
  border-color: var(--auth-line, rgba(255,255,255,.1));
  background: var(--auth-panel, rgba(23,28,35,.76));
  color: var(--auth-text, #f1f5fa);
}

.auth-card h1,
.auth-field,
.auth-links,
.auth-profile-top {
  color: var(--auth-text, #f1f5fa);
}

.auth-field input,
.auth-field textarea,
.auth-field select {
  border-color: var(--auth-line, rgba(255,255,255,.12));
  background: color-mix(in srgb, var(--auth-panel, #171c23) 76%, transparent);
  color: var(--auth-text, #f1f5fa);
}

.auth-brand,
.auth-profile-top .auth-brand { color: var(--auth-text, #f1f5fa); }
.auth-primary { background: var(--auth-accent, #00a3ff); }
.auth-card a { color: var(--auth-accent, #8bd1ff); }
/* Link-styled buttons (e.g. "Open artist studio") must keep the button text colour, not the accent link colour. */
.auth-card a.auth-primary, .auth-card a.auth-primary:hover { color: #05131e; }

.store-brand img,
.studio-brand img,
.auth-brand img {
  display: block;
  width: 40px;
  height: 28px;
  object-fit: contain;
}

body[data-theme-mode="dark"] .store-search,
body[data-theme-mode="dark"] .price-range-fields input,
body[data-theme-mode="dark"] .studio-field input,
body[data-theme-mode="dark"] .studio-field textarea,
body[data-theme-mode="dark"] .studio-field select {
  background: rgba(0,0,0,.2);
  color: var(--app-theme-text);
}

body[data-theme-mode="dark"] .theme-card,
body[data-theme-mode="dark"] .theme-details-window,
body[data-theme-mode="dark"] .theme-details-dialog {
  box-shadow: 0 16px 42px rgba(0,0,0,.22);
}

body[data-theme-mode="dark"] .store-topbar {
  box-shadow: 0 1px 0 var(--app-theme-line);
}

body[data-theme-mode="dark"] .preview-window,
body[data-theme-mode="dark"] .preview-sidebar {
  background: rgba(0,0,0,.34);
}

@media (prefers-reduced-motion: reduce) {
  .shared-theme-wallpaper { display: none !important; }
}

body[data-theme-mode="dark"] {
  --ink: var(--app-theme-text);
  --muted: var(--app-theme-muted);
  --line: var(--app-theme-line);
  --accent: var(--app-theme-accent);
  --glass: var(--app-theme-panel);
  background: transparent !important;
}

body[data-theme-mode="light"] {
  --ink: var(--app-theme-text);
  --muted: var(--app-theme-muted);
  --line: var(--app-theme-line);
  --accent: var(--app-theme-accent);
  --glass: var(--app-theme-panel);
}

body[data-theme-mode="dark"] .store-tools,
body[data-theme-mode="dark"] .theme-card,
body[data-theme-mode="dark"] .theme-studio,
body[data-theme-mode="dark"] .theme-details-dialog,
body[data-theme-mode="dark"] .auth-card {
  border-color: var(--app-theme-line);
  background-color: var(--app-theme-panel);
  color: var(--app-theme-text);
}

body[data-theme-mode="dark"] .store-topbar {
  border-color: var(--app-theme-line);
  background: var(--app-theme-panel);
}

body[data-theme-mode="dark"] .theme-card-title p,
body[data-theme-mode="dark"] .theme-current,
body[data-theme-mode="dark"] .theme-card-author,
body[data-theme-mode="dark"] .back-link,
body[data-theme-mode="dark"] .store-filters button,
body[data-theme-mode="dark"] .preview-caption,
body[data-theme-mode="dark"] .studio-field,
body[data-theme-mode="dark"] .visibility-field legend,
body[data-theme-mode="dark"] .auth-field {
  color: var(--app-theme-muted);
}

body[data-theme-mode="dark"] .studio-field > input:not([type="range"]),
body[data-theme-mode="dark"] .studio-field > textarea,
body[data-theme-mode="dark"] .studio-field > select,
body[data-theme-mode="dark"] .store-search,
body[data-theme-mode="dark"] .price-range-fields input {
  border-color: var(--app-theme-line);
  background: rgba(0,0,0,.2);
  color: var(--app-theme-text);
}

body[data-theme-mode="dark"] .mode-switch,
body[data-theme-mode="dark"] .preview-tabs,
body[data-theme-mode="dark"] .color-input,
body[data-theme-mode="dark"] .price-input {
  border-color: var(--app-theme-line);
  background: rgba(0,0,0,.2);
}

body[data-theme-mode="dark"] .mode-switch button.selected,
body[data-theme-mode="dark"] .preview-tabs button.active {
  background: var(--app-theme-card);
  color: var(--app-theme-accent);
}

body[data-theme-mode="dark"] .studio-close,
body[data-theme-mode="dark"] .studio-cancel {
  border-color: var(--app-theme-line);
  background: var(--app-theme-card);
  color: var(--app-theme-text);
}

.store-topbar-inner { min-width: 0; }
.store-page-links { min-width: 0; }

.theme-studio {
  border-color: var(--app-theme-line);
  background: var(--app-theme-panel);
  color: var(--app-theme-text);
}

.studio-form,
.theme-details-info { color: var(--app-theme-text); }
.store-tools,
.theme-card { background: var(--app-theme-panel); }
.store-search input,
.price-range-fields input,
.studio-field input,
.studio-field textarea,
.studio-field select { color: var(--app-theme-text); }
.theme-card-footer { border-color: var(--app-theme-line); }
.theme-current,
.theme-card-author { color: var(--app-theme-muted); }
.studio-open,
.studio-publish,
.studio-actions .studio-publish,
.theme-card-footer button,
.theme-details-actions button:not(:disabled) {
  background: var(--app-theme-accent);
}
.theme-details-dialog { background: var(--app-theme-bg); color: var(--app-theme-text); }

@media (max-width: 780px) {
  .store-catalog { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  .store-catalog > *,
  .store-tools,
  .store-groups,
  .store-grid { min-width: 0; width: 100%; }
  .store-tools { max-width: 100%; overflow: hidden; }
  .store-filters { min-width: 0; max-width: 100%; overflow-x: auto; }
  .store-page-links { gap: 8px; }
}
