/* Chat: answers, tool steps, the model picker and "Connect NSIN data".
   Black and white like the rest; uses app.css's variables. */

.msg.answer { align-self: stretch; max-width: 100%; white-space: normal; }
.md { line-height: 1.7; font-size: 14px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5, .md h6 { margin: 18px 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.md h3 { font-size: 17px; }
.md ul, .md ol { margin: 0 0 10px; padding-inline-start: 22px; }
.md li { margin: 2px 0; }
.md a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.md a:hover { text-decoration-color: var(--text); }
.md hr { border: 0; height: 1px; background: var(--line-soft); margin: 14px 0; }
.md li > ul, .md li > ol { margin: 2px 0 4px; }
.md li > p { margin: 0 0 6px; }
.md del { color: var(--muted); }
.md blockquote {
  margin: 0 0 10px; padding: 2px 0; padding-inline-start: 14px; border-inline-start: 2px solid var(--line); color: var(--muted);
}
.md blockquote > :last-child { margin-bottom: 0; }
/* Persian, English and mixed lines each run their own way (NSIN Agent's rule). */
.md p, .md li, .md h3, .md h4, .md h5, .md h6, .md blockquote, .md th, .md td, .thinking-body {
  unicode-bidi: plaintext; text-align: start;
}
/* Items line up with their markers; each line still orders its own words. */
.md [dir="ltr"] > li { text-align: left; }
.md [dir="rtl"] > li { text-align: right; }
.md .ic { unicode-bidi: isolate; }
.table-wrap { margin: 4px 0 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.55; }
.md th, .md td { padding: 7px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.md th { font-weight: 600; background: var(--glass-soft); white-space: nowrap; }
.md tbody tr:last-child td { border-bottom: 0; }
.md .al-center { text-align: center; }
.md .al-end { text-align: end; }
.md .ic {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; border-radius: 6px;
  background: var(--glass-hover); border: 1px solid var(--line-soft);
}
.code { margin: 6px 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-soft); overflow: hidden; }
.code-lang { text-transform: lowercase; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; padding: 6px 10px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--faint); border-bottom: 1px solid var(--line-soft);
}
.code-copy {
  border: 0; background: transparent; color: var(--muted); font: 12px Inter, Vazirmatn, sans-serif; cursor: pointer;
  padding: 2px 6px; border-radius: 6px;
}
.code-copy:hover { color: var(--text); background: var(--glass-hover); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; text-align: left; }
.code pre code { font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }

.usage { font-size: 12px; color: var(--faint); }

/* A tool step: a quiet line between the question and the answer. */
.tool-step { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: -6px 0; }
.tool-step-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); flex: 0 0 auto; }
.tool-step.failed .tool-step-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.tool-step.running .tool-step-dot { background: var(--muted); }
.tool-step-ms { color: var(--faint); font-size: 12px; }

/* The model's thinking: open while it runs, then "Thought for 4s". */
.thinking { align-self: stretch; margin: -4px 0; font-size: 13px; color: var(--muted); }
.thinking summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; padding: 2px 0; border-radius: 6px;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::after {
  content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg); margin-inline-start: 2px; opacity: 0.7;
}
.thinking[open] summary::after { transform: rotate(45deg); margin-top: -3px; }
.thinking summary:hover { color: var(--text); }
.thinking summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.thinking.quiet summary { cursor: default; }
.thinking.quiet summary::after { display: none; }
.thinking-body {
  margin-top: 6px; padding: 2px 0; padding-inline-start: 12px; border-inline-start: 2px solid var(--line);
  max-height: 180px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; color: var(--faint);
}
.thinking.quiet .thinking-body { display: none; }

