:root {
  --bg: #ffffff;
  --text: #1b1f27;
  --muted: #6b7280;
  --line: #e7e9ee;
  --accent: #1f56c4;       /* blue from the Todo Sales logo */
  --accent-soft: #eaf0fc;
  --bot: #f4f6f9;
  --danger: #c62828;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 6px; }
.muted { color: var(--muted); margin: 0 0 16px; }
.error { color: var(--danger); margin: 0 0 12px; font-size: 14px; }

.top {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.logo { height: 36px; width: auto; display: block; }
.ghost {
  border: 1px solid var(--line); background: var(--bg); color: var(--accent);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer;
}

/* login */
.login { flex: 1; overflow: auto; padding: 32px 20px; display: flex; justify-content: center; }
.login form { width: 100%; max-width: 360px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.primary {
  width: 100%; padding: 13px; border: 0; border-radius: 12px; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
}
.primary:disabled { opacity: .6; }

/* chat */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; -webkit-overflow-scrolling: touch; }
.welcome { text-align: center; padding: 28px 8px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 999px;
  padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.chip:active { background: var(--accent-soft); }

.msg { max-width: 88%; margin: 0 0 12px; padding: 10px 14px; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { margin-left: auto; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { margin-right: auto; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.bot p { margin: 0 0 8px; }
.msg.bot p:last-child, .msg.bot ul:last-child, .msg.bot ol:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: 0 0 8px; padding-left: 20px; }
.msg.bot li { margin: 2px 0; }
.msg.bot code { background: #e9edf3; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.msg.err { background: #fdecea; color: var(--danger); margin-right: auto; }

.status { color: var(--muted); font-size: 13px; margin: 0 0 12px 4px; display: flex; align-items: center; gap: 8px; }
.dots span { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

.composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--line);
}
.composer textarea { margin: 0; resize: none; max-height: 120px; border-radius: 22px; padding: 11px 16px; }
.send {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.send:disabled { background: #b8c4dd; cursor: default; }

/* charts + files */
.msg.bot { width: 100%; max-width: 100%; }
.msg.bot > div > p:last-child { margin-bottom: 0; }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 4px 0 10px; }
.chart-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.chart-box { position: relative; height: 240px; }
.chart-pending { color: var(--muted); font-size: 13px; padding: 6px 0; }
.ghost.small { font-size: 12px; padding: 4px 12px; margin-top: 8px; }
.small { font-size: 13px; }
a.file { display: inline-block; margin: 2px 0; padding: 8px 14px; background: var(--accent-soft); color: var(--accent); border-radius: 10px; font-weight: 600; text-decoration: none; }

/* voice */
.actions { display: flex; align-items: center; gap: 8px; }
.lang { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 999px; padding: 6px 10px; font: inherit; font-size: 13px; }
.mic {
  flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--accent);
  display: grid; place-items: center; cursor: pointer;
}
.mic.on { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.3s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198, 40, 40, .45); } 70% { box-shadow: 0 0 0 12px rgba(198, 40, 40, 0); } 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); } }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 10px; }

/* splash */
#splash {
  position: fixed; inset: 0; z-index: 1000; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  transition: opacity .45s ease;
}
#splash.out { opacity: 0; pointer-events: none; }
#splash img { width: min(62vw, 280px); height: auto; animation: splash-pop .8s cubic-bezier(.2, .8, .2, 1) both; }
.splash-bar { width: 120px; height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; animation: splash-fill 1.9s ease-in-out both; }
@keyframes splash-pop { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: scale(1); } }
@keyframes splash-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { #splash img, .splash-bar span { animation: none; } #splash { transition: none; } }
