:root {
  --bg: #f6f8fb;
  /* Slightly blue-tinted wash for a calmer, more polished feel */
  --bg-gradient-top: #edf0f9;
  --bg-gradient-mid: #f2f5fb;
  --bg-gradient-bottom: #f8fafd;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --border: #e4e7ec;
  --accent: #1f4fd1;
  --accent-hover: #1b46ba;
  --accent-soft: #eef3ff;
  --app-shell-max: 1240px;
}

* {
  box-sizing: border-box;
}

/* Reserve scrollbar space so Create vs Explore doesn’t shift layout when one page scrolls */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  scrollbar-gutter: stable;
  background-color: var(--bg-gradient-bottom);
  background-image: linear-gradient(
    180deg,
    var(--bg-gradient-top) 0%,
    var(--bg-gradient-mid) 42%,
    var(--bg-gradient-bottom) 100%
  );
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  background: rgba(251, 252, 254, 0.82);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
}

.nav-shell {
  max-width: min(100%, 1520px);
  margin: 0 auto;
  padding: 10px clamp(10px, 1.2vw, 20px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.site-brand {
  text-decoration: none;
  color: #1f2937;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.site-brand:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 4px;
  background: #f3f5f9;
  border: 1px solid #e2e7ef;
  border-radius: 999px;
  padding: 3px;
}

.nav-links a {
  text-decoration: none;
  color: #475467;
  min-width: 88px;
  text-align: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 650;
  border: 1px solid transparent;
  transition: all 0.16s ease;
}

.nav-links a.active,
.nav-links a:hover {
  background: #ffffff;
  border-color: #d4ddec;
  color: #1b46ba;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.09);
}

.container {
  max-width: 860px;
  margin: 34px auto 56px;
  padding: 0 20px;
  position: relative;
  isolation: isolate;
}

/* Soft focus: faint radial wash behind the main column (form area), barely visible */
.container::before {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: min(108%, 920px);
  height: clamp(380px, 56vh, 620px);
  background: radial-gradient(
    ellipse 74% 62% at 50% 50%,
    rgba(255, 255, 255, 0.34) 0%,
    rgba(252, 253, 255, 0.14) 42%,
    rgba(248, 250, 253, 0.04) 62%,
    transparent 76%
  );
}

.container > * {
  position: relative;
  z-index: 1;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2.05rem, 2.9vw, 2.7rem);
  letter-spacing: -0.03em;
  line-height: 1.12;
  text-align: center;
  background: linear-gradient(135deg, #1a3a8f 0%, #1f4fd1 45%, #5b5ef5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 620px;
  margin-inline: auto;
  text-align: center;
}

.hero-lead {
  font-size: 1rem;
  line-height: 1.5;
  color: #7a8496;
}

/* Inline “Explore” links (hero, visibility help, success note) */
.explore-inline-link {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
  border-bottom: 1px solid rgba(31, 79, 209, 0.35);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.explore-inline-link:hover {
  color: var(--accent-hover);
  border-bottom-color: rgba(27, 70, 186, 0.55);
}

.explore-pointer {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #475467;
  font-size: 0.89rem;
  font-weight: 600;
  border-bottom: 1px solid #d8dee8;
  padding-bottom: 2px;
}

.explore-pointer:hover {
  color: #344054;
  border-bottom-color: #b9c4d6;
}

.card {
  background: var(--card);
  border: 1px solid #c9d2e3;
  border-radius: 18px;
  padding: 28px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 -1px 0 rgba(230, 235, 245, 0.5) inset,
    0 2px 4px rgba(15, 23, 42, 0.04),
    0 20px 56px -8px rgba(15, 23, 42, 0.12);
}

.hidden {
  display: none;
}

.share-result {
  margin: 20px 0;
  background: #effaf4;
  border-color: #cdeed9;
}

.manage-card {
  margin: 14px 0 0;
  border-color: #d8e4fb;
  background: #f5f8ff;
}

.success-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.success-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.visibility-badge {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e5e7eb;
  color: #374151;
}

.visibility-badge.is-public {
  background: #dcfce7;
  color: #166534;
}

.share-note {
  margin: 8px 0 0;
  color: #374151;
}

.share-row {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.form-card {
  max-width: 560px;
  margin: 24px auto 0;
  display: grid;
  gap: 15px;
}

label {
  font-weight: 600;
  font-size: 0.94rem;
  color: #1f2937;
  margin-top: 2px;
}

input[type="text"],
.share-row input {
  width: 100%;
  border: 1px solid #dbe0e8;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  width: 100%;
  border: 1px solid #dbe0e8;
  border-radius: 12px;
  padding: 11px 13px;
  font: inherit;
  background: #fff;
  resize: vertical;
  min-height: 88px;
}

textarea:focus {
  border-color: #b8cef5;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  outline: none;
}

input[type="text"]:focus,
.share-row input:focus {
  border-color: #b8cef5;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  outline: none;
}

#htmlFile {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.visibility-picker {
  margin: 2px 0 0;
  border: 0;
  padding: 0;
}

.visibility-picker legend {
  font-weight: 600;
  margin-bottom: 9px;
  font-size: 0.94rem;
  color: #1f2937;
}

.file-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #dbe0e8;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-upload:hover {
  border-color: #cfd7e4;
}

.file-upload:focus-within {
  border-color: #b8cef5;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d3dae6;
  border-radius: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  color: #111827;
  font-weight: 600;
  white-space: nowrap;
}

.file-upload-name {
  color: #475467;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visibility-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
  padding: 8px 12px;
  border: 1px solid #e3e7ee;
  border-radius: 999px;
  background: #fafbfc;
  cursor: pointer;
  transition: all 0.16s ease;
}

.visibility-option input {
  accent-color: #2563eb;
}

.visibility-option:hover {
  border-color: #dbe6fb;
  background: #f1f5ff;
}

.visibility-help {
  margin: 2px 0 0;
  color: #5b6472;
  font-size: 0.86rem;
  display: grid;
  gap: 4px;
  line-height: 1.4;
}

.safety-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  max-width: 520px;
  color: #7b8595;
  font-size: 0.82rem;
  line-height: 1.6;
  background: #fbfcfd;
  border: 1px solid #edf0f4;
  border-radius: 12px;
  padding: 10px 12px;
}

.safety-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 999px;
  border: 1px solid #cfd8e6;
  color: #60708a;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.action-btn {
  border: 0;
  border-radius: 13px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 7px 18px rgba(31, 79, 209, 0.3), 0 1px 3px rgba(31, 79, 209, 0.15);
}