/* A run of tool steps, folded: "Used 6 tools", closed until clicked. */
.tool-group { align-self: stretch; margin: -4px 0; font-size: 13px; color: var(--muted); }
.tool-group summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; padding: 2px 0; border-radius: 6px;
}
.tool-group summary::-webkit-details-marker { display: none; }
.tool-group summary::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text); flex: 0 0 auto;
}
.tool-group.running summary::before { animation: tool-pulse 1.2s ease-in-out infinite; }
.tool-group summary::after {
  content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg); margin-inline-start: 2px; opacity: 0.7;
}
.tool-group[open] summary::after { transform: rotate(45deg); margin-top: -3px; }
.tool-group summary:hover { color: var(--text); }
.tool-group summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tool-group-body {
  display: flex; flex-direction: column; gap: 10px; margin-top: 8px; padding: 4px 0;
  padding-inline-start: 12px; border-inline-start: 2px solid var(--line);
}
.tool-group-body .tool-step { margin: 0; }
@keyframes tool-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .tool-group.running summary::before { animation: none; } }

/* What a running turn waits on. */
.turn-status { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.turn-status[hidden] { display: none; }
.turn-status-label { font-variant-numeric: tabular-nums; }

/* A failed answer: what happened, and Try again. */
.error-card {
  align-self: stretch; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-radius: 16px; padding: 12px 14px;
  border: 1px solid var(--line);
}
.error-card p { margin: 0; flex: 1 1 240px; font-size: 14px; line-height: 1.6; }
.error-card p::before {
  content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%;
  margin-inline-end: 8px; font: 700 11px Inter, Vazirmatn, sans-serif; border: 1.5px solid var(--text); vertical-align: 1px;
}
.retry {
  min-height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer;
  background: var(--accent); color: var(--on-accent); font: 600 13px Inter, Vazirmatn, sans-serif;
}
.retry:hover { opacity: 0.88; }
.retry:disabled { opacity: 0.5; cursor: default; }
.msg.note.stopped::before { border-radius: 2px; }
.error-card .cap-reset { display: block; margin-top: 2px; padding-inline-start: 26px; color: var(--muted); font-size: 13px; }

/* Send becomes Stop while a turn runs. */
.send.stop svg { display: none; }
.send.stop::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: currentColor; }

.jump {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 15; /* above the toast */
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; color: var(--text); font: 16px Inter, Vazirmatn, sans-serif;
  display: flex; align-items: center; justify-content: center; background: var(--menu);
}
.jump[hidden] { display: none; }
.jump:hover { border-color: var(--muted); }

.typing { align-self: flex-start; display: flex; gap: 5px; padding: 8px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: 0.4; }
@media (prefers-reduced-motion: no-preference) {
  .typing i { animation: blink 1.2s infinite ease-in-out; }
  .typing i:nth-child(2) { animation-delay: 0.15s; }
  .typing i:nth-child(3) { animation-delay: 0.3s; }
  .tool-step.running .tool-step-dot { animation: blink 1s infinite ease-in-out; }
  .thinking.running .thinking-label { animation: breathe 1.6s infinite ease-in-out; }
  .msg.answer.live .md > :is(p, h3, h4, h5, h6):last-child::after,
  .msg.answer.live .md > :is(ul, ol):last-child > li:last-child::after {
    content: ""; display: inline-block; width: 7px; height: 15px; margin-inline-start: 3px; vertical-align: -2px;
    background: var(--text); animation: blink 1s infinite steps(2);
  }
}
@keyframes blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

.connect-card { align-self: stretch; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-radius: 16px; padding: 12px 14px; }
.connect-card p { margin: 0; flex: 1 1 260px; font-size: 14px; color: var(--muted); line-height: 1.6; }
.connect-go {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 10px; text-decoration: none;
  background: var(--accent); color: var(--on-accent); font: 600 13px Inter, Vazirmatn, sans-serif;
}
.connect-go:hover { opacity: 0.88; }

/* Composer pills that work. */
.pill.live { cursor: pointer; }
.pill.live:hover, .pill.live[aria-expanded="true"] { color: var(--text); background: var(--glass-hover); }
.pill .chev { opacity: 0.6; }
.pill.on { color: var(--text); }
.pill.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text); }
.model-pick { position: relative; }
.model-menu { left: 0; right: auto; bottom: calc(100% + 8px); top: auto; width: 220px; }
@media (max-width: 720px) { .model-menu { left: 0; right: auto; top: auto; bottom: calc(100% + 8px); } }
.model-menu .menu-item[aria-checked="true"]::after { content: "✓"; margin-inline-start: auto; color: var(--muted); }

