/* EvoMate™ Chat — ChatGPT-like monochrome UI */

:root {
  --bg: #ffffff;
  --text: #0d0d0d;
  --muted: #6b6b6b;
  --muted-2: #9b9b9b;
  --line: #e6e6e6;
  --surface: #f4f4f4;
  --surface-hover: #ececec;
  --user-bubble: #f4f4f4;
  --btn: #0d0d0d;
  --btn-text: #ffffff;
  --warn-bg: #fff8e6;
  --warn-text: #8a5a00;
  --warn-line: #efdcb0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --logo-filter: invert(1);
  --radius: 26px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --text: #ececec;
    --muted: #a6a6a6;
    --muted-2: #7d7d7d;
    --line: #3a3a3a;
    --surface: #2f2f2f;
    --surface-hover: #3a3a3a;
    --user-bubble: #303030;
    --btn: #ffffff;
    --btn-text: #0d0d0d;
    --warn-bg: #332a12;
    --warn-text: #f3c969;
    --warn-line: #4a3b16;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
    --logo-filter: none;
  }
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ------------------------------------------------------------- app bar */

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  height: 64px;
  padding: 0 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  padding: 4px;
  margin-left: -4px;
}

.brand-logo {
  display: block;
  width: 128px;
  height: 39px;
  filter: var(--logo-filter);
  opacity: 0.92;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.icon-btn,
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn {
  width: 34px;
}

.pill-btn {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
}

.icon-btn:hover,
.pill-btn:hover {
  color: var(--text);
  background: var(--surface);
}

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

/* --------------------------------------------------------------- layout */

.main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

body[data-view="home"] .main {
  justify-content: center;
  padding-bottom: 5vh;
}

.stream {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  padding: 0 20px;
}

.scroller {
  flex: none;
  width: 100%;
  min-height: 0;
}

body[data-view="chat"] .scroller {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body[data-view="chat"] .stream {
  padding-top: 14px;
  padding-bottom: 10px;
}

.scroller::-webkit-scrollbar {
  width: 10px;
}

.scroller::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid var(--bg);
  border-radius: 999px;
}

.dock {
  flex: none;
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  padding: 0 20px 6px;
}

/* ----------------------------------------------------------------- hero */

.hero {
  padding: 0 0 26px;
  text-align: center;
}

.hero h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.hero p {
  max-width: 520px;
  margin: 10px auto 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
}

body[data-view="chat"] .hero,
body[data-view="chat"] .suggestions {
  display: none;
}

/* ------------------------------------------------------------- messages */

.messages {
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
}

.msg.user {
  display: flex;
  justify-content: flex-end;
  margin: 20px 0 6px;
}

.msg.user .bubble {
  max-width: min(78%, 620px);
  padding: 10px 18px;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  background: var(--user-bubble);
  border-radius: 22px;
}

.msg.user .bubble .prose {
  font-size: inherit;
  line-height: inherit;
}

.msg.assistant {
  display: flex;
  gap: 12px;
  margin: 6px 0 26px;
}

.avatar {
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 2px;
}

.avatar img {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  filter: var(--logo-filter);
  opacity: 0.92;
}

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

.prose {
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p {
  margin: 0.75em 0;
}

.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 1.2em 0 0.5em;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.5;
}

.prose ul,
.prose ol {
  margin: 0.75em 0;
  padding-left: 1.4em;
}

.prose li {
  margin: 0.3em 0;
}

.prose code {
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface);
  border-radius: 5px;
}

.prose pre {
  margin: 0.8em 0;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--surface);
  border-radius: 12px;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: 13px;
  line-height: 1.6;
}

.prose blockquote {
  margin: 0.8em 0;
  padding: 2px 0 2px 14px;
  color: var(--muted);
  border-left: 3px solid var(--line);
}

.prose hr {
  margin: 1.2em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.prose a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--muted-2);
  text-underline-offset: 2px;
}

.prose a:hover {
  text-decoration-color: currentColor;
}

.msg.pending .prose {
  color: var(--muted);
  font-size: 15px;
}

.msg.streaming .prose > :last-child::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.95em;
  margin-left: 3px;
  vertical-align: -0.12em;
  background: currentColor;
  opacity: 0.4;
  animation: caret 1s steps(2, start) infinite;
}

@keyframes caret {
  to {
    visibility: hidden;
  }
}

.msg-actions {
  display: flex;
  gap: 14px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.msg:hover .msg-actions,
.msg:focus-within .msg-actions {
  opacity: 1;
}

@media (hover: none) {
  .msg-actions {
    opacity: 1;
  }
}

.text-btn {
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

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

.text-btn.subtle {
  opacity: 0.7;
}

/* ---------------------------------------------------------------- banner */

.banner[hidden] {
  display: none;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 14px;
}

.banner-actions {
  display: flex;
  flex: none;
  gap: 14px;
  margin-left: auto;
}

/* -------------------------------------------------------------- composer */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.composer:focus-within {
  border-color: var(--muted-2);
}

#input {
  flex: 1 1 auto;
  min-height: 26px;
  max-height: 200px;
  padding: 8px 0;
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  color: inherit;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
}

#input::placeholder {
  color: var(--muted-2);
}

.send-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--btn-text);
  background: var(--btn);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.send-btn:hover {
  opacity: 0.88;
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  color: var(--muted-2);
  background: var(--surface);
  cursor: default;
  opacity: 1;
}

.send-btn .icon {
  width: 19px;
  height: 19px;
  stroke-width: 2.1;
}

.send-btn .icon-stop {
  display: none;
  width: 16px;
  height: 16px;
}

.composer.is-streaming .icon-send {
  display: none;
}

.composer.is-streaming .icon-stop {
  display: block;
}

/* ----------------------------------------------------------- suggestions */

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.suggestion {
  padding: 8px 14px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.suggestion:hover {
  background: var(--surface);
  border-color: var(--muted-2);
}

.disclaimer {
  margin: 12px 0 10px;
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------- utility */

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

:focus-visible {
  outline: 2px solid var(--muted-2);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 640px) {
  .appbar {
    height: 56px;
    padding: 0 12px;
  }


  body[data-view="home"] .main {
    padding-bottom: 2vh;
  }

  .stream,
  .dock {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hero {
    padding-bottom: 20px;
  }

  .hero h1 {
    font-size: 24px;
  }

  .hero p {
    font-size: 13.5px;
  }

  .msg.user .bubble {
    max-width: 88%;
  }

  .prose,
  .msg.user .bubble {
    font-size: 15.5px;
  }

  .suggestions {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .suggestions::-webkit-scrollbar {
    display: none;
  }

  .suggestion {
    flex: none;
    white-space: nowrap;
  }
}
