/* ============== EXIT51 CREATOR HUB ============== */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@700;800;900&family=Barlow:wght@500;600;700&family=JetBrains+Mono:wght@600;700&display=swap');

:root {
  --bg-base: #0a0a0a;
  --bg-elev: #141414;
  --bg-card: #1a1a1a;
  --bg-input: #0f0f0f;
  --border: #2a2a2a;
  --border-bright: #3a3a3a;
  --text-1: #ffffff;
  --text-2: #b8b8b8;
  --text-3: #6e6e6e;
  --text-4: #4a4a4a;

  --red: #e8352a;
  --red-hover: #ff4438;
  --red-dim: #b8281f;
  --red-glow: rgba(232, 53, 42, 0.35);

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #22c55e;
  --accent-gold: #eab308;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-1);
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* ============== TOP BAR ============== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-base);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  letter-spacing: 0.02em;
  position: relative;
  text-shadow: 0 0 6px rgba(232, 53, 42, 0.35), 0 0 18px rgba(232, 53, 42, 0.18);
}
.brand .exit {
  font-size: 30px;
  color: var(--text-1);
  letter-spacing: 0.02em;
  margin-right: -0.06em;
}
.brand .num {
  font-size: 30px;
  color: var(--red);
  margin-left: 0;
  letter-spacing: 0.02em;
}
.brand .slash {
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%) skewX(-28deg);
  width: 28px;
  height: 4px;
  background: var(--red);
  box-shadow: 0 0 8px rgba(232, 53, 42, 0.6);
  border-radius: 1px;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  border-left: 1px solid var(--border-bright);
  padding-left: 14px;
  margin-left: 4px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-2);
  transition: all 0.12s ease;
  border: 1px solid transparent;
}

.tab:hover {
  color: var(--text-1);
  background: var(--bg-elev);
}

.tab.active {
  background: var(--red);
  color: white;
  box-shadow: 0 0 0 1px var(--red), 0 0 24px var(--red-glow);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-3);
}

.page-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-base);
  border: 1px solid var(--red);
  border-radius: 999px;
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(232,53,42,0.22), 0 0 22px rgba(232,53,42,0.18);
}
.page-switch .ps-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 10px 18px;
  border-radius: 999px;
  transition: all 0.14s;
  white-space: nowrap;
  text-decoration: none;
}
.page-switch .ps-tab svg { width: 16px; height: 16px; }
.page-switch .ps-tab.active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 16px var(--red-glow);
}
.page-switch .ps-tab:not(.active) {
  color: #fff;
  background: rgba(232,53,42,0.13);
  animation: ps-breathe 1.9s ease-in-out infinite;
}
.page-switch .ps-tab:not(.active):hover { background: rgba(232,53,42,0.24); }
.page-switch .ps-tab .ps-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red);
  animation: ps-pulse 1.5s ease-out infinite;
}
@keyframes ps-pulse {
  0% { box-shadow: 0 0 0 0 rgba(232,53,42,0.6); }
  70% { box-shadow: 0 0 0 7px rgba(232,53,42,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,53,42,0); }
}
@keyframes ps-breathe {
  0%,100% { box-shadow: 0 0 0 0 rgba(232,53,42,0); }
  50% { box-shadow: 0 0 14px 1px rgba(232,53,42,0.4); }
}
@media (prefers-reduced-motion: reduce) {
  .page-switch .ps-tab:not(.active), .page-switch .ps-tab .ps-dot { animation: none; }
}
.topbar-right { gap: 13px; }
@media (max-width: 680px) {
  .topbar-right .live-pill { display: none; }
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--red);
  color: var(--red);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 11px;
  text-transform: uppercase;
}
.live-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--red);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============== STUDIO LAYOUT ============== */
.studio {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: calc(100vh - 57px);
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(100vh - 57px);
  padding-bottom: 24px;
}

.sidebar-header {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1;
}
.sidebar-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

.sb-section {
  padding: 18px 22px 4px;
}

.sb-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-label::before {
  content: "";
  width: 3px;
  height: 11px;
  background: var(--red);
  display: inline-block;
}

/* unit toggle */
.unit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.unit-btn {
  padding: 11px;
  border-radius: var(--radius-md);
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.12s ease;
}
.unit-btn:hover { border-color: var(--border-bright); color: var(--text-1); }
.unit-btn.active {
  background: var(--bg-base);
  border-color: var(--red);
  color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
}