/* The live preview: a glass panel to the right of the chat, below it on
   narrow screens. The frame itself is the workspace's own page. */
.preview {
  flex: 1 1 520px; min-width: 0; border-radius: 22px; overflow: hidden;
  position: sticky; top: 16px; align-self: flex-start; height: calc(100vh - 32px); min-height: 420px;
  display: flex; flex-direction: column;
}
body.previewing .main { flex: 1 1 480px; padding-inline: 8px; }
.preview-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line-soft);
}
.preview-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); flex: 0 0 auto; }
.preview.loading .preview-dot { background: var(--muted); }
.preview.failed .preview-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.preview-name {
  font: 500 13px "JetBrains Mono", ui-monospace, monospace; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.ibtn.small { width: 32px; height: 32px; border-radius: 10px; }
.ibtn:disabled { opacity: 0.45; cursor: default; }
.ibtn:disabled:hover { background: transparent; color: var(--faint); }
.preview-body { position: relative; flex: 1; min-height: 0; background: var(--glass-soft); }
.preview-body iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
.preview-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; padding: 24px;
  text-align: center; font-size: 14px; line-height: 1.6; color: var(--muted);
}
.preview-state[hidden] { display: none; }
#preview-btn[aria-expanded="true"] { color: var(--text); }
@media (prefers-reduced-motion: no-preference) {
  .preview.loading .preview-dot { animation: blink 1s infinite ease-in-out; }
}
/* Narrow: the preview goes below the chat, full width. */
@media (max-width: 1100px) {
  body.previewing .shell { flex-wrap: wrap; }
  body.previewing .main { flex: 1 1 calc(100% - 96px); }
  .preview { flex: 1 1 100%; position: static; align-self: stretch; width: 100%; height: 72vh; min-height: 360px; order: 3; }
}
@media (max-width: 720px) {
  .preview { height: 70vh; border-radius: 18px; }
  .composer-row { flex-wrap: wrap; }
}
body.previewing .hint { display: none; }

/* The chat list: a glass panel beside the rail (below it on a phone). */
.chats {
  position: fixed; top: 16px; bottom: 16px; left: 92px; width: 300px; z-index: 29; border-radius: 22px;
  display: flex; flex-direction: column; padding: 10px; background: var(--menu);
}
.chats-head { display: flex; align-items: center; gap: 6px; padding: 2px 2px 8px 8px; }
.chats-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.chat-new {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 0 12px; margin-bottom: 8px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--glass-hover); color: var(--text);
  font: 500 14px Inter, Vazirmatn, sans-serif; cursor: pointer;
}
.chat-new:hover { border-color: var(--muted); }
.chat-new svg { color: var(--muted); }
.chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.chat-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-row:hover, .chat-row:focus-within { background: var(--glass-hover); }
.chat-row.on { background: var(--glass-hover); }
.chat-row.on::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--text);
}
.chat-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 4px 8px 12px; text-align: start;
  border: 0; background: transparent; color: var(--muted); font: 14px Inter, Vazirmatn, sans-serif; cursor: pointer; border-radius: 10px;
}
.chat-row.on .chat-open, .chat-open:hover { color: var(--text); }
/* Every title starts at the row's left edge, whatever its script: the title
   is only as wide as its text (up to the row), so a Persian one does not
   stretch across and sit at the far right. It still runs right to left
   inside, with the ellipsis at its own end. */
.chat-name {
  max-width: 100%; overflow: hidden; white-space: nowrap;
  /* No CSS ellipsis: it drops whole letters and, in a right-to-left title,
     leaves the hole at the left. app.js fitTitles cuts to fit instead. */
  text-overflow: clip;
  unicode-bidi: plaintext; text-align: start;
}
.chat-when { font-size: 12px; color: var(--faint); }
.chat-del { flex: 0 0 auto; margin-inline-end: 4px; opacity: 0; }
.chat-row:hover .chat-del, .chat-row:focus-within .chat-del, .chat-del:focus-visible { opacity: 1; }
@media (hover: none) { .chat-del { opacity: 1; } }
.chats-empty { padding: 12px; font-size: 13px; color: var(--muted); line-height: 1.6; }
#chats-btn[aria-expanded="true"] { background: var(--glass-hover); color: var(--text); }
@media (max-width: 720px) {
  .chats { top: 76px; left: 10px; right: 10px; bottom: auto; width: auto; max-height: calc(100vh - 96px); }
}

