/* JARVIS UI — shared styles (chat + training). Light/dark follow the system. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --border: #e3e6eb;
  --text: #16181d;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --ok: #18a058;
  --ok-soft: #e3f6ec;
  --warn: #c98a0b;
  --warn-soft: #fdf3dc;
  --err: #d64545;
  --err-soft: #fde8e8;
  --user-bubble: #2f6fed;
  --user-ink: #ffffff;
  --code-bg: #0f1420;
  --code-ink: #e6e9ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1016; --panel: #141821; --panel-2: #1b2030; --border: #262d3d; --text: #e7eaf0;
    --muted: #9aa3b5; --faint: #6c7486; --accent: #5b8cff; --accent-soft: #1b2847; --ok: #34c77b;
    --ok-soft: #12291f; --warn: #e3a72f; --warn-soft: #2d2412; --err: #f06a6a; --err-soft: #331a1d;
    --user-bubble: #2d5bd6; --code-bg: #0a0d14; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1016; --panel: #141821; --panel-2: #1b2030; --border: #262d3d; --text: #e7eaf0;
  --muted: #9aa3b5; --faint: #6c7486; --accent: #5b8cff; --accent-soft: #1b2847; --ok: #34c77b;
  --ok-soft: #12291f; --warn: #e3a72f; --warn-soft: #2d2412; --err: #f06a6a; --err-soft: #331a1d;
  --user-bubble: #2d5bd6; --code-bg: #0a0d14; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: .92em; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 9px; border: 1px solid transparent; background: transparent;
  display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.input, select.input, textarea.input { height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel); outline: none; min-width: 0; }
textarea.input { height: auto; padding: 8px 11px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
label.field > span { font-weight: 550; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px;
  font-size: 12px; font-weight: 650; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.run { background: var(--accent-soft); color: var(--accent); }
.pill.run .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.progress { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s; }
.progress.ok > div { background: var(--ok); }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--panel); box-shadow: var(--shadow); max-width: 420px; font-size: 14px; }
.toast.err { background: var(--err); color: #fff; }

.modal-bg { position: fixed; inset: 0; background: rgba(10, 12, 18, .45); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }
.modal h3 { margin: 0 0 12px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
