/* A project's Work tab and the Work page, Apps, a conversation's goal, the agent map; last of the stylesheets. */
/* ---- a project's Work tab (work.js): a field for ideas, a board of columns, the item chosen in a drawer ---- */
.work-top { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.work-quick { display: flex; gap: 8px; align-items: center; }
.work-quick input { flex: 1; min-width: 0; min-height: var(--control-h); font-size: var(--text-sm2); }
.work-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: var(--text-sm); }
.work-bar .seg-control .count { margin-left: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.work-bar .seg-control .count:empty { display: none; }
.work-bar .seg-control button.has-mine .count { color: var(--primary-ink); }
.work-settings-btn { min-height: var(--control-h-sm); font-size: var(--text-xs); }

/* The board: columns as wide as the page allows, an empty one narrow (its hint only), cards that say only what's news. */
.work-board { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; scroll-snap-type: x proximity; }
.work-col { flex: 1 1 220px; min-width: 200px; display: flex; flex-direction: column; background: var(--tool-bg); border: 1px solid var(--line); border-radius: var(--radius); scroll-snap-align: start; }
.work-col.empty { flex: 0 1 150px; min-width: 130px; }
.work-col.over { border-color: var(--accent); background: var(--accent-soft); }
.work-col-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: var(--text-sm); }
.work-col-head .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-col-head .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.work-col-head .count.yours { color: var(--primary-ink); font-weight: 700; }
.work-col-head .who { margin-left: auto; font-size: var(--text-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.work-col-head .who-you { color: var(--primary-ink); }
.work-col-head .who-agent { color: var(--warn); }
.work-col-cards { display: flex; flex-direction: column; gap: 6px; padding: 0 8px 8px; min-height: 40px; }
.work-col-cards > .empty { margin: 2px; color: var(--muted); font-size: var(--text-xs); line-height: 1.4; }
.col-running.over .work-col-cards > .empty::before { content: "Drop to start it. "; color: var(--accent-strong); font-weight: 600; }
.work-card { padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s, box-shadow .15s; }
.work-card:hover, .work-card:focus-visible { border-color: var(--accent); }
.work-card.chosen { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.work-card.yours { border-left: 3px solid var(--primary-ink); }
.work-card.needs { border-left: 3px solid var(--err); }
.work-card.fresh, #planner-list .card.fresh, #ksrc-list .card.fresh { box-shadow: 0 0 0 2px var(--accent-soft); border-color: var(--accent); }
#planner-list .card { transition: box-shadow 0.4s, border-color 0.4s; }
.work-card .row { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); min-width: 0; }
.work-card .title { font-size: var(--text-sm); line-height: 1.35; overflow-wrap: anywhere; }
.work-card .hint-text, .work-card .work-why { font-size: var(--text-xs); overflow-wrap: anywhere; }
.work-card .badge { font-size: var(--text-2xs); }
.work-card[draggable="true"] { cursor: grab; }
.work-card-foot { min-height: 20px; }
.work-card-flows { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-card-go { min-height: 24px; padding: 0 8px; font-size: var(--text-2xs); border-radius: var(--r-full); opacity: 0; transition: opacity .15s; }
.work-card:hover .work-card-go, .work-card:focus-within .work-card-go, .work-card.chosen .work-card-go { opacity: 1; }
@media (hover: none) { .work-card-go { opacity: 1; } }
.work-branch { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-id { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.work-card.done, .work-card.rejected, .work-card.split { opacity: .7; }
/* An agent on it: a dot that breathes; queued: a hollow one. */
.work-live, .work-queued { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-2xs); color: var(--warn); font-weight: 600; }
.work-live::before, .work-queued::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); animation: work-pulse 1.6s ease-in-out infinite; }
.work-queued { color: var(--muted); font-weight: 500; }
.work-queued::before { background: none; border: 1.5px solid var(--muted); animation: none; }
@keyframes work-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .work-live::before { animation: none; } }
.work-state.plan_review, .work-state.review, .work-state.question, .work-state.waiting { background: var(--primary-bg); color: var(--primary-ink); }
.work-state.stuck { background: var(--err-soft); color: var(--err); }
.work-state.paused, .work-state.split, .work-state.draft, .work-state.rejected { background: var(--tool-bg); color: var(--muted); }
.work-state.planning, .work-state.working, .work-state.changes { background: var(--warn-soft); color: var(--warn); }
.work-state.done { background: var(--ok-soft); color: var(--ok); }
.work-why { color: var(--err); font-size: var(--text-sm); }

/* ---- the Work page (work-board.js): the same board across projects, each card marked with its project ---- */
#view-work .work-top { margin-top: 4px; }
.work-board-project-filter select { min-height: var(--control-h-sm); font-size: var(--text-xs); max-width: 180px; }
.work-board-card { text-decoration: none; color: inherit; }
.work-card-project { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-size: var(--text-2xs); color: var(--muted); }
.work-card-project .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#work-board > .empty { color: var(--muted); font-size: var(--text-sm); }

/* The drawer: over the board's right side and under the header, so the board keeps its width and the header its buttons;
   a phone's whole screen. Under the scrim: the menu's drawer opens over it. */
.work-drawer { position: fixed; top: calc(var(--header-h) + var(--safe-top)); right: 0; bottom: 0; z-index: var(--z-panel); width: min(500px, 100cqw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-3); padding-bottom: var(--safe-bottom); }
/* With the drawer open, the board scrolls on under it: room on its right as wide as the drawer, so any column (Review,
   Done) can come out from under it; an item opened scrolls its column into view (work.js). A phone's drawer is the
   whole screen: none there. */
@container shell (width >= 640px) {
  .project-work.drawer-on .work-board, #view-work.drawer-on .work-board { padding-right: min(1100px, 100cqw); scroll-padding-left: 8px; }
}
/* The work drawers (an item in any state, an idea's form, the settings): wide, as the form template's panels are. */
/* Every drawer of the Work tab the same width: an idea's, an item's (its review desk, its path), the settings. */
.work-drawer, .work-drawer.wide { width: min(1100px, 100cqw); }
.work-drawer-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--line); }
.work-drawer-head h3 { margin: 0; font-size: var(--text-md); }
.work-drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
/* The body scrolls, its parts never shrink: the tabs (overflow-x) would otherwise collapse to 0 high under a tall item. */
.work-drawer-body > * { flex-shrink: 0; }
.work-drawer-body > .work-form { margin: 0; padding: 0; border: 0; box-shadow: none; background: none; }
.work-drawer-body > .work-form .actions:not(.form-actions) { position: static; margin: 4px 0 0; padding: 10px 0 0; background: none; }
/* Long forms (form-kit.js): sections folded to a line saying what each is set to, "More…", Save kept in view. */
.form-sec { border: var(--bw) solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.form-sec > summary { cursor: pointer; list-style: none; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; min-height: var(--tap-sm); }
.form-sec > summary::-webkit-details-marker { display: none; }
.form-sec-title { font-weight: 600; font-size: var(--text-sm); }
.form-sec-title::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--muted); }
.form-sec[open] .form-sec-title::before { content: "▾"; }
.form-sec-line { padding-left: 1.1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-sec[open] .form-sec-line { white-space: normal; }
.form-sec-body { display: flex; flex-direction: column; gap: 12px; padding: 0 12px 12px; }
.form-sec-body > label { margin: 0; }
.form-more > summary { cursor: pointer; font-size: var(--text-xs); color: var(--muted); width: max-content; }
.form-more > p { margin: 4px 0 0; }
/* Save always in view at the foot of the panel the form scrolls in (its padding: --form-pad), saying when something isn't saved. */
.form-actions, .item-form .actions.form-actions { position: sticky; border-radius: 0; bottom: calc(-1 * var(--form-pad, 16px)); z-index: 1; margin: 0 calc(-1 * var(--form-pad, 16px)) calc(-1 * var(--form-pad, 16px)); padding: 10px var(--form-pad, 16px) 12px; background: var(--surface); border-top: var(--bw) solid var(--line); }
.form-dirty { font-size: var(--text-xs); color: var(--warn); }
/* A project's Settings tab on the form template: its Save in view at the page's foot (the page's padding, not a panel's). */
.item-form.p-settings-form > .actions.form-actions { position: sticky; bottom: calc(-1 * var(--page-pad-bottom)); margin: 0; padding: 10px 0 calc(10px + var(--safe-bottom)); background: var(--bg); border: none; border-top: var(--bw) solid var(--line); }
.p-settings-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.p-agents-work-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: var(--text-sm); }
.p-agents-work-list dt { color: var(--muted); }
.p-agents-work-list dd { margin: 0; overflow-wrap: anywhere; }
/* A tab holding what were tabs of their own (Conversations & memory, Where it runs): a heading per part. */
.p-tab-sec + .p-tab-sec { margin-top: 24px; padding-top: 16px; border-top: var(--bw) solid var(--line); }
.p-tab-sec > h2 { font-size: var(--text-md); margin: 0 0 10px; }
/* The Work settings' instructions: a tab each, what Settings says for every project read-only above the project's own. */
.work-instr-tabs { margin-bottom: 0; }
.work-instr-tabs .tab.has-text .work-dot::after { content: "•"; margin-left: 4px; color: var(--accent); }
.work-instr-panel { display: flex; flex-direction: column; gap: 10px; }
.work-instr-panel > label { margin: 0; }
.work-inherited { border-left: 3px solid var(--line-strong); background: var(--surface-sunken); border-radius: 0 var(--r-md) var(--r-md) 0; padding: 6px 10px; }
.work-inherited-head { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--muted); }
.work-inherited-text { white-space: pre-wrap; font-size: var(--text-sm); color: var(--ink-2); max-height: 9em; overflow-y: auto; margin-top: 4px; }
.work-inherited p { margin: 4px 0 0; }
.work-title { margin: 0; font-size: var(--text-lg, 1.15rem); line-height: 1.3; overflow-wrap: anywhere; }
.work-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: var(--text-xs); color: var(--muted); }
/* What it waits for, and whose move it is. */
.work-next { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); font-size: var(--text-sm); background: var(--tool-bg); border-left: 3px solid var(--muted); }
.work-next.you { background: var(--primary-bg); color: var(--primary-ink); border-left-color: var(--primary-ink); }
.work-next.agent { background: var(--warn-soft); border-left-color: var(--warn); }
.work-next.err { background: var(--err-soft); color: var(--err); border-left-color: var(--err); }
.work-next.done { background: var(--ok-soft); border-left-color: var(--ok); }
.work-ask { font-weight: 600; font-size: var(--text-sm2); color: var(--ink); }
.work-ask p { margin: 0; }
.work-now { font-size: var(--text-xs); color: var(--ink-2); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* What a running item is doing now: a sentence or two, whole in the drawer, two lines on its card. */
.work-now.work-summary { font-size: var(--text-sm); white-space: normal; }
.work-card .work-card-now { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wf-step .run-summary { margin: 4px 0 0; }
.work-tabs { margin-bottom: 0; position: sticky; top: -14px; background: var(--surface); z-index: 1; }
.work-tab-body { display: flex; flex-direction: column; gap: 12px; }
.work-tab-body h4 { margin: 0 0 6px; font-size: var(--text-sm); color: var(--ink-2); }
.work-tab-body ol, .work-tab-body ul { margin: 0; padding-left: 1.4em; }
.work-tab-body > .empty, .work-tab-body > p { margin: 0; }
.work-crit { list-style: none; padding-left: 0 !important; }
.work-crit li { position: relative; padding-left: 22px; margin: 2px 0; }
.work-crit li::before { content: ""; position: absolute; left: 2px; top: .3em; width: 11px; height: 11px; border: 1.5px solid var(--muted); border-radius: 3px; }
.work-plan { border-left: 3px solid var(--accent); padding-left: 12px; }
.work-plan-edit { width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: var(--text-sm); }
.work-plan-box { display: grid; gap: 6px; min-width: 0; }
.work-plan-actions { display: flex; align-items: center; gap: 8px; margin: 0; }
.work-merge { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.work-merge-msg { width: 100%; box-sizing: border-box; font-family: var(--font-mono); font-size: var(--text-sm); }
.work-merge .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.work-points { display: flex; flex-direction: column; gap: 8px; }
.work-point { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.work-point:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.work-point input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.work-point .title { font-weight: 600; font-size: var(--text-sm); }
.work-point .desc { font-size: var(--text-sm); }
.work-point details summary { cursor: pointer; font-size: var(--text-xs); color: var(--muted); }
/* The change at review: lines added and removed, its files. */
.work-change { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; font-size: var(--text-sm); }
.work-change-sum { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.work-change .add { color: var(--ok); font-variant-numeric: tabular-nums; }
.work-change .del { color: var(--err); font-variant-numeric: tabular-nums; }
.work-files { list-style: none; padding: 0 !important; margin: 6px 0 0 !important; display: flex; flex-direction: column; gap: 2px; font-size: var(--text-xs); }
.work-files li { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.work-files a, .work-files .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.work-change > p { margin: 4px 0 0; }
.work-change-sum.clickable { cursor: pointer; }
.work-change-sum.clickable:hover strong { text-decoration: underline; }
/* The Changes tab: each file, its diff (the chat's) under it, scrolled in its own box. */
.work-file { border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.work-file > summary { display: flex; align-items: baseline; gap: 8px; padding: 5px 10px; cursor: pointer; font-size: var(--text-xs); min-width: 0; }
.work-file > summary .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.work-file .add { color: var(--ok); font-variant-numeric: tabular-nums; }
.work-file .del { color: var(--err); font-variant-numeric: tabular-nums; }
.work-file[open] > summary { border-bottom: 1px solid var(--line); }
.work-diff { max-height: 60vh; overflow: auto; padding: 6px; }
.work-diff:empty { display: none; }
.work-diff > p { margin: 4px; }
.work-diff .md .code-block { margin: 0; }
.work-notes { gap: 10px; }
.work-note { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; }
.work-note.mine { background: var(--accent-soft); border-color: transparent; }
.work-note.question { border-color: var(--primary-ink); }
.work-note .meta { display: flex; gap: 8px; font-size: var(--text-xs); color: var(--muted); margin-bottom: 4px; }
.work-note .meta strong { color: var(--ink); }
.work-note .desc > :first-child { margin-top: 0; }
.work-note .desc > :last-child { margin-bottom: 0; }
.work-note.checks .run-output { max-height: 16em; overflow: auto; }
.work-runs { gap: 6px; }
.work-runs details summary { cursor: pointer; font-size: var(--text-sm); padding: 4px 0; }
.work-runs .run-output { max-height: 20em; overflow: auto; }
.work-run-convs { font-size: var(--text-sm); color: var(--muted); margin: 2px 0 6px; }
/* What an item and each of its runs spent in tokens (the same report as Settings → Usage). */
.work-usage { padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.work-run-usage { margin: 2px 0 4px; }
.wf-step-usage { white-space: nowrap; }
.badge.wf-top-step { background: var(--warn-soft); color: var(--warn); }
/* The note and the state's buttons, always at hand at the drawer's foot. */
.work-act { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.work-act.empty-act { padding: 0 16px; border: 0; }
.work-act textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 44px; max-height: 40cqh; }
.work-act .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.work-act-hint { font-size: var(--text-2xs); text-align: right; }
@media (hover: none) { .work-act-hint { display: none; } }
/* The drawer's parts (work.js workDetail): each drawn on its own, laid out as if they weren't there. */
.wd-part { display: contents; }
.work-drawer-body > .wd-part > * { flex-shrink: 0; }
.wd-err .err { margin: 0; }
/* The path a new idea (or an Ask) starts on, as a chip that opens the paths. */
.work-path-chip { border: 1px solid var(--line); cursor: pointer; flex: none; }
.work-path-chip:hover { border-color: var(--accent); }
.work-paths-link { font-size: var(--text-sm); }
.work-paths-row { margin-top: -4px; }
/* An idea's view: what gets it going, under its form. */
.work-idea-go { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.work-idea-go h4 { margin: 0; font-size: var(--text-sm); color: var(--ink-2); }
.work-idea-go textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.work-idea-go .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.work-ask-chat { margin: -4px 0 0; }
.work-path-steps > summary { cursor: pointer; font-size: var(--text-sm); color: var(--ink-2); padding: 4px 0; }
.wf-used-by { color: var(--ink-2); }
.git-branch-row.chosen { background: var(--accent-soft); border-radius: var(--r-md); }
.p-ask-becomes { margin: 4px 0 0; }
.work-drawer a.button { display: inline-flex; align-items: center; text-decoration: none; }
/* A phone: the columns one under another, the empty ones but Ideas left out. */
@container shell (width < 640px) {
  .work-board { flex-direction: column; align-items: stretch; overflow-x: visible; }
  .work-col, .work-col.empty { flex: none; min-width: 0; }
  .work-col.empty:not(.col-ideas) { display: none; }
  .work-quick button:not(.primary) { display: none; }
  .work-drawer { width: 100cqw; border-left: 0; }
}
@container shell (width < 600px) { .work-drawer { top: 0; padding-top: var(--safe-top); } }
/* A phone: what's asked of you first and at hand; the diff wraps instead of scrolling sideways, a file full width. */
@container shell (width < 600px) {
  .work-drawer-body { padding: 10px 12px 12px; gap: 10px; }
  .work-drawer-body .work-meta { display: none; }
  .work-tabs .tab { padding-inline: 10px; }
  .wr-line { grid-template-columns: 34px 12px minmax(0, 1fr); }
  .wr-num { padding: 0 3px; }
  .wr-text { white-space: pre-wrap; overflow-wrap: anywhere; }
  .wr-diff { overflow-x: hidden; margin-inline: -12px; border-radius: 0; border-inline: 0; }
  .wr-crit-head { align-items: flex-start; }
  .wr-crit-head .wr-verdict { width: 100%; justify-content: stretch; }
  .wr-crit-head .wr-verdict button { flex: 1; }
  .wr-file > summary { flex-wrap: wrap; }
  .work-act { padding: 8px 12px calc(10px + var(--safe-bottom, 0px)); }
  .work-act .actions > button { flex: 1 1 auto; min-height: var(--tap); }
  .work-act-hint { display: none; }
  /* At review the diff keeps the room: the note one line until it's written in. */
  .work-act.reviewing .work-note:not(:focus-within) .md-inline { max-height: 1.6em; min-height: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .work-act.reviewing .work-note:not(:focus-within) textarea { min-height: 0; height: 2.2em; }
  .work-card-ask .small { min-height: var(--tap-sm, 32px); }
  .path-cards { grid-template-columns: 1fr; }
}
:root[data-display^="eink"] .work-live::before { animation: none; }
:root[data-display^="eink"] .work-drawer { box-shadow: none; border-left: var(--bw) solid var(--line); }
:root[data-display^="eink"] .work-card-go { opacity: 1; }


/*
  ---- the voice panel (voice.js): talking has a window of its own, over the conversation ----
  A bubble with what you said and the reply over a bar: its state (an orb, the label, a wave), Open the conversation
  and Stop. Both float at the foot; the bubble only while there are words.
*/
.voice-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
  display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 16px - var(--safe-top));
}
/* Wide enough: in the corner, not across, the bar a pill of its own. */
@container shell (width >= 600px) {
  .voice-panel { left: auto; right: 24px; bottom: 24px; width: 380px; }
  .voice-panel .vp-bubbles { padding-inline: 0; }
  .voice-panel .vp-bar { border-radius: 32px; border-bottom: 1px solid var(--line); padding: 0 8px 0 10px; min-height: 64px; }
}
.voice-panel .vp-bubble, .voice-panel .vp-bar { background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 28px rgb(0 0 0 / 30%); }
/* The exchanges: the newest at the foot, the earlier ones moving up and scrolling away, faded at the top edge. */
.voice-panel .vp-bubbles { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; padding: 16px 12px 0; mask-image: linear-gradient(to bottom, transparent, black 24px); scrollbar-width: none; }
.voice-panel .vp-bubble { flex: none; border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.voice-panel .vp-bubble.past .vp-reply { font-size: inherit; color: var(--ink-2); }
/* The higher, the fainter: the one going on is last, so the newest earlier one is the second from the end. */
.voice-panel .vp-bubble.past { opacity: .3; transition: opacity .3s; }
.voice-panel .vp-bubble.past:nth-last-child(2) { opacity: .85; }
.voice-panel .vp-bubble.past:nth-last-child(3) { opacity: .65; }
.voice-panel .vp-bubble.past:nth-last-child(4) { opacity: .45; }
/* What you said, small, and the reply as it's read aloud. */
.voice-panel .vp-said { margin: 0; font-size: var(--text-sm2); color: var(--muted); overflow-wrap: anywhere; }
.voice-panel .vp-reply { margin: 0; font-size: var(--text-lg); line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
/* The bar across the foot, flush with the screen's edges, its background under the navigation buttons too. */
.voice-panel .vp-bar { flex: none; min-height: 64px; box-sizing: border-box; border-radius: 24px 24px 0 0; border-bottom: none; display: flex; align-items: center; gap: 12px; padding: 10px 12px calc(10px + var(--safe-bottom)) 14px; }
.voice-panel .vp-orb { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; }
.voice-panel .vp-orb i { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }
.voice-panel .vp-state { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.voice-panel .vp-label { font-weight: 600; font-size: var(--text-sm2); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-panel .vp-wave { display: flex; align-items: center; gap: 2px; height: 12px; }
.voice-panel .vp-wave i { width: 2px; height: 4px; border-radius: 1px; background: var(--line-strong); }
.voice-panel :is(.vp-chat, .vp-stop) { flex: none; border-radius: 50%; border: 0; padding: 0; display: flex; align-items: center; justify-content: center; }
.voice-panel .vp-chat { width: 44px; height: 44px; background: var(--surface-hover); color: var(--ink-2); }
.voice-panel .vp-stop { width: 48px; height: 48px; background: var(--accent); color: var(--accent-ink); }
.voice-panel .vp-chat svg, .voice-panel .vp-stop svg { width: 18px; height: 18px; }
/* Listening and speaking: the wave moves and the orb breathes; transcribing and thinking: the wave runs slowly. */
.voice-panel:is([data-state="recording"], [data-state="conversation"], [data-state="speaking"]) .vp-wave i { background: var(--accent); animation: vp-wave .9s ease-in-out infinite alternate; }
.voice-panel:is([data-state="transcribing"], [data-state="thinking"]) .vp-wave i { background: var(--accent); opacity: .5; animation: vp-wave 1.6s ease-in-out infinite alternate; }
.voice-panel .vp-wave i:nth-child(3n+2) { animation-delay: -.3s; } .voice-panel .vp-wave i:nth-child(3n) { animation-delay: -.6s; }
.voice-panel .vp-wave i:nth-child(4n+1) { animation-duration: 1.1s; }
.voice-panel:is([data-state="recording"], [data-state="conversation"], [data-state="speaking"]) .vp-orb i { animation: vp-breathe 1.4s ease-in-out infinite; }
.voice-panel[data-state="error"] .vp-orb { background: var(--err-soft); } .voice-panel[data-state="error"] .vp-orb i { background: var(--err); }
.voice-panel[data-state="error"] .vp-label { color: var(--err); white-space: normal; }
@keyframes vp-wave { from { height: 3px; } to { height: 12px; } }
@keyframes vp-breathe { 0%, 100% { transform: scale(.85); } 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .voice-panel :is(.vp-wave i, .vp-orb i) { animation: none !important; } }
/* E-ink: nothing moving (requirements/ui/eink.md); the state's words carry it instead. */
:root[data-display^="eink"] .voice-panel :is(.vp-wave i, .vp-orb i) { animation: none !important; }
:root[data-display^="eink"] .voice-panel :is(.vp-bubble, .vp-bar) { box-shadow: none; border-width: var(--bw); }
:root[data-display^="eink"] .voice-panel .vp-bubbles { mask-image: none; }
:root[data-display^="eink"] .voice-panel .vp-bubble.past { opacity: 1; }
:root[data-display^="eink"] .voice-panel .vp-bubble.past:nth-last-child(2), :root[data-display^="eink"] .voice-panel .vp-bubble.past:nth-last-child(3), :root[data-display^="eink"] .voice-panel .vp-bubble.past:nth-last-child(4) { opacity: 1; }
:root[data-display^="eink"] .voice-panel:is([data-state="transcribing"], [data-state="thinking"]) .vp-wave i { opacity: 1; }
/*
  The panel is the window: while it's up, the app behind it keeps out of the way, so nothing but the assistant shows
  (the phone's assistant is reached from another app, not to land in the middle of Jarvis). Open the conversation
  takes the panel down and it all comes back.
*/
:root[data-voice-panel] #app > :not(#voice-panel, #toasts, #auth-screen) { display: none !important; }
/* Over another app (the Android app's assistant panel, index.html voiceOverlay): the page see-through, the dimmed screen behind it. */
:root[data-voice-overlay][data-voice-panel], :root[data-voice-overlay][data-voice-panel] :is(body, #app-frame, #app) { background: transparent !important; }

/* ---- Apps (/apps, apps.js): each app a card with its files ---- */
.app-card { margin-bottom: 10px; }
.app-card h3 { margin: 0 0 2px; font-size: var(--text-sm2); }
.app-card .app-what { margin: 0 0 10px; color: var(--ink-2); }
.app-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.app-file { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; max-width: 100%; }
.app-file-name { overflow-wrap: anywhere; }
.app-file-meta { color: var(--muted); font-size: var(--text-2xs); }
#apps-list h2:first-child { margin-top: 0; }

/* ---- a conversation's goal (/goal): its chip in the header, marked by how it stands ---- */
.goal-chip[data-state="active"] { color: var(--accent-strong); }
.goal-chip[data-state="blocked"] { color: var(--err); }
.goal-chip[data-state="done"] { color: var(--ok); }
.pop .goal-pop-title { margin: 0; padding: 8px 12px 2px; font-weight: 600; max-width: 320px; overflow-wrap: anywhere; }
.pop .pop-note { margin: 0; padding: 0 12px 6px; max-width: 320px; }

/* ---- the agent map (agent-map.js, after Claude Code's): the map, an agent's detail, its transcript ---- */
.agents-chip.running { color: var(--ok); border-color: var(--ok); }
.agent-map-wrap { position: fixed; inset: 0; z-index: calc(var(--z-sheet) + 1); background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; padding: 8cqh 16px 16px; }
.agent-map-wrap[hidden] { display: none; }
.agent-map { width: min(720px, 100%); max-height: 84cqh; display: flex; flex-direction: column; background: var(--surface-raised); border: 1px solid var(--accent); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.am-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 4px; }
.am-top h2 { margin: 0; font-size: var(--text-lg, 18px); }
.am-body { overflow: auto; padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.am-sub { margin: 6px 0 0; color: var(--muted); font-size: var(--text-sm); }
.am-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.am-dot.am-running { box-shadow: 0 0 0 3px var(--ok-soft); }
.am-dot.am-failed { background: var(--err); }
.am-dot.am-completed { background: var(--ok); }
.am-dot.am-stopped, .am-dot.am-idle { background: var(--muted); }
.am-node { display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left; min-width: 0; width: 100%; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm, 4px); background: var(--surface-sunken); color: var(--ink); font: inherit; }
.am-node:not(:disabled) { cursor: pointer; }
.am-node:not(:disabled):hover { border-color: var(--accent); }
.am-node:disabled { opacity: 1; }
.am-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.am-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-root .am-label { font-weight: 600; }
.am-meta { color: var(--muted); font-size: var(--text-xs); padding-left: 16px; }
/* The tree: the agent on the left, its subagents on the right, joined by lines. */
.am-tree { display: flex; align-items: center; gap: 0; }
.am-trunk { flex: 1 1 45%; min-width: 0; }
.am-children { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding-left: 32px; position: relative; }
.am-children::before { content: ""; position: absolute; left: 0; width: 16px; top: 50%; border-top: 1px solid var(--line-strong); }
.am-branch { position: relative; }
.am-branch::before { content: ""; position: absolute; left: -16px; width: 16px; top: 50%; border-top: 1px solid var(--line-strong); }
.am-branch::after { content: ""; position: absolute; left: -16px; top: 0; bottom: 0; border-left: 1px solid var(--line-strong); }
.am-branch:first-child::after { top: 50%; }
.am-branch:last-child::after { bottom: 50%; }
.am-branch:only-child::after { display: none; }
.am-tasks { display: flex; flex-direction: column; gap: 6px; max-width: 50%; }
/* An agent: its head, answer, prompt, calls; its transcript as a timeline. */
.am-head { display: flex; flex-direction: column; gap: 2px; }
.am-title { display: flex; align-items: center; gap: 8px; font-size: var(--text-md, 16px); }
.am-title strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-stop { font-size: var(--text-sm); }
.am-line { margin: 0; color: var(--muted); font-size: var(--text-xs); padding-left: 36px; }
.am-answer { margin: 4px 0; }
.am-fold summary { cursor: pointer; color: var(--ink-2); }
.am-prompt { white-space: pre-wrap; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm, 4px); background: var(--surface-sunken); font-size: var(--text-sm); }
.am-calls { display: flex; flex-direction: column; gap: 6px; padding: 6px 0 0 14px; }
.am-call-sum { color: var(--muted); }
.am-open { width: 100%; padding: 10px; }
.am-transcript { display: flex; flex-direction: column; gap: 12px; overflow: auto; max-height: 64cqh; border-top: 1px solid var(--line); padding: 10px 4px 4px 0; }
.am-ask { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.am-ask .am-prompt { align-self: stretch; }
.am-time { color: var(--muted); font-size: var(--text-xs); }
.am-step { display: flex; gap: 10px; align-items: flex-start; }
.am-step > .am-dot { margin-top: 6px; }
.am-step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.am-thinking .am-step-body { color: var(--muted); }
.am-io { width: 100%; border-collapse: collapse; border: 1px solid var(--line-strong); border-radius: var(--r-sm, 4px); table-layout: fixed; }
.am-io th { width: 44px; text-align: left; vertical-align: top; padding: 8px; color: var(--muted); font: 500 var(--text-xs) var(--font-mono); }
.am-io td { padding: 6px 8px; border-left: 0; }
.am-io tr + tr { border-top: 1px solid var(--line-strong); }
.am-io pre { margin: 0; max-height: 12em; overflow: auto; white-space: pre; font: var(--text-xs) var(--font-mono); }
.am-io pre.err { color: var(--err); }
.am-message summary { cursor: pointer; color: var(--ink-2); list-style: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-text { padding-left: 18px; }
@container (max-width: 560px) {
  .am-tree { flex-direction: column; align-items: stretch; gap: 6px; }
  .am-children { padding-left: 16px; }
  .am-children::before { display: none; }
  .am-branch::before { left: -12px; width: 10px; }
  .am-branch::after { left: -12px; }
  .am-branch:first-child::after { top: -6px; }
  .am-tasks { max-width: none; }
}

/* Settings → Voice → Latency (voice-services.js loadVoiceLatency) */
#voice-latency { overflow-x: auto; }
.latency-table { border-collapse: collapse; font-size: var(--text-sm); margin: 8px 0; }
.latency-table th, .latency-table td { padding: 4px 10px 4px 0; text-align: right; white-space: nowrap; }
.latency-table th[scope="row"], .latency-table td:last-child { text-align: left; }
.latency-table thead th { color: var(--muted); font-weight: 500; }
.latency-turns { font-size: var(--text-xs); padding-left: 18px; }
