/* Community theme preview chrome (preview bar + signed-out sign-in popup).
   Mirrors the dashboard's HeroUI tokens (src/dashboard/styles.css) so the
   preview reads as part of the dashboard. Everything is scoped under
   .tp-ui so the previewed theme's own variables can't leak in. */
.tp-ui {
  --tp-accent: oklch(54.04% 0.1498 251.4);
  --tp-accent-fg: oklch(99.11% 0 0);
  --tp-accent-hover: color-mix(in oklab, var(--tp-accent) 90%, var(--tp-accent-fg) 10%);
  --tp-background: oklch(97.02% 0 251.4);
  --tp-border: oklch(90% 0 251.4);
  --tp-danger: oklch(65.32% 0.2328 25.45);
  --tp-success: oklch(62% 0.17 150.52);
  --tp-default: oklch(94% 0 251.4);
  --tp-default-fg: oklch(21.03% 0.0059 251.4);
  --tp-default-hover: color-mix(in oklab, var(--tp-default) 96%, var(--tp-default-fg) 4%);
  --tp-field-bg: oklch(100% 0 251.4);
  --tp-field-border: color-mix(in oklab, var(--tp-border) 68%, var(--tp-fg));
  --tp-field-placeholder: oklch(55.17% 0 251.4);
  --tp-fg: oklch(21.03% 0 251.4);
  --tp-muted: oklch(55.17% 0 251.4);
  --tp-overlay: oklch(100% 0 251.4);
  --tp-separator: oklch(92% 0 251.4);
  --tp-radius: 0.125rem;
  --tp-surface-shadow: 0 2px 4px 0 #0000000a, 0 1px 2px 0 #0000000f, 0 0 1px 0 #0000000f;
  --tp-overlay-shadow: 0 2px 8px 0 #0000000f, 0 -6px 12px 0 #00000008, 0 14px 28px 0 #00000014;
  color-scheme: light;
  color: var(--tp-fg);
  font: 14px/1.43 Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: normal; text-transform: none; text-align: left; text-shadow: none;
}
html[data-preview-ui="dark"] .tp-ui, .tp-ui[data-mode="dark"] {
  --tp-background: oklch(12% 0 251.4);
  --tp-border: oklch(28% 0 251.4);
  --tp-danger: oklch(59.4% 0.1967 24.34);
  --tp-success: oklch(73.29% 0.1935 150.52);
  --tp-default: oklch(27.4% 0 251.4);
  --tp-default-fg: oklch(99.11% 0 0);
  --tp-field-bg: oklch(21.03% 0 251.4);
  --tp-field-placeholder: oklch(70.5% 0 251.4);
  --tp-fg: oklch(99.11% 0 251.4);
  --tp-muted: oklch(70.5% 0 251.4);
  --tp-overlay: oklch(21.03% 0 251.4);
  --tp-separator: oklch(25% 0 251.4);
  --tp-surface-shadow: 0 0 0 1px var(--tp-border);
  --tp-overlay-shadow: 0 0 0 1px var(--tp-border), 0 14px 28px 0 #0006;
  color-scheme: dark;
}
.tp-ui *, .tp-ui *::before, .tp-ui *::after { box-sizing: border-box; }
.tp-ui :focus-visible { outline: 2px solid var(--tp-accent); outline-offset: 2px; }

/* Buttons: HeroUI .button, primary / secondary / ghost. */
.tp-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 0; border-radius: calc(var(--tp-radius) * 3);
  background: var(--tp-default); color: var(--tp-accent);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, transform .1s;
}
.tp-button:hover { background: var(--tp-default-hover); }
.tp-button:active { transform: scale(.97); }
.tp-button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.tp-button--primary { background: var(--tp-accent); color: var(--tp-accent-fg); }
.tp-button--primary:hover { background: var(--tp-accent-hover); }
.tp-button--ghost { background: transparent; color: var(--tp-default-fg); }
.tp-button--ghost:hover { background: var(--tp-default); }
.tp-button--sm { height: 32px; padding: 0 12px; }
.tp-button--block { width: 100%; }
.tp-button--icon { width: 32px; height: 32px; padding: 0; }
.tp-button .bi { font-size: 15px; line-height: 1; }

