/* Theme variables are overwritten at runtime from /api/config (per brand). */
:root {
  --primary: #4338ca;
  --primary-dark: #3730a3;
  --accent: #0d9488;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --text: #1e2230;
  --muted: #5b6172;

  --border: #e6e8f0;
  --user-bubble: var(--primary);
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 18, 36, 0.06), 0 8px 24px rgba(16, 18, 36, 0.05);
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-dot {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}

.brand-text { min-width: 0; }
.brand-text h1 { font-size: 1.05rem; margin: 0; line-height: 1.2; }
.tagline {
  margin: 2px 0 0; font-size: 0.78rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.style-toggle { display: flex; align-items: center; gap: 8px; }
.style-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.segmented {
  display: inline-flex; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 3px;
}
.seg {
  border: 0; background: transparent; color: var(--muted);
  font-size: 0.8rem; padding: 6px 11px; border-radius: 7px;
  cursor: pointer; font-weight: 600; transition: all 0.15s ease;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ── Messages ───────────────────────────────────────────────────────────── */
.messages {
  flex: 1; overflow-y: auto; padding: 22px 18px;
  display: flex; flex-direction: column; gap: 16px;
}

.msg { display: flex; gap: 10px; max-width: 100%; }
.msg .avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; color: #fff;
}
.msg.assistant .avatar { background: linear-gradient(135deg, var(--primary), var(--accent)); }
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: #cfd2e0; color: #3a3f52; }

.bubble {
  padding: 12px 15px; border-radius: var(--radius); line-height: 1.55;
  font-size: 0.95rem; max-width: 78%; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.assistant .bubble {
  background: var(--surface); border: 1px solid var(--border);
  border-top-left-radius: 4px; box-shadow: var(--shadow);
}
.msg.user .bubble {
  background: var(--user-bubble); color: #fff; border-top-right-radius: 4px;
}

/* Markdown inside assistant bubbles */
.bubble p { margin: 0 0 0.6em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0.3em 0 0.7em; padding-left: 1.3em; }
.bubble li { margin: 0.2em 0; }
.bubble h1, .bubble h2, .bubble h3 { margin: 0.6em 0 0.35em; line-height: 1.25; }
.bubble h1 { font-size: 1.1rem; } .bubble h2 { font-size: 1.02rem; } .bubble h3 { font-size: 0.96rem; }
.bubble code {
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  padding: 1px 5px; border-radius: 5px; font-size: 0.86em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.bubble pre {
  background: #0f1226; color: #e7e9f5; padding: 12px 14px; border-radius: 10px;
  overflow-x: auto; margin: 0.5em 0;
}
.bubble pre code { background: none; padding: 0; color: inherit; }
.bubble a { color: var(--primary); text-decoration: underline; }
.bubble strong { font-weight: 700; }
.bubble table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.88rem; width: 100%; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; }
.bubble th { background: color-mix(in srgb, var(--primary) 7%, transparent); }

/* typing dots */
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  opacity: 0.5; animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 0.9; } }

/* ── Suggestions ────────────────────────────────────────────────────────── */
.suggestions {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px;
}
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 0.83rem; padding: 8px 13px;
  border-radius: 999px; cursor: pointer; transition: all 0.15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ── Composer ───────────────────────────────────────────────────────────── */
.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border);
}
.input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 14px; font: inherit; font-size: 0.95rem; line-height: 1.4;
  max-height: 160px; outline: none; background: var(--bg); color: var(--text);
}
.input:focus { border-color: var(--primary); background: var(--surface); }
.send {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: var(--primary); color: #fff; cursor: pointer; display: grid; place-items: center;
  transition: background 0.15s ease;
}
.send:hover { background: var(--primary-dark); }
.send:disabled { opacity: 0.5; cursor: not-allowed; }

.disclaimer {
  margin: 0; padding: 0 18px 12px; font-size: 0.7rem; color: var(--muted);
  text-align: center; background: var(--surface);
}

@media (max-width: 640px) {
  .header { gap: 10px; }
  .style-label { display: none; }
  .seg { padding: 6px 9px; font-size: 0.74rem; }
  .bubble { max-width: 88%; }
  .tagline { display: none; }
}
