:root {
  --hub-bg: #f7f7f5;
  --card-bg: #ffffff;
  --card-border: rgba(15, 23, 42, 0.08);
  --muted: rgba(15, 23, 42, 0.65);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
}

body {
  background: var(--hub-bg);
}

.hub-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.25rem;
}

@media (max-width: 980px) {
  .hub-shell {
    grid-template-columns: 1fr;
  }
}

.hub-sidebar {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  height: fit-content;
  position: sticky;
  top: 1rem;
}

@media (max-width: 980px) {
  .hub-sidebar {
    position: static;
  }
}

.sidebar-section + .sidebar-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(15, 23, 42, 0.65);
  margin-bottom: 0.6rem;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(15, 23, 42, 0.88);
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.sidebar-btn:hover {
  background: rgba(15, 23, 42, 0.04);
}

.sidebar-btn.is-active {
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.25);
  color: rgba(2, 132, 199, 1);
  font-weight: 600;
}

.sidebar-hint {
  font-size: 0.9rem;
  color: rgba(15, 23, 42, 0.7);
  line-height: 1.4;
}

.hub-content {
  min-width: 0;
}

.hub-topbar {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

@media (max-width: 980px) {
  .hub-topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

.hub-title h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.hub-subtitle {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.hub-search {
  display: flex;
  gap: 0.5rem;
}

.hub-search input[type='search'] {
  flex: 1;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 1rem;
  min-width: 0;
}

.hub-actions {
  display: flex;
  justify-content: flex-end;
}

.hub-section + .hub-section {
  margin-top: 2rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.section-sub {
  color: var(--muted);
  font-size: 0.95rem;
}

.featured-row {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.template-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(2, 132, 199, 0.25);
}

.template-cover {
  position: relative;
  height: 96px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.18), rgba(2, 132, 199, 0.04));
}

.template-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.55), transparent 45%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.35), transparent 55%),
    radial-gradient(circle at 60% 90%, rgba(255, 255, 255, 0.25), transparent 55%);
  opacity: 0.9;
}

.template-cover[data-pattern='grid']::after {
  background: radial-gradient(rgba(255, 255, 255, 0.8) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.22;
}

.template-cover[data-pattern='waves']::after {
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0.22) 12px,
    transparent 12px,
    transparent 24px
  );
  opacity: 0.4;
}

.template-cover[data-pattern='noise']::after {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.35;
}

.template-body {
  padding: 0.9rem 0.9rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
  min-height: 0;
}

.template-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(15, 23, 42, 0.65);
  text-transform: uppercase;
}

.template-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: rgba(15, 23, 42, 0.92);
  line-height: 1.25;
}

.template-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-preview {
  margin-top: 0.25rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.06);
  padding: 0.6rem 0.7rem;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: rgba(15, 23, 42, 0.82);
  max-height: 5.2rem;
  overflow: hidden;
  white-space: pre;
}

.template-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
}

.template-stats {
  display: flex;
  gap: 0.6rem;
  color: rgba(15, 23, 42, 0.6);
  font-size: 0.85rem;
}

.template-actions {
  display: flex;
  gap: 0.35rem;
}

.btn-mini {
  padding: 0.35rem 0.55rem;
  border-radius: 9px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 0.85rem;
  color: rgba(15, 23, 42, 0.82);
}

.btn-mini:hover {
  background: rgba(15, 23, 42, 0.04);
}

.skeleton-card,
.skeleton-tile {
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.07), rgba(15, 23, 42, 0.04));
  background-size: 180% 100%;
  animation: shimmer 1.1s ease-in-out infinite;
}

.skeleton-card {
  width: 320px;
  height: 180px;
  flex: 0 0 auto;
}

.skeleton-tile {
  height: 220px;
}

@keyframes shimmer {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 180% 0%;
  }
}

/* Preview dialog */
#preview-dialog {
  width: min(760px, 92vw);
  border: none;
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow-md);
}

#preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.preview-shell {
  background: var(--card-bg);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  overflow: hidden;
}

.preview-head {
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.preview-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.preview-sub {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.preview-body {
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.preview-desc {
  color: rgba(15, 23, 42, 0.82);
  font-size: 0.98rem;
  line-height: 1.45;
}

.preview-code {
  margin: 0;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.07);
  padding: 0.9rem;
  max-height: 320px;
  overflow: auto;
  font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
  font-size: 0.85rem;
}

.preview-actions {
  padding: 0.9rem 1rem 1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Shared auth modal (marketing pages) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 14px;
  width: min(420px, 92vw);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: rgba(15, 23, 42, 0.7);
  line-height: 1;
}

.modal-body {
  padding: 16px;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  font-size: 1rem;
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-button {
  padding: 8px 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.03);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.modal-button.primary {
  background: var(--clr-accent);
  border-color: var(--clr-accent);
  color: #fff;
}

.modal-button:hover {
  filter: brightness(0.98);
}

/* Submit dialog */
#submit-dialog {
  width: min(520px, 92vw);
  border: none;
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--shadow-md);
}

#submit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

#submit-dialog form {
  background: var(--card-bg);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 1rem;
}
