/* The side panels of the home page (side-panels-view.js): the column beside the work list
   is a stack of panels (Agents, Work streams, Mail, Teams, Artifacts). Two are open at most; they share
   the height of the column, a splitter between them sets the share, and the right edge of
   the column sets its width. The tokens are those of home.css (colours, glass, density),
   so light and dark follow the theme without a rule of their own here.
   No size is written into the markup (the CSP refuses a style attribute): the wiring sets
   --side-w on the aside that holds the column and --grow on each open panel with style.setProperty. */

/* ---- the column: no frame of its own, each panel is glass ---- */
.agents:has(> .sp-col) {
  width: var(--side-w, 330px); min-width: 240px; max-width: 560px;
  /* The wiring measures where the column starts and sets --side-h to the room down to the
     bottom of the window (home-side.js fit()); the fixed value is only the first guess. */
  height: calc(100vh - 68px); height: var(--side-h, calc(100dvh - 68px)); max-height: none;
  overflow: visible; background: none; border: 0; border-radius: 0;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
/* The page gives the column the width it asks for. */
.page:has(> .agents > .sp-col),
.page[data-layout="list"]:not([data-agents="off"]):has(> .agents > .sp-col) { grid-template-columns: auto minmax(0, 1fr); }
.page[data-agents="off"]:has(> .agents > .sp-col) { grid-template-columns: minmax(0, 1fr); }
/* A wide window (home-side.js place()): the column leaves the centred page and stands at the
   left edge of the window; the page keeps an empty first track of the width it had, so the
   work list keeps its place and its width. --side-top follows the list down to the top bar. */
@media (min-width: 900px) {
  .page[data-layout="list"][data-side-out="on"]:not([data-agents="off"]):has(> .agents > .sp-col) { grid-template-columns: 330px minmax(0, 1fr); }
  .page[data-layout="list"][data-side-out="on"]:not([data-agents="off"]):has(> .agents > .sp-col) > main { grid-column: 2; }
  .page[data-layout="list"][data-side-out="on"]:not([data-agents="off"]) > .agents:has(> .sp-col) { position: fixed; left: 16px; top: var(--side-top, 52px); z-index: 5; }
}
.sp-col { position: relative; height: 100%; display: flex; flex-direction: column; gap: 6px; min-height: 0; }

/* ---- a panel ---- */
.sp-pnl { flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); transition: box-shadow .15s; }
.sp-pnl.open { flex-grow: var(--grow, 1); flex-shrink: 1; flex-basis: 0; min-height: 120px; }
.sp-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--btn-h); padding: 4px 10px; border: 0; background: none; text-align: left; user-select: none; flex: none; color: var(--ink); }
.sp-head:hover { background: var(--sunk); }
.sp-head:focus-visible { outline-offset: -2px; }
.sp-pnl.open .sp-head { border-bottom: 1px solid var(--line); }
.sp-head .ic { color: var(--muted); transform: rotate(-90deg); transition: transform .15s; }
.sp-pnl.open .sp-head .ic { transform: none; }
.sp-ttl { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sp-pnl.open .sp-ttl { color: var(--ink); }
.sp-ind { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.sp-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* The agents list keeps its own head for its mock tag; the panel head already names it. */
.sp-body[data-panel-body="agents"] .agents-head h2 { display: none; }
.sp-body[data-panel-body="agents"] .agents-head { padding: 0 10px; }
.sp-body[data-panel-body="agents"] .ag-search { margin-top: 6px; }

/* ---- the indicators of a head ---- */
.sp-badge { font-family: var(--f-mono); font-size: .66rem; line-height: 16px; padding: 0 6px; border-radius: 99px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-badge.quiet { background: var(--idle-soft); color: var(--muted); }
.sp-chip { font-family: var(--f-mono); font-size: .64rem; font-weight: 700; line-height: 16px; padding: 0 7px; border-radius: 5px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.sp-chip.review { background: var(--accent); color: var(--on-accent); }
/* The accent dot: a review waits. Also beside the proposal of a group head in the list. */
.sp-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: sp-pulse 1.6s ease-in-out infinite; }
@keyframes sp-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* ---- the splitter between two open panels and the width edge of the column ---- */
/* Both are grips that show without a hover: a bar of three dots that the user can find. */
.sp-split { flex: none; height: 14px; margin: -10px 0; cursor: row-resize; position: relative; z-index: 2; touch-action: none; }
.sp-split::before { content: ""; position: absolute; left: 12px; right: 12px; top: 6px; height: 2px; border-radius: 2px; background: var(--line); }
.sp-split::after { content: ""; position: absolute; left: 50%; top: 2px; width: 44px; height: 10px; margin-left: -22px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); background-image: radial-gradient(circle, var(--muted) 1.2px, transparent 1.6px);
  background-size: 9px 10px; background-position: center; background-repeat: space no-repeat; }
.sp-split:hover::before, .sp-split.on::before { background: var(--accent); }
.sp-split:hover::after, .sp-split.on::after { border-color: var(--accent); }
.sp-edge { position: absolute; top: 0; bottom: 0; right: -12px; width: 12px; cursor: col-resize; touch-action: none; z-index: 3; }
.sp-edge::after { content: ""; position: absolute; left: 3px; top: 50%; width: 6px; height: 48px; margin-top: -24px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--panel); background-image: radial-gradient(circle, var(--muted) 1.2px, transparent 1.6px);
  background-size: 6px 9px; background-position: center; background-repeat: no-repeat space; }
.sp-edge:hover::after, .sp-edge.on::after { border-color: var(--accent); background-color: var(--accent-soft); }

/* ---- the lists inside the panels ---- */
.sp-list { display: flex; flex-direction: column; }
.sp-search { margin: 6px 10px; }

/* A stream: health, name, Review; under it the next action and what it waits on. */
.sp-stream { padding: 6px 10px; border-top: 1px solid var(--line); font-size: .86rem; line-height: 1.3; }
.sp-stream:first-child { border-top: 0; }
.sp-stream:hover { background: var(--sunk); }
.sp-l1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sp-hl { flex: none; width: 8px; height: 8px; border-radius: 50%; }
/* A stream without health (a paired device, or none set) keeps the indent of the others. */
.sp-l1:not(:has(.sp-hl)) { padding-left: 16px; }
.sp-hl.green { background: var(--ok); }
.sp-hl.amber { background: var(--warn); }
.sp-hl.red { background: var(--bad); }
.sp-name { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 6px; border: 0; background: none; padding: 0; text-align: left; color: var(--ink); }
.sp-name b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-name .ref { flex: none; font-size: .68rem; color: var(--muted); }
.sp-name:hover b { color: var(--accent); }
.sp-review { flex: none; min-height: var(--btn-sm); padding: 1px 8px; }
.sp-next, .sp-wait { margin: 1px 0 0 16px; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-next { color: var(--muted); }
.sp-wait { color: var(--warn); display: flex; align-items: center; gap: 4px; }
.sp-wait span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* An artifact: title and ref, under it the kind and the age, the arrow on the right. */
.sp-art { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0 8px; align-items: center; padding: 5px 6px 5px 10px; border-top: 1px solid var(--line); font-size: .86rem; line-height: 1.3; cursor: grab; }
.sp-art:first-child { border-top: 0; }
.sp-art:hover { background: var(--sunk); }
.sp-art:active { cursor: grabbing; }
.sp-art.dragging { opacity: .45; }
.sp-title { grid-column: 1; grid-row: 1; min-width: 0; border: 0; background: none; padding: 0; text-align: left; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
button.sp-title b { font-weight: 600; }
button.sp-title:hover { color: var(--accent); }
.sp-meta { grid-column: 2; grid-row: 1; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.sp-l2 { grid-column: 1 / span 2; grid-row: 2; font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-send { grid-column: 3; grid-row: 1 / span 2; }
/* With "Pin as app" the pin stands before the arrow. */
.sp-art.pinnable { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.sp-art.pinnable .sp-pin { grid-column: 3; grid-row: 1 / span 2; }
.sp-art.pinnable .sp-send { grid-column: 4; }

/* ---- Mail and Teams (office-view.js): the filters, then a row per mail or chat ---- */
.sp-tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px 0; }
.sp-seg { min-height: var(--btn-sm, 26px); }
.sp-seg button { padding: 0 9px; font-size: .74rem; }
.side-note.warn { color: var(--warn); }
.sp-it { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0 8px; align-items: center; padding: 5px 6px 5px 10px; border-top: 1px solid var(--line); border-left: 3px solid transparent; font-size: .86rem; line-height: 1.3; cursor: grab; }
.sp-it:first-child { border-top: 0; }
.sp-it:hover { background: var(--sunk); }
.sp-it:active { cursor: grabbing; }
.sp-it.dragging { opacity: .45; }
.sp-it .sp-title { font-weight: 500; }
.sp-it .sp-title b { font-weight: 500; }
/* Unread or new: bold, with the accent bar on the left. */
.sp-it.unread { border-left-color: var(--accent); }
.sp-it.unread .sp-title, .sp-it.unread .sp-title b { font-weight: 700; }
.sp-mk { display: inline-flex; align-items: center; margin-right: 4px; color: var(--muted); }
.sp-mk.flag { color: var(--warn); }
.sp-it .sp-l2 { grid-column: 1 / span 2; }
/* A mail row: title line, time, the bin, the arrow. */
.sp-it { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.sp-l1x { grid-column: 1; grid-row: 1; display: flex; align-items: center; gap: 4px; min-width: 0; }
.sp-l1x .sp-title { flex: 0 1 auto; min-width: 0; }
.sp-it .sp-meta { grid-column: 2; }
.sp-it .sp-del { grid-column: 3; grid-row: 1 / span 2; }
.sp-it .sp-send { grid-column: 4; }
/* The bin shows while the pointer is over the row or the row has the focus; always on touch,
   and always while it waits for the second tap. */
.sp-del { opacity: 0; transition: opacity .12s; }
.sp-it:hover .sp-del, .sp-it:focus-within .sp-del, .sp-del:focus-visible, .sp-del.armed { opacity: 1; }
.sp-del:hover:not(:disabled) { color: var(--bad); }
.sp-del.armed { color: var(--on-accent); background: var(--bad); border-color: var(--bad); }
.sp-ask { color: var(--bad); font-weight: 600; }
/* A conversation: its newest mail with a count and a chevron; open, its mails follow. */
.sp-chev { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--muted); }
.sp-chev:hover { background: var(--sunk); color: var(--ink); }
.sp-chev .ic { transform: rotate(-90deg); transition: transform .15s; }
.sp-chev[aria-expanded="true"] .ic { transform: none; }
.sp-count { flex: none; font-family: var(--f-mono); font-size: .66rem; line-height: 15px; padding: 0 5px; border-radius: 99px; background: var(--idle-soft); color: var(--muted); font-variant-numeric: tabular-nums; }
.sp-it.unread .sp-count { background: var(--accent-soft); color: var(--accent); }
.sp-thread { border-left: 2px solid var(--line); margin-left: 12px; }
.sp-it.member { padding-left: 12px; font-size: .84rem; }
/* A row in motion: a fresh read, a delete or a put-back after a failed delete. The wiring
   gives the class for the one paint that brings the change (home-side.js). The row folds to
   nothing or unfolds from it; 160px is taller than any row, so the cap is never visible. */
.sp-it.enter, .sp-it.leaving { overflow: hidden; max-height: 160px; }
.sp-it.enter { animation: sp-it-in .22s ease-out; }
.sp-it.leaving { animation: sp-it-out .22s ease-in forwards; }
@keyframes sp-it-in {
  from { max-height: 0; padding-top: 0; padding-bottom: 0; border-top-width: 0; opacity: 0; transform: translateY(-4px); }
}
@keyframes sp-it-out {
  to { max-height: 0; padding-top: 0; padding-bottom: 0; border-top-width: 0; opacity: 0; transform: translateX(10px); }
}

/* ---- the reader of a mail or a chat (dialog#item-dialog) ---- */
dialog.panel[data-kind="reader"] { width: min(760px, calc(100vw - 2 * var(--gap))); height: calc(100dvh - 2 * var(--gap)); }
.rd-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-bottom: 6px; font-size: .78rem; color: var(--muted); }
.rd-sub .chip { font-size: .7rem; }
.rd { display: flex; flex-direction: column; gap: 10px; }
.rd > * { flex-shrink: 0; }
.rd-mh { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; margin: 0; font-size: .84rem; }
.rd-mh dt { color: var(--muted); font-size: .78rem; }
.rd-mh dd { margin: 0; overflow-wrap: anywhere; }
.rd-body { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: .9rem; line-height: 1.45; white-space: pre-wrap; }
.rd-sec h3, .rd-hand h3 { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.rd-parts { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.rd-parts-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--line); font-size: .8rem; }
.rd-part { display: flex; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); font-size: .86rem; cursor: pointer; }
.rd-parts-bar + .rd-part { border-top: 0; }
.rd-part input { margin-top: 3px; flex: none; }
.rd-part-main { display: grid; gap: 2px; min-width: 0; }
.rd-part-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.rd-files, .rd-links { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-file { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: .8rem; color: var(--ink); text-decoration: none; background: var(--surface); }
a.sp-file:hover { border-color: var(--accent); color: var(--accent); }
.rd-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-choice { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.act.dangerb { border-color: var(--bad); color: var(--bad); }
.act.dangerb.armed { background: var(--bad); color: var(--on-accent); }
.rd-hand { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.rd-hand .seg { align-self: flex-start; }
.rd-hand textarea { width: 100%; min-height: 4.5em; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.rd-agent { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.rd-agent select { flex: 1; min-width: 0; padding: 3px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.rd-search { margin: 0; }
.rd-cands { display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow: auto; }
.rd-cand { display: grid; gap: 1px; text-align: left; border: 1px solid transparent; background: none; padding: 4px 8px; border-radius: 8px; font-size: .84rem; color: var(--ink); }
.rd-cand:hover { border-color: var(--line); background: var(--sunk); }
.rd-cand[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.rd-cand .muted { font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-opts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .82rem; }
.rd-opts .chk { display: inline-flex; align-items: center; gap: 6px; }
.rd-send { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rd-hand .side-note, .rd-armed { padding: 0; }
.rd .muted, .rd-sub .muted { color: var(--muted); }

/* ---- drag and drop ---- */
body.dragging .drop { outline: 1px dashed var(--muted); outline-offset: -2px; }
.drop.over { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); position: relative; }
body.dragging .drop.over { outline: 2px solid var(--accent); }
.drop.over[data-drop-label]::after { content: attr(data-drop-label); position: absolute; right: 8px; top: 6px; padding: 1px 8px; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-size: .7rem; font-weight: 700; white-space: nowrap; pointer-events: none; }
/* Held over a closed head while dragging: the panel is about to open. */
.sp-pnl.spring { box-shadow: 0 0 0 2px var(--accent); animation: sp-spring .65s ease-in-out infinite alternate; }
@keyframes sp-spring { to { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 0 2px var(--accent); } }
/* Review goes to the proposal of the group head in the list and marks it for a moment. */
.sp-mark { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; transition: outline-color .3s; }

/* ---- the picker "Send to" ---- */
dialog.panel[data-kind="send-to"] { width: min(460px, calc(100vw - 2 * var(--gap))); }
/* The card of a stream without open work (side-panels-view.js renderStreamCard). */
dialog.panel[data-kind="stream-card"] { width: min(440px, calc(100vw - 2 * var(--gap))); height: fit-content; }
dialog.panel[data-kind="stream-card"] .d-title .sp-hl { margin-right: 2px; }
.sp-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; font-size: .86rem; }
.sp-facts dt { color: var(--muted); font-size: .78rem; }
.sp-facts dd { margin: 0; overflow-wrap: anywhere; }
.sp-card-foot { display: flex; justify-content: flex-end; margin-top: 12px; }
.sp-pick { display: flex; flex-direction: column; gap: 2px; }
/* The body of the dialog scrolls: an entry keeps the height of its text, a long label of a row
   wraps and never runs into the next section head. */
.sp-pick > * { flex-shrink: 0; }
.sp-src { display: grid; gap: 1px; padding: 6px 10px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: .86rem; }
.sp-src-k, .sp-pick-sec { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sp-src-p { font-size: .78rem; color: var(--muted); }
.sp-pick-sec { margin: 8px 0 2px; padding: 3px 8px; border-radius: 6px; background: var(--sunk); }
.sp-pick-btn { text-align: left; border: 1px solid transparent; background: none; padding: 5px 8px; border-radius: 8px; font-size: .88rem; color: var(--ink); min-height: var(--btn-h); overflow-wrap: anywhere; }
.sp-pick-btn:hover { border-color: var(--line); background: var(--sunk); color: var(--accent); }
/* What the thread of a mail or a chat went to before, on top of the picker. */
.sp-pick-btn.sugg { font-weight: 600; border-color: var(--accent-soft); background: var(--accent-soft); }
.sp-sugg-wait { padding: 4px 8px; }

/* The reader is the whole screen on a phone, as every dialog of the page (home.css). */
@media (max-width: 559px) {
  dialog.panel[data-kind="reader"] { inset: 0; width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; margin: 0; }
}

/* ---- the phone: the column is the view "Agents", as wide as the screen; no width edge ---- */
@media (max-width: 899px) {
  .agents:has(> .sp-col), .page[data-view="agents"] .agents:has(> .sp-col) { width: auto; max-width: none; min-width: 0; position: static; height: calc(100vh - 150px); height: calc(100dvh - 150px); }
  .sp-edge { display: none; }
}
/* A finger cannot drag here: the arrow is the way, so it is easy to hit. */
@media (pointer: coarse) {
  .sp-art, .sp-it { cursor: default; }
  .sp-del { opacity: 1; min-width: 36px; }
  .sp-send { min-width: 36px; }
}

/* ---- less motion, less transparency ---- */
@media (prefers-reduced-motion: reduce) {
  .sp-dot, .sp-pnl.spring { animation: none; }
  .sp-it.enter, .sp-it.leaving { animation: none; }
  .sp-pnl, .sp-head .ic { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .sp-pnl { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
