:root {
  --ground:    #0B0F14;
  --raised:    #131A22;
  --raised-2:  #1A2430;
  --line:      #22303D;
  --ink:       #DFE6ED;
  --ink-soft:  #93A1AF;
  --ink-faint: #63717E;
  --brass:     #C99544;
  --brass-dim: #8A6528;
  --teal:      #6FA3B0;
  --good:      #5FA97C;
  --bad:       #C4665B;

  --f-display: "Zilla Slab", Georgia, serif;
  --f-body:    "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16.5px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* ---------------- top bar ---------------- */

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 13px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0E141B, var(--ground));
  position: sticky;
  top: 0;
  z-index: 5;
}

.identity {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.wordmark {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 1.32rem;
  letter-spacing: 0.14em;
  color: var(--ink);
  line-height: 1.1;
}

.build {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
}
.pill:hover { border-color: var(--brass-dim); color: var(--ink); }
.pill:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: 0 0 auto;
}
.dot.on  { background: var(--good); box-shadow: 0 0 7px #5FA97C88; }
.dot.off { background: var(--bad); }
.dot.busy { background: var(--brass); animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .28 } }

/* ---------------- conversation ---------------- */

.log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 26px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scroll-behavior: smooth;
}

.log > * { max-width: 720px; width: 100%; margin: 0 auto; }

.boot { padding: 8px 0 2px; }
.boot-line {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 1.24rem;
  color: var(--brass);
  margin: 0 0 6px;
}
.boot-sub {
  color: var(--ink-soft);
  margin: 0;
  font-size: 0.97rem;
  max-width: 46ch;
}

.turn { display: flex; flex-direction: column; gap: 7px; }

.who {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.turn.me   .who { color: var(--teal); }
.turn.them .who { color: var(--brass); }

.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.turn.me .body { color: var(--ink-soft); }

.body strong { font-weight: 600; color: var(--ink); }
.body code {
  font-family: var(--f-mono);
  font-size: 0.88em;
  background: var(--raised-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* tool trace — shown because Michael should always be able to see what
   JARVIS actually touched, not just what it says it touched */
.trace {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.trace span {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  background: var(--raised);
}

.thinking {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--brass);
}
.thinking::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: "" }
  25%  { content: "." }
  50%  { content: ".." }
  75%  { content: "..." }
}

.fault {
  border-left: 3px solid var(--bad);
  background: #C4665B12;
  padding: 11px 14px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------------- composer ---------------- */

.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 18px calc(env(safe-area-inset-bottom) + 14px);
  border-top: 1px solid var(--line);
  background: var(--ground);
}

.composer > * { }

#input {
  flex: 1 1 auto;
  resize: none;
  max-height: 168px;
  font-family: var(--f-body);
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
}
#input::placeholder { color: var(--ink-faint); }
#input:focus { outline: none; border-color: var(--brass-dim); }

#send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--brass-dim);
  background: var(--brass);
  color: #14100A;
  display: grid;
  place-items: center;
  cursor: pointer;
}
#send:disabled { opacity: 0.34; cursor: default; }
#send:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .log { scroll-behavior: auto; }
}
