:root {
  color-scheme: dark;
  --black: #000;
  --sidebar: #080808;
  --surface: #212121;
  --surface-hover: #2b2b2b;
  --surface-raised: #2f2f2f;
  --line: #2b2b2b;
  --line-light: #444;
  --text: #f3f3f3;
  --muted: #a7a7a7;
  --dim: #727272;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--black);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: #111;
  background: #fff;
  border-radius: 8px;
  transform: translateY(-160%);
  transition: transform 150ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  z-index: 10;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 260px;
  justify-content: space-between;
  flex-direction: column;
  padding: 14px 10px 18px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.side-brand {
  display: flex;
  height: 45px;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
}

.side-brand-mark {
  display: grid;
  width: 54px;
  height: 50px;
  place-items: center;
}

.side-brand-mark img {
  display: block;
  width: 54px;
  height: 50px;
  object-fit: contain;
}

.side-brand-name {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 650;
  letter-spacing: 0.1em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 18px;
}

.side-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  color: #e7e7e7;
  border-radius: 9px;
  font-size: 0.9rem;
}

.side-link:hover,
.side-link.is-active {
  background: #202020;
}

.side-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sidebar-bottom {
  padding: 17px 11px 4px;
  border-top: 1px solid var(--line);
}

.sidebar-bottom p,
.sidebar-bottom span,
.sidebar-bottom small {
  display: block;
}

.sidebar-bottom p {
  margin: 0 0 7px;
  font-size: 0.82rem;
  font-weight: 620;
}

.sidebar-bottom span {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.42;
}

.sidebar-bottom small {
  margin-top: 18px;
  color: #666;
  font-size: 0.62rem;
}

.main-panel {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 100vh;
  flex-direction: column;
  grid-column: 2;
}

.topbar {
  position: fixed;
  z-index: 9;
  top: 0;
  right: 0;
  left: 260px;
  display: flex;
  height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
}

.product-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 1.12rem;
  font-weight: 650;
}

.topbar-logo {
  display: none;
  width: 42px;
  height: 34px;
}

.topbar-logo img {
  display: block;
  width: 42px;
  height: 34px;
  object-fit: contain;
}

.product-name svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.new-link-action {
  min-height: 38px;
  padding: 9px 16px;
  color: #111;
  background: #fff;
  border-radius: 999px;
  font-size: 0.79rem;
  font-weight: 580;
}

.is-builder .new-link-action {
  display: none;
}

main {
  display: flex;
  min-height: calc(100vh - 64px);
  flex: 1;
  padding: 64px 24px 70px;
}

.builder-view,
.replay-view {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

.center-column {
  width: min(100%, 760px);
  margin-top: -3vh;
}

.builder-heading,
.chat-greeting {
  margin-bottom: 24px;
  text-align: center;
}

.hero-logo {
  display: block;
  width: clamp(135px, 17vw, 190px);
  height: auto;
  margin: 0 auto 8px;
}

.chat-greeting h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  font-weight: 450;
  letter-spacing: -0.03em;
}

