/* Spark — plain themeable skin.
   To re-skin later, override the CSS variables under [data-theme="..."]. */

:root,
[data-theme="plain"] {
  --bg: #0b1020;
  --surface: #141a2e;
  --surface-2: #1d2742;
  --text: #eef1f8;
  --muted: #9aa3bd;
  --accent: #5b8cff;
  --accent-contrast: #ffffff;
  --user-bubble: #2a55c4;
  --bot-bubble: #1d2742;
  --error: #ff8080;
  --warn: #ffd166;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}
body { overflow: hidden; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--error); }

/* ---------- Lock screen ---------- */
.lock { align-items: center; justify-content: center; padding: 24px; }
.lock-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); border-radius: var(--radius);
  padding: 32px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.logo { font-size: 56px; line-height: 1; color: var(--accent); }
.lock-card h1 { margin: 8px 0 4px; font-size: 28px; letter-spacing: .5px; }
#pin-form { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
#pin-input {
  font-size: 28px; text-align: center; letter-spacing: 8px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--surface-2);
  background: var(--surface-2); color: var(--text);
}
#pin-submit, #pin-form button {
  font-size: 18px; padding: 14px; border: none; border-radius: 14px;
  background: var(--accent); color: var(--accent-contrast); font-weight: 600;
}
#pin-error { margin-top: 14px; }

/* ---------- Chat ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--surface);
  border-bottom: 1px solid var(--surface-2);
}
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.brand .dot { color: var(--accent); }
.spacer { flex: 1; }
.budget { font-size: 12px; color: var(--muted); }
.icon-btn {
  background: var(--surface-2); color: var(--text); border: none;
  border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 600;
}

.banner {
  margin: 10px 14px 0; padding: 10px 14px; border-radius: 12px;
  background: rgba(255,209,102,.15); color: var(--warn); font-size: 14px;
  border: 1px solid rgba(255,209,102,.35);
}
.banner.block { background: rgba(255,128,128,.15); color: var(--error); border-color: rgba(255,128,128,.4); }

.log {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.msg .bubble {
  padding: 12px 15px; border-radius: var(--radius); font-size: 17px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; }
.msg.bot .bubble { background: var(--bot-bubble); color: var(--text); border-bottom-left-radius: 6px; }
.msg .tools { display: flex; gap: 8px; }
.speak-btn {
  background: transparent; border: 1px solid var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font-size: 13px;
}
.speak-btn.speaking { color: var(--accent); border-color: var(--accent); }
.typing .bubble { color: var(--muted); font-style: italic; }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--surface-2);
}
#input {
  flex: 1; resize: none; max-height: 140px;
  font-size: 17px; font-family: var(--font); line-height: 1.4;
  padding: 12px 14px; border-radius: 18px;
  border: 1px solid var(--surface-2); background: var(--surface-2); color: var(--text);
}
.round-btn {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%;
  border: none; font-size: 20px; background: var(--surface-2); color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.round-btn.send { background: var(--accent); color: var(--accent-contrast); }
.round-btn:disabled { opacity: .5; }
#mic-btn.listening { background: var(--error); color: #fff; }

@media (min-width: 800px) {
  .log { max-width: 760px; width: 100%; margin: 0 auto; }
  .composer > * { }
  .composer { justify-content: center; }
  .composer #input { max-width: 640px; }
}