/* template grid */
.tpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tpl-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  transition: all 0.12s ease;
  position: relative;
  min-height: 76px;
}
.tpl-card:hover {
  border-color: var(--border-bright);
  background: #0c0c0c;
}
.tpl-card.active {
  border-color: var(--red);
  background: #1a0807;
  box-shadow: inset 0 0 0 1px var(--red);
}
.tpl-card .tpl-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.tpl-card.active .tpl-icon { color: var(--red); }

.tpl-card .tpl-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--text-1);
  line-height: 1.1;
}
.tpl-card .tpl-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--red);
  background: rgba(232, 53, 42, 0.1);
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

/* color theme */
.theme-row {
  display: flex;
  gap: 10px;
}
.theme-swatch {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  position: relative;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.theme-swatch:hover { transform: scale(1.05); }
.theme-swatch.active {
  border-color: var(--text-1);
  box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--red);
}
.theme-swatch.active::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 900;
  font-size: 18px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* background toggle */
.bg-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bg-btn {
  padding: 11px;
  border-radius: var(--radius-md);
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.12s ease;
}
.bg-btn:hover { border-color: var(--border-bright); color: var(--text-1); }
.bg-btn.active {
  border-color: var(--red);
  color: var(--text-1);
  background: #1a0807;
}

/* fields */
.field-group { display: flex; flex-direction: column; gap: 12px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.12s ease;
  font-family: 'Barlow', sans-serif;
}
.field-input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}

/* speed reference */
.speed-ref {
  background: rgba(232, 53, 42, 0.07);
  border: 1px solid rgba(232, 53, 42, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.speed-ref-icon {
  color: var(--red);
  flex-shrink: 0;
  margin-top: 1px;
}
.speed-ref-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 3px;
}
.speed-ref-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
}

/* download button */
.dl-section {
  padding: 22px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
.dl-btn {
  width: 100%;
  background: var(--red);
  color: white;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.12s ease;
  position: relative;
  overflow: hidden;
}
.dl-btn:hover {
  background: var(--red-hover);
  box-shadow: 0 0 24px var(--red-glow);
}
.dl-btn:disabled {
  background: var(--bg-card);
  color: var(--text-3);
  cursor: not-allowed;
  box-shadow: none;
}
.dl-btn .stripe {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 26px;
  height: 4px;
  background: rgba(255,255,255,0.4);
  transform: skewX(-30deg);
}

.dl-meta {
  text-align: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
}

/* ============== PREVIEW ============== */
.preview-wrap {
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
.preview-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.02em;
  margin: 0;
}
.preview-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

.preview-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background:
    linear-gradient(var(--bg-base), var(--bg-base)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255,255,255,0.02) 12px 13px);
  background-blend-mode: normal;
  position: relative;
  overflow: auto;
}

.preview-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.preview-stage {
  position: relative;
  z-index: 1;
}

.preview-frame-label {
  position: absolute;
  top: -22px;
  left: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.preview-frame-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--text-4);
  border-style: solid;
  pointer-events: none;
}
.preview-frame-corner.tl { top: -6px; left: -6px; border-width: 2px 0 0 2px; }
.preview-frame-corner.tr { top: -6px; right: -6px; border-width: 2px 2px 0 0; }
.preview-frame-corner.bl { bottom: -6px; left: -6px; border-width: 0 0 2px 2px; }
.preview-frame-corner.br { bottom: -6px; right: -6px; border-width: 0 2px 2px 0; }

/* ============== OUTPUT CARD (the actual exported asset) ============== */
.output-card {
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
  font-family: 'Barlow', sans-serif;
  color: white;
  display: flex;
  flex-direction: column;
}

.output-card.transparent {
  background: transparent;
}

/* EXIT51 wordmark */
.e51-wordmark {
  display: inline-flex;
  align-items: baseline;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  letter-spacing: 0.01em;
  position: relative;
  line-height: 0.85;
}
.e51-wordmark .e51-exit {
  color: white;
}
.e51-wordmark .e51-num {
  color: var(--red);
  margin-left: 0.05em;
}
.e51-wordmark .e51-slash {
  position: absolute;
  bottom: -0.06em;
  left: 0.05em;
  height: 0.12em;
  width: 0.5em;
  background: var(--red);
  transform: skewX(-28deg);
}

/* alt logo treatments */
.e51-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  line-height: 0.82;
}
.e51-stack .e51-stack-top {
  color: white;
  letter-spacing: 0.18em;
  font-size: 0.42em;
  margin-bottom: 0.08em;
}
.e51-stack .e51-stack-bottom {
  color: white;
  position: relative;
}
.e51-stack .e51-stack-bottom::after {
  content: "";
  position: absolute;
  bottom: 0.05em;
  left: -0.05em;
  width: 0.55em;
  height: 0.14em;
  background: var(--red);
  transform: skewX(-28deg);
}

