:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1a2540;
  --text: #e6edf7;
  --muted: #8a9bb8;
  --accent: #4fc3f7;
  --ok: #4caf7a;
  --bad: #e57373;
  --user: #1e3a5f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  max-width: 820px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { font-weight: 600; font-size: 1.2rem; letter-spacing: .04em; display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.bad { background: var(--bad); }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; padding: 4px 8px; }

#cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 0 16px 8px;
}
.card { background: var(--panel); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.value { font-size: 1.35rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-line { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
@media (max-width: 560px) { #cards { grid-template-columns: repeat(2, 1fr); } }

#chat { flex: 1; overflow-y: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.jarvis { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.msg.jarvis p { margin: 0 0 .5em; }
.msg.jarvis p:last-child, .msg.jarvis ul:last-child { margin-bottom: 0; }
.msg.jarvis ul { margin: .2em 0 .5em; padding-left: 1.2em; }
.msg.error { border: 1px solid var(--bad); }
.msg.thinking { color: var(--muted); font-style: italic; }

#composer { display: flex; gap: 8px; padding: 10px 16px 14px; }
#input {
  flex: 1; resize: none; max-height: 140px; overflow-y: hidden;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--panel-2); border-radius: 12px;
  padding: 10px 12px; font: inherit;
}
#input:focus { outline: 1px solid var(--accent); }
#send { background: var(--accent); color: var(--bg); border: 0; border-radius: 12px; width: 48px; font-size: 1.2rem; cursor: pointer; }
#send:disabled { opacity: .5; cursor: default; }

dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 14px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-top: 0; font-size: 1.1rem; }
dialog label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
dialog input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--panel-2); background: var(--bg); color: var(--text); font: inherit; }
.hint { color: var(--muted); font-size: .8rem; }
.row { display: flex; justify-content: flex-end; gap: 8px; }
.row button { border: 0; border-radius: 8px; padding: 8px 16px; font: inherit; cursor: pointer; background: var(--accent); color: var(--bg); }
.row button.secondary { background: var(--panel-2); color: var(--text); }
