:root {
  color-scheme: dark;
  --bg: #141a24;
  --ink: #f1f5f9;
  --muted: #9eacbd;
  --line: rgba(202, 215, 231, 0.11);
  --accent: #a84d1e;
  --accent-soft: rgba(168, 77, 30, 0.16);
  --accent-2: #80d2db;
  --header: rgba(13, 18, 28, 0.92);
  --bot-bubble: rgba(20, 27, 38, 0.98);
  --user-bubble: linear-gradient(135deg, #8e4318, #642b10);
  --error-bubble: rgba(133, 25, 25, 0.24);
  --composer: rgba(13, 18, 28, 0.96);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 148, 77, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(128, 210, 219, 0.10), transparent 24%),
    linear-gradient(180deg, #1d2531 0%, var(--bg) 100%);
  background-size: auto, auto, auto;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("/static/floating-cogs.svg") repeat;
  background-size: 320px 320px;
  opacity: 0.16;
  filter: brightness(1.35);
  pointer-events: none;
  z-index: 0;
}

.chat-shell {
  position: relative;
  z-index: 1;
}

.chat-shell {
  width: min(960px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 0;
}

.eyebrow {
  margin: 0 0 3px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
}

.eyebrow span {
  color: var(--accent-2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 10px 14px;
  background: var(--header);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

@supports (padding-top: env(safe-area-inset-top)) {
  .chat-header {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}

.chat-header h1 {
  margin: 0;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.header-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.menu {
  position: relative;
}

.menu[open] .menu-button {
  background: rgba(36, 46, 61, 0.96);
}

.menu-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(28, 36, 49, 0.88);
  border: 1px solid var(--line);
  padding: 0;
  list-style: none;
  cursor: pointer;
}

.menu-button::-webkit-details-marker {
  display: none;
}

.menu-button span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(15, 21, 31, 0.98);
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  z-index: 4;
}

.menu-panel form {
  margin: 0;
}

.menu-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 700;
}

.menu-item:hover {
  background: rgba(255, 148, 77, 0.12);
}

.chat-history {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 4px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-history::-webkit-scrollbar {
  display: none;
}

.message-row {
  display: flex;
}

.date-separator {
  display: flex;
  justify-content: center;
  margin: 6px 0 2px;
}

.date-separator span {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(24, 31, 43, 0.94);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: lowercase;
}

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

.bot-row {
  justify-content: flex-start;
}

.message-bubble {
  max-width: min(720px, 88%);
  padding: 14px 16px 16px;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
}

.user-bubble {
  background: var(--user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

.bot-bubble {
  background: var(--bot-bubble);
  border-bottom-left-radius: 4px;
}

.error-bubble {
  background: var(--error-bubble);
  border-bottom-left-radius: 4px;
}

.intro-bubble {
  max-width: 520px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.user-bubble .message-meta {
  color: rgba(255, 255, 255, 0.82);
}

.message-bubble p {
  margin: 0;
  line-height: 1.6;
  white-space: pre-wrap;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button.ghost {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(28, 36, 49, 0.92);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mode-chip {
  cursor: pointer;
}

.chip.secondary {
  background: rgba(124, 201, 210, 0.10);
  color: var(--accent-2);
}

.inline-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(124, 201, 210, 0.12);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 700;
}

.dictionary-output {
  line-height: 1.7;
  white-space: pre-wrap;
}

.dictionary-output blockquote {
  margin: 10px 0 0;
  padding-left: 12px;
  border-left: 3px solid rgba(18, 92, 97, 0.25);
  white-space: pre-wrap;
}

.dictionary-output code {
  font-family: "IBM Plex Mono", monospace;
}

.message-stats,
.feedback-row,
.retry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.feedback-row,
.retry-row {
  justify-content: flex-end;
}

.feedback-row {
  margin-top: 6px;
}

.message-stats span {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(24, 31, 43, 0.96);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.composer-wrap {
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: transparent;
}

.composer {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 14px;
}

.composer-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(24, 31, 43, 0.96);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.composer-status-floating {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% - 54px);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 3;
  pointer-events: none;
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  background: rgba(4, 7, 12, 0.48);
  backdrop-filter: blur(2px);
  color: rgba(241, 245, 249, 0.96);
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.34);
}

.composer-status-floating[hidden] {
  display: none;
}

.typing-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.28;
  animation: pulse 1.1s infinite ease-in-out;
}

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

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

.composer-input-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  border-bottom-right-radius: 4px;
  padding: 10px 16px;
  height: 42px;
  min-height: 42px;
  max-height: 50vh;
  font: inherit;
  line-height: 1.35;
  color: var(--ink);
  background: rgba(24, 31, 43, 0.96);
  overflow-y: auto;
}

.composer textarea.is-translating {
  filter: blur(1.5px);
  opacity: 0.72;
}

.composer textarea:focus {
  outline: 2px solid rgba(208, 90, 0, 0.24);
  border-color: rgba(208, 90, 0, 0.40);
}

.send-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8e4318, #642b10);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  padding-left: 4px;
}

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

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

.send-button.is-translating {
  filter: blur(1.5px);
}

.muted {
  color: var(--muted);
}

.feedback-dialog {
  width: min(520px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 21, 31, 0.98);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42);
  padding: 16px;
}

.feedback-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 138, 61, 0.12);
  color: var(--accent);
  padding: 2px;
  font-size: 28px;
  line-height: 1;
}

.feedback-form h2 {
  margin: 0;
  font-size: 20px;
}

.about-content h2 {
  margin: 0;
  font-size: 20px;
}

.feedback-form p {
  margin: 8px 0 12px;
  color: var(--muted);
}

.about-content p,
.about-content ul {
  margin: 10px 0 0;
  color: var(--ink);
  line-height: 1.55;
}

.about-content ul {
  padding-left: 18px;
}

.about-content li + li {
  margin-top: 6px;
}

.about-content a {
  color: var(--accent-2);
}

.feedback-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: rgba(24, 31, 43, 0.96);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

@keyframes pulse {
  0%, 80%, 100% {
    transform: scale(0.85);
    opacity: 0.28;
  }
  40% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@media (max-width: 700px) {
  .chat-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
  }

  .header-chips {
    flex: 0 0 auto;
  }

  .brand {
    min-width: 0;
    flex: 1 1 auto;
  }

  .message-bubble {
    max-width: 94%;
  }

  .composer-input-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .send-button {
    width: 42px;
  }

  .message-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #efe8dd;
    --ink: #1e1d1a;
    --muted: #6a645a;
    --line: rgba(53, 41, 27, 0.14);
    --accent: #d05a00;
    --accent-soft: rgba(208, 90, 0, 0.12);
    --accent-2: #125c61;
    --header: rgba(255, 249, 241, 0.9);
    --bot-bubble: rgba(255, 251, 246, 0.97);
    --user-bubble: linear-gradient(135deg, #d05a00, #a84400);
    --error-bubble: rgba(133, 25, 25, 0.08);
    --composer: rgba(255, 249, 241, 0.96);
    --shadow: 0 16px 48px rgba(78, 54, 28, 0.12);
  }

  body {
    background:
      radial-gradient(circle at top left, rgba(255, 148, 77, 0.18), transparent 28%),
      radial-gradient(circle at top right, rgba(18, 92, 97, 0.10), transparent 24%),
      linear-gradient(180deg, #f8f1e7 0%, var(--bg) 100%);
    background-size: auto, auto, auto;
  }

  body::before {
    opacity: 0.03;
    filter: none;
  }

  .menu[open] .menu-button {
    background: rgba(255, 244, 232, 0.96);
  }

  .menu-button {
    background: rgba(255, 252, 247, 0.92);
  }

  .menu-panel {
    background: rgba(255, 250, 245, 0.98);
    box-shadow: 0 12px 28px rgba(53, 41, 27, 0.16);
  }

  .menu-item:hover {
    background: rgba(240, 146, 64, 0.12);
  }

  .date-separator span {
    background: rgba(255, 251, 247, 0.88);
  }

  .message-bubble {
    box-shadow: 0 4px 10px rgba(78, 54, 28, 0.05);
  }

  .chip {
    background: rgba(255, 252, 247, 0.92);
  }

  .message-stats span,
  .composer-status {
    background: rgba(255, 251, 246, 0.92);
  }

  .composer-status-floating {
    background: rgba(24, 21, 18, 0.38);
  }

  .composer textarea,
  .feedback-form textarea {
    background: rgba(255, 254, 250, 0.96);
  }

  .feedback-dialog {
    background: rgba(255, 250, 244, 0.98);
    box-shadow: 0 20px 50px rgba(53, 41, 27, 0.22);
  }

  .feedback-dialog::backdrop {
    background: rgba(24, 20, 16, 0.32);
  }

  .dialog-close {
    background: rgba(240, 146, 64, 0.14);
  }
}