/* The Repository picker: a glass panel over a dimmed page. */
.repos-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.18); }
.repos-wrap[hidden] { display: none; }
.repos {
  width: min(520px, 100%); max-height: min(640px, calc(100vh - 32px)); border-radius: 22px;
  display: flex; flex-direction: column; padding: 10px; background: var(--menu);
}
.repo-conns { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 8px; }
.repo-conn[aria-selected="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.repo-q {
  width: 100%; min-height: 38px; margin-bottom: 8px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--glass-hover); color: var(--text); font: 14px Inter, Vazirmatn, sans-serif; outline: none;
}
.repo-q:focus-visible { border-color: var(--muted); }
.repo-list { max-height: 420px; }

/* A save to the person's repository, waiting for their Confirm. Black and
   white like the rest: the primary button is the accent, failures are text. */
.action-card {
  margin: 6px 0 14px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.6;
}
.action-card p { margin: 0; }
.action-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.action-state { font-size: 12px; color: var(--muted); }
.action-card[data-state="pending"] .action-state { color: var(--text); }
.action-where code, .action-files code { font-size: 12.5px; }
.action-msg { padding: 8px 10px; border-radius: 10px; background: var(--glass-hover); white-space: pre-wrap; }
.action-files summary { cursor: pointer; color: var(--muted); }
.action-files ul { margin: 6px 0 0; padding-inline-start: 4px; list-style: none; max-height: 220px; overflow: auto; }
.action-files li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.action-files li span { flex: 0 0 56px; color: var(--faint); font-size: 12px; }
.action-files .file-D { text-decoration: line-through; }
.action-pr { color: var(--muted); font-size: 13px; }
.action-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.action-foot:empty { display: none; }
.action-foot button {
  min-height: 34px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font: 500 14px Inter, Vazirmatn, sans-serif; cursor: pointer;
}
.action-foot .action-confirm { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.action-foot button:disabled { opacity: 0.5; cursor: default; }
.action-foot a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.action-error { color: var(--text); }
.action-error::before { content: "⚠ "; }
.action-card[data-state="done"] { border-color: var(--muted); }
/* The Repository button names the chat's repository once it has one; long
   names end in an ellipsis (the full name is in its title). */
#repo-btn { min-width: 0; max-width: 240px; }
#repo-btn svg { flex: 0 0 auto; }
#repo-btn.has-repo { color: var(--text); }
.repo-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* In a chat the composer stays at the bottom of the window while the
   conversation scrolls behind it. Sticky, not fixed: it stays in the page's
   flow after the thread, so it never covers the last message, and it keeps
   to the chat's column beside (or above) the preview. app.js adds .small
   while the person reads further up. */
body.chatting .main { padding-bottom: 0; }
body.chatting .stage { position: sticky; bottom: 16px; z-index: 5; margin-top: auto; }
/* The chat's own ground below and under the composer, so messages do not
   show in the gap between it and the window's edge. */
body.chatting .stage::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: -12px; right: -12px; bottom: -16px; height: calc(50% + 16px);
  background: linear-gradient(to bottom, transparent, var(--ground) 45%);
}
/* --glass alone is nearly clear on black; the ground under it keeps the text
   readable while the blur still shows what scrolls behind. */
body.chatting .composer {
  background: linear-gradient(var(--glass), var(--glass)), color-mix(in srgb, var(--ground) 78%, transparent);
}
/* An explicit height (the three rows it had), so the change to one row can
   be animated. */
body.chatting .composer textarea { height: calc(4.8em + 4px); }

/* Small: one line, the text and Send (Stop while answering). */
body.chatting .composer.small { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 18px; }
body.chatting .composer.small textarea { flex: 1; min-width: 0; min-height: 0; height: calc(1.6em + 4px); overflow: hidden; }
body.chatting .composer.small textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.chatting .composer.small .composer-row { margin-top: 0; flex: 0 0 auto; }
body.chatting .composer.small .composer-row > :not(.send) { display: none; }
body.chatting .composer.small .send { width: 36px; height: 36px; border-radius: 10px; }

