:root {
  --bg: #070b16;
  --bg-2: #0b1224;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2fb;
  --muted: #9aa6c4;
  --muted-2: #6c7897;
  --accent: #7c9bff;
  --accent-2: #b985ff;
  --accent-3: #4ad6c8;
  --danger: #ff8087;
  --ok: #57e08e;
  --grad: linear-gradient(135deg, #7c9bff 0%, #b985ff 55%, #4ad6c8 120%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

html:not(.i18n-ready) body {
  opacity: 0;
}
html.i18n-ready body {
  opacity: 1;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(1200px 800px at 85% -10%, #16204a 0%, transparent 60%),
    radial-gradient(1000px 700px at 0% 0%, #191233 0%, transparent 55%), var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Animated aurora background */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
}
.blob {
  position: absolute;
  width: 42vmax;
  height: 42vmax;
  border-radius: 50%;
  mix-blend-mode: screen;
  animation: drift 22s ease-in-out infinite;
}
.blob-1 {
  background: #5468ff;
  top: -10%;
  left: -8%;
}
.blob-2 {
  background: #b04dff;
  bottom: -18%;
  right: -6%;
  animation-delay: -7s;
}
.blob-3 {
  background: #17b3a3;
  top: 30%;
  right: 25%;
  animation-delay: -14s;
}
@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(4vw, 3vh) scale(1.08);
  }
  66% {
    transform: translate(-3vw, -2vh) scale(0.95);
  }
}
@media (prefers-reduced-motion: reduce) {
  .blob {
    animation: none;
  }
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  color: #0a0e1a;
  background: var(--grad);
  box-shadow: 0 10px 30px rgba(124, 155, 255, 0.4);
}
.brand-text h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.2px;
}
.status-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.lang-dropdown {
  position: relative;
  z-index: 30;
}
.lang-trigger {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  color: var(--muted);
}
.lang-trigger:hover,
.lang-trigger[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--panel-strong);
}
.lang-globe {
  width: 13px;
  height: 13px;
  border: 1.35px solid currentColor;
  border-radius: 50%;
  position: relative;
  opacity: 0.85;
  flex: 0 0 auto;
}
.lang-globe::before {
  content: "";
  position: absolute;
  inset: -1.35px 3.5px;
  border: 1.2px solid currentColor;
  border-radius: 50%;
}
.lang-globe::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 50%;
  border-top: 1.2px solid currentColor;
}
.lang-caret {
  width: 6px;
  height: 6px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0.75;
}
.lang-trigger[aria-expanded="true"] .lang-caret {
  transform: rotate(225deg) translate(-1px, -2px);
}
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(10, 15, 30, 0.82);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.lang-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.lang-option:hover {
  color: var(--text);
  background: rgba(124, 155, 255, 0.1);
}
.lang-option.is-active {
  color: var(--text);
  background: rgba(124, 155, 255, 0.16);
}
.lang-option-hint {
  font-size: 11px;
  color: var(--muted-2);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  backdrop-filter: blur(8px);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 0 rgba(87, 224, 142, 0.5);
}
.dot.live {
  background: var(--ok);
  animation: pulse 2s infinite;
}
.dot.mock {
  background: var(--accent-2);
}
.dot.down {
  background: var(--danger);
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(87, 224, 142, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(87, 224, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(87, 224, 142, 0);
  }
}

/* Layout */
.layout {
  flex: 1;
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 40px) 24px;
}
.stat-pill {
  gap: 6px;
}
.stat-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

/* Chat card */
.chat-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
  min-height: 560px;
}
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.welcome {
  margin: auto;
  text-align: center;
  max-width: 460px;
  color: var(--muted);
}
.welcome-mark {
  font-size: 34px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome h2 {
  margin: 8px 0 6px;
  color: var(--text);
  font-size: 22px;
}
.welcome p {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.6;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: center;
}
.chip {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.06s ease, border-color 0.16s ease, background 0.16s ease;
}
.chip:hover {
  border-color: var(--accent);
  background: rgba(124, 155, 255, 0.12);
}
.chip:active {
  transform: translateY(1px);
}

/* Messages */
.msg {
  display: flex;
  gap: 12px;
  max-width: 100%;
  animation: rise 0.25s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.msg.user {
  flex-direction: row-reverse;
}
.avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}
.avatar.user {
  background: rgba(124, 155, 255, 0.2);
  color: var(--accent);
  border: 1px solid rgba(124, 155, 255, 0.35);
}
.avatar.bot {
  background: var(--grad);
  color: #0a0e1a;
}
.bubble {
  padding: 12px 15px;
  border-radius: 15px;
  line-height: 1.62;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: min(80%, 640px);
}
.msg.user .bubble {
  background: linear-gradient(135deg, rgba(124, 155, 255, 0.9), rgba(185, 133, 255, 0.9));
  color: #0a0e1a;
  border-bottom-right-radius: 5px;
  font-weight: 500;
}
.msg.bot .bubble {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  white-space: normal;
}
.bubble .caret {
  display: inline-block;
  width: 8px;
  height: 17px;
  margin-left: 1px;
  vertical-align: -3px;
  background: var(--accent);
  border-radius: 2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 0;
}
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.3s infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.18s;
}
.typing span:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes bounce {
  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* Notice bar */
.notice {
  margin: 0 22px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--muted);
}
.notice.warn {
  border-color: rgba(255, 190, 90, 0.4);
  background: rgba(255, 190, 90, 0.1);
  color: #ffd79a;
}
.notice.error {
  border-color: rgba(255, 128, 135, 0.4);
  background: rgba(255, 128, 135, 0.1);
  color: #ffb3b8;
}

