:root {
  --accent: #3f51b5;
  --accent-hover: #26389c;
  --cyan: #00c8ec;
  --ink: #1c1c21;
  --heading: #29293a;
  --muted: #74747f;
  --line: #ebebeb;
  --soft: #f3f3f3;
  --danger: #a52432;
  --surface: #ffffff;
  color-scheme: light;
  font-family: "Roboto", Arial, sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

.chat-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface);
}

.chat-header {
  position: relative;
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px 11px 14px;
  color: #fff;
  background: var(--ink);
  border-bottom: 3px solid var(--accent);
}

.brand-mark {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 3px;
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  line-height: 1.15;
}

.brand-copy strong {
  overflow: hidden;
  color: #fff;
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-copy span {
  overflow: hidden;
  color: #c3c3c9;
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #d7d7dc;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
}

.icon-button:hover {
  color: #fff;
  background: #2b2b31;
  border-color: #44444c;
}

.icon-button.is-confirming {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

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

.messages {
  min-height: 0;
  padding: 24px 18px 22px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #c8c8ce transparent;
  scrollbar-width: thin;
}

.welcome {
  max-width: 340px;
  margin: 7% auto 0;
}

.welcome-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #eef0fb;
  border-left: 3px solid var(--accent);
  border-radius: 3px;
}

.welcome-mark svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.55;
}

.welcome h1 {
  margin: 18px 0 9px;
  color: var(--heading);
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.02em;
}

.welcome > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.suggestions {
  display: grid;
  gap: 8px;
  margin-top: 21px;
}

.suggestions button {
  width: 100%;
  min-height: 43px;
  padding: 9px 12px;
  color: var(--heading);
  background: #fff;
  border: 1px solid #ddddE4;
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.suggestions button:hover {
  color: var(--accent-hover);
  background: #f8f8fb;
  border-color: #c5c9df;
  border-left-color: var(--accent-hover);
}

.message-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
}

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

.avatar {
  flex: 0 0 29px;
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 3px;
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 9px;
  font-weight: 800;
}

.message {
  max-width: calc(100% - 37px);
  padding: 12px 13px;
  background: var(--soft);
  border: 1px solid #e4e4e8;
  border-radius: 3px;
}

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

.message-content {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.58;
}

.message-content p {
  margin: 0 0 0.72em;
}

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

.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 0.9em 0 0.38em;
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.3;
}

.message-content h2:first-child,
.message-content h3:first-child,
.message-content h4:first-child {
  margin-top: 0;
}

.message-content ul,
.message-content ol {
  margin: 0.45em 0 0.75em;
  padding-left: 1.45em;
}

.message-content blockquote {
  margin: 0.65em 0;
  padding-left: 0.75em;
  color: #5d5d67;
  border-left: 3px solid #b8bac8;
}

.message-content code {
  padding: 0.12em 0.34em;
  color: var(--ink);
  background: #e5e5e9;
  border-radius: 2px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
}

.message-content pre {
  max-width: 100%;
  margin: 0.65em 0;
  padding: 10px;
  overflow-x: auto;
  color: var(--ink);
  background: #e5e5e9;
  border-radius: 2px;
}

.message-content pre code {
  padding: 0;
  background: transparent;
}

.message-content a,
.source-item[href] {
  color: var(--accent-hover);
  font-weight: 700;
}

.user .message-content a {
  color: #fff;
}

.source-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d6d6dc;
}

.source-panel summary {
  color: #5d5d67;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.source-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.source-item {
  display: block;
  padding: 8px 9px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #dedee3;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.4;
  text-decoration: none;
}

.source-item[href]:hover {
  background: #f8f8fb;
  border-color: #c5c9df;
}

.source-notice {
  margin-top: 12px;
  padding: 8px 9px;
  color: #684f18;
  background: #fff8e8;
  border: 1px solid #e4c78d;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.4;
}

.feedback-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #d6d6dc;
}

.feedback-question {
  margin-right: 2px;
  color: #666671;
  font-size: 11px;
  font-weight: 700;
}

.feedback-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  color: var(--heading);
  background: #fff;
  border: 1px solid #d8d8df;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.feedback-button:hover {
  border-color: #aeb3d0;
}

.feedback-button[aria-pressed="true"] {
  color: #263a8e;
  background: #eef0fb;
  border-color: #8f99d2;
}

.feedback-button[data-rating="dislike"][aria-pressed="true"] {
  color: #81232e;
  background: #f9e9eb;
  border-color: #cc8d95;
}

.feedback-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.feedback-status {
  min-height: 1.35em;
  flex-basis: 100%;
  color: #696974;
  font-size: 10px;
  line-height: 1.35;
}

.feedback-status.feedback-error,
.error-message .message-content {
  color: var(--danger);
}

.typing {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing i {
  width: 6px;
  height: 6px;
  background: #83838d;
  border-radius: 50%;
  animation: typing-pulse 1.1s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

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

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

.composer-wrap {
  padding: 11px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
}

.composer {
  padding: 9px;
  background: #fff;
  border: 1px solid #cfcfd6;
  border-radius: 3px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.12);
}

.composer textarea {
  width: 100%;
  max-height: 116px;
  display: block;
  padding: 3px 4px 8px;
  resize: none;
  overflow-y: auto;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #8a8a94;
}

.composer textarea:focus-visible {
  outline: 0;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.web-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #666671;
  font-size: 10px;
  line-height: 1.2;
}

.web-control input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.send-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 11px 8px 13px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 3px;
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

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

.send-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.send-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.privacy-note {
  margin: 7px 3px 0;
  color: #777781;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
}

.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: 360px) {
  .chat-header {
    padding-inline: 10px;
  }

  .brand-mark {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .brand-copy strong {
    font-size: 12px;
  }

  .brand-copy span {
    font-size: 10px;
  }

  .messages {
    padding-inline: 13px;
  }
}

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