/* "Jump to the latest" and the toast sit above the composer. */
body.chatting .jump { bottom: calc(var(--composer-h, 140px) + 88px); }
body.chatting .toast { bottom: calc(var(--composer-h, 140px) + 28px); z-index: 14; }

@media (max-width: 720px) {
  body.chatting .stage { bottom: 10px; }
  body.chatting .stage::before { bottom: -10px; height: calc(50% + 10px); }
}
@media (prefers-reduced-motion: no-preference) {
  body.chatting .composer { transition: padding 0.25s ease, border-radius 0.25s ease; }
  body.chatting .composer textarea { transition: height 0.25s ease; }
  body.chatting .composer .send { transition: width 0.25s ease, height 0.25s ease, opacity 0.2s ease; }
}
.action-foot button.busy { display: inline-flex; align-items: center; gap: 8px; opacity: 1; }
.btn-spin {
  width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent;
  animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spin { animation-duration: 2.4s; } }

/* Charts (```chart) and follow-up questions (```suggestions), md.js. */
.chart { margin: 8px 0 14px; padding: 14px 14px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--glass-soft); color: var(--text); }
.chart-wait { color: var(--muted); font-size: 13px; padding: 18px 14px; }
.chart-title { font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.chart-box { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; color: var(--text); }
.chart-svg.round { max-width: 220px; margin: 0 auto; }
.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--faint); font: 11px Inter, Vazirmatn, sans-serif; }
.chart-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area, .chart-bar, .chart-dot, .chart-slice { fill: currentColor; }
.chart-slice { stroke: var(--ground); stroke-width: 2; }
.chart-slice:hover, .chart-bar:hover { filter: brightness(1.15); }
.chart-guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-total { fill: var(--text); font: 600 18px Inter, Vazirmatn, sans-serif; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; min-width: 110px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--menu); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; color: var(--text); }
.chart-tip div { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip b { font-weight: 600; }
.chart-tip .chart-tip-head { color: var(--muted); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { width: 12px; height: 12px; border-radius: 3px; background: var(--text); }
.chart-key i.dashed { height: 3px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--text) 0 4px, transparent 4px 7px); }
.chart-key b { font-weight: 500; color: var(--text); }
.suggests { display: none; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
.msg.answer.latest .suggests { display: flex; }
.suggest { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: var(--glass); color: var(--text); font: 13px Inter, Vazirmatn, sans-serif; cursor: pointer; text-align: start; backdrop-filter: blur(var(--blur)); }
.suggest:hover { background: var(--glass-hover); border-color: var(--muted); }

/* The page the agent opened (app.js pageCard). */
.page-card { align-self: stretch; max-width: 520px; margin: 2px 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--glass); backdrop-filter: blur(var(--blur)); }
.page-shot { position: relative; aspect-ratio: 16 / 7; overflow: hidden; background: var(--glass-soft); border-bottom: 1px solid var(--line); }
.page-shot img { display: block; width: 100%; height: auto; }
.page-shot::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; background: linear-gradient(to bottom, transparent, var(--glass-soft)); pointer-events: none; }
.page-shot.empty { aspect-ratio: 16 / 3; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 22px 22px; }
.page-foot { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.page-text { flex: 1; min-width: 0; }
.page-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-sub { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-open { flex: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; background: var(--glass-hover); color: var(--text); font: 500 13px Inter, Vazirmatn, sans-serif; cursor: pointer; }
.page-open:hover { border-color: var(--muted); }

/* A shell command: the command, Run (into the Terminal tab) and Copy. */
.cmd { display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; padding: 6px 8px 6px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-soft); }
.cmd pre { flex: 1; min-width: 0; margin: 0; overflow-x: auto; text-align: left; scrollbar-width: thin; }
.cmd pre code { font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; background: none; padding: 0; }
.cmd-acts { display: flex; gap: 2px; flex: none; align-self: flex-start; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--glass-hover); }
.icon-btn:focus-visible { outline: 2px solid var(--muted); outline-offset: 1px; }