.builder-heading .site-headline {
  margin: 0 0 14px;
  font-family: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  font-size: clamp(3.35rem, 6.2vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.96;
}

.builder-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.prompt-composer,
.replay-composer {
  position: relative;
  display: grid;
  min-height: 68px;
  align-items: center;
  padding: 12px 64px 12px 56px;
  background: var(--surface);
  border: 1px solid #303030;
  border-radius: 28px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 180ms ease, transform 180ms ease;
}

.prompt-composer:focus-within,
.replay-composer.is-typing {
  border-color: #4c4c4c;
  box-shadow: 0 0 0 1px #373737;
}

.composer-plus {
  position: absolute;
  bottom: 18px;
  left: 21px;
  color: #dedede;
  font-size: 1.72rem;
  font-weight: 250;
  line-height: 1;
}

.prompt-composer textarea {
  width: 100%;
  min-height: 28px;
  max-height: 180px;
  padding: 3px 0;
  resize: none;
  overflow-y: auto;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.prompt-composer textarea::placeholder {
  color: #9a9a9a;
}

.make-button,
.send-button {
  position: absolute;
  right: 13px;
  bottom: 12px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  cursor: pointer;
  color: #111;
  background: #f2f2f2;
  border: 0;
  border-radius: 50%;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.make-button:hover {
  background: #fff;
  transform: scale(1.04);
}

.make-button svg,
.send-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.composer-meta {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px 0;
}

.field-error {
  margin: 0;
  color: #ff8b8b;
  font-size: 0.72rem;
}

.character-count {
  color: var(--dim);
  font-size: 0.67rem;
}

.character-count.is-near-limit {
  color: #ff9a9a;
}

.result-panel {
  margin-top: 22px;
  padding: 20px;
  opacity: 0;
  background: #111;
  border: 1px solid var(--line-light);
  border-radius: 18px;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.result-panel.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-heading span:first-child {
  color: var(--muted);
  font-size: 0.67rem;
}

.result-heading h2 {
  margin: 3px 0 0;
  font-size: 1.05rem;
  font-weight: 580;
}

.result-check {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  color: #111;
  background: #fff;
  border-radius: 50%;
  font-size: 0.75rem;
}

.share-field {
  display: grid;
  margin-top: 15px;
  padding: 5px 5px 5px 13px;
  background: var(--surface);
  border: 1px solid #383838;
  border-radius: 11px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.share-field input {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #bebebe;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.69rem;
}

.copy-button {
  padding: 8px 13px;
  cursor: pointer;
  color: #111;
  background: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 14px;
}

.result-actions a,
.result-actions button {
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  background: none;
  border: 0;
  font-size: 0.72rem;
}

.result-actions a:hover,
.result-actions button:hover {
  color: #fff;
}

.replay-column {
  position: relative;
}

.replay-composer {
  display: flex;
  min-height: 68px;
}

.replay-composer[hidden] {
  display: none;
}

.replay-composer.is-sent {
  opacity: 0;
  transform: translateY(12px);
}

.typed-prompt {
  width: 100%;
  flex: 1;
  margin: 0;
  min-height: 28px;
  max-height: 180px;
  padding: 3px 0;
  overflow-y: auto;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.4;
  text-align: left;
  white-space: pre-wrap;
}

.typing-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.13em;
  background: #e9e9e9;
  animation: blink 0.7s steps(1) infinite;
}

.typed-prompt.is-complete .typing-caret {
  opacity: 0;
  animation: none;
}

.send-button {
  cursor: default;
  color: #777;
  background: #353535;
}

.send-button.is-ready {
  color: #111;
  background: #fff;
}

.send-button.is-clicked {
  transform: scale(0.86);
}

.sent-message {
  display: flex;
  min-height: 124px;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 26px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.sent-message.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sent-bubble {
  max-width: min(82%, 610px);
  max-height: 180px;
  overflow: hidden;
  padding: 11px 16px;
  background: var(--surface);
  border-radius: 18px 4px 18px 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.sent-avatar {
  display: grid;
  width: 31px;
  height: 31px;
  flex: none;
  place-items: center;
  color: #111;
  background: #fff;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
}

.stage-status {
  display: grid;
  min-height: 34px;
  align-items: center;
  gap: 18px;
  padding: 7px 12px 0;
  grid-template-columns: 1fr 140px;
}

.status-copy {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--dim);
  font-size: 0.68rem;
}

.status-dot {
  width: 5px;
  height: 5px;
  background: #aaa;
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

.status-progress {
  height: 2px;
  overflow: hidden;
  background: #222;
  border-radius: 99px;
}

.status-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: #aaa;
  border-radius: inherit;
}

.status-progress span.is-typing {
  width: 65%;
  transition: width 2.3s linear;
}

.status-progress span.is-redirecting,
.status-progress span.is-paused {
  width: 100%;
  transition: width 1.4s linear;
}

.replay-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
}

.replay-actions button,
.replay-actions a {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 0.7rem;
}

.replay-actions button:hover,
.replay-actions a:hover {
  color: #fff;
  background: #161616;
}

.bottom-note {
  position: fixed;
  z-index: 2;
  right: 24px;
  bottom: 14px;
  left: 284px;
  display: flex;
  justify-content: center;
  gap: 16px;
  color: #666;
  font-size: 0.62rem;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  max-width: calc(100vw - 44px);
  padding: 11px 15px;
  color: #111;
  background: #fff;
  border-radius: 9px;
  opacity: 0;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  transform: translateY(9px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.noscript-banner {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  left: 278px;
  padding: 13px;
  color: #fff;
  background: #7c2c2c;
  border-radius: 10px;
  text-align: center;
  font-size: 0.8rem;
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .main-panel {
    min-height: 100vh;
  }

  .topbar {
    left: 0;
    height: 58px;
    padding: 0 15px;
  }

  .topbar-logo {
    display: block;
  }

  main {
    min-height: 100vh;
    padding: 58px 14px 70px;
  }

  .center-column {
    width: min(100%, 680px);
    margin-top: -2vh;
  }

  .bottom-note {
    right: 14px;
    bottom: 10px;
    left: 14px;
  }

  .bottom-note span:last-child {
    display: none;
  }

  .noscript-banner {
    left: 18px;
  }
}

@media (max-width: 520px) {
  .builder-heading,
  .chat-greeting {
    margin-bottom: 20px;
  }

  .chat-greeting h1 {
    font-size: 1.6rem;
  }

  .builder-heading .site-headline {
    margin-bottom: 12px;
    font-size: clamp(3rem, 15vw, 4.35rem);
  }

  .hero-logo {
    width: clamp(120px, 34vw, 150px);
    margin-bottom: 6px;
  }

  .builder-heading p {
    max-width: 290px;
    margin: 9px auto 0;
    line-height: 1.45;
  }

  .prompt-composer,
  .replay-composer {
    min-height: 62px;
    padding: 10px 56px 10px 48px;
    border-radius: 25px;
  }

  .composer-plus {
    bottom: 16px;
    left: 17px;
    font-size: 1.6rem;
  }

  .make-button,
  .send-button {
    right: 10px;
    bottom: 9px;
    width: 41px;
    height: 41px;
  }

  .result-panel {
    padding: 16px;
  }

  .stage-status {
    grid-template-columns: 1fr 70px;
  }

  .replay-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
