/* NeoCom — Inbox (ib-), History (hs-), More (mo-), Claude chat (ch-) and the OAuth sign-in pages (oa-).
   Built on the tokens and shared components in styles.css. Every view is at most a few hundred pixels wide
   (the Fold cover screen, or the left pane of the inner screen), so there is one layout, not two. */

/* ---------- Inbox ---------- */
.ib-top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin: 4px 2px -6px; }
.ib-count { font-weight: 700; }
.ib-top .text-btn { padding: 10px 4px; }
.ib-row { align-items: flex-start; gap: 11px; padding: 12px; }
.ib-row.unread { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ib-row > .avatar, .ib-sys { margin-top: 1px; }
.ib-sys {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.ib-sys .ico { width: 17px; height: 17px; }
.ib-title, .ib-body {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}
.ib-title { line-height: 1.3; color: color-mix(in srgb, var(--text) 78%, var(--muted)); }
.ib-row.unread .ib-title { font-weight: 700; color: var(--text); }
.ib-body { margin-top: 2px; font-size: 13.5px; color: var(--muted); }
.ib-time { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.ib-row > .dot { margin-top: 6px; }
.ib-more { margin-top: 12px; }
.ib-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14vh 20px 0; color: var(--muted); }
.ib-empty .ico { opacity: .6; }
.ib-empty p { margin: 0; max-width: 300px; }
.ib-empty .ib-empty-t { margin-top: 8px; font-size: 17px; font-weight: 700; color: var(--text); }

/* ---------- History ---------- */
.hs-bar { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.hs-search { position: relative; display: flex; align-items: center; }
.hs-search > .ico { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
/* by id: the base rule for inputs is more specific than a class */
#hs-q { height: 44px; padding-left: 37px; padding-right: 42px; border-radius: 14px; background: var(--surface); }
#hs-q::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.hs-clear { position: absolute; right: 2px; width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); }
#hs-q:placeholder-shown ~ .hs-clear { display: none; }
.hs-who { display: flex; }
.hs-who button { flex: 1; min-width: 0; padding: 9px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hs-chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 2px;
}
.hs-chips::-webkit-scrollbar { display: none; }
.hs-chips .chip { flex: none; min-height: 38px; padding: 0 13px; }
.hs-chips .hs-arch { opacity: .6; }
.hs-chip-em { font-size: 14px; }
#hs-results { transition: opacity .15s; }
#hs-results.hs-busy { opacity: .5; }
.hs-month { margin-top: 18px; gap: 10px; }
.hs-sum { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.hs-sum b { font-weight: 600; color: var(--text); }
.hs-row { gap: 11px; padding: 10px 12px; min-height: 58px; }
.hs-row.on { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.hs-em, .mo-em { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; font-size: 18px; line-height: 1; }
.hs-none { background: var(--surface-2); color: var(--muted); }
.hs-none .ico { width: 18px; height: 18px; }
.hs-row .t1 { display: block; }
.hs-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; overflow: hidden; white-space: nowrap; }
.hs-meta > span { flex: none; }
.hs-meta > span + span::before { content: "·"; margin-right: 6px; }
.hs-by { display: inline-flex; align-items: center; }
.hs-by .avatar { margin-right: 4px; width: 16px; height: 16px; font-size: 9.5px; }
.hs-meta > .hs-in { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hs-cost { font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.hs-more { margin-top: 12px; }
.hs-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 9vh 20px 0; color: var(--muted); }
.hs-empty > .ico { opacity: .6; }
.hs-empty p { margin: 0; max-width: 300px; }
.hs-empty .hs-empty-t { margin-top: 8px; font-size: 17px; font-weight: 700; color: var(--text); }
.hs-empty .secondary { width: auto; margin-top: 12px; }

/* ---------- More ---------- */
.mo-page code, .ch-chat code {
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere;
}
.mo-panel { display: flex; flex-direction: column; gap: 12px; }
.mo-state { display: flex; align-items: flex-start; gap: 12px; }
.mo-state > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-self: center; }
.mo-state .muted { font-size: 13px; line-height: 1.45; }
.mo-state-ico {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--muted);
}
.mo-state-ico .ico { width: 20px; height: 20px; }
.mo-state.on .mo-state-ico { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.mo-state.mo-warn .mo-state-ico { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.mo-spin, .ch-spin {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, var(--accent) 28%, transparent); border-top-color: var(--accent);
  animation: mo-turn .7s linear infinite;
}
.mo-state > .mo-spin { margin: 11px; }
.mo-sub { margin: 14px 2px 6px; font-size: 12.5px; color: var(--muted); }
.mo-hint { margin: 6px 2px 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.mo-pref { min-height: 58px; cursor: pointer; }
.mo-t1 { display: block; font-weight: 600; }
.mo-pref .t2 { display: block; }
.mo-switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0; cursor: pointer;
  width: 46px; height: 28px; border-radius: 999px; background: var(--line); transition: background .15s;
}
.mo-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .15s;
}
.mo-switch:checked { background: var(--accent); }
.mo-switch:checked::after { transform: translateX(18px); }

.mo-list { gap: 0; padding: 0 4px 0 0; }
.mo-list-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; min-height: 58px; padding: 10px 6px 10px 12px; text-align: left; }
.mo-page .item .t1, .mo-page .item .t2, .mo-server .item .t1, .mo-server .item .t2 { display: block; }
.mo-list .icon-btn { width: 40px; height: 44px; }
.mo-list .icon-btn:disabled { opacity: .22; cursor: default; }
.mo-up .ico { transform: rotate(180deg); }
.mo-archived .mo-list { gap: 11px; padding: 8px 6px 8px 12px; }
.mo-archived .mo-em { filter: grayscale(.7); opacity: .7; }
.mo-archived .t1 { font-weight: 500; color: var(--muted); }
.mo-archived .text-btn { padding: 10px 8px; }
.mo-none { font-size: 14px; color: var(--muted); }
.mo-emojis { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; margin-bottom: 8px; }
.mo-emojis button { height: 42px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); font-size: 20px; line-height: 1; }
.mo-emojis button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.mo-colors { display: flex; flex-wrap: wrap; gap: 10px; }
.mo-colors button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--bg); }
.mo-colors button.on { box-shadow: 0 0 0 2px var(--text); }