/* The files a turn changed. */
.files-card { display: grid; margin: 8px 0 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-soft); overflow: hidden; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; min-width: 0; }
.file-row + .file-row { border-top: 1px solid var(--line-soft); }
.file-row:hover:not(:disabled) { background: var(--glass-hover); }
.file-row:focus-visible { outline: 2px solid var(--muted); outline-offset: -2px; }
.file-row:disabled { cursor: default; }
.file-icon { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--faint); flex: none; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.file-dir { color: var(--faint); }
.file-row.deleted .file-name { text-decoration: line-through; color: var(--muted); }
.file-add, .file-del { flex: none; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.file-add { color: #2f9e57; }
.file-del { color: #d05050; }
.file-row.deleted .file-add { color: var(--muted); font-family: inherit; }

/* Under an answer: Copy, the time, what it cost. */
.answer-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; margin-left: -7px; color: var(--faint); font-size: 12px; }
.answer-foot .icon-btn { width: 28px; height: 28px; }
.answer-time { white-space: nowrap; }
.answer-foot .usage::before { content: "·"; margin-right: 8px; }

/* The agent's question (ask_person): a button per option, a box for anything else. */
.ask-card { display: grid; gap: 6px; margin: 10px 0 4px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass-soft); }
.ask-q { font-weight: 600; font-size: 14px; line-height: 1.45; padding: 0 2px 4px; }
.ask-opts { display: grid; gap: 6px; }
.ask-opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); color: var(--text); font: 13px/1.4 Inter, Vazirmatn, sans-serif; cursor: pointer; }
.ask-opt:hover:not(:disabled) { border-color: var(--muted); background: var(--glass-hover); }
.ask-opt:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ask-key { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--glass-hover); color: var(--muted); font-size: 11px; font-weight: 600; }
.ask-text { display: grid; gap: 1px; min-width: 0; }
.ask-label { font-weight: 500; }
.ask-detail { color: var(--muted); font-size: 12px; }
.ask-other { display: flex; gap: 6px; margin-top: 2px; }
.ask-other input { flex: 1; min-width: 0; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); color: var(--text); font: 13px Inter, Vazirmatn, sans-serif; }
.ask-other input:focus { outline: none; border-color: var(--muted); }
.ask-other button { flex: none; height: 34px; padding: 0 14px; border-radius: 10px; border: 0; background: var(--accent); color: var(--on-accent); font: 600 13px Inter, Vazirmatn, sans-serif; cursor: pointer; }
.ask-card.answered .ask-opt { cursor: default; opacity: .7; }
.ask-card.answered .ask-other { display: none; }