/* Composer */
.composer {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
  background: rgba(6, 10, 22, 0.35);
}
.composer-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 155, 255, 0.16);
}
.input {
  display: block;
  width: 100%;
  resize: none;
  min-height: 24px;
  max-height: 180px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 6px 4px 0 0;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  outline: none;
}
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.composer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: border-color 0.16s ease, color 0.16s ease;
}
.ghost-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.send-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: #0a0e1a;
  background: var(--grad);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.16s ease, opacity 0.16s ease;
}
.send-btn:hover {
  filter: brightness(1.06);
}
.send-btn:active {
  transform: translateY(1px);
}
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

/* Info card */
.info-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.info-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.endpoint {
  display: block;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--accent-3);
  background: rgba(74, 214, 200, 0.08);
  border: 1px solid rgba(74, 214, 200, 0.2);
  border-radius: 10px;
  padding: 9px 12px;
  word-break: break-all;
}
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin: 8px 0 0;
}
.code {
  margin: 0;
  padding: 14px;
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #cdd6f4;
}
.copy-btn {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
}
.copy-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.copy-btn.copied {
  color: var(--ok);
  border-color: rgba(87, 224, 142, 0.4);
}
.limits {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.limits li {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text);
}
.limits li::before {
  content: "▸";
  color: var(--accent);
  font-size: 12px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}
.metric-value {
  font-size: 22px;
  font-weight: 700;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}
.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.notice.info {
  border-color: rgba(124, 155, 255, 0.35);
  background: rgba(124, 155, 255, 0.1);
  color: #c5d4ff;
}

.msg-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: min(80%, 640px);
}
.msg.user .msg-col {
  align-items: flex-end;
}
.msg .bubble {
  max-width: 100%;
}
.msg-actions {
  display: flex;
  gap: 6px;
}
.msg-action {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-2);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.msg-action:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.bubble :is(pre, code, strong) {
  font-size: inherit;
}
.bubble .md-code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 6px;
  padding: 0.1em 0.35em;
}
.bubble .md-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 8px 0 0;
  background: rgba(0, 0, 0, 0.2);
}
.bubble .md-pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.composer-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  font-size: 12px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.composer-meta .hint {
  display: none;
  white-space: nowrap;
}
@media (min-width: 720px) {
  .composer-meta .hint {
    display: inline;
  }
}
.danger-btn:hover {
  border-color: rgba(255, 128, 135, 0.45);
  color: #ffb3b8;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
}
.tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
}
.tab.is-active {
  color: var(--text);
  border-color: rgba(124, 155, 255, 0.45);
  background: rgba(124, 155, 255, 0.12);
}

.pill.is-secure {
  color: var(--ok);
}
.pill.is-insecure {
  color: #ffd79a;
}
.pill .lock {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  border: 1.5px solid currentColor;
  position: relative;
}
.pill .lock::before {
  content: "";
  position: absolute;
  width: 5px;
  height: 4px;
  border: 1.4px solid currentColor;
  border-bottom: none;
  border-radius: 5px 5px 0 0;
  left: 0.5px;
  top: -5px;
}

.footer {
  text-align: center;
  padding: 16px;
  font-size: 12.5px;
  color: var(--muted-2);
}

@media (prefers-reduced-motion: reduce) {
  .msg,
  .dot.live,
  .bubble .caret,
  .typing span {
    animation: none;
  }
}

@media (max-width: 900px) {
  .chat-card {
    min-height: 70vh;
  }
}

/* Scrollbar */
.chat-scroll::-webkit-scrollbar,
.code::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
.chat-scroll::-webkit-scrollbar-thumb,
.code::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
}
