@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-tight-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/fraunces-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/fraunces-italic-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --color-bg: #0a0a0a;
  --color-surface: #0f0f0f;
  --color-surface-alt: #151515;
  --color-surface-elevated: #1c1c1c;
  --color-header-bg: rgba(10, 10, 10, .88);
  --color-text: #f5f5f0;
  --color-text-muted: #a0a0a0;
  --color-text-dim: #707070;
  --color-accent: #e11d2e;
  --color-accent-hover: #c4162a;
  --color-accent-soft: rgba(225, 29, 46, .14);
  --color-border: #262626;
  --color-border-strong: #3a3a3a;
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Inter Tight", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-bg: #faf8f3;
  --color-surface: #f5f2eb;
  --color-surface-alt: #f0ede5;
  --color-surface-elevated: #ffffff;
  --color-header-bg: rgba(250, 248, 243, .9);
  --color-text: #1b1b18;
  --color-text-muted: #56564f;
  --color-text-dim: #82827a;
  --color-accent: #d11425;
  --color-accent-hover: #a90f1d;
  --color-accent-soft: rgba(209, 20, 37, .12);
  --color-border: #e4e0d5;
  --color-border-strong: #cdc8bb;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--color-text);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, .03) 1px, transparent 1px),
    var(--color-bg);
  background-size: 44px 44px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
button,
input,
textarea {
  letter-spacing: 0;
}

body.chat-busy {
  cursor: progress;
}

button,
textarea {
  font: inherit;
}

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

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
}

svg {
  display: block;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px max(24px, calc((100vw - 1180px) / 2));
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.brand:hover {
  color: var(--color-text);
}

.brand img,
.chat-title img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.brand-dot {
  color: var(--color-accent);
}

.site-links {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-left: auto;
}

.site-links a {
  color: var(--color-text-muted);
  font-size: 15px;
  font-weight: 600;
}

.site-links a:hover {
  color: var(--color-text);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.icon-button:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
  background: var(--color-surface-alt);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .icon-sun {
  display: none;
}

:root[data-theme="light"] .icon-button .icon-sun {
  display: block;
}

:root[data-theme="light"] .icon-button .icon-moon {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 760px);
  gap: 36px;
  width: min(1180px, calc(100vw - 48px));
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  padding: 44px 0;
  align-items: center;
}

.app-shell > *,
.chat-shell,
.chat-header,
.messages,
.message,
.bubble {
  min-width: 0;
}

.intro-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 10ch;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 800;
  line-height: 1.02;
}

.intro-copy {
  max-width: 31ch;
  margin: 24px 0 0;
  color: var(--color-text-muted);
  font-size: 20px;
  line-height: 1.45;
}

.profile-block {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.profile-block img {
  width: 76px;
  height: 76px;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  object-fit: cover;
}

.profile-name {
  margin: 0;
  color: var(--color-text);
  font-weight: 700;
}

.profile-note {
  max-width: 30ch;
  margin: 3px 0 0;
  color: var(--color-text-muted);
  font-size: 15px;
  line-height: 1.45;
}

.topic-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.topic-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  height: min(760px, calc(100vh - 128px));
  min-height: 620px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}

.chat-title {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.chat-title img {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border-strong);
}

.chat-title p {
  margin: 0;
  color: var(--color-text);
  font-weight: 800;
  line-height: 1.15;
}

.chat-title span {
  display: block;
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1.25;
}

.reset-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: color .2s, border-color .2s, background .2s;
}

.reset-button:hover {
  color: var(--color-bg);
  background: var(--color-text);
  border-color: var(--color-text);
}

.messages {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: min(88%, 640px);
}

.message.user {
  align-self: flex-end;
  justify-content: flex-end;
}

.message.bot {
  align-self: flex-start;
}

.message-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.bubble {
  max-width: 100%;
  padding: 12px 14px;
  color: var(--color-text);
  background: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  color: #ffffff;
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.bubble strong {
  color: inherit;
  font-weight: 800;
}

.bubble em {
  font-family: var(--font-display);
}

.bubble a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.quick-replies {
  align-self: flex-start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 560px);
  margin: -4px 0 4px 38px;
}

.choice-button {
  min-height: 48px;
  padding: 10px 12px;
  color: var(--color-text);
  text-align: left;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  transition: border-color .2s, background .2s, transform .12s;
}

.choice-button:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.choice-button:active {
  transform: translateY(1px);
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typing-pulse 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: .15s;
}

.typing span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes typing-pulse {
  0%,
  70%,
  100% {
    opacity: .35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
}

.composer textarea {
  flex: 1 1 auto;
  width: 100%;
  max-height: 150px;
  min-height: 48px;
  padding: 12px 14px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  outline: none;
  resize: none;
  line-height: 1.4;
  transition: border-color .2s, background .2s;
}

.composer textarea:focus {
  border-color: var(--color-accent);
}

.composer textarea::placeholder {
  color: var(--color-text-dim);
}

.send-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: #ffffff;
  background: var(--color-accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s, transform .12s, opacity .2s;
}

.send-button:hover {
  background: var(--color-accent-hover);
}

.send-button:active {
  transform: translateY(1px);
}

.send-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.send-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.chat-legal {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 14px;
  color: var(--color-text-dim);
  background: var(--color-surface-alt);
  font-size: 12px;
  line-height: 1.4;
}

.chat-legal a {
  flex: 0 0 auto;
  font-weight: 700;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: stretch;
    width: min(760px, calc(100vw - 32px));
    min-height: auto;
    padding: 28px 0;
  }

  .intro-panel {
    justify-content: flex-start;
  }

  h1 {
    max-width: 12ch;
    font-size: 44px;
  }

  .intro-copy {
    max-width: 42ch;
    font-size: 18px;
  }

  .profile-block {
    margin-top: 28px;
  }

  .chat-shell {
    height: calc(100vh - 120px);
    min-height: 560px;
  }
}

@media (max-width: 700px) {
  body {
    background-size: 36px 36px;
  }

  .topbar {
    min-height: 64px;
    padding: 12px 16px;
  }

  .brand {
    font-size: 20px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .site-links {
    display: none;
  }

  .app-shell {
    width: 100%;
    padding: 16px 12px 12px;
    gap: 16px;
  }

  .intro-panel {
    padding: 0 4px;
  }

  .eyebrow {
    font-size: 12px;
    margin-bottom: 10px;
  }

  h1 {
    font-size: 32px;
  }

  .intro-copy {
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.45;
  }

  .profile-block,
  .topic-strip {
    display: none;
  }

  .chat-shell {
    width: 100%;
    height: min(530px, calc(100vh - 300px));
    min-height: 420px;
  }

  .chat-header {
    padding: 12px;
  }

  .reset-button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .messages {
    padding: 16px 12px;
  }

  .message {
    max-width: 100%;
  }

  .message.bot {
    width: 100%;
  }

  .message.user {
    max-width: 92%;
  }

  .message-avatar {
    width: 24px;
    height: 24px;
  }

  .bubble {
    padding: 11px 12px;
    font-size: 15px;
  }

  .quick-replies {
    grid-template-columns: 1fr;
    width: calc(100% - 34px);
    margin-left: 34px;
  }

  .choice-button {
    min-height: 44px;
    font-size: 14px;
  }

  .composer {
    padding: 12px;
  }

  .chat-legal {
    flex-direction: column;
    gap: 4px;
    padding: 0 12px 12px;
  }
}

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