:root {
  --bg: oklch(0.98 0.01 85);
  --surface: oklch(0.995 0.005 85);
  --surface-2: oklch(0.96 0.014 85);
  --ink: oklch(0.2 0.035 45);
  --muted: oklch(0.45 0.02 55);
  --accent: oklch(0.58 0.11 50);
  --accent-soft: oklch(0.93 0.045 68);
  --line: oklch(0.85 0.015 75);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.8rem;
  --text-2xl: 3rem;
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 80% 0%, oklch(0.97 0.025 82), var(--bg) 45%);
  color: var(--ink);
  font-family: "Public Sans", sans-serif;
  font-size: var(--text-md);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow: hidden;
}

.shell {
  width: min(1100px, 92vw);
  height: min(100vh, 100svh);
  margin: 0 auto;
  padding: var(--space-lg) 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--space-lg);
}

.hero {
  max-width: 70ch;
  display: grid;
  gap: var(--space-lg);
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  font-size: var(--text-xs);
}

h1 {
  margin: 0;
  font-family: "Spectral", serif;
  font-size: clamp(1.9rem, 2.3vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  max-width: none;
  white-space: nowrap;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 65ch;
  line-height: 1.58;
}

.planner {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: var(--space-xl);
  min-height: 0;
}

.planner.is-gated {
  grid-template-columns: minmax(760px, 980px);
  justify-content: center;
}

.planner.is-gated .chat-panel {
  display: none;
}

.planner.is-focused {
  grid-template-columns: 1fr;
}

.planner.is-focused .city-selector-wrap {
  display: none;
}

.city-selector-wrap {
  min-height: 0;
}

.planner.is-gated .city-selector-wrap {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in oklch, var(--surface) 92%, white);
  padding: var(--space-xl);
}

.planner.is-gated .city-selector {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-md);
}

.city-selector {
  display: grid;
  align-content: start;
  gap: var(--space-md);
}

.city-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  transition: background 180ms var(--ease-out-quart), transform 180ms var(--ease-out-quart), border-color 180ms var(--ease-out-quart);
}

.city-icon {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--line) 78%, var(--accent));
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--surface-2) 72%, white);
  flex: 0 0 auto;
}

.city-icon svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: color-mix(in oklch, var(--ink) 75%, var(--accent));
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.city-text {
  display: grid;
  text-align: left;
  gap: 0.1rem;
}

.city-text strong {
  font-size: 0.93rem;
  font-weight: 600;
}

.city-pill:hover {
  transform: translateY(-1px);
  border-color: color-mix(in oklch, var(--accent) 55%, var(--line));
}

.city-pill:active {
  transform: translateY(0.5px);
}

.city-pill small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.62rem;
}

.city-pill.is-active {
  background: var(--accent-soft);
  border-color: color-mix(in oklch, var(--accent) 70%, var(--line));
}

.planner.is-gated .city-pill {
  border-radius: 14px;
  padding: 0.9rem;
  min-height: 112px;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.7rem;
}

.planner.is-gated .city-icon {
  width: 2.4rem;
  height: 2.4rem;
}

.planner.is-gated .city-icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

.planner.is-gated .city-text strong {
  font-size: 1.02rem;
}

.planner.is-gated .city-text small {
  font-size: 0.66rem;
}

.chat-panel {
  border: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 88%, white 12%);
  border-radius: 22px;
  padding: var(--space-xl);
  display: grid;
  gap: var(--space-lg);
  min-height: 0;
}

.chat-header h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-family: "Spectral", serif;
  font-weight: 500;
}

.chat-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-md);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.city-menu {
  position: relative;
}

.city-menu-toggle {
  min-width: 2.2rem;
  padding: 0.5rem 0.7rem;
}

.city-menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: min(260px, 70vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 30px color-mix(in oklch, black 10%, transparent);
  padding: 0.35rem;
  display: none;
  z-index: 12;
}

.city-menu-panel.is-open {
  display: grid;
  gap: 0.35rem;
}

.city-menu-item {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.5rem 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  font: inherit;
  cursor: pointer;
}

.city-menu-item small {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.city-menu-item:hover {
  border-color: color-mix(in oklch, var(--accent) 42%, var(--line));
  background: color-mix(in oklch, var(--accent-soft) 18%, var(--surface));
}

.city-menu-item.is-active {
  border-color: color-mix(in oklch, var(--accent) 60%, var(--line));
  background: color-mix(in oklch, var(--accent-soft) 30%, var(--surface));
}

.chat-header p {
  margin: var(--space-xs) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-log {
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: grid;
  gap: var(--space-md);
  padding-right: var(--space-sm);
  min-width: 0;
}

.starter-state {
  min-height: 100%;
  display: grid;
  align-content: center;
  gap: var(--space-md);
}

.starter-title {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.starter-prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-sm);
}

.starter-chip {
  border: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 94%, white);
  color: var(--ink);
  border-radius: 12px;
  text-align: left;
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1.45;
  padding: 0.62rem 0.72rem;
  cursor: pointer;
  transition: border-color 120ms var(--ease-out-quart), background 120ms var(--ease-out-quart), transform 120ms var(--ease-out-quart);
}

.starter-chip:hover {
  border-color: color-mix(in oklch, var(--accent) 50%, var(--line));
  background: color-mix(in oklch, var(--accent-soft) 20%, var(--surface));
  transform: translateY(-0.5px);
}

