*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-subtle: #fafaf9;
  --bg: #ffffff;
  --fg: #0c0a09;
  --fg-muted: #78716c;
  --border: #e7e5e4;
  --fill-muted: #f3efed;
  --accent: #f26522;
  --accent-strong: #ea580c;
  --r-1: 2px;
  --header-h: 60px;
  --footer-h: 32px;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
}

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

body {
  background: var(--bg-subtle);
  color: var(--fg);
  font-family: "Geist", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv11", "ss01";
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 1px dotted var(--accent-strong);
  outline-offset: 3px;
  border-radius: 4px;
}

.home-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.container-1312 {
  width: 100%;
  max-width: 1408px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
}

@media (min-width: 768px) {
  .container-1312 {
    padding-left: 32px;
    padding-right: 32px;
  }
}

@media (min-width: 1024px) {
  .container-1312 {
    padding-left: 64px;
    padding-right: 64px;
  }
}

/* --- Header --- */

.site-header {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 50;
  width: 100%;
  height: var(--header-h);
  background-color: var(--bg-subtle);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.site-header__logo-link {
  display: flex;
  flex-shrink: 0;
  align-items: center;
}

.site-header__logo {
  display: block;
  height: 20px;
  width: auto;
}

.site-header__nav {
  display: flex;
  align-items: center;
}

.site-header__nav .btn-slide {
  align-items: center;
  color: var(--fg);
  display: inline-flex;
  font-size: 14px;
  font-weight: 500;
  height: 36px;
  line-height: 20px;
  padding: 8px 16px;
}

.site-header__yc {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.yc-square__svg {
  display: block;
  width: 100%;
  height: 100%;
}

.yc-square .yc-square-bg {
  fill: #0c0a09;
  transition: fill 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.yc-square:hover .yc-square-bg,
.yc-square:focus-visible .yc-square-bg {
  fill: var(--accent);
}

/* --- Shared slide button --- */

.btn-slide {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-1) !important;
  isolation: isolate;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-slide-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 460ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  pointer-events: none;
  z-index: 0;
  background: var(--fill-muted);
}

.btn-slide:hover .btn-slide-fill,
.btn-slide:focus-visible .btn-slide-fill {
  transform: scaleX(1);
}

.btn-slide-content {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border) !important;
  color: var(--fg);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.btn-secondary.is-active {
  background: #0c0a09;
  border-color: #0c0a09 !important;
  color: #ffffff;
}

.btn-secondary.is-active .btn-slide-fill {
  background: var(--accent-strong);
}

.btn-secondary.is-active:hover .btn-slide-fill,
.btn-secondary.is-active:focus-visible .btn-slide-fill {
  transform: scaleX(1);
}

/* --- Footer --- */

.site-footer {
  width: 100%;
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--fg-muted);
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--footer-h);
  font-size: 12px;
}

.site-footer a:hover {
  color: var(--fg);
  transition: color 150ms ease;
}

/* --- Embed mode (blog iframe: ?embed=1) — base tokens only; layout overrides at file end --- */

html.embed {
  --header-h: 0px;
  --footer-h: 0px;
}

/* --- Main / demo --- */

.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--header-h);
  overflow: hidden;
}

.demo {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 20px;
  padding-bottom: 16px;
}

.demo__header {
  max-width: 720px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.h-display {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  line-height: 1.15;
  letter-spacing: calc(-2 / 48 * 1em);
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 6px;
}

.demo__lede {
  color: var(--fg-muted);
  font-size: 14px;
  max-width: none;
  line-height: 1.4;
  white-space: nowrap;
}

.control-label {
  color: var(--fg-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.control-hint {
  margin-top: 6px;
  color: var(--fg-muted);
  font-size: 11px;
}

.prompt-list,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-text {
  margin: 0;
  color: var(--fg);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
}

#view-list {
  flex-wrap: nowrap;
  width: 100%;
}

#view-list .btn-secondary {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  font-size: 11px;
}

#ratio-list {
  flex-wrap: nowrap;
}

#ratio-list .btn-secondary {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  font-size: 12px;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
  width: 100%;
}

.stage__visual {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.canvas-wrap {
  position: relative;
  width: auto;
  height: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  max-width: min(100%, calc(100dvh - var(--header-h) - var(--footer-h) - 120px));
  overflow: hidden;
  border-radius: var(--r-1);
  border: 1px solid var(--border);
  background: #0c0a09;
}

.patch-tooltip {
  position: absolute;
  z-index: 3;
  max-width: calc(100% - 8px);
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--r-1);
  background: rgba(12, 10, 9, 0.88);
  color: #fafaf9;
  font-family: "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.patch-tooltip[hidden] {
  display: none;
}

#stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.side-panel {
  flex: 0 0 280px;
  width: 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  padding: 2px 12px 10px;
  align-self: stretch;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.side-section--answer {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-section--last {
  border-bottom: none;
  padding-bottom: 2px;
  flex-shrink: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stats div {
  padding: 6px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-1);
  background: var(--bg-subtle);
}

.stats dt {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 2px;
}

.stats dd {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  font-weight: 500;
}

.answer-card__ratio {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.answer-card__text {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

#method-text {
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1.4;
}

.legend {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  color: var(--fg-muted);
  font-size: 12px;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: var(--r-1);
  border: 1px solid var(--border);
}

.swatch--kept {
  background: #fafaf9;
}

.swatch--pruned {
  background: #292524;
}

@media (max-width: 920px) {
  .demo__lede {
    white-space: normal;
  }

  .home-page {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .home-main,
  .demo {
    overflow: visible;
  }

  .stage {
    flex-direction: column;
    align-items: center;
    flex: none;
  }

  .canvas-wrap {
    width: min(100%, 420px);
    height: auto;
    max-height: none;
    max-width: 100%;
  }

  .side-panel {
    width: min(100%, 420px);
    flex-basis: auto;
    height: auto;
  }
}

@media (max-width: 640px) {
  .demo {
    padding-top: 20px;
    padding-bottom: 24px;
  }

  .site-header__inner {
    justify-content: center;
  }

  .site-header__logo-link,
  .site-header__yc {
    display: none;
  }

  .site-header__nav {
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0;
  }

  .site-header__nav .btn-slide {
    padding-left: 8px;
    padding-right: 8px;
    font-size: 13px;
    white-space: nowrap;
  }
}

/* --- Embed mode layout (must follow responsive rules so it wins) --- */

html.embed,
html.embed body {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

html.embed .site-header,
html.embed .site-footer,
html.embed .demo__header {
  display: none !important;
}

html.embed .home-page {
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

html.embed .home-main {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden !important;
}

html.embed .demo {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  overflow: hidden !important;
}

html.embed .container-1312 {
  max-width: none;
  padding-left: 8px;
  padding-right: 8px;
}

html.embed .stage {
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  gap: 10px;
  overflow: hidden;
}

html.embed .stage__visual {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 0;
  height: min(100%, 460px);
  max-height: 460px;
}

html.embed .canvas-wrap {
  width: auto !important;
  height: 100% !important;
  max-height: 460px !important;
  aspect-ratio: 1;
  max-width: 460px !important;
  margin: 0 auto;
}

html.embed .side-panel {
  flex: 0 0 200px !important;
  width: 200px !important;
  max-width: 200px !important;
  height: min(100%, 460px) !important;
  max-height: 460px !important;
  align-self: center !important;
  overflow: hidden !important;
  padding: 2px 8px 10px !important;
}

html.embed .side-section {
  padding: 5px 0;
}

html.embed .control-label {
  font-size: 9px;
  margin-bottom: 4px;
}

html.embed .prompt-text {
  font-size: 14px;
  line-height: 1.35;
}

html.embed #ratio-list .btn-secondary,
html.embed #view-list .btn-secondary {
  height: 26px;
  font-size: 10px;
  padding: 0 4px;
}

html.embed .answer-card__text {
  font-size: 13px;
  overflow-y: auto;
}

html.embed .side-section--answer {
  flex: 1 1 0;
  min-height: 64px;
}

/* Keep token counters fully visible — never crush under Answer. */
html.embed .side-section--last {
  flex: 0 0 auto;
  flex-shrink: 0;
  padding-bottom: 2px;
  overflow: visible;
}

html.embed .stats {
  gap: 4px;
  font-size: 11px;
}

html.embed .stats > div {
  min-height: 44px;
}

html.embed .legend {
  margin-top: 6px;
  gap: 8px;
  font-size: 11px;
}

/* Narrow iframe / phone: image on top, controls full-width underneath */
@media (max-width: 640px) {
  html.embed,
  html.embed body {
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
  }

  html.embed .home-page,
  html.embed .home-main,
  html.embed .demo {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  html.embed .demo {
    padding-top: 2px !important;
    padding-bottom: 0 !important;
  }

  html.embed .stage {
    flex: 0 0 auto !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start;
    gap: 6px;
    overflow: visible;
  }

  html.embed .stage__visual {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: none;
  }

  html.embed .canvas-wrap {
    width: min(100%, 360px) !important;
    height: auto !important;
    max-height: none !important;
    max-width: min(100%, 360px) !important;
    aspect-ratio: 1;
    margin: 0 auto;
  }

  html.embed .side-panel {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    align-self: stretch !important;
    overflow: visible !important;
    padding: 0 4px 0 !important;
  }

  html.embed .side-section--answer {
    flex: 0 0 auto;
    min-height: 0;
  }

  html.embed .answer-card__text {
    max-height: 7.5rem;
  }
}