/* ============== TOAST ============== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--red);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 24px var(--red-glow);
  z-index: 200;
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============== LEADERBOARD ============== */
.lb-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 32px 80px;
}

.lb-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 32px;
}

.lb-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 56px;
  margin: 0;
  letter-spacing: 0.005em;
  line-height: 0.9;
  position: relative;
  display: inline-block;
}
.lb-title-sub {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 10px;
  letter-spacing: 0.02em;
}
.lb-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  background: var(--red);
  transform: skewX(-30deg);
  margin-top: 12px;
}

.lb-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  min-width: 380px;
}
.lb-stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.lb-stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 18px;
  height: 3px;
  background: var(--red);
  transform: skewX(-30deg);
  margin-left: 8px;
}
.lb-stat-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 30px;
  color: white;
  line-height: 1;
  margin-top: 8px;
}
.lb-stat-label {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 6px;
}

.lb-getlink {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.lb-getlink::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 280px;
  height: 100%;
  background: radial-gradient(circle at 100% 0%, rgba(232, 53, 42, 0.08), transparent 70%);
  pointer-events: none;
}

.lb-getlink h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 24px;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}
.lb-getlink p {
  color: var(--text-3);
  font-size: 13px;
  margin: 0 0 16px;
}
.lb-getlink-row {
  display: flex;
  gap: 10px;
}
.lb-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 14px;
  transition: border-color 0.12s ease;
}
.lb-input-wrap:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}
.lb-input-wrap .at {
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  margin-right: 4px;
}
.lb-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 12px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-1);
}

.lb-getlink-btn {
  background: var(--red);
  color: white;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 22px;
  border-radius: var(--radius-md);
  transition: all 0.12s ease;
}
.lb-getlink-btn:hover {
  background: var(--red-hover);
  box-shadow: 0 0 20px var(--red-glow);
}

.lb-result {
  margin-top: 18px;
  background: var(--bg-base);
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: result-in 0.3s ease;
}
@keyframes result-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.lb-result-info { flex: 1; min-width: 0; }
.lb-result-label {
  font-size: 10px;
  color: var(--red);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 4px;
}
.lb-result-link {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: white;
  font-size: 16px;
  word-break: break-all;
}

.lb-copy-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  transition: all 0.12s;
  white-space: nowrap;
}
.lb-copy-btn:hover { border-color: var(--red); }

/* table */
.lb-table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lb-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.lb-refresh-btn {
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s;
}
.lb-refresh-btn:hover { color: white; border-color: var(--red); }

.lb-table {
  width: 100%;
  border-collapse: collapse;
}
.lb-table th {
  text-align: left;
  padding: 10px 18px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.lb-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr:hover td { background: rgba(255,255,255,0.02); }

.lb-rank {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  color: var(--text-3);
  letter-spacing: 0.04em;
}
.lb-rank.top { color: var(--red); }

.lb-creator {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--bg-card), var(--bg-elev));
  border: 1px solid var(--border-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.lb-table .lb-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--red);
}

.lb-table .lb-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: white;
}
.lb-table .lb-num.dim { color: var(--text-2); }

.lb-mine td {
  background: rgba(232, 53, 42, 0.06) !important;
  border-bottom-color: rgba(232, 53, 42, 0.2);
}
.lb-mine td:first-child {
  position: relative;
}
.lb-mine td:first-child::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--red);
}

/* ============== SOCIAL SHARE / DOWNLOAD MODAL ============== */
.dl-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dl-modal {
  background: var(--bg-elev);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 30px;
  width: 480px;
  max-width: calc(100vw - 40px);
  position: relative;
}
.dl-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all 0.12s;
}
.dl-modal-close:hover { background: var(--red); color: white; }

.dl-modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 26px;
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}
.dl-modal-sub {
  color: var(--text-3);
  font-size: 13px;
  margin: 0 0 20px;
}

.dl-modal-checkmark {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: rgba(232, 53, 42, 0.15);
  border: 2px solid var(--red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  margin-bottom: 14px;
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}
.share-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  transition: all 0.12s;
}
.share-btn:hover { border-color: var(--red); color: white; transform: translateY(-1px); }

.dl-modal-note {
  margin-top: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.5;
}
.dl-modal-note b { color: var(--text-2); font-weight: 700; }

