:root[data-theme="light"] {
  --bg: #eef1f6;
  --bg2: #f8f9fc;
  --bg3: #e2e7ef;
  --border: rgba(15, 23, 42, .09);
  --text: #172033;
  --muted: #5f6b80;
  --heading: #0b1220;
  --accent: oklch(.52 .19 262);
  --accent-dim: oklch(.52 .19 262 / .10);
  --accent-border: oklch(.52 .19 262 / .30);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  --nav-bg: rgba(238, 241, 246, .90);
  color-scheme: light;
}

:root,
:root[data-theme="dark"] {
  --bg: #0a0e16;
  --bg2: #111725;
  --bg3: #182032;
  --border: rgba(180, 195, 225, .09);
  --text: #e4e8f0;
  --muted: #8b95a8;
  --heading: #f3f5f9;
  --accent: oklch(.66 .17 262);
  --accent-dim: oklch(.66 .17 262 / .14);
  --accent-border: oklch(.66 .17 262 / .40);
  --shadow: none;
  --nav-bg: rgba(10, 14, 22, .86);
  color-scheme: dark;
}

:root {
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --pad: clamp(20px, 5vw, 64px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-dim); color: var(--accent); }
input::placeholder { color: var(--muted); }
button { font: inherit; }

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

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* App shell: one screen tall; views fill the space between nav and footer */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color .3s, color .3s;
}
.view { flex: 1; min-height: 0; }
.view[hidden] { display: none !important; }

/* Nav */
.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  height: 60px;
  padding: 0 var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { font-family: var(--mono); font-size: 14px; letter-spacing: .05em; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--muted);
  transition: all .2s;
}
.nav a:hover { color: var(--text); background: var(--bg3); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-dim); font-weight: 500; }
.theme-toggle {
  width: 32px;
  height: 32px;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.theme-toggle:hover { color: var(--text); background: var(--bg3); }
.theme-toggle span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* Shared pieces */
.backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 30% 40%, black 20%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 70% at 30% 40%, black 20%, transparent 100%);
}
.backdrop::after {
  content: "";
  position: absolute;
  top: 15%;
  right: 10%;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: var(--accent-dim);
  filter: blur(90px);
}
.backdrop.centered {
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 45%, black 20%, transparent 100%);
  mask-image: radial-gradient(ellipse 60% 60% at 50% 45%, black 20%, transparent 100%);
}
.backdrop.centered::after { top: 25%; right: auto; left: 50%; transform: translateX(-50%); width: 480px; height: 360px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--accent-border);
  background: var(--accent-dim);
  color: var(--accent);
  font: 11px var(--mono);
  letter-spacing: .04em;
}
.pip { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.soft { color: var(--muted); font-weight: 300; }

.ask-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg2);
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.ask-form:focus-within { border-color: var(--accent-border); }
.ask-form > svg { flex: none; color: var(--muted); }
.ask-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 16px var(--font);
}
.ask-form button {
  flex: none;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all .2s;
}
.ask-form button:hover { opacity: .85; }
/* Muted but still visible on dark backgrounds */
.ask-form button:disabled { background: var(--accent-dim); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-border); opacity: .55; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips[hidden] { display: none; }
.chips button {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: 12px var(--mono);
  cursor: pointer;
  transition: all .2s;
}
.chips button:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-dim); }