.mo-ico {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--muted);
}
.mo-ico .ico { width: 18px; height: 18px; }
.mo-chev { width: 18px; height: 18px; color: var(--muted); }
.mo-token { align-items: flex-start; }
.mo-token .t2 { margin-top: 2px; overflow-wrap: anywhere; }
.mo-token .text-btn { padding: 8px 4px; }
.mo-danger { color: var(--danger); }
.mo-version { margin: 20px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* Connect Claude: the custom-connector steps, connected apps, then API tokens */
.mo-connect { display: flex; flex-direction: column; gap: 12px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.mo-connect .mo-state-ico { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.mo-connect .mo-state b { font-size: 15.5px; }
.mo-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: mo-step; }
.mo-steps > li { position: relative; padding-left: 34px; min-height: 24px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; counter-increment: mo-step; }
.mo-steps > li::before {
  content: counter(mo-step); position: absolute; left: 0; top: -1px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
}
.mo-url {
  display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 4px 4px 4px 10px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.mo-page .mo-url code { flex: 1; min-width: 0; background: none; padding: 0; font-size: 12.5px; user-select: all; -webkit-user-select: all; }
.mo-url .text-btn { flex: none; padding: 9px 8px; }
.mo-notes { margin: 0; padding: 0 0 0 2px; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.mo-notes li { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.mo-notes .ico { width: 15px; height: 15px; margin-top: 2px; color: var(--muted); }
.mo-conn { align-items: flex-start; }
.mo-conn .t2 { margin-top: 2px; }
.mo-conn .text-btn { padding: 8px 4px; }
.mo-conn .mo-ico { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 700; }

/* in sheets */
.mo-p { margin: -4px 0 12px; font-size: 13.5px; }
.mo-log {
  margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; overflow: auto;
}
.mo-log { max-height: 42dvh; font-size: 11px; line-height: 1.45; }
.mo-wrap { display: block; font-size: 13.5px; overflow-wrap: anywhere; }
.mo-offscreen { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }

/* ---------- Claude chat ---------- */
.ch-chat { display: flex; flex-direction: column; min-height: 0; }
/* the tab fills the view and reaches into its bottom padding, so only the message list scrolls */
.ch-tab { height: calc(100% + 16px); margin-bottom: -20px; }
.sheet.full > .ch-sheet { flex: 1; }
.ch-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 4px 0 8px; }
.ch-mark {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.ch-mark .ico { width: 19px; height: 19px; }
.ch-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ch-head-t b { font-size: 16px; }
.ch-head-t .muted { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-head-act .text-btn { padding: 10px 6px; }
.ch-body { position: relative; flex: 1; min-height: 0; display: flex; }
.ch-list {
  flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 6px 0 10px;
}
.ch-list > * { flex: none; }

.ch-msg { display: flex; flex-direction: column; min-width: 0; }
.ch-msg.user { align-items: flex-end; }
.ch-msg.ai { align-items: flex-start; }
.ch-bubble { max-width: 88%; min-width: 0; padding: 9px 12px; border-radius: 16px; overflow-wrap: anywhere; }
.ch-msg.user .ch-bubble { white-space: pre-wrap; border-bottom-right-radius: 5px; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.ch-msg.them .ch-bubble { background: var(--surface-2); }
.ch-msg.ai .ch-bubble { max-width: 95%; border-bottom-left-radius: 5px; background: var(--surface); border: 1px solid var(--line); }
.ch-who { display: flex; align-items: center; gap: 5px; margin: 0 4px 3px; font-size: 11.5px; color: var(--muted); }
.ch-who .avatar { width: 16px; height: 16px; font-size: 9.5px; }
.ch-note { margin: 3px 6px 0; font-size: 11.5px; color: var(--muted); }

.ch-md:empty, .ch-tools:empty { display: none; }
.ch-md > :first-child { margin-top: 0; }
.ch-md > :last-child { margin-bottom: 0; }
.ch-md p { margin: 0 0 8px; }
.ch-md .ch-h { margin-top: 12px; }
.ch-md ul, .ch-md ol { margin: 0 0 8px; padding-left: 21px; }
.ch-md li { margin: 2px 0; }
.ch-md li > ul, .ch-md li > ol { margin: 2px 0 0; }
.ch-md blockquote { margin: 0 0 8px; padding: 1px 0 1px 10px; border-left: 3px solid var(--line); color: var(--muted); }
.ch-md hr { margin: 10px 0; border: 0; border-top: 1px solid var(--line); }
.ch-md a { overflow-wrap: anywhere; }
.ch-code {
  margin: 0 0 8px; padding: 9px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line);
  overflow-x: auto; white-space: pre; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ch-chat .ch-code code { font: inherit; background: none; padding: 0; overflow-wrap: normal; }
.ch-table { margin: 0 0 8px; overflow-x: auto; }
.ch-table table { border-collapse: collapse; font-size: 13px; }
.ch-table th, .ch-table td { padding: 4px 8px; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: normal; }
.ch-table th { background: var(--surface-2); font-weight: 600; }

.ch-tools { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.ch-md:not(:empty) + .ch-tools { margin-top: 9px; }
.ch-tool {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 9px 4px 7px; border-radius: 9px;
  background: var(--surface-2); font-size: 12.5px; color: var(--muted);
}
.ch-tool .ico { width: 14px; height: 14px; }
.ch-tool .ch-spin { width: 12px; height: 12px; margin: 1px; }
.ch-tool-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-tool.done .ico { color: var(--good); }
.ch-tool.run { color: var(--text); }
.ch-tool.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.ch-tool-s { font-weight: 700; }
.ch-sq { width: 9px; height: 9px; border-radius: 2px; background: currentColor; flex: none; }
.ch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ch-dots { display: flex; gap: 4px; padding: 5px 0 3px; }
.ch-md:not(:empty) ~ .ch-dots, .ch-tools:not(:empty) ~ .ch-dots { margin-top: 6px; }
.ch-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: ch-blink 1.2s infinite both; }
.ch-dots i:nth-child(2) { animation-delay: .2s; }
.ch-dots i:nth-child(3) { animation-delay: .4s; }

.ch-fail {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; font-size: 13.5px;
  background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.ch-fail-t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ch-fail .text-btn { flex: none; white-space: nowrap; padding: 10px 6px; }
.ch-bang { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--danger); color: #fff; font-size: 13px; font-weight: 800; }

.ch-list > .ch-empty, .ch-list > .ch-off { margin: auto 0; }
.ch-empty, .ch-off { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14px 6px; }
.ch-empty p, .ch-off p { margin: 0; max-width: 330px; }
.ch-off p.muted { line-height: 1.6; }
.ch-empty .ch-empty-t, .ch-off .ch-off-t { font-size: 17px; font-weight: 700; }
.ch-off-ico {
  width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 6px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.ch-starters { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 380px; margin-top: 14px; }
.ch-starter {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 10px 10px 10px 14px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; font-weight: 500;
}
.ch-starter .ico { color: var(--muted); }

.ch-jump {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: none; align-items: center; gap: 5px;
  padding: 8px 13px 8px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.ch-away .ch-jump { display: inline-flex; }

.ch-composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding-top: 8px; }
.ch-composer textarea {
  flex: 1; resize: none; min-height: 46px; max-height: 136px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); line-height: 1.35;
}
.ch-go { flex: none; display: flex; }
.ch-send { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.ch-stop {
  height: 46px; padding: 0 14px; border-radius: 16px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 700;
}
.ch-stop .ch-sq { width: 11px; height: 11px; color: var(--danger); }

/* ---------- OAuth sign-in pages (src/oauth.js): server-rendered, no script, opened in the Claude app's browser ---------- */
body.oa { height: auto; min-height: 100%; overflow: auto; overscroll-behavior: auto; }
.oa-page {
  max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding: calc(18px + var(--safe-t)) var(--gutter) calc(24px + var(--safe-b));
}
.oa-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .2px; padding: 4px 2px; }
.oa-card { display: flex; flex-direction: column; gap: 14px; padding: 18px 16px; }
.oa-card h1 { margin: 0; font-size: 21px; line-height: 1.25; overflow-wrap: anywhere; }
.oa-card p { margin: 0; line-height: 1.45; overflow-wrap: anywhere; }
.oa-card > .muted { font-size: 14px; }
.oa-name { color: var(--text); }
.oa-pair { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.oa-pair > .ico { width: 18px; height: 18px; }
.oa-app {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 18px;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
}
.oa-app.oa-nc { background: var(--surface-2); border: 1px solid var(--line); }
.oa-who { display: flex; align-items: center; gap: 12px; }
.oa-who > div { display: flex; flex-direction: column; min-width: 0; }
.oa-who .muted { font-size: 13px; overflow-wrap: anywhere; }
.oa-sub { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.oa-can { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.oa-can li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; line-height: 1.4; }
.oa-can .ico { width: 18px; height: 18px; margin-top: 1px; color: var(--good); }
.oa-note { font-size: 13px; color: var(--muted); }
.oa-form { display: flex; flex-direction: column; }
.oa-form .field input { font-size: 16px; }   /* 16px keeps phone browsers from zooming in on focus */
.oa-form .primary { margin-top: 4px; }
.oa-err { color: var(--danger); font-size: 13.5px; margin: 0 0 10px !important; }
.oa-actions { display: flex; flex-direction: column; gap: 8px; }
.oa-foot { margin: 0; padding: 0 6px; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.oa-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.oa-center { align-items: stretch; text-align: center; }
.oa-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.oa-mark.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
@media (min-width: 600px) { .oa-page { padding-top: calc(8vh + var(--safe-t)); } .oa-card { padding: 22px 22px; } }

@keyframes mo-turn { to { transform: rotate(360deg); } }
@keyframes ch-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