/* ============== SCROLLBARS ============== */
.sidebar::-webkit-scrollbar,
.preview-canvas::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.sidebar::-webkit-scrollbar-track,
.preview-canvas::-webkit-scrollbar-track {
  background: var(--bg-base);
}
.sidebar::-webkit-scrollbar-thumb,
.preview-canvas::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 4px;
}

/* ============== SAVE PROMPT (mobile share-to-photos) ============== */
.save-prompt-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: savePromptFade 0.2s ease;
}
@keyframes savePromptFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.save-prompt {
  background: var(--bg-elev);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(232, 53, 42, 0.2);
}
.save-prompt-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(232, 53, 42, 0.15);
  border: 1px solid rgba(232, 53, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  margin: 0 auto 18px;
}
.save-prompt-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 0.02em;
  color: white;
  margin: 0 0 8px;
}
.save-prompt-sub {
  font-size: 14px;
  color: var(--text-2);
  margin: 0 0 22px;
  line-height: 1.4;
}
.save-prompt-hint {
  font-size: 12px;
  color: var(--text-3);
  margin: -14px 0 22px;
  line-height: 1.5;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
}
.save-prompt-hint b {
  color: white;
  font-weight: 700;
}
.save-prompt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 14px 20px;
  background: var(--red);
  color: white;
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.12s ease;
}
.save-prompt-btn:active {
  filter: brightness(0.9);
}
.save-prompt-cancel {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: transparent;
  color: var(--text-2);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.save-prompt-cancel:active {
  color: white;
}

/* ============== MOBILE / TABLET RESPONSIVE ==============
   Below 900px the desktop side-by-side studio layout becomes unusable —
   stack the sidebar above the preview so creators can scroll through
   inputs naturally on a phone. Desktop (>=900px) is entirely unaffected. */
@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }
  .topbar-left {
    gap: 10px;
    flex-wrap: wrap;
  }
  .topbar-right {
    margin-left: auto;
  }
  .brand-sub {
    display: none; /* "Creator Hub" sub-label crowds small screens */
  }
  .tabs {
    width: 100%;
    order: 3;
  }
  .tabs .tab {
    flex: 1;
    justify-content: center;
  }
  .live-pill {
    font-size: 10px;
    padding: 4px 8px;
  }

  /* Stack studio: PREVIEW on top, sidebar (edit panels) below.
     min-width: 0 prevents grid items from expanding to their content width
     (the preview-stage was forcing the grid cell to 700+px, breaking layout). */
  body {
    overflow-x: hidden;
  }
  .studio {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .studio > * {
    min-width: 0;
  }
  .preview-wrap {
    order: 1;
  }
  .sidebar {
    order: 2;
    max-height: none;
    border-right: none;
    border-top: 1px solid var(--border);
    padding-bottom: 18px;
  }

  /* Preview gets a fixed-ish height so the user can see it without scrolling
     past it — the canvas JS auto-scales the 1080×1080 art to fit. */
  .preview-wrap {
    min-height: 60vh;
    min-width: 0;
    width: 100%;
    overflow: hidden;
  }
  .preview-canvas {
    min-width: 0;
    overflow: hidden;
    padding: 20px;
  }
  .preview-stage {
    max-width: 100%;
    max-height: 100%;
  }
  .preview-header {
    padding: 12px 16px;
  }
  .preview-title {
    font-size: 18px;
  }
  .preview-meta {
    gap: 8px;
    font-size: 10px;
  }

  /* Bigger tap targets for fields & buttons (Apple guideline ≥44px) */
  .field-input,
  .tpl-card,
  .theme-swatch {
    min-height: 44px;
  }

  /* Template grid keeps 2 cols on tablet, drops to 1 on phone (<480px block) */
  .tpl-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tpl-card {
    min-width: 0;
  }

  /* Leaderboard: stack hero stats */
  .lb-page {
    padding: 20px 16px 60px;
  }
  .lb-stats {
    grid-template-columns: 1fr;
    min-width: 0;
  }
  .lb-title {
    font-size: 38px;
  }
  .lb-hero-glow {
    display: none;
  }

  /* Download modal — already has max-width:calc(100vw-40px), but tighten padding */
  .dl-modal {
    padding: 22px;
  }
}

/* Phone-sized — extra compaction */
@media (max-width: 480px) {
  .tpl-grid {
    grid-template-columns: 1fr;
  }
  .tabs .tab {
    font-size: 11px;
    padding: 7px 10px;
  }
}