/* Preview bar: a dashboard card pinned to the bottom of the page. */
.theme-preview-bar {
  position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 2147483647; width: min(760px, calc(100% - 32px));
  display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px;
  padding: 12px 12px 12px 16px; border-radius: calc(var(--tp-radius) * 3);
  background: var(--tp-overlay); box-shadow: var(--tp-overlay-shadow);
}
.theme-preview-heading { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.theme-preview-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.theme-preview-eyebrow { color: var(--tp-muted); font-size: 12px; }
.theme-preview-title { margin: 0; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.theme-preview-creator { display: inline-flex; align-items: center; gap: 6px; min-width: 0; margin: 0; color: var(--tp-muted); font-size: 13px; }
.theme-preview-creator img { width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%; object-fit: cover; }
.theme-preview-creator a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-preview-creator a:hover { color: var(--tp-fg); text-decoration: underline; }
.theme-preview-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
#themePreviewStatus { flex-basis: 100%; margin: 0; color: var(--tp-muted); font-size: 12px; text-align: center; }
@media (max-width: 520px) {
  .theme-preview-bar { flex-direction: column; align-items: stretch; padding: 12px; gap: 10px; }
  .theme-preview-actions { justify-content: stretch; }
  .theme-preview-actions .tp-button { flex: 1; }
}

/* Sign-in popup: HeroUI modal backdrop + dialog. */
.ts-overlay {
  position: fixed; inset: 0; z-index: 2147483647; display: flex;
  align-items: center; justify-content: center; padding: 16px;
  background: #00000080; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.ts-overlay.open { animation: tp-fade .15s ease-out; }
.ts-modal {
  position: relative; width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px; padding: 32px;
  border-radius: calc(var(--tp-radius) * 3); background: var(--tp-overlay); box-shadow: var(--tp-overlay-shadow);
  animation: tp-zoom .15s ease-out;
}
@keyframes tp-fade { from { opacity: 0; } }
@keyframes tp-zoom { from { opacity: 0; transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .ts-overlay.open, .ts-modal { animation: none; } }
@media (max-width: 480px) { .ts-modal { padding: 24px 20px; } }
@media (min-width: 768px) { .ts-modal { max-width: 560px; padding: 36px 40px; } }
.ts-close { position: absolute; top: 16px; right: 16px; color: var(--tp-muted); }
.ts-brand { display: block; width: auto; height: 26px; margin: 0 auto 4px; }
.ts-header { display: flex; flex-direction: column; gap: 4px; padding-right: 32px; }
.ts-header h2 { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.5; color: var(--tp-fg); }
.ts-header p { margin: 0; color: var(--tp-muted); font-size: 14px; }
.ts-form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.ts-field { display: flex; flex-direction: column; gap: 4px; }
.ts-field label { font-size: 14px; font-weight: 500; color: var(--tp-fg); }
.ts-field input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--tp-field-border); border-radius: var(--tp-radius);
  background: var(--tp-field-bg); color: var(--tp-fg); box-shadow: var(--tp-surface-shadow);
  font: inherit; font-size: 16px; line-height: 1.5; outline: none; transition: border-color .15s, box-shadow .15s;
}
@media (min-width: 640px) { .ts-field input { font-size: 14px; line-height: 1.43; } }
.ts-field input::placeholder { color: var(--tp-field-placeholder); }
.ts-field input:hover { border-color: color-mix(in oklab, var(--tp-field-border) 70%, var(--tp-fg)); }
.ts-field input:focus { border-color: var(--tp-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--tp-accent) 25%, transparent); }
.ts-alert { display: none; margin: 0; padding: 8px 12px; border-radius: calc(var(--tp-radius) * 3); font-size: 13px; }
.ts-alert.error { display: block; background: color-mix(in srgb, var(--tp-danger) 12%, transparent); color: var(--tp-danger); }
.ts-alert.success { display: block; background: color-mix(in srgb, var(--tp-success) 14%, transparent); color: var(--tp-success); }
.ts-divider { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--tp-muted); font-size: 12px; }
.ts-divider::before, .ts-divider::after { content: ""; flex: 1; height: 1px; background: var(--tp-separator); }
.ts-oauth { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ts-oauth .tp-button { width: 100%; color: var(--tp-default-fg); }
.ts-oauth .tp-button .bi { font-size: 17px; }
.ts-footer { display: flex; flex-direction: column; gap: 4px; padding-top: 16px; border-top: 1px solid var(--tp-separator); color: var(--tp-muted); font-size: 13px; text-align: center; }
.ts-footer p { margin: 0; }
.ts-link { padding: 0; border: 0; background: none; color: var(--tp-accent); font: inherit; text-decoration: none; cursor: pointer; }
.ts-link:hover { text-decoration: underline; }
.ts-terms { margin: 0; color: var(--tp-muted); font-size: 12px; text-align: center; }
.ts-terms a { color: inherit; text-decoration: underline; }
.ts-panel { display: none; flex-direction: column; gap: 16px; }
.ts-panel.active { display: flex; }
