/* jDevWeb app glue ONLY. The handoff kits are the source of truth and are used
   as-is: portal.css (chrome, .jp-*) and output-kit/jcd-output.css (replies).
   This file does NOT redefine kit components — it only adds things the kits
   don't ship (login, context menu, resizer, the call loader, attachments,
   activity feed) plus a few host states (settings checkmark, new-badge,
   stop button, toggle gating). Tokens come from portal.css --jp-*. */

.hidden { display: none !important; }

/* Kit bug fix (portal.css:28 has `--jp-control: var(--jp-control)` — a
   self-referential value that resolves to invalid, so in the DARK theme every
   `border: solid var(--jp-control)` outline collapses to none: checkbox boxes,
   radio rings, ghost/icon-button + textarea hover borders all vanish). Restore
   a real dark value here (kit left as-is). Light keeps its own #d4d3cf via the
   higher-specificity .jp-app[data-theme="light"] rule. */
:root { --jp-control: #44444c; }

/* ---------- resizable sidebar (not a kit component) ---------- */
.resizer { flex: 0 0 5px; cursor: col-resize; background: var(--jp-border); }
.resizer:hover { background: var(--jp-accent); }

/* ---------- editable chat title ---------- */
#chat-title {
  font-size: 15px; font-weight: 600; color: var(--jp-heading);
  outline: none; border-radius: 6px; padding: 2px 6px; margin-left: -6px; cursor: text;
}
#chat-title:hover { background: var(--jp-surface-2); }
#chat-title:focus { background: var(--jp-surface-2); box-shadow: 0 0 0 1px var(--jp-border) inset; }
.status { color: var(--jp-mute); font-size: 13px; }

