/* List or grid on every collection (the Founder's walk, 1 October 2026). */
/* The switch sits at the right end of its box's count heading, never on a line of its own (the Founder, 5 October 2026). */
.card-head>.view-toggle{margin-inline-start:auto}
.card-head:has(>.view-toggle){flex-wrap:nowrap;min-width:0}
/* Tasks' View is in the same box, between the count and the switch. On a phone the count and the switch keep
   their line and the View takes the box's next row, full width. */
.card-head>h2{flex:0 0 auto;white-space:nowrap}
.card-head>.task-view{margin-inline-start:auto;flex:0 1 auto;min-width:0}
.card-head>.task-view+.view-toggle{margin-inline-start:0}
.card-head>.task-view .input{max-width:100%}
@media(max-width:480px){
 #main .card>.card-head:has(>.task-view){flex-wrap:wrap;row-gap:10px}
 .card-head>.task-view{order:3;flex:1 0 100%;margin-inline-start:0}
 .card-head>.task-view .input{flex:1;width:100%}
 .card-head>.task-view+.view-toggle{margin-inline-start:auto}
}
.card-head:has(>.view-toggle)>h2{min-width:0;overflow-wrap:anywhere}
.collection-box{min-width:0}
.collection-box>.ws-collection[data-view=list]{border-radius:12px}
.view-toggle{display:inline-flex;flex:none;gap:0;border:1px solid var(--line);border-radius:12px;background:var(--surface,#fff);overflow:hidden}
.view-toggle button{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:0;background:none;color:var(--muted);cursor:pointer}
.view-toggle button+button{border-inline-start:1px solid var(--line)}
.view-toggle button .icon{width:19px;height:19px}
.view-toggle button[aria-pressed=true]{background:#f3eafc;color:var(--purple,#7c3aed)}
.view-toggle button:focus-visible{outline:2px solid var(--purple,#7c3aed);outline-offset:-2px}
[data-theme=dark] .view-toggle button[aria-pressed=true]{background:#2d2440}

/* Workspaces: tiles. The cover slot holds a Workspace's picture once it has one; until then a plain tint. */
.ws-collection{display:grid;gap:12px;min-width:0}
.ws-tile{position:relative;isolation:isolate;display:flex;min-width:0;color:inherit;text-decoration:none;border:1px solid var(--line);border-radius:16px;background:var(--surface,#fff);overflow:hidden}
.ws-tile:hover{border-color:#cdb4ec}
.ws-tile:focus-visible{outline:2px solid var(--purple,#7c3aed);outline-offset:2px}
.ws-cover{position:absolute;inset:0;z-index:-1;overflow:hidden;background-size:cover;background-position:center}
.ws-tone-0{background-color:#efe4fc;background-image:linear-gradient(150deg,#f6effe 0%,#e2cdfa 100%)}
.ws-tone-1{background-color:#e7e9fd;background-image:linear-gradient(150deg,#f1f2ff 0%,#d7dbfb 100%)}
.ws-tone-2{background-color:#fbe7f3;background-image:linear-gradient(150deg,#fff1f8 0%,#f5d2e7 100%)}
.ws-tone-3{background-color:#e3f4f1;background-image:linear-gradient(150deg,#f0faf8 0%,#cfeae4 100%)}
.ws-tone-4{background-color:#fdf0e1;background-image:linear-gradient(150deg,#fff7ee 0%,#f8dfc2 100%)}
.ws-tone-5{background-color:#ece6f5;background-image:linear-gradient(150deg,#f6f2fb 0%,#d9cfe9 100%)}
[data-theme=dark] .ws-cover{filter:brightness(.32) saturate(1.4)}
/* A cover picture (0080) fills the slot; a shade at the foot keeps the name legible over it. */
.ws-cover img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
.ws-tile.has-cover .ws-cover::after{content:'';position:absolute;inset:0;background:linear-gradient(180deg,rgba(20,10,35,.18) 0%,rgba(20,10,35,0) 30%,rgba(20,10,35,.12) 45%,rgba(20,10,35,.72) 100%)}
[data-theme=dark] .ws-tile.has-cover .ws-cover{filter:none}
[data-view=grid]>.ws-tile.has-cover .ws-name,[data-theme=dark] [data-view=grid]>.ws-tile.has-cover .ws-name{color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.45)}
[data-view=grid]>.ws-tile.has-cover .ws-icon{color:#fff}
/* The cover dialog (the Founder, 6 October 2026): the preview edge to edge in the Workspace page's cover shape (the
   page's own measure is set on it when it is open; 8/3 otherwise), Upload and Take a photo on one grid, a small Remove
   beside them once there is a cover, and Save. */
.cover-editor{display:grid;gap:12px}
.cover-preview{position:relative;overflow:hidden;width:100%;aspect-ratio:8/3;margin:0;border:1px solid var(--line);border-radius:16px}
.cover-preview img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block}
/* Moving it (the Founder, 7 October 2026): the picture is dragged inside the frame, Zoom and Reset under it. */
.cover-preview{touch-action:none;-webkit-user-select:none;user-select:none}
.cover-preview img{pointer-events:none;-webkit-user-drag:none}
.cover-preview.can-move{cursor:grab}
.cover-preview.can-move:active{cursor:grabbing}
.cover-preview:focus-visible{outline:3px solid var(--purple,#7929c3);outline-offset:2px}
.cover-editor-hint{position:absolute;inset-inline-start:10px;bottom:10px;z-index:1;display:inline-flex;align-items:center;gap:6px;min-height:30px;max-width:calc(100% - 20px);padding:0 12px;border-radius:999px;background:rgba(20,12,30,.58);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);color:#fff;font-size:.8rem;font-weight:600;white-space:nowrap;pointer-events:none}
.cover-editor-hint svg{flex:0 0 14px;width:14px;height:14px}
.cover-editor-hint[hidden],.cover-editor-tools[hidden]{display:none}
.cover-editor-tools{display:flex;align-items:center;gap:12px;min-width:0}
.cover-editor label.cover-editor-zoom{display:flex;flex-direction:row;align-items:center;gap:10px;flex:1;min-width:0;margin:0;font-weight:600;font-size:.9rem}
.cover-editor-zoom input{flex:1;min-width:0;width:auto;margin:0;padding:0;border:0;background:none;accent-color:var(--purple,#7929c3)}
.cover-editor-tools .btn.cover-editor-reset{width:auto;min-height:40px;padding:0 16px;border-radius:999px;flex:0 0 auto}
.cover-editor-pick{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.cover-editor-pick.has-remove{grid-template-columns:repeat(2,minmax(0,1fr)) 48px}
.cover-editor-pick .btn{flex-direction:column;gap:6px;min-height:68px;min-width:0;padding:10px 8px;border-radius:12px}
.cover-editor-pick .btn span{max-width:100%;overflow-wrap:anywhere;line-height:1.2}
.cover-editor-pick svg{flex:0 0 22px;width:22px;height:22px}
.cover-editor-pick .btn:hover:not(:disabled){border-color:var(--purple);color:var(--purple)}
.cover-editor-pick .btn.cover-editor-remove{padding:0;color:var(--red)}
.cover-editor-pick .btn.cover-editor-remove:hover:not(:disabled){border-color:var(--red);color:var(--red)}
.cover-editor-confirm{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--soft)}
.cover-editor-confirm[hidden]{display:none}
.cover-editor-confirm span{flex:1 1 auto;font-weight:600;font-size:.9rem}
.cover-editor-status{min-height:0;font-size:.875rem;color:var(--muted)}
.cover-editor-status:empty{display:none}
.cover-editor-save{justify-self:end;min-width:140px;min-height:44px}
@media (max-width:700px){.cover-preview{border-radius:14px}.cover-editor-save{justify-self:stretch}}
.ws-icon{display:flex;color:#7a3fc0}
.ws-icon .icon{width:22px;height:22px}
.ws-text{min-width:0}
.ws-name{display:block;overflow-wrap:anywhere}
.ws-go{display:flex;color:var(--muted)}
.ws-go .icon{width:18px;height:18px}

.ws-collection[data-view=grid]{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
[data-view=grid]>.ws-tile{flex-direction:column;justify-content:flex-end;aspect-ratio:5/4;padding:14px}
[data-view=grid]>.ws-tile .ws-icon{position:absolute;top:12px;inset-inline-start:14px;opacity:.8}
[data-view=grid]>.ws-tile .ws-status{position:absolute;top:10px;inset-inline-end:10px}
[data-view=grid]>.ws-tile .ws-name{font-size:21px;line-height:1.15;font-weight:700;letter-spacing:-.3px;color:#2a1543;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
[data-theme=dark] [data-view=grid]>.ws-tile .ws-name{color:var(--ink,#f2eef8)}
[data-view=grid]>.ws-tile .ws-objective,[data-view=grid]>.ws-tile .ws-go{display:none}
@media (min-width:900px){
 .ws-collection[data-view=grid]{grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:16px}
 [data-view=grid]>.ws-tile{padding:18px}
 [data-view=grid]>.ws-tile .ws-name{font-size:26px}
}
/* On Home the tiles sit inside the Workspaces card. */
[data-home-workspaces] .ws-collection{margin-top:4px}

.ws-collection[data-view=list]{gap:0;border:1px solid var(--line);border-radius:14px;background:var(--surface,#fff);overflow:hidden}
[data-view=list]>.ws-tile{align-items:center;gap:12px;min-height:64px;padding:14px 16px;border:0;border-radius:0;border-bottom:1px solid var(--line)}
[data-view=list]>.ws-tile:last-child{border-bottom:0}
[data-view=list]>.ws-tile .ws-cover{display:none}
[data-view=list]>.ws-tile .ws-text{flex:1}
[data-view=list]>.ws-tile .ws-name{font-size:16px;font-weight:600;line-height:1.3}
[data-view=list]>.ws-tile .ws-objective{display:block;margin-top:3px;font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Tasks: one fixed layout in both views, in task-page.css. */

/* Agents. Grid: square tiles, every one the same size, the face at the top left of each, the name, the role and the
   status under it in the same places (the Founder, 5 October 2026, 07:14: "the grid needs to be one square"). List: the
   two-line rows (terminal-next.css). The grid is drawn by these rules whatever the number of agents. */
[data-collection-items=agents][data-view=grid]{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(176px,max(144px,calc(50% - 6px))),1fr))!important;grid-auto-rows:1fr;gap:30px 12px;align-items:stretch}
[data-collection-items=agents][data-view=grid]>.agent-card{display:flex;flex-direction:column;align-items:stretch;aspect-ratio:1;min-width:0;margin:0;padding:12px}
[data-collection-items=agents][data-view=grid]>.agent-card>.agent-card-open{display:flex;flex:1;width:100%;min-height:0}
[data-collection-items=agents][data-view=grid] .agent-compact-content{flex:1;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:8px;min-height:0}
[data-collection-items=agents][data-view=grid] .agent-compact-content>.portrait-box.small{flex:none;width:48px;min-width:48px;height:48px;align-self:flex-start}
[data-collection-items=agents][data-view=grid] .agent-compact-copy{flex:1;gap:2px;min-height:0}
[data-collection-items=agents][data-view=grid] .agent-compact-name{font-size:15px;padding-inline-end:0!important}
[data-collection-items=agents][data-view=grid] .agent-compact-meta{flex:1;flex-direction:column;align-items:flex-start;gap:0;min-width:0;width:100%}
[data-collection-items=agents][data-view=grid] .agent-role-runtime{flex:none;width:100%;line-height:16px}
[data-collection-items=agents][data-view=grid] .agent-compact-meta>.status-badge{margin-top:auto}
[data-collection-items=agents][data-view=grid] .agent-role-runtime{margin-bottom:10px}
[data-collection-items=agents][data-view=grid] .agent-compact-meta>.icon{display:none}
/* "N waiting for you" beside the face, at the tile's top right, wrapping rather than running over it. */
[data-collection-items=agents][data-view=grid] .agent-waiting{top:12px;inset-inline-end:12px;max-width:calc(100% - 48px - 34px);white-space:normal;text-align:end;line-height:16px}
[data-collection-items=agents][data-view=list]{grid-template-columns:minmax(0,1fr)!important;gap:8px}
[data-collection-items=agents][data-view=list]>.agent-card{aspect-ratio:auto}

/* Humans */
[data-collection-items=humans][data-view=list]>.member-identity+.member-identity{margin-top:14px;padding-top:14px;border-top:1px solid var(--line)}
[data-collection-items=humans][data-view=grid]{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px;padding:0;border:0;background:none;box-shadow:none}
[data-collection-items=humans][data-view=grid]>.member-identity{flex-direction:column;justify-content:center;text-align:center;gap:10px;padding:18px 12px;border:1px solid var(--line);border-radius:14px;background:var(--surface,#fff)}
[data-collection-items=humans][data-view=grid]>.member-identity h2{font-size:17px;margin:0 0 4px;overflow-wrap:anywhere}
[data-collection-items=humans][data-view=grid]>.member-identity p{overflow-wrap:anywhere}
/* A tile says how many agents and when it is due under its name (audit 5 Oct). */
.ws-tile .ws-meta{display:block;margin-top:3px;font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* The box a switch controls: its heading and the switch on one line, the items under them (the Founder, 5 October 2026). */
.collection-box>.card-head,.card>.card-head:has(>.view-toggle){display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:nowrap;min-width:0}
.collection-box>.card-head h2{margin:0;min-width:0;overflow-wrap:anywhere}
.card-head>.view-toggle{margin-inline-start:auto}
.collection-box{display:flex;flex-direction:column;gap:14px}

/*
 * An agent asking to join, in the same Agents grid and list as the crew (terminal-views.js askingCard): the name, then
 * the line under it, as a crew card has them; Activate and Decline beside the words in a list, under them in a grid
 * (the Founder, 6 October 2026: the line sat over the name, and there was no Decline). A grid tile stays square: the
 * line takes one line on a narrow tile and two on a wider one, its whole text in its title and on the request's page.
 */
.agent-card.agent-asking,[data-collection-items=agents][data-view=list]>.agent-card.agent-asking{display:flex;flex-wrap:wrap;align-items:center;gap:10px 12px}
.agent-card.agent-asking>.agent-card-open{flex:1 1 220px;min-width:0}
.agent-card.agent-asking .agent-compact-copy{min-width:0}
.agent-card.agent-asking .agent-role-runtime{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;white-space:normal;overflow-wrap:anywhere;line-height:18px}
.agent-asking-actions{display:flex;gap:8px;margin-inline-start:auto;flex:none}
.agent-asking-actions>.btn{min-height:44px}
[data-collection-items=agents][data-view=grid]>.agent-card.agent-asking{flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:8px;container-type:inline-size}
[data-collection-items=agents][data-view=grid]>.agent-card.agent-asking>.agent-card-open{flex:0 1 auto;min-height:0;overflow:hidden}
[data-collection-items=agents][data-view=grid] .agent-asking .agent-compact-copy,[data-collection-items=agents][data-view=grid] .agent-asking .agent-compact-meta{flex:none}
[data-collection-items=agents][data-view=grid] .agent-asking .agent-role-runtime{-webkit-line-clamp:1;margin-bottom:0;line-height:16px}
@container (min-width:160px){[data-collection-items=agents][data-view=grid] .agent-asking .agent-role-runtime{-webkit-line-clamp:2}}
[data-collection-items=agents][data-view=grid] .agent-asking-actions{margin:auto 0 0;width:100%;gap:6px}
[data-collection-items=agents][data-view=grid] .agent-asking-actions>.btn{flex:1 1 0;min-width:0;min-height:44px;padding:8px 6px;font-size:.8125rem}
/* Where a tile asking to join needs more than a square (a phone's two columns), every tile in the grid takes the row's height, so the tiles stay one size. */
[data-collection-items=agents][data-view=grid]:has(>.agent-asking)>.agent-card:not(.agent-asking){height:100%;aspect-ratio:auto}

/* Only the count gets a text-sized backing on dark photo tiles; dates and other views keep their styling. */
[data-theme=dark] [data-view=grid]>.ws-tile.has-cover .ws-agent-count{display:inline-block;max-width:100%;padding:0 6px;border-radius:var(--radius,14px);color:var(--ink);background:var(--surface)}

/* Photo tiles carry only their cover, name and agent count. List rows and plain tiles retain their metadata. */
.ws-collection[data-view=grid]>.ws-tile.has-cover :is(.ws-icon,.ws-objective,.ws-status,.ws-go,.ws-due){display:none}