.action-btn:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(27, 70, 186, 0.34), 0 2px 6px rgba(27, 70, 186, 0.18);
}

.secondary-btn {
  white-space: nowrap;
  background: linear-gradient(135deg, #1c2433 0%, #111827 100%);
}

.secondary-btn:hover {
  background: linear-gradient(135deg, #111827 0%, #030712 100%);
}

.link-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.explore-main {
  /* Use % not vw — 100vw ignores classic scrollbar width and can cause horizontal overflow */
  max-width: min(100%, 1920px);
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(6px, 1vw, 16px);
  position: relative;
  isolation: isolate;
}

/* Same soft radial focus as Create `.container`, scaled for the wide Explore layout */
.explore-main::before {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(96%, 1600px);
  height: min(88vh, 960px);
  background: radial-gradient(
    ellipse 72% 58% at 50% 50%,
    rgba(255, 255, 255, 0.34) 0%,
    rgba(252, 253, 255, 0.14) 42%,
    rgba(248, 250, 253, 0.04) 62%,
    transparent 76%
  );
}

.explore-main > * {
  position: relative;
  z-index: 1;
}

/* Match header width to the wider Explore canvas */
.explore-page .nav-shell {
  max-width: min(100%, 1920px);
}

/* Flex row: prev | stage | next — avoids fragile absolute left/right on the arrows */
.explore-stage-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(8px, 1.2vw, 20px);
  max-width: 100%;
  margin: 8px auto 0;
}

.explore-stage {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid #c9d2e3;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 -1px 0 rgba(230, 235, 245, 0.5) inset,
    0 2px 4px rgba(15, 23, 42, 0.04),
    0 20px 56px -8px rgba(15, 23, 42, 0.12);
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 6px;
  padding: 4px 10px 0;
}

.stage-head h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.3;
}

.stage-meta {
  max-width: 72ch;
}

