:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #242424;
  --muted: #6d6d65;
  --line: #deded8;
  --line-strong: #c8c8c0;
  --accent: #245d59;
  --accent-hover: #1d4d4a;
  --accent-soft: #e7f0ee;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 45px rgba(39, 41, 38, 0.09);
  --radius: 8px;
  --header-height: 72px;
}

* {
  box-sizing: border-box;
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea {
  font: inherit;
}

input,
textarea {
  min-width: 0;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 750;
  line-height: 1.2;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  font-weight: 760;
  letter-spacing: 0;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 46px;
  max-height: 150px;
  resize: none;
  padding: 12px 13px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 93, 89, 0.14);
}

.primary-button,
.send-button {
  min-height: 46px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 720;
  white-space: nowrap;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.primary-button {
  padding: 0 18px;
}

.send-button {
  align-self: end;
  min-width: 72px;
  padding: 0 16px;
}

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

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

.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  padding: 0 12px;
  font-weight: 680;
}

.ghost-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 0.92rem;
  line-height: 1.4;
}

.site-legal {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: center;
}

.legal-links {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 10px;
  margin-left: 8px;
}

.site-legal a {
  color: inherit;
  text-decoration: none;
}

.site-legal a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-view {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}

.chat-header {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) 12px
    max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.chat-header h1 {
  font-size: 1.18rem;
}

.brand-heading {
  min-width: 0;
}

.app-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 560;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

.message-list {
  overflow-y: auto;
  padding: 18px 18px 20px;
  scroll-behavior: smooth;
}

.message-stack {
  width: min(100%, 760px);
  margin: 0 auto;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
  padding: 28px 8px;
}

.message {
  display: flex;
  margin: 0 0 14px;
}

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

.message.is-assistant,
.message.is-system {
  justify-content: flex-start;
}

.bubble {
  max-width: min(88%, 620px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 11px 13px;
  box-shadow: 0 6px 20px rgba(39, 41, 38, 0.045);
}

.is-user .bubble {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.is-system .bubble {
  border-color: #ffd6cf;
  background: var(--danger-soft);
  color: var(--danger);
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
  line-height: 1.48;
}

.route-plan {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.route-plan-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.route-plan-title {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.25;
}

.route-plan-meta {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.route-model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.route-model-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 680;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.route-plan-list {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.route-plan-list li + li {
  margin-top: 4px;
}

.route-plan-sequence {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.route-plan-question {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.loading-dots span:nth-child(3) {
  animation-delay: 240ms;
}

.composer {
  width: min(100%, 796px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px max(18px, env(safe-area-inset-right))
    calc(12px + env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.chat-legal {
  width: 100%;
  padding: 0 max(18px, env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(247, 247, 244, 0.95);
}

.legal-body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(231, 240, 238, 0.75), rgba(247, 247, 244, 0) 280px),
    var(--bg);
}

.legal-page {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    calc(36px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.legal-page-header {
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--line);
}

.legal-page-header h1 {
  margin-top: 6px;
  font-size: clamp(1.65rem, 5vw, 2.45rem);
  line-height: 1.12;
}

.legal-page-header p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 18px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 720;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.legal-section h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.legal-section p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.legal-section p + p {
  margin-top: 10px;
}

.legal-page-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding-top: 20px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.legal-page-footer a {
  color: inherit;
  text-decoration: none;
}

.legal-page-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.report-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(18px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: rgba(36, 36, 36, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.report-panel {
  width: min(100%, 820px);
  max-height: min(88vh, 860px);
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.report-header h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.25;
}

.report-note {
  margin: 0;
  padding: 12px 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  border-bottom: 1px solid var(--line);
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.report-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.report-status .form-message {
  flex: 1;
  min-height: auto;
  margin: 0;
}

.report-output {
  overflow: auto;
  padding: 18px;
  background: #fff;
}

.report-output h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.report-output pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.58;
}

.report-cta {
  display: flex;
  justify-content: flex-end;
  margin: 4px 0 16px;
}

.report-button {
  min-width: 112px;
  padding: 0 18px;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 560px) {
  .primary-button {
    width: 100%;
  }

  .chat-header {
    padding-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right));
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .ghost-button {
    padding-inline: 9px;
  }

  .message-list {
    padding: 14px 14px 16px;
  }

  .bubble {
    max-width: 92%;
  }

  .composer {
    grid-template-columns: 1fr;
    padding-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right));
  }

  .send-button {
    width: 100%;
  }

  .chat-legal {
    display: grid;
    gap: 4px;
  }

  .legal-links {
    margin-left: 0;
  }

  .report-cta {
    margin-bottom: 14px;
  }

  .report-button {
    width: 100%;
  }

  .report-panel {
    max-height: 92vh;
  }

  .report-header,
  .report-note,
  .report-status,
  .report-output {
    padding-inline: 14px;
  }

  .report-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .report-status {
    align-items: stretch;
    display: grid;
  }
}