/* The pages the agent read, one line a turn. */
.pages-card { align-self: flex-start; max-width: 100%; margin: 2px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--glass-soft); font-size: 13px; }
.pages-card > summary { display: flex; align-items: center; gap: 8px; padding: 7px 12px; color: var(--muted); cursor: pointer; list-style: none; }
.pages-card > summary::-webkit-details-marker { display: none; }
.pages-card > summary:hover { color: var(--text); }
.pages-label { color: var(--text); font-weight: 500; }
.pages-hosts { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pages-hosts::before { content: "· "; }
.pages-list { display: grid; padding: 0 6px 6px; }
.page-row { display: grid; gap: 1px; padding: 6px 8px; border-radius: 8px; border: 0; background: none; text-align: start; color: var(--text); text-decoration: none; font: inherit; cursor: pointer; min-width: 0; }
.page-row:hover { background: var(--glass-hover); }
.page-row-title, .page-row-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-row-url { color: var(--muted); font-size: 12px; }

/* A screenshot the agent took. */
.capture { align-self: flex-start; width: min(100%, 460px); margin: 4px 0; border-radius: 14px; border: 1px solid var(--line); background: var(--glass-soft); overflow: hidden; }
.capture-shot { display: block; width: 100%; padding: 0; border: 0; background: var(--glass); cursor: zoom-in; }
.capture-shot img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; object-position: top; }
.capture figcaption { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); min-width: 0; }
.capture figcaption span:first-of-type { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capture-url { margin-inline-start: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-box.shot-box { width: fit-content; max-width: none; padding: 0; border-radius: 16px; overflow: hidden; position: fixed; }
.shot-box img { display: block; max-width: min(1200px, calc(100vw - 48px)); max-height: calc(100vh - 80px); cursor: zoom-out; }
.shot-close { position: absolute; top: 10px; inset-inline-end: 10px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--menu, var(--glass)); color: var(--text); font: 18px/1 system-ui; cursor: pointer; }

/* Today's AI use: a ring by Send; a click shows the numbers. */
.usage-pick { position: relative; display: flex; }
.usage-ring { width: 32px; height: 32px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.usage-ring:hover, .usage-ring[aria-expanded="true"] { background: var(--glass-hover); }
.usage-ring svg { transform: rotate(-90deg); }
.usage-track { fill: none; stroke: var(--line); stroke-width: 4; }
.usage-arc { fill: none; stroke: var(--text); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray .3s; }
.usage-ring.high .usage-arc { stroke: #d9822b; }
.usage-ring.full .usage-arc { stroke: #d33a3a; }
.usage-pop, .usage-pop.menu { left: auto; right: 0; top: auto; bottom: calc(100% + 10px); width: 270px; padding: 14px; }
@media (max-width: 720px) { .usage-pop.menu { left: auto; right: -50px; top: auto; bottom: calc(100% + 10px); width: min(270px, calc(100vw - 40px)); } }
.usage-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.usage-head span:last-child { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.usage-bar { height: 6px; margin: 10px 0 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.usage-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--text); transition: width .3s; }
.usage-pop.high .usage-bar span { background: #d9822b; }
.usage-pop.full .usage-bar span { background: #d33a3a; }
.usage-text { font-size: 12px; line-height: 1.55; color: var(--muted); }

/* A published site: its address where Publish was. */
.live-link { color: var(--text); text-decoration: none; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #22a55b; box-shadow: 0 0 0 3px rgba(34,165,91,.18); flex: none; }
.live-host { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-live[hidden], .live-link[hidden] { display: none; }
.live-word { display: none; }

/* --- Phone ------------------------------------------------------------------ */
@media (max-width: 720px) {
  /* The box: two lines, and buttons as icons (their names stay for screen readers). */
  body.chatting .composer { padding: 10px 10px 10px 14px; border-radius: 20px; }
  body.chatting .composer textarea { height: calc(3.2em + 4px); }
  .composer-row, body.chatting .composer-row { gap: 6px; flex-wrap: nowrap; }
  #repo-btn { flex: 0 1 auto; min-width: 0; }
  .composer-row .pill { min-height: 34px; padding: 0 9px; }
  .pill-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .repo-name { max-width: 96px; }
  .model-name { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #live-btn .live-host { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #live-btn .live-word { display: inline; }
  #preview-btn { display: none; }
  .send { width: 40px; height: 40px; }
  /* The side pane is a sheet over the chat, closed with its ×. */
  .preview, body.previewing .preview {
    position: fixed; inset: 8px; z-index: 40; width: auto; height: auto; min-height: 0; order: 0; border-radius: 18px;
  }
  body.previewing { overflow: hidden; }
  body.previewing .shell { flex-wrap: nowrap; }
  body.previewing .main { flex: 1 1 auto; padding-inline: 6px; }
  .preview-head #preview-open { display: none; }
  .pane-toggle.fresh { animation: pill-pulse 1.2s ease-in-out 3; }
}

/* The box's row never pushes Send out: names shrink first, and with the pane
   open its Preview and the site's address are in the pane's own header. */
#repo-btn, .live-link { flex: 0 1 auto; min-width: 0; }
.live-link .live-host { min-width: 0; }
body.previewing #preview-btn, body.previewing #live-btn { display: none; }

/* The pane's size: small, medium or big (wide screens; remembered). */
.pane-size { display: inline-flex; gap: 2px; padding: 2px; margin-right: 4px; border-radius: 10px; border: 1px solid var(--line-soft); }
.pane-size button { width: 28px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer; }
.pane-size button:hover { color: var(--text); }
.pane-size button[aria-checked="true"] { background: var(--glass-hover); color: var(--text); }
@media (min-width: 1101px) {
  body.previewing .main { flex: 1 1 0; min-width: 340px; }
  body.pane-s .preview { flex: 0 0 32vw; }
  body.pane-m .preview { flex: 0 0 46vw; }
  body.pane-l .preview { flex: 0 0 60vw; }
}
@media (max-width: 1100px) { .pane-size { display: none; } }

/* The pane's header fits its width: Open in a new tab and the name go
   before the tabs and controls do. */
.preview { container-type: inline-size; container-name: pane; }
.preview-head { flex-wrap: nowrap; min-width: 0; }
.preview-head .seg { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.preview-head .seg::-webkit-scrollbar { display: none; }
.pane-size, #preview-reload, #preview-close, #preview-open { flex: none; }
@container pane (max-width: 560px) {
  #preview-open { display: none; }
}
@container pane (max-width: 500px) {
  .preview-name { display: none; }
}

/* The site bar, under the header: the published address (like a
   browser's address bar) and what can be done with it. */
.site-bar {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px;
  padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.site-bar[hidden] { display: none; }
.site-bar .grow { flex: 1 1 0; min-width: 4px; }
.preview-live {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0;
  color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none;
  padding: 0; margin: 0; border: 0; background: none; border-radius: 0;
}
.preview-live .live-host { min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-live .live-out { flex: none; color: var(--faint); }
.preview-live:hover .live-host { text-decoration: underline; text-underline-offset: 3px; }
.preview-live:hover .live-out { color: var(--text); }
.preview-unlive { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.preview-unlive[hidden] { display: none; }
.site-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 30px; padding: 0 10px;
  border-radius: 9px; border: 1px solid var(--line-soft); background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.site-btn:hover { color: #d33a3a; border-color: currentColor; }
.site-btn:disabled { opacity: .5; cursor: default; }
.site-btn[hidden] { display: none; }
.site-bar .preview-publish { flex: none; margin: 0; height: 30px; padding: 0 14px; border-radius: 9px; font-size: 12.5px; }
@container pane (max-width: 420px) {
  .site-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* An unpublished site: grey dot, Put online. */
.live-dot.off, .offline .live-dot { background: var(--faint); box-shadow: none; }
.preview-live.offline { color: var(--muted); }
.msg.note.unpublished, .msg.note.republished { align-self: center; font-size: 13px; color: var(--muted); }

/* A Store install card: what the install creates. */
.install-list { margin: 8px 0; padding-inline-start: 18px; font-size: 13.5px; line-height: 1.7; }
.install-list li::marker { color: var(--faint); }

/* A repeating task: its runs' label, and the card's state line. */
.sched-tag { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; color: var(--faint); }
.msg.answer.scheduled { border-inline-start: 2px solid var(--line); padding-inline-start: 14px; }
.sched-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sched-status p { margin: 0; color: var(--muted); font-size: 13px; }

@keyframes pill-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); } }
.ask-browser {
  display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 10px; padding: 8px 14px; border-radius: 12px;
  border: 0; background: var(--send); color: var(--on-send); font: 600 13px Inter, Vazirmatn, sans-serif; cursor: pointer;
}
.ask-browser:hover { opacity: 0.88; }

/* A chat that answers now. */
.chat-row.running .chat-name::after {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px; vertical-align: middle; border-radius: 50%;
  background: currentColor; animation: chat-live 1.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .chat-row.running .chat-name::after { animation: none; } }

/* A repeating task in the Jobs tab: its runs, newest first. */
.sched-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-runs { display: flex; flex-direction: column; gap: 10px; padding: 4px 12px 12px; max-height: 60vh; overflow: auto; }
.sched-run { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.sched-run:first-child { border-top: 0; padding-top: 0; }
.sched-run-when { font-size: 12px; color: var(--faint); margin-bottom: 4px; }
.sched-run .md { font-size: 13px; line-height: 1.5; }
.sched-all { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.sched-all:hover { color: var(--text); }
