/* Agent OS work tools: agent and team settings, the Studio, Tasks, Builds,
   Artifacts, the Coding studio, Capture and Operations. Built on the os.css
   tokens; every screen here is scoped under .sd so nothing leaks into the
   rest of the shell. Phone rules: 44px targets, rails that scroll instead of
   squashing, one column at 760px and no horizontal page scroll. */

/* ---- targets and form controls ------------------------------------------------ */
.sd .btn, .sd .chip, .sd .sd-tab, .sd select, .sd input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.sd .sd-pick, .sd .list-link, .sd summary, .sd .sd-switch { min-height: 44px; }
.sd .btn-sm { min-height: 44px; padding: 0 14px; }
.sd .icon-btn-sm { width: 44px; height: 44px; }
.sd input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .sd textarea, .sd select {
  width: 100%; max-width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--text); font-size: 15px; line-height: 1.4;
}
.sd textarea { resize: vertical; min-height: 88px; }
.sd select { padding: 0 10px; }
.sd input:focus-visible, .sd textarea:focus-visible, .sd select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.sd input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--violet); flex: none; margin: 2px 0 0; }
.sd-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sd-field > label, .sd-label { font-size: 13px; font-weight: 600; color: var(--soft); }
.sd-field-end { justify-content: flex-end; }
.sd-grid-2, .sd-grid-3 { display: grid; gap: 12px; }
.sd-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sd-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sd-choices { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 4px 12px; min-width: 0; }
.sd-choices legend { font-size: 13px; font-weight: 600; color: var(--soft); padding: 0 6px; }
.sd-check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 8px 4px; cursor: pointer; font-size: 14px; min-width: 0; }
.sd-check > span { min-width: 0; overflow-wrap: anywhere; }
.sd-status { margin: 0; font-size: 14px; color: var(--soft); }
.sd-status-ok { color: var(--green); }
.sd-status-error { color: var(--red); }
.sd-wrap { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.sd-plain { list-style: none; margin: 0; padding: 0; }
.sd-back { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
.sd-head-id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.sd-head-id h1 { overflow-wrap: anywhere; }
.sd-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.sd-sub { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.sd-sub h3 { margin: 0; font-size: 15px; }
.sd-details { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; min-width: 0; }
.sd-details > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: 14px; list-style-position: inside; padding: 8px 0; }
.sd-details[open] { padding-bottom: 12px; }
.sd-indent { padding-left: 16px; display: flex; flex-direction: column; gap: 8px; }
.sd-pre, .approval-evidence { margin: 0; max-width: 100%; max-height: 420px; overflow: auto; padding: 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--soft); }
.sd-code { font: 13px/1.5 var(--mono) !important; white-space: pre; overflow: auto; }
.sd-scroll-x { overflow-x: auto; max-width: 100%; }

/* ---- rails, segmented buttons, chips ------------------------------------------- */
.sd-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding: 2px 2px 8px; margin: 0 0 16px; max-width: 100%; -webkit-overflow-scrolling: touch; }
.sd-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--soft); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.sd-tab:hover { background: rgba(155, 107, 255, .1); color: var(--text); }
.sd-tab[aria-current="page"], .sd-tab[aria-selected="true"] { background: rgba(155, 107, 255, .22); border-color: transparent; color: #fff; box-shadow: var(--glow-violet); }
.sd-tab-count { font: 600 11px var(--mono); color: var(--muted); }
.sd-seg { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.sd .chips { flex-wrap: wrap; }
.sd-facts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.sd-facts .pill { white-space: normal; overflow-wrap: anywhere; }
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
.sd-chip { display: inline-flex; gap: 4px; align-items: center; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 12px; color: var(--soft); overflow-wrap: anywhere; }
.sd-chip-allow { border-color: rgba(61, 255, 168, .4); color: var(--green); }
.sd-chip-approve { border-color: rgba(255, 194, 77, .5); color: var(--amber); }
.sd-badge { font: 600 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--cyan); }

/* ---- states -------------------------------------------------------------------------- */
.sd-state { display: inline-flex; align-items: center; font: 600 11px var(--mono); letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.sd-s-done, .sd-s-passed, .sd-s-applied, .sd-s-approved { color: var(--green); border-color: rgba(61, 255, 168, .4); }
.sd-s-running, .sd-s-busy { color: var(--cyan); border-color: rgba(62, 230, 255, .45); }
.sd-s-waiting, .sd-s-approval-required, .sd-s-blocked, .sd-s-pending, .sd-s-proposed { color: var(--amber); border-color: rgba(255, 194, 77, .5); }
.sd-s-failed, .sd-s-denied, .sd-s-rejected, .sd-s-stopped { color: var(--red); border-color: rgba(255, 143, 163, .45); }

/* ---- timeline, flow and route -------------------------------------------------------------- */
.sd-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sd-tl-node, .sd-route li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.sd-tl-node > .grow, .sd-route li > .grow { min-width: 0; overflow-wrap: anywhere; }
.sd-tl-node.sd-s-running { border-color: rgba(62, 230, 255, .45); }
.sd-tl-node.sd-s-approval-required, .sd-tl-node.sd-s-waiting { border-color: rgba(255, 194, 77, .5); }
.sd-tl-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 600 12px var(--mono); background: rgba(155, 107, 255, .18); color: var(--violet-2); }
.sd-timeline-wrap { display: flex; flex-direction: column; gap: 8px; }
.sd-route { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sd-flow { list-style: none; margin: 0; padding: 0 0 6px; display: flex; gap: 8px; overflow-x: auto; max-width: 100%; }
.sd-flow > li { flex: none; min-width: 150px; max-width: 220px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.sd-flow-mini > li { min-width: 120px; padding: 6px 10px; }
.sd-flow > li.is-current { border-color: rgba(62, 230, 255, .5); }
.sd-pnode-approval { border-color: rgba(255, 194, 77, .5) !important; }
.sd-pnode-gate, .sd-pnode-join { border-style: dashed !important; }

/* ---- library cards, members, rows --------------------------------------------------------- */
.sd-lib { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.sd-lib-card { gap: 8px; }
.sd-lib-main { display: flex; flex-direction: column; gap: 8px; color: var(--text); min-width: 0; }
.sd-lib-id { display: flex; gap: 10px; align-items: center; min-width: 0; }
.sd-member { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); min-width: 0; }
.sd-member-lead { border-color: rgba(155, 107, 255, .45); }
.sd-member-id { display: flex; gap: 12px; align-items: center; color: var(--text); min-height: 44px; min-width: 0; }
.sd-member-id b { overflow-wrap: anywhere; }
.sd-row { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 14px; }
.sd-row-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.sd-row-main b { overflow-wrap: anywhere; }
.sd-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.sd-focus { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.sd-pick { display: flex; flex-direction: column; justify-content: center; width: 100%; text-align: left; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; min-width: 0; }
.sd-pick:hover { background: rgba(155, 107, 255, .08); color: var(--text); }
.sd-pick[aria-current="true"], .sd-pteam[aria-pressed="true"] { border-color: rgba(155, 107, 255, .6); background: rgba(155, 107, 255, .12); }
.sd-pteam { text-align: left; cursor: pointer; font: inherit; width: 100%; }
.sd-evidence { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }

/* ---- reach and permissions ---------------------------------------------------------------------- */
.sd-reach { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sd-reach-row { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.sd-reach-row p { margin: 2px 0 0; overflow-wrap: anywhere; }
.sd-reach-state { flex: none; min-width: 64px; text-align: center; font: 600 11px var(--mono); text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); }
.sd-reach-on { color: var(--green); border-color: rgba(61, 255, 168, .4); }
.sd-reach-warn { color: var(--amber); border-color: rgba(255, 194, 77, .5); }
.sd-reach-off { color: var(--red); border-color: rgba(255, 143, 163, .45); }
.sd-reach-wait { color: var(--muted); }

/* ---- switch ------------------------------------------------------------------------------------------ */
.sd-switch { width: 58px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-2); padding: 0 4px; display: inline-flex; align-items: center; cursor: pointer; }
.sd-switch-knob { width: 24px; height: 24px; border-radius: 50%; background: var(--faint); transition: transform .15s, background-color .15s; }
.sd-switch[aria-checked="true"] { background: rgba(61, 255, 168, .18); border-color: rgba(61, 255, 168, .45); }
.sd-switch[aria-checked="true"] .sd-switch-knob { transform: translateX(24px); background: var(--green); }
@media (prefers-reduced-motion: reduce) { .sd-switch-knob { transition: none; } }

/* ---- plans, programmes -------------------------------------------------------------------------------- */
.sd-desk h2 { margin: 0; }
.sd-pwork { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.sd-role { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); min-width: 0; }
.sd-perms { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.sd-savebar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }
.sd-savebar > span { flex: 1 1 240px; min-width: 0; }
.sd-proposal { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; border: 1px dashed rgba(255, 194, 77, .5); }
.sd-diff { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sd-diff-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sd-diff-before { border-color: rgba(255, 143, 163, .35); }
.sd-diff-after { border-color: rgba(61, 255, 168, .35); }
.sd-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
.sd-child { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.sd-child > span:first-child { align-self: flex-start; }
.sd-gate { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255, 194, 77, .4); min-width: 0; }
.sd-gate > .grow { min-width: 0; overflow-wrap: anywhere; }
.sd-gate-act { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; }

/* ---- previews ------------------------------------------------------------------------------------------ */
.sd-preview-sheet { width: min(1100px, 100%); height: min(92dvh, 960px); max-height: 92dvh; }
.sd-preview-sheet .sheet-head { align-items: flex-start; }
.sd-preview-sheet h2 { margin: 0; }
.sd-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 8px; }
.sd-preview-actions .btn { min-height: 44px; }
.sd-preview-notice { margin: 0 18px 10px; color: var(--soft); }
.sd-preview-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 0 18px 18px; }
.sd-preview-frame { flex: 1; width: 100%; min-height: 320px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.sd-thumb-website { background: linear-gradient(135deg, rgba(62, 230, 255, .18), rgba(155, 107, 255, .18)); }
.sd-thumb-image { background: linear-gradient(135deg, rgba(255, 95, 210, .16), rgba(255, 180, 77, .16)); }
.sd-thumb-data { background: linear-gradient(135deg, rgba(61, 255, 168, .14), rgba(62, 230, 255, .12)); }
.sd-builds .tile { min-width: 0; }

/* ---- artifacts ------------------------------------------------------------------------------------------ */
.sd-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.sd-filters .sd-field { flex: 1 1 160px; }
.sd-filters .sd-field.grow { flex: 2 1 220px; }
.sd-art-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sd-art-row { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.sd-art-thumb { flex: none; width: 72px; height: 72px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.sd-art-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sd-art-title { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.sd-lineage { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.sd-dl { margin: 0; }
.sd-dl dd { margin: 0; }

/* ---- capture, operations, research watch ------------------------------------------------------------------ */
.sd-cap { flex-direction: column; gap: 6px; color: var(--text); }
.sd-ops-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sd-watch-screen { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.sd-watch-img { width: 100%; max-height: 420px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); }
.sd-watch-captures { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.sd-watch-captures img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.sd-watch.sd-watch-expanded { position: fixed; inset: 12px; z-index: 30; overflow: auto; }

/* ---- coding studio ------------------------------------------------------------------------------------------ */
.cs-bench { display: grid; grid-template-columns: 320px minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cs-bench [data-pane="files"] { grid-row: span 3; }
.cs-bench [data-pane="code"], .cs-bench [data-pane="preview"] { grid-column: span 2; }
.cs-phone-tabs { display: none; }
.cs-editor { min-height: 360px; }
.cs-diff { max-height: 520px; }
.cs-frame { min-height: 420px; }
.cs-files { max-height: 420px; overflow: auto; }

/* ---- the More list that links to these tools ---- */
.list-link { min-height: 44px; }

/* ---- approvals (the shared card) ----------------------------------------------------------------------------- */
.approval-evidence { margin-top: 8px; }

/* ---- laptop narrower ------------------------------------------------------------------------------------------ */
@media (max-width: 1180px) {
  .sd-pwork { grid-template-columns: minmax(0, 1fr); }
  .cs-bench { grid-template-columns: minmax(0, 1fr); }
  .cs-bench [data-pane="files"] { grid-row: auto; }
  .cs-bench [data-pane="code"], .cs-bench [data-pane="preview"] { grid-column: auto; }
  .sd-ops-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- phone ------------------------------------------------------------------------------------------------------ */
@media (max-width: 760px) {
  .sd-grid-2, .sd-grid-3, .sd-diff-pair { grid-template-columns: minmax(0, 1fr); }
  .sd .page-head { align-items: flex-start; }
  .sd .page-actions { width: 100%; flex-wrap: wrap; }
  .sd .row-actions { flex-wrap: wrap; }
  .sd-row { flex-direction: column; }
  .sd-row-side { flex-direction: row; align-items: center; align-self: stretch; justify-content: space-between; }
  .sd-ops-board { grid-template-columns: minmax(0, 1fr); }
  .sd-art-thumb { width: 56px; height: 56px; }
  .cs-phone-tabs { display: flex; }
  .cs-bench [data-active="false"] { display: none; }
  .cs-editor { min-height: 260px; }
  .sd-preview-sheet { height: 92dvh; }
  .sd-preview-actions, .sd-preview-notice, .sd-preview-stage { padding-left: 14px; padding-right: 14px; }
  .sd-preview-notice { margin-left: 14px; margin-right: 14px; padding: 0; }
  .sd-preview-frame { min-height: 240px; }
  .sd-watch.sd-watch-expanded { inset: 0; border-radius: 0; }
}

/* Agent settings › Overview: chats, schedules and recent runs */
.sd-ws-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sd-ws-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.sd-ws-row:last-child { border-bottom: 0; }
.sd-ws-row > .grow { flex: 1 1 14em; min-width: 0; overflow-wrap: anywhere; }
.sd-ws-row .list-link { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.sd-ws-row .row-actions { flex-wrap: wrap; }
.sd-ws-row .btn, .sd .page-actions .btn { min-height: 44px; }
.sd-ws-facts { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