/* Home */
.home {
  position: relative;
  display: flex;
  align-items: safe center;
  overflow: hidden;
  padding: calc(60px + clamp(8px, 3vh, 40px)) var(--pad) clamp(8px, 3vh, 40px);
}
.hero {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: 680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr);
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
}
.hero-copy { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; animation: rise .6s ease both; }
.hero-copy .badge { margin-bottom: clamp(12px, 2.2vh, 24px); }
.hero h1 {
  margin-bottom: clamp(12px, 2.4vh, 24px);
  color: var(--heading);
  font-size: clamp(28px, min(5.6vw, 7vh), 80px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero .lede {
  max-width: 500px;
  margin-bottom: clamp(12px, 2.8vh, 36px);
  color: var(--muted);
  font-size: clamp(15px, min(1.6vw, 2.2vh), 18px);
  font-weight: 300;
  line-height: 1.65;
}
.ask { width: 100%; max-width: 560px; }
.home .ask-form { padding: clamp(4px, .8vh, 8px) clamp(4px, .8vh, 8px) clamp(4px, .8vh, 8px) 18px; }
.home .ask-form input { padding: clamp(6px, 1.4vh, 12px) 4px; }
.home .chips { margin-top: clamp(10px, 1.6vh, 16px); }
.home .chips button { padding: clamp(4px, .9vh, 7px) 14px; }

.photo-desktop {
  min-width: 0;
  min-height: 0;
  height: 80%;
  max-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rise .7s ease .1s both;
}
.photo-card {
  position: relative;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: #1b2232;
}
.photo-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.photo-fade {
  position: absolute;
  inset: auto 0 0;
  height: 46%;
  background: linear-gradient(to top, rgba(8, 11, 18, .96) 0%, rgba(8, 11, 18, .85) 30%, rgba(8, 11, 18, 0) 100%);
}
.photo-tag {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(8, 11, 18, .72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.photo-tag > div { display: flex; flex-direction: column; }
.photo-tag .name { color: #f3f5f8; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.photo-tag .place { color: #b7bfcd; font: 11px var(--mono); letter-spacing: .04em; }
.photo-tag .status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .10);
  color: #f3f5f8;
  font: 11px var(--mono);
}
.photo-tag .status span { width: 6px; height: 6px; border-radius: 50%; background: #6f9bff; }

.photo-mobile {
  display: none;
  width: 88px;
  height: 88px;
  margin-bottom: 18px;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #1b2232;
}
/* Zoomed in so the face fills more of the small square */
.photo-mobile img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; transform: scale(1.45); transform-origin: 50% 24%; }

/* Chat */
.chat-view {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: calc(60px + clamp(8px, 2.4vh, 32px)) clamp(16px, 4vw, 32px) 0;
  display: flex;
  flex-direction: column;
}
.chat-head {
  flex: none;
  margin-bottom: clamp(8px, 1.6vh, 20px);
  padding-bottom: clamp(10px, 2vh, 20px);
  border-bottom: 1px solid var(--border);
}
.chat-head h1 {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--heading);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.chat-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-dim); }
.chat-head p { color: var(--muted); font-size: 14px; }
.chat-head a { text-decoration: underline; text-underline-offset: 3px; }

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg3) transparent;
}
.msg { display: flex; gap: 12px; padding: 16px 4px; animation: rise .3s ease both; }
.msg.user { flex-direction: row-reverse; }
.msg .avatar {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: 600 12px var(--mono);
}
.msg.user .avatar { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }
.msg .body { flex: 1; min-width: 0; max-width: calc(100% - 56px); }
.msg .who {
  margin-bottom: 6px;
  color: var(--muted);
  font: 11px var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.msg.user .who { text-align: right; }
.bubble {
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.msg.user .bubble { border-color: var(--accent-border); background: var(--accent-dim); color: var(--accent); white-space: pre-wrap; }
.bubble p { margin-bottom: 8px; }
.bubble ul { margin: 0 0 8px; padding-left: 20px; }
.bubble p:last-child, .bubble ul:last-child { margin-bottom: 0; }
/* Limits and errors: same shape as an answer, but dashed so it reads as a status message */
.bubble.notice { border-style: dashed; background: transparent; color: var(--muted); }
.caret { display: inline-block; margin-left: 4px; animation: pulse 1.4s infinite; }

.chat-view .chips { flex: none; margin-bottom: 10px; }
.chat-view .chips button { background: var(--bg2); color: var(--text); }
.chat-view .ask-form { flex: none; margin-bottom: 8px; }
.chat-view .ask-form button { width: 38px; height: 38px; }
.disclaimer { margin-bottom: clamp(10px, 2vh, 16px); color: var(--muted); font-size: 12px; text-align: center; }

/* Blog */
.blog {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: calc(60px + clamp(8px, 3vh, 40px)) var(--pad) clamp(8px, 3vh, 40px);
  text-align: center;
}
.blog-inner { position: relative; z-index: 1; max-width: 620px; display: flex; flex-direction: column; align-items: center; animation: rise .6s ease both; }
.blog .badge { padding: 3px 10px; margin-bottom: clamp(14px, 2.4vh, 24px); }
.blog h1 {
  margin-bottom: clamp(12px, 2.4vh, 24px);
  color: var(--heading);
  font-size: clamp(32px, min(6vw, 8vh), 72px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.blog .lede {
  max-width: 500px;
  margin-bottom: clamp(18px, 3.4vh, 36px);
  color: var(--muted);
  font-size: clamp(15px, min(1.8vw, 2.2vh), 18px);
  font-weight: 300;
  line-height: 1.7;
}
.topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: clamp(20px, 4vh, 40px); }
.topics span { padding: 6px 14px; border-radius: 100px; border: 1px solid var(--border); color: var(--muted); font: 12px var(--mono); }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  transition: opacity .2s;
}
.cta:hover { opacity: .85; }

/* Footer */
.footer {
  flex: none;
  padding: clamp(10px, 2vh, 18px) var(--pad);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font: 12px var(--mono);
}
.socials { display: flex; gap: 8px; }
.socials a {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: all .2s;
}
.socials a:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }

/* Narrow screens: the page scrolls normally (footer at the end), except chat, which keeps
   a one-screen layout so the log scrolls above the input. */
@media (max-width: 719px) {
  .app:not([data-page="chat"]) { height: auto; min-height: 100dvh; overflow: visible; }
  .app[data-page="chat"] .footer { display: none; }

  .hero { grid-template-columns: minmax(0, 1fr); height: auto; max-height: none; }
  .photo-desktop { display: none; }
  .photo-mobile { display: block; }
  .home { padding-bottom: 40px; }
  .hero h1 { font-size: clamp(32px, 9vw, 44px); }
  .hero-copy .badge { white-space: nowrap; }

  .blog { align-items: flex-start; padding-top: calc(60px + 12vh); padding-bottom: 48px; }

  .chat-head { margin-bottom: 4px; padding-bottom: 10px; }
  .chat-head h1 { margin-bottom: 4px; font-size: 20px; }
  .chat-head p { font-size: 13px; }
  .msg { padding: 10px 2px; }
  .bubble { padding: 12px 14px; }
  /* Chips sit on one row that scrolls sideways; the padding leaves room for the tap areas */
  .chat-view .chips { flex-wrap: nowrap; overflow-x: auto; margin: -4px -16px 6px; padding: 4px 16px; scrollbar-width: none; }
  .chat-view .chips::-webkit-scrollbar { display: none; }
  .chat-view .chips button { flex: none; }
  .disclaimer { margin-bottom: 8px; font-size: 11px; }

  /* 44px tap areas without making the controls look bigger */
  .nav a, .theme-toggle, .socials a, .chips button { position: relative; }
  .nav a::after, .theme-toggle::after, .socials a::after, .chips button::after { content: ""; position: absolute; }
  .nav a::after { inset: -5px 0; }
  .theme-toggle::after { inset: -6px; }
  .socials { gap: 12px; }
  .socials a::after { inset: -6px; }
  .chips button { min-height: 36px; }
  .chips button::after { inset: -4px 0; }
}

@media (max-width: 359px) {
  .badge-place { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
