/* Night Desk: the City's own pieces for Spaces (docs/NIGHT-DESK.md 7b), in the design's tokens and its k- classes.
   The design's handoff has no Spaces; these follow its language: amber means a person is needed, the accent pulse
   means working, green means done, muted means ready or not live. Dark and light both come from the tokens. */

/* ---------- the kind's mark: the same everywhere a Space shows an agent ---------- */
.k-agent-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; flex: none;
  font: 600 11px/1 var(--font-num); letter-spacing: .02em; background: var(--surface2); color: var(--ink2); border: 1px solid var(--line); }
.k-agent-mark.m-claude { background: #d97757; border-color: #d97757; color: #1a0e08; }
.k-agent-mark.m-codex { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- the agent strip ---------- */
.k-agents { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.k-agents::-webkit-scrollbar { display: none; }
.k-agent { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 280px; padding: 6px 10px 6px 6px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; text-align: left; cursor: pointer; text-decoration: none; flex: none; }
.k-agent:hover { background: var(--hover, var(--surface2)); }
.k-agent.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.k-agent-text { display: grid; min-width: 0; line-height: 1.25; }
.k-agent-text b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-agent-doing { font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-agent-state { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink2); white-space: nowrap; }
.k-agent-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mute); flex: none; display: inline-block; }
.s-working .k-agent-dot { background: var(--accent); animation: pulse 1.2s infinite; }
.s-waiting .k-agent-dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); }
.s-finished .k-agent-dot { background: var(--ok); }
.s-stale .k-agent-dot, .s-unknown .k-agent-dot { background: transparent; border: 1px dashed var(--mute); }
.k-agent.s-waiting { border-color: var(--amber-line); background: var(--amber-bg); }
.k-agent.s-waiting .k-agent-state { color: var(--amber); font-weight: 600; }
.k-agent.s-finished .k-agent-state { color: var(--ok); }
.k-agents.is-compact { gap: 4px; padding: 0; overflow: visible; }
.k-agents.is-compact .k-agent { padding: 3px 7px 3px 3px; gap: 5px; border-radius: 999px; }
.k-agents.is-compact .k-agent-mark { width: 20px; height: 20px; border-radius: 50%; font-size: 9.5px; }

/* ---------- a terminal's screen ---------- */
.k-term { display: grid; grid-template-rows: auto 1fr; min-height: 0; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); overflow: hidden; }
.k-term.s-waiting { border-color: var(--amber-line); }
.k-term-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.k-term-head b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.k-term-title { flex: 1; min-width: 0; font-size: 12.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-term-body { position: relative; min-height: 120px; background: var(--lane-bg, var(--bg)); }
.k-term-screen { margin: 0; padding: 10px 12px; font: 12.5px/1.45 var(--font-num); color: var(--ink); white-space: pre-wrap;
  overflow: auto; max-height: 100%; tab-size: 4; }
.k-term-note { margin: 0; padding: 18px 14px; color: var(--mute); font-size: 13px; }
.k-term-live { position: absolute; inset: 0; }
.k-term-live[hidden] { display: none; }

/* ---------- an agent's question: the approval card's amber, answered in place ---------- */
.k-ask { display: grid; gap: 8px; }
.k-ask.is-idle { background: var(--surface); border-color: var(--line); }
.k-ask .k-ap-head { margin-bottom: 0; }
.k-ask-who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.k-ask-where { color: var(--mute); }
.k-ask-body { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface2); max-height: 220px; overflow: auto;
  font: 12.5px/1.45 var(--font-num); white-space: pre-wrap; }
.k-ask-q { margin: 0; font-size: 15px; font-weight: 500; line-height: 1.45; }
.k-ask-form { display: grid; gap: 10px; margin: 0; }
.k-ask-opts { display: grid; gap: 6px; }
.k-ask-opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 9px 12px; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.k-ask-opt:hover:not([disabled]) { border-color: var(--amber); }
.k-ask-opt[disabled] { cursor: default; opacity: .7; }
.k-ask-opt.is-tick input { margin: 3px 0 0; accent-color: var(--amber-btn); }
.k-ask-key { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; flex: none;
  font: 600 11.5px/1 var(--font-num); color: var(--amber); border: 1px solid var(--amber-line); }
.k-ask-ot { display: grid; gap: 2px; min-width: 0; }
.k-ask-ot b { font-weight: 600; }
.k-ask-ot span { font-size: 12.5px; color: var(--ink2); }
.k-ask-own { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; border: 1px dashed var(--amber-line);
  border-radius: var(--radius-sm); background: var(--surface); }
.k-ask-own input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 6px 0; outline: none; }
.k-ask .k-actions { margin-top: 2px; }
.k-ask-why { margin: 0; }
.k-ask-open { justify-self: start; }

/* ---------- a Space on the index ---------- */
.k-spaces { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.k-space { display: grid; gap: 10px; align-content: start; padding: 14px var(--pad); border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); position: relative; min-width: 0; }
.k-space.is-needs { border-color: var(--amber-line); }
.k-space.is-needs::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--amber); }
.k-space-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.k-space-title { display: grid; gap: 2px; min-width: 0; }
.k-space-name { font-size: 15.5px; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
a.k-space-name:hover { color: var(--accent); }
.k-space-line { margin: 0; font-size: 13px; color: var(--ink2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.k-space-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- a part's tools (Export, Why) and count line in a Space's window: the City's own rules for them (shell.css,
   kit/adapt.py), here too, so the window looks the same with the desk's stylesheet and without it ---------- */
body.sp-window .k-tools { display: inline-flex; align-items: center; gap: 12px; font-size: 12.5px; font-weight: 400; text-transform: none; letter-spacing: 0; }
body.sp-window .k-tools .k-src { margin: 0; }
body.sp-window .k-count > a, body.sp-window .k-count > .k-tools { margin-left: auto; }
body.sp-window .k-count > a + .k-tools { margin-left: 12px; }
body.sp-window .k-link { text-decoration: none; }

@media (max-width: 760px) {
  .k-agent { max-width: 220px; }
  .k-spaces { grid-template-columns: 1fr; }
  .k-ask-opt { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { .s-working .k-agent-dot { animation: none; } }
