/* Calm and light. Not a market terminal. IBM Plex per the house style; the stack falls back
   gracefully because this is served from the mini with no external font fetch. */

:root {
  --bg: #faf9f7;
  --ink: #1a1a1a;
  --muted: #6b6862;
  --line: #e6e3dd;
  --me: #ecebe7;
  --accent: #d4a544;
  --private: #8a6a2f;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --ink: #ebe9e4;
    --muted: #8f8b84;
    --line: #2a2825;
    --me: #22201d;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, -apple-system, system-ui, sans-serif;
  font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px) 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; letter-spacing: .01em; }

.state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.dot.ok { background: #4f9a5e; }
.dot.busy { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.dot.bad { background: #b4553f; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

main {
  flex: 1; overflow-y: auto;
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}

.msg { max-width: 42rem; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; letter-spacing: .02em; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }

.msg.me { align-self: flex-end; }
.msg.me .body {
  background: var(--me); padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
}

.msg.private .who::after {
  content: " · lokalt"; color: var(--private); font-weight: 600;
}

.tool {
  font-size: 13px; color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  padding-left: 2px;
}
.tool::before { content: "· "; }

.caret::after {
  content: "▌"; color: var(--accent);
  animation: blink 1s steps(2) infinite; margin-left: 1px;
}
@keyframes blink { 0%,50% { opacity: 1 } 50.01%,100% { opacity: 0 } }

form {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}

input {
  flex: 1; border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 11px 16px; font: inherit; font-size: 16px;
  transition: border-color .2s;
}
input:focus { outline: none; border-color: var(--accent); }

button {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  width: 44px; height: 44px; border-radius: 50%; font-size: 17px;
  cursor: pointer; flex: none; transition: all .15s;
}
button:active { transform: scale(.94); }
#mic.recording { background: var(--accent); border-color: var(--accent); color: #fff; }
#send { border: none; font-size: 22px; color: var(--muted); }