.bubble {
  width: fit-content;
  max-width: 100%;
  border-radius: 16px;
  padding: var(--space-md) var(--space-lg);
  line-height: 1.6;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bubble p {
  margin: 0 0 0.6rem;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble ul,
.bubble ol {
  margin: 0.25rem 0 0.75rem 1.2rem;
  padding: 0;
}

.bubble li + li {
  margin-top: 0.2rem;
}

.bubble code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0.05rem 0.35rem;
  border-radius: 6px;
  background: color-mix(in oklch, var(--surface-2) 80%, white);
}

.bubble pre {
  margin: 0.4rem 0 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  overflow-x: auto;
  max-width: 100%;
  background: color-mix(in oklch, var(--surface-2) 78%, white);
}

.bubble pre code {
  padding: 0;
  background: transparent;
}

.bubble a {
  color: color-mix(in oklch, var(--accent) 80%, black);
}

.bubble-assistant {
  background: var(--surface-2);
}

.bubble-user {
  margin-left: auto;
  background: color-mix(in oklch, var(--accent-soft) 75%, var(--surface));
}

.composer {
  display: grid;
  gap: var(--space-md);
  min-height: 0;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  padding: var(--space-md);
  resize: vertical;
  min-height: 88px;
  transition: border-color 180ms var(--ease-out-quart), box-shadow 180ms var(--ease-out-quart);
}

textarea:focus-visible,
button:focus-visible {
  outline: 2px solid color-mix(in oklch, var(--accent) 68%, white);
  outline-offset: 2px;
}

textarea:focus-visible {
  border-color: color-mix(in oklch, var(--accent) 48%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent-soft) 72%, white);
}

.composer-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-sm);
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.ghost-button.is-disabled {
  color: color-mix(in oklch, var(--muted) 82%, var(--line));
  border-color: color-mix(in oklch, var(--line) 88%, white);
  background: color-mix(in oklch, var(--surface-2) 78%, white);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--line) 72%, white);
  cursor: help;
}

button[type="submit"] {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  background: var(--accent);
  color: oklch(0.99 0.01 90);
  font: inherit;
  font-weight: 600;
  transition: transform 120ms var(--ease-out-quart), filter 120ms var(--ease-out-quart);
  cursor: pointer;
}

button[type="submit"]:hover {
  transform: translateY(-0.5px);
  filter: saturate(1.03);
}

button[type="submit"]:active {
  transform: translateY(0.5px);
}

button[disabled] {
  opacity: 1;
  cursor: default;
}

#send-button.is-loading[disabled] {
  cursor: wait;
}

button.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.5rem;
  border-radius: 999px;
  background: color-mix(in oklch, white 88%, var(--accent));
  animation: pulse-dot 1400ms var(--ease-out-quart) infinite;
}

.error-line {
  min-height: 1.2rem;
  margin: 0;
  color: oklch(0.53 0.17 30);
  font-size: var(--text-sm);
}

.plan-modal {
  position: fixed;
  inset: 0;
  display: none;
}

.plan-modal[aria-hidden="false"] {
  display: grid;
  place-items: center;
}

.plan-modal__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in oklch, black 32%, transparent);
}

.plan-modal__dialog {
  position: relative;
  width: min(760px, 92vw);
  max-height: 85vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: var(--space-xl);
  display: grid;
  gap: var(--space-lg);
}

.plan-modal__header h3 {
  margin: 0;
  font-family: "Spectral", serif;
  font-size: 1.4rem;
}

.plan-modal__header p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.plan-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.premium-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: var(--space-lg);
  background: color-mix(in oklch, var(--surface-2) 55%, white);
}

.premium-list p {
  margin: 0 0 var(--space-sm);
  font-weight: 600;
}

.premium-list ul {
  margin: 0 0 0 1.1rem;
  padding: 0;
}

.plan-modal__dialog input[type="email"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.72rem 0.86rem;
  font: inherit;
  background: var(--surface);
}

.plan-modal-status {
  min-height: 1.2rem;
  margin: -0.25rem 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.plan-modal-status.is-error {
  color: oklch(0.53 0.17 30);
}

.bubble-assistant.is-streaming::after {
  content: "";
  display: inline-block;
  width: 0.5ch;
  height: 1.05em;
  margin-left: 0.14rem;
  vertical-align: -0.1em;
  background: color-mix(in oklch, var(--accent) 78%, black);
  animation: streaming-cursor 1250ms steps(1, end) infinite;
}

.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;
}

@media (max-width: 920px) {
  body {
    overflow: hidden;
  }

  .shell {
    height: 100svh;
    min-height: 100svh;
    padding: var(--space-md) 0;
    gap: var(--space-md);
  }

  .planner {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .planner.is-gated {
    grid-template-columns: 1fr;
  }

  .planner.is-gated .city-selector {
    grid-template-columns: 1fr;
  }

  .planner.is-focused .city-selector-wrap {
    display: none;
  }

  .city-selector {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .planner.is-focused .chat-panel {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: var(--space-md);
    padding: var(--space-md);
  }

  .planner.is-focused .chat-log {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .planner.is-focused .composer {
    position: sticky;
    bottom: 0;
    background: color-mix(in oklch, var(--surface) 96%, white);
    padding-top: var(--space-sm);
    border-top: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
  }

  .planner.is-focused textarea {
    min-height: 64px;
    max-height: 26svh;
  }

  h1 {
    white-space: normal;
  }
}

@keyframes pulse-dot {
  0% { transform: scale(0.92); opacity: 0.62; }
  50% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(0.92); opacity: 0.62; }
}

@keyframes streaming-cursor {
  0%, 52% { opacity: 0.78; }
  49%, 100% { opacity: 0; }
}

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