/* ---------- conversation badge: green when new ---------- */
.jp-conv__count.is-new { background: rgba(34, 197, 94, 0.16); color: #7fdca0; }

/* ---------- stats / metrics strip ---------- */
/* reserve a stable height so showing the row doesn't shove the chat down */
#statsbar { min-height: 34px; align-items: center; }
.stats-empty { color: var(--jp-mute); font-family: var(--jp-mono); font-size: 11px; }

/* ---------- transcript container: kit's .jp-thread (flex/gap); host centers it ---------- */
#messages { max-width: 820px; margin: 0 auto; padding: 28px; width: 100%; box-sizing: border-box; }
.msg { max-width: 80%; word-wrap: break-word; }
.jp-msg-user { white-space: pre-wrap; font-weight: 400; color: #c7ccd4; }
.msg.assistant { align-self: stretch; max-width: 100%; }
.msg.note { align-self: center; color: var(--jp-mute); font-size: 13px; font-style: italic; }
.msg.error {
  align-self: center; background: rgba(217, 106, 106, 0.15); color: var(--jp-err);
  font-size: 13px; padding: 8px 12px; border-radius: 8px;
}
.msg .body { display: block; }
.msg.assistant .body { white-space: normal; }
.msg.assistant .body.streaming { white-space: pre-wrap; }

/* ---------- call loader: TRDGW-style ring — a circle whose top arc is the
   accent red, rotating (ported from the TRDGW assistant's .spin) ---------- */
@keyframes jcd-rot { to { transform: rotate(360deg); } }
.jcd-loader {
  width: 16px; height: 16px; display: block; border-radius: 50%;
  /* all-red ring: a gray base blends with the thin red arc at the seams and
     reads orange — the accent tint keeps every pixel in the same red family */
  border: 2px solid var(--jp-accent-tint); border-top-color: var(--jp-accent);
  animation: jcd-rot .8s linear infinite;
}
/* fade the loader out fast as content arrives (not a hard switch-off) */
.msg.assistant.fading { opacity: 0; transition: opacity .12s ease; }
@media (prefers-reduced-motion: reduce) { .jcd-loader { animation: none; } }

/* ---------- settings checkmark (shown only when the toggle is on) ---------- */
.jp-check .chk { width: 11px; height: 11px; opacity: 0; }
.jp-opt.is-on .jp-check .chk { opacity: 1; }

/* ---------- transcript: reasoning / tools (portal.css jp-reason/jp-tool) ---------- */
/* gated by the View toggles; each row is individually collapsible (is-open) */
.jp-reason, .jp-tool { display: none; }
.messages.show-reasoning .jp-reason { display: block; }
.messages.show-tools .jp-tool { display: block; }
.jp-reason.is-open .jp-caret, .jp-tool.is-open .jp-caret { transform: rotate(90deg); }

/* ---------- activity feed (kind=progress; not part of the kit) ---------- */
.msg.progress { font-family: var(--jp-sans); display: none; max-width: 80%; align-self: flex-start; }
.messages.show-tools .msg.progress { display: block; }
.progress-line { color: var(--jp-mute); font-size: 12px; font-family: var(--jp-mono); opacity: .85; }
.progress-line.err { color: var(--jp-err); }

/* output-kit empty-node cleanup */
.jcd-output :is(p, div, ul, ol):empty { display: none; }

/* "Show raw HTML" — the model's reply source, unrendered */
.raw-html {
  margin: 0; white-space: pre-wrap; word-break: break-word; overflow-x: auto;
  font-family: var(--jp-mono); font-size: 12px; line-height: 1.5; color: var(--jp-dim);
  background: var(--jp-code); border: 1px solid var(--jp-border); border-radius: 8px; padding: 12px 14px;
}

/* ---------- attachments ---------- */
.jp-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 28px 12px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--jp-surface-2); border: 1px solid var(--jp-border); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; color: var(--jp-text); max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-x { cursor: pointer; color: var(--jp-mute); font-size: 14px; line-height: 1; }
.att-x:hover { color: var(--jp-err); }
#messages > .att-img { align-self: flex-end; max-width: 60%; max-height: 480px; border-radius: 10px; display: block; }
#messages > .att-doc { align-self: flex-end; }

/* ---------- download button row (gated by the "Download buttons" toggle) ---------- */
.fa-row { display: flex; gap: 8px; margin-top: -2px; }
.fa-row.fa-right { align-self: flex-end; }
.fa-row.fa-left { align-self: stretch; }
.fa-btn {
  font-family: var(--jp-sans); font-size: 11.5px; color: var(--jp-mute);
  background: transparent; border: 1px solid var(--jp-border); border-radius: 6px;
  padding: 3px 10px; cursor: pointer; line-height: 1.4;
}
.fa-btn:hover { color: var(--jp-text); border-color: var(--jp-accent); background: var(--jp-accent-tint); }

/* ---------- model options inside the settings panel ---------- */
#model-opts { display: flex; flex-direction: column; gap: 6px; }

/* ---------- composer: keep the send button red/stop state, file input hidden ---------- */
.jp-btn--send.stop { background: var(--jp-err); }

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--jp-bg); color: var(--jp-text); font-family: var(--jp-sans);
}
.login-card {
  width: 320px; background: var(--jp-surface); border: 1px solid var(--jp-border);
  border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-family: var(--jp-mono); font-size: 22px; color: var(--jp-heading); }
.login-card .sub { margin: 0 0 8px; color: var(--jp-mute); font-size: 13px; }
.login-card input {
  background: var(--jp-surface-2); border: 1px solid var(--jp-border); border-radius: 8px;
  color: var(--jp-text); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.login-card button {
  background: var(--jp-accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.login-error { color: var(--jp-err); font-size: 13px; min-height: 16px; }

/* ---------- right-click context menu ---------- */
.ctx-menu {
  position: fixed; z-index: 1000; background: var(--jp-surface-2); border: 1px solid var(--jp-border);
  border-radius: 8px; padding: 4px; min-width: 140px; box-shadow: var(--jp-shadow);
}
.ctx-item { padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--jp-text); }
.ctx-item:hover { background: var(--jp-accent-tint); }
.ctx-item.danger { color: var(--jp-err); }
