/* Jarvis: one stylesheet, mobile first, light and dark. No inline styles anywhere (the CSP forbids them). */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e2e0db;
  --accent: #1f4e8c;
  --accent-text: #ffffff;
  --good: #1d7a46;
  --warn: #9a5b00;
  --bad: #b3261e;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #1c1c1f;
    --text: #ececef;
    --muted: #9b9ba1;
    --line: #2e2e33;
    --accent: #7fb0ff;
    --accent-text: #0b1a30;
    --good: #5fd28f;
    --warn: #f0b45a;
    --bad: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
h1 { font-size: 1.6rem; margin: 0.6rem 0 0.4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 0.5rem; }
p { margin: 0.5rem 0; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: 0.02em; }
.nav { display: flex; flex-wrap: wrap; gap: 0.1rem 0.9rem; }
.nav a { text-decoration: none; color: var(--muted); padding: 0.35rem 0; }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }

main { flex: 1; width: 100%; max-width: 44rem; margin: 0 auto; padding: 0.5rem 1rem 2rem; }
.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 44rem;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}
.muted { color: var(--muted); }
.figure { font-size: 1.6rem; font-weight: 600; margin: 0.25rem 0; }
.figure .muted { font-size: 1rem; font-weight: 400; }
.note, .good { color: var(--good); }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.8rem; }
.error { color: var(--bad); }
[hidden] { display: none !important; }

.badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { color: var(--good); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }

label { display: block; font-weight: 600; margin: 0.75rem 0 0.3rem; }
input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 17px; /* 16px or more keeps iOS from zooming into the field */
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button {
  font: inherit;
  min-height: 44px;
  padding: 0.55rem 1rem;
  margin: 0.6rem 0 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.small { min-height: 36px; padding: 0.3rem 0.7rem; margin: 0; font-size: 0.9rem; }
button.wide { width: 100%; }
button.link { background: none; border: none; color: var(--accent); padding: 0; min-height: 0; margin: 0; text-decoration: underline; }
button[disabled] { opacity: 0.6; cursor: progress; }
form.inline { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

meter { width: 100%; height: 0.9rem; }

.list, .links, .log { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}
.list li span { display: block; font-size: 0.9rem; }
.links li { padding: 0.4rem 0; }
.log li { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.log-head { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: baseline; font-size: 0.9rem; }
.log time { color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
pre { overflow-x: auto; font-size: 0.85rem; background: var(--bg); padding: 0.5rem; border-radius: 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; }

.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Memory and archive (brief F2). */
textarea, select, input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; line-height: 1.4; resize: vertical; }
select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.row.nowrap { flex-wrap: nowrap; align-items: center; }
.row.nowrap button { margin: 0; }
.small { font-size: 0.85rem; }
.crumbs { color: var(--muted); font-size: 0.9rem; margin-top: 0.8rem; }
.lead { font-size: 1.05rem; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.files li:last-child { border-bottom: none; }
.files li span { display: block; }
.meta { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; margin: 0.5rem 0; font-size: 0.9rem; }
.meta div { display: flex; gap: 0.35rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.md { overflow-wrap: anywhere; }
.md h1 { font-size: 1.35rem; }
.md h2 { font-size: 1.15rem; margin-top: 1rem; }
.md h3 { font-size: 1rem; margin-top: 0.9rem; }
.md ul, .md ol { padding-left: 1.3rem; }
.md blockquote { margin: 0.5rem 0; padding-left: 0.8rem; border-left: 3px solid var(--line); color: var(--muted); }
.md table th, .md table td { white-space: normal; }
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }
pre.diff, pre.passage { white-space: pre-wrap; overflow-wrap: anywhere; }
.passages { list-style: none; padding: 0; margin: 0; }
.nav-sub a[aria-current="page"], nav.row a[aria-current="page"] { font-weight: 600; color: var(--text); }

/* Chat (brief F3): the conversation, newest at the bottom, and a composer that stays at the bottom. */
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.chat-head button { margin: 0; }
.chat-log { list-style: none; padding: 0; margin: 0.5rem 0 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.msg { border-radius: var(--radius); padding: 0.6rem 0.85rem; overflow-wrap: anywhere; }
.msg p { margin: 0.3rem 0; }
.msg.user { align-self: flex-end; max-width: 88%; background: var(--accent); color: var(--accent-text); white-space: pre-wrap; }
.msg.reply { align-self: stretch; background: var(--surface); border: 1px solid var(--line); }
.msg.reply .live { white-space: pre-wrap; }
.msg.reply.failed { border-color: var(--bad); }
.msg.reply.failed .meta { color: var(--bad); }
.msg.empty { align-self: center; }
.msg .tool { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0; }
.msg .tool::before { content: "↳ "; }
.msg .meta { color: var(--muted); font-size: 0.8rem; margin-top: 0.4rem; }
.msg.streaming .meta:empty { display: none; }
.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1 1 12rem;
  min-height: 2.9rem;
  max-height: 40vh;
  font-family: inherit;
  font-size: 17px; /* 16px or more keeps iOS from zooming into the field */
  line-height: 1.4;
}
.composer button { margin: 0; }
.composer .error { flex-basis: 100%; margin: 0; }
.past summary { padding: 0.2rem 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.token-once { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; word-break: break-all; padding: 0.6rem; background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; }
