:root {
  --bg: #05090f;
  --panel: #0b1420;
  --line: #16314a;
  --text: #d8f6ff;
  --muted: #7d9bb0;
  --accent: #38e1ff;
  --accent-2: #9ff3ff;
  --warn: #ffb547;
  --bad: #ff5b6b;
  --good: #3ddc97;
  --level: 0;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(circle at 30% 20%, #0c1d2e 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

button, input { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .35em; color: var(--accent); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: var(--panel); white-space: nowrap;
}
.pill.on { color: var(--good); border-color: color-mix(in srgb, var(--good) 50%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }

.layout {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 0;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}

.core {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px 16px; border-right: 1px solid var(--line);
}
@media (max-width: 820px) { .core { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; } }

.orb {
  position: relative; width: 210px; height: 210px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle, rgba(56,225,255,.15) 0%, rgba(56,225,255,0) 70%);
  transform: scale(calc(1 + var(--level) * .25)); transition: transform 80ms linear;
}
@media (max-width: 820px) { .orb { width: 150px; height: 150px; } }
.orb .ring {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: .35;
}
.orb .r1 { inset: 0; border-style: dashed; animation: spin 18s linear infinite; }
.orb .r2 { inset: 14%; opacity: .55; border-width: 3px; border-left-color: transparent; animation: spin 7s linear infinite reverse; }
.orb .r3 { inset: 28%; opacity: .7; border-right-color: transparent; animation: spin 4s linear infinite; }
.orb .heart {
  position: absolute; inset: 39%; border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 0 25px var(--accent), 0 0 60px rgba(56,225,255,.5);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 45px var(--accent), 0 0 110px rgba(56,225,255,.8); } }

body[data-state="off"] .orb .ring, body[data-state="off"] .orb .heart { filter: grayscale(1); opacity: .35; animation-play-state: paused; }
body[data-state="listening"] .orb .heart { background: #fff; animation: pulse 1s ease-in-out infinite; }
body[data-state="thinking"] .orb .r2, body[data-state="tool"] .orb .r2,
body[data-state="transcribing"] .orb .r2 { animation-duration: 1.2s; }
body[data-state="speaking"] .orb .heart { animation: pulse .6s ease-in-out infinite; }

.state { font-size: 17px; color: var(--accent-2); text-align: center; min-height: 1.5em; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px;
  font-size: 12px; background: var(--panel);
}

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 380px; }
.controls button, dialog button, .composer button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.controls button:hover, dialog button:hover, .composer button:hover { border-color: var(--accent); color: var(--accent-2); }
.controls button.active { border-color: var(--accent); color: var(--accent); }
.controls button.danger:hover { border-color: var(--bad); color: var(--bad); }

.log { overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { max-width: 760px; padding: 9px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; border-color: #234d6b; background: #0e2335; }
.msg.jarvis { align-self: flex-start; border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.msg.system { align-self: center; color: var(--muted); font-size: 13px; background: transparent; }
.msg.error { align-self: flex-start; border-color: var(--bad); color: #ffc2c8; }
.msg .who { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }

.card { align-self: flex-start; max-width: min(520px, 100%); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.card img { display: block; max-width: 100%; max-height: 420px; object-fit: contain; background: #000; }
.card .cap { padding: 7px 11px; font-size: 13px; color: var(--muted); }
.card a { color: var(--accent); }

.composer { border-top: 1px solid var(--line); padding: 12px 20px; }
.composer form { display: flex; gap: 8px; max-width: 1100px; margin: 0 auto; }
.composer input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; outline: none;
}
.composer input:focus { border-color: var(--accent); }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  max-width: min(560px, 92vw); padding: 18px 22px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin-top: 0; color: var(--accent); }
dialog input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
dialog menu { display: flex; justify-content: flex-end; padding: 0; margin: 14px 0 0; }
dialog a { color: var(--accent); }
dialog pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px; white-space: pre-wrap; word-break: break-all; font-size: 12px; }
.muted { color: var(--muted); font-size: 13px; }
