:root {
  --page: #050608;
  --panel: #ffffff;
  --soft: rgba(255, 255, 255, 0.06);
  --line: #e8e8e8;
  --line-strong: #dedede;
  --text: #181818;
  --muted: #8b8b8b;
  --hero-text: #f5f6f8;
  --feed-text: #eef1f6;
  --feed-muted: #88909d;
  --feed-border: #202734;
  --rail-bg: rgba(255, 255, 255, 0.04);
  --rail-border: #242a33;
  --accent: #ff8a00;
  --accent-strong: #f97316;
  --accent-soft: rgba(255, 138, 0, 0.2);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --theme-icon-muted: rgba(255, 255, 255, 0.58);
  --theme-icon-active: #151515;
}

html[data-theme="light"],
html:has(#theme-toggle:not(:checked)) {
  --page: #f6f6f4;
  --soft: rgba(0, 0, 0, 0.045);
  --hero-text: #151515;
  --feed-text: #17191d;
  --feed-muted: #737b86;
  --feed-border: #dbdedf;
  --rail-bg: rgba(0, 0, 0, 0.04);
  --rail-border: rgba(0, 0, 0, 0.1);
  --shadow: 0 18px 48px rgba(22, 24, 28, 0.09);
  --theme-icon-muted: #9aa2ae;
  --theme-icon-active: #151515;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hero {
  position: relative;
  min-height: 540px;
  padding: 18px 24px 48px;
  background: var(--page);
}

.hero-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 228px;
  max-width: calc(100vw - 48px);
  height: 38px;
  margin: 0;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: var(--soft);
}

.mode-button {
  border-radius: 999px;
  background: transparent;
  color: #9aa2ae;
  font-size: 14px;
  font-weight: 500;
}

.mode-button.active {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 7px 20px rgba(0, 0, 0, 0.08);
}

.theme-toggle {
  justify-self: end;
  cursor: pointer;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 78px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--rail-border);
  border-radius: 999px;
  background: var(--soft);
}

.theme-icon {
  position: relative;
  z-index: 1;
  display: grid;
  width: 34px;
  height: 32px;
  place-items: center;
  color: var(--theme-icon-muted);
}

.sun-icon::before {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 999px;
  content: "";
}

.sun-icon::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  border-radius: 999px;
  box-shadow:
    0 -10px 0 currentColor,
    0 10px 0 currentColor,
    10px 0 0 currentColor,
    -10px 0 0 currentColor,
    7px -7px 0 currentColor,
    -7px -7px 0 currentColor,
    7px 7px 0 currentColor,
    -7px 7px 0 currentColor;
  content: "";
  transform: translate(-50%, -50%);
}

.moon-icon::before {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  box-shadow: inset -5px -2px 0 currentColor;
  content: "";
}

.theme-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 34px;
  height: 32px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  transition: transform 160ms ease;
}

.theme-toggle input:not(:checked) + .theme-track .sun-icon,
.theme-toggle input:checked + .theme-track .moon-icon {
  color: var(--theme-icon-active);
}

.theme-toggle input:checked + .theme-track .theme-thumb {
  transform: translateX(38px);
}

.hero-center {
  width: clamp(560px, 48vw, 860px);
  max-width: calc(100vw - 48px);
  margin: clamp(178px, 22vh, 235px) auto 0;
}

.hero h1 {
  margin: 0 0 28px;
  text-align: center;
  color: var(--hero-text);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.25;
}

.prompt-box {
  width: 100%;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.prompt-box:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 20px 58px rgba(18, 18, 18, 0.09);
}

textarea {
  width: 100%;
  min-height: 48px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.35;
}

textarea::placeholder {
  color: #9a9a9a;
}

.prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.right-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--text);
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.icon-button.secondary {
  color: #202020;
}