.stage-meta h1 {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.stage-description {
  margin: 3px 0 0;
  color: #4f5d72;
  font-size: 0.95rem;
  line-height: 1.45;
}

.stage-description.is-empty {
  color: #98a2b3;
  font-style: italic;
}

.meta {
  margin: 7px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.stage-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475467;
  border: 1px solid #e6e9ef;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f9fafb;
}

.stage-frame-wrap {
  border: 1px solid #cdd5e4;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) inset;
}

.stage-frame {
  width: 100%;
  min-height: 82vh;
  border: 0;
  background: #fff;
}

/* Explore carousel: light circles + open stroked chevrons (not filled / not play-style) */
.stage-nav {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 128px;
  height: 128px;
  border-radius: 999px;
  text-decoration: none;
  color: #5a6b85;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease,
    color 0.2s ease;
  z-index: 3;
}

.stage-nav:hover {
  transform: translateY(-1px);
  background: #ffffff;
  border-color: rgba(100, 116, 139, 0.35);
  color: #3d4f6a;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1), 0 2px 6px rgba(15, 23, 42, 0.05);
}

.stage-nav:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.stage-nav.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.stage-nav-icon {
  width: 64%;
  height: 64%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Optical balance: chevrons read slightly off-center without a hair nudge */
}

.stage-nav-prev .stage-nav-icon {
  transform: translateX(-0.5px);
}

.stage-nav-next .stage-nav-icon {
  transform: translateX(0.5px);
}

.stage-nav-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.stage-nav-chevron path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage-link {
  text-decoration: none;
  color: #475467;
  font-size: 0.86rem;
  font-weight: 600;
  border-bottom: 1px solid #d0d7e2;
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.stage-link:hover {
  color: #2f3b52;
  border-bottom-color: #afbccc;
}

.stage-copy-btn {
  appearance: none;
  border: 1px solid #dbe3f0;
  border-radius: 999px;
  padding: 5px 12px;
  background: #f4f7fc;
  color: #475467;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.stage-copy-btn:hover {
  background: #eaeffa;
  border-color: #c5d0e8;
  color: #1f3a6e;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.07);
}

.stage-copy-btn.copied {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.explore-page {
  background-color: var(--bg-gradient-bottom);
  background-image: linear-gradient(
    180deg,
    var(--bg-gradient-top) 0%,
    var(--bg-gradient-mid) 42%,
    var(--bg-gradient-bottom) 100%
  );
}

.explore-page .container {
  max-width: min(100%, 1520px);
  margin-top: 8px;
  margin-bottom: 20px;
  padding-inline: clamp(10px, 1.2vw, 20px);
}

.empty-state {
  text-align: center;
  max-width: 560px;
  margin: 40px auto 0;
}

/* Explore empty state: same “card” presence as Create */
.explore-main .empty-state {
  margin-top: 32px;
  padding: 36px 28px;
  background: var(--card);
  border: 1px solid #c9d2e3;
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.88) inset,
    0 2px 4px rgba(15, 23, 42, 0.04),
    0 18px 50px -6px rgba(15, 23, 42, 0.11);
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0 0 14px;
  color: var(--muted);
}

@media (max-width: 760px) {
  .nav-shell {
    padding: 9px 14px;
  }

  .container {
    margin: 24px auto 34px;
    padding: 0 14px;
  }

  .card {
    padding: 20px;
    border-radius: 16px;
  }

  .share-row {
    flex-direction: column;
  }

  .success-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .visibility-option {
    margin-bottom: 8px;
  }

  .file-upload {
    flex-direction: column;
    align-items: flex-start;
  }

  .explore-stage-wrap {
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .explore-stage {
    flex: 1 1 100%;
    order: 1;
  }

  .stage-nav-prev {
    order: 2;
    width: calc(50% - 6px);
    max-width: 200px;
    height: 88px;
    border-radius: 999px;
    margin-top: 10px;
  }

  .stage-nav-next {
    order: 3;
    width: calc(50% - 6px);
    max-width: 200px;
    height: 88px;
    border-radius: 999px;
    margin-top: 10px;
  }

  .stage-head {
    flex-direction: column;
  }

  .stage-tools {
    width: 100%;
    justify-content: space-between;
  }

  .stage-frame {
    min-height: 68vh;
  }
}