.add-button {
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.add-button:hover,
.add-button:focus-visible {
  background: #151515;
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.icon-button.submit {
  background: var(--accent);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.mic-icon {
  position: relative;
  width: 13px;
  height: 20px;
  border: 2px solid currentColor;
  border-bottom-width: 4px;
  border-radius: 999px;
}

.mic-icon::before,
.mic-icon::after {
  position: absolute;
  left: 50%;
  content: "";
  transform: translateX(-50%);
  background: currentColor;
}

.mic-icon::before {
  top: 16px;
  width: 2px;
  height: 8px;
}

.mic-icon::after {
  top: 24px;
  width: 12px;
  height: 2px;
  border-radius: 999px;
}

.text-button {
  height: 34px;
  padding: 0 4px;
  background: transparent;
  color: #777777;
  font-size: 14px;
  font-weight: 500;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-results {
  padding: 14px 24px 58px;
  background: var(--page);
  color: var(--feed-text);
}

.search-results[hidden] {
  display: none;
}

.results-inner {
  width: min(1450px, calc(100vw - 48px));
  margin: 0 auto;
}

.results-heading {
  align-items: end;
}

.results-heading > div {
  min-width: 0;
}

.results-summary {
  margin: 8px 0 0 17px;
  color: var(--feed-muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.clear-results {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--rail-border);
  border-radius: 999px;
  background: var(--rail-bg);
  color: var(--feed-text);
  font-size: 13px;
  font-weight: 650;
}

.clear-results:hover,
.clear-results:focus-visible {
  border-color: var(--accent);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 218px));
  gap: 22px 16px;
}

.match-pill {
  display: inline-flex;
  width: max-content;
  max-width: calc(100% - 4px);
  min-height: 24px;
  align-items: center;
  margin: 9px 2px 0;
  padding: 0 9px;
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #138a3d;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
}

body.search-focused .discovery-feed {
  display: none;
}

.discovery-feed {
  margin-top: -1px;
  padding: 44px 24px 86px;
  background: var(--page);
  color: var(--feed-text);
}

.feed-inner {
  width: min(1450px, calc(100vw - 48px));
  margin: 0 auto;
}

.row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.row-heading.compact {
  margin-top: 66px;
}

.row-heading h2 {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 0;
  color: var(--feed-text);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.row-heading h2::before {
  width: 4px;
  height: 25px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.rail-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--rail-border);
  border-radius: 999px;
  background: var(--rail-bg);
  color: var(--feed-text);
  font-size: 34px;
  line-height: 1;
}

.template-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 218px;
  gap: 16px;
  overflow-x: auto;
  padding: 0 8px 10px 0;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.template-row::-webkit-scrollbar {
  display: none;
}

.template-row.wide {
  grid-auto-columns: 360px;
}

.template-card {
  min-width: 0;
  display: block;
  color: inherit;
  text-decoration: none;
  outline: none;
}

.template-card:focus-visible .template-preview {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 12px 28px rgba(0, 0, 0, 0.18);
}

.template-card:hover .template-preview {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.template-card h3 {
  margin: 13px 2px 4px;
  overflow: hidden;
  color: var(--feed-text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-card p {
  margin: 0 2px;
  overflow: hidden;
  color: var(--feed-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-preview {
  position: relative;
  height: 274px;
  overflow: hidden;
  border: 1px solid var(--feed-border);
  border-radius: 8px;
  background: #111722;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.template-preview.landscape {
  height: 170px;
}

.live-site-preview {
  --frame-height: 620px;
  --frame-scale: 0.383;
  --frame-width: 940px;

  background: #ffffff;
}

.live-site-preview.mobile-preview {
  --frame-height: 780px;
  --frame-scale: 0.559;
  --frame-width: 390px;
}

.site-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: var(--frame-width);
  height: var(--frame-height);
  border: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transform: scale(var(--frame-scale));
  transform-origin: top left;
  transition: opacity 220ms ease;
}

.live-site-preview.loaded .site-frame {
  opacity: 1;
}

.preview-fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 22px 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.62)),
    linear-gradient(135deg, #1a2028, #77808c);
  color: #ffffff;
  transition: opacity 220ms ease;
}

.preview-fallback strong {
  font-size: 17px;
  font-weight: 750;
  line-height: 1.1;
}

.preview-fallback span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.live-site-preview.loaded .preview-fallback {
  opacity: 0;
}

.rank-badge {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 46px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  line-height: 0.95;
  text-align: center;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
}

.rank-badge span {
  font-size: 10px;
}

.rank-badge strong {
  font-size: 14px;
}

@media (max-width: 1240px) {
  .results-grid {
    grid-template-columns: repeat(4, minmax(0, 218px));
  }
}

@media (max-width: 980px) {
  .results-grid {
    grid-template-columns: repeat(3, minmax(0, 218px));
  }
}

@media (max-width: 720px) {
  .hero {
    min-height: 535px;
    padding: 14px 16px 48px;
  }

  .mode-switch {
    width: 204px;
    height: 36px;
  }

  .hero-topbar {
    grid-template-columns: 1fr auto;
  }

  .hero-topbar > div:first-child {
    display: none;
  }

  .mode-switch {
    justify-self: start;
  }

  .theme-track {
    width: 78px;
    height: 38px;
  }

  .theme-thumb {
    width: 34px;
    height: 32px;
  }

  .theme-toggle input:checked + .theme-track .theme-thumb {
    transform: translateX(38px);
  }

  .mode-button {
    font-size: 15px;
  }

  .hero-center {
    width: 100%;
    margin-top: 168px;
  }

  .hero h1 {
    margin-bottom: 22px;
    font-size: 21px;
  }

  .prompt-box {
    min-height: 122px;
    padding: 14px;
    border-radius: 22px;
  }

  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .text-button {
    display: none;
  }

  .discovery-feed {
    padding: 26px 16px 64px;
  }

  .search-results {
    padding: 12px 16px 46px;
  }

  .feed-inner {
    width: 100%;
  }

  .results-inner {
    width: 100%;
  }

  .results-heading {
    align-items: center;
    gap: 14px;
  }

  .results-summary {
    margin-left: 17px;
    font-size: 13px;
  }

  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 14px;
  }

  .row-heading h2 {
    font-size: 21px;
  }

  .template-row {
    grid-auto-columns: 204px;
  }

  .template-row.wide {
    grid-auto-columns: 292px;
  }

  .template-preview {
    height: 252px;
  }

  .template-preview.landscape {
    height: 150px;
  }

  .live-site-preview {
    --frame-height: 620px;
    --frame-scale: 0.324;
    --frame-width: 900px;
  }

  .live-site-preview.mobile-preview {
    --frame-height: 780px;
    --frame-scale: 0.523;
    --frame-width: 390px;
  }
}

@media (max-width: 460px) {
  .results-grid {
    grid-template-columns: 1fr;
  }
}
