/* Presentation fidelity against the approved studies/motion Work and onboarding states.
   Loaded last. Presentation only: no markup meaning, API, persistence or consent behaviour lives here. */

/* ---- Work: task menu ---- */
#work-workspace .work-heading{margin-bottom:6px;align-items:center}
#work-workspace .work-heading h2{margin:0 0 2px}
#work-workspace .work-heading button{font-size:12px;min-height:34px;padding:6px 12px}
#work-workspace .work-setup,#work-workspace #research-assignment{display:inline-block;vertical-align:top;margin:2px 22px 2px 0;font-size:12px}#work-workspace .work-setup[open],#work-workspace #research-assignment[open]{display:block;margin-right:0}
#work-workspace .work-setup summary,#work-workspace #research-assignment>summary{padding:4px 0}
#work-workspace .work-layout{height:calc(100dvh - 225px);min-height:460px;border-radius:0}
#work-workspace .work-menu{padding:48px 8px 16px;background:#fbfdfb}
#work-workspace .work-menu h3{font-size:11px;font-weight:650;margin:0;padding:8px 12px}
#work-workspace .work-menu>p{font-size:12px;color:var(--color-muted);padding:8px 12px}
#work-workspace .work-task{padding:10px 12px;margin:3px 0;font-size:12px;line-height:1.5;border-radius:0}
#work-workspace .work-task strong{font-size:12px;font-weight:400}
#work-workspace .work-task small{font-size:11px;margin-top:3px}
#work-workspace .work-task small:last-of-type{font-size:12px;font-weight:500;color:#335f94}
#work-workspace .work-task[data-state=running]>small:first-of-type::before{content:"";display:inline-block;width:10px;height:10px;margin-right:6px;vertical-align:-1px;border:1.5px solid var(--color-line);border-top-color:var(--color-accent);border-right-color:var(--color-accent);border-radius:50%;animation:work-turn 1s linear infinite}
#work-workspace .work-task[data-state=waiting_input]>small:first-of-type,#work-workspace .work-task[data-state=failed]>small:first-of-type{color:var(--color-warning)}
@keyframes work-turn{to{transform:rotate(360deg)}}
#work-workspace .work-menu-toggle{width:34px;height:32px;padding:0;display:grid;place-items:center;background:#fff;color:var(--color-accent);font-size:16px}
#work-workspace .work-menu-toggle:hover{background:var(--color-leaf)}

/* ---- Work: session header, thread and composer ---- */
#work-workspace .work-task-header{align-items:center;padding:14px 24px}
#work-workspace .work-task-header h3{font-size:15px;margin:0 0 3px}
#work-workspace .work-task-header small{font-size:11px}
#work-workspace .work-task-header small[data-state=running]{color:var(--color-accent)}
#work-workspace .work-task-header small[data-state=waiting_input],#work-workspace .work-task-header small[data-state=failed]{color:var(--color-warning)}
#work-workspace .work-task-header button{min-height:34px}
#work-workspace .work-thread{padding:24px max(24px,calc((100% - 740px)/2));scrollbar-gutter:stable}
#work-workspace .work-conversation .v-message{max-width:740px}
#work-workspace .work-brief{margin:0 0 16px;padding:8px 14px}#work-workspace .work-brief summary{color:var(--color-accent);font-size:12px;padding:5px 0}
#work-workspace .work-result-card{border-radius:12px;background:#fbfdfb;margin:12px 0 24px}
#work-workspace .work-result-card button,#work-workspace .work-result-card a{font-size:12px;min-height:32px;padding:6px 12px;display:inline-flex;align-items:center}
#work-workspace .work-blocker{margin:0 0 20px;padding:16px;border:1px solid #cdbb85;border-radius:10px;background:var(--color-warning-bg);font-size:13px}
#work-workspace .work-blocker p{margin:0 0 10px}
#work-workspace .work-blocker button{font-size:12px;margin:0 6px 6px 0;background:#fff}
#work-workspace .work-blocker details{font-size:12px;color:var(--color-muted)}

#work-workspace [data-work-followup]{display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-areas:"text text text" "mode ver ver" "cost cost send" "opts opts opts";gap:0 12px;align-items:center;width:calc(100% - 48px);max-width:780px;margin:8px auto 14px;padding:10px 12px 8px 16px;border:1px solid var(--color-line);border-radius:20px;box-shadow:0 2px 8px #172e2906;background:#fff}
#work-workspace [data-work-followup]:focus-within{border-color:var(--color-accent);box-shadow:0 0 0 3px var(--color-leaf)}
#work-workspace [data-work-followup]>label:has(textarea){grid-area:text;align-self:stretch;margin:0;font-size:0;line-height:0}
#work-workspace [data-work-followup] textarea{display:block;width:100%;min-height:44px;max-height:160px;margin:0;padding:6px 2px;border:0;border-radius:0;outline:none;box-shadow:none;background:transparent;resize:none;font-size:14px;line-height:1.5}
#work-workspace [data-work-followup]>button:first-of-type{grid-area:send;grid-column:auto;grid-row:auto;align-self:end;justify-self:auto;max-width:132px;padding:7px 14px;border:1px solid var(--color-citron-line);border-radius:18px;background:var(--color-citron);color:var(--color-ink);font-size:12px;line-height:1.25;white-space:normal}
#work-workspace [data-work-followup]>.work-mode{grid-area:mode;display:flex;align-items:center;gap:8px;margin:6px 0 0;font-size:11px;color:var(--color-muted)}
#work-workspace [data-work-followup]>.work-mode select{width:auto;margin:0;padding:4px 8px;font-size:11px;border-radius:8px}
#work-workspace [data-work-followup]>.work-draft-version{grid-area:ver;margin:6px 0 0;font-size:11px;color:var(--color-muted)}
#work-workspace [data-work-followup]>.v-cost{grid-area:cost;margin:6px 0 0;font-size:12px;line-height:1.5;color:var(--color-ink)}
#work-workspace [data-work-followup]>.work-draft-options{grid-area:opts;margin:2px 0 0}
#work-workspace [data-work-followup] .work-draft-options summary{font-size:11px;color:var(--color-muted)}
#work-workspace .work-layout[data-menu] [data-work-followup]{grid-template-columns:auto minmax(0,1fr) auto!important}
#work-workspace .work-layout[data-menu] [data-work-followup]>.work-mode{display:flex}
#work-workspace [data-work-followup]>.work-mode{flex-wrap:wrap}
/* Narrow session column (preview open or phone): stack the composer. */
#work-workspace .work-layout[data-files=true] [data-work-followup]{grid-template-columns:minmax(0,1fr) auto!important;grid-template-areas:"text text" "mode mode" "ver ver" "cost cost" "opts send"}
#work-workspace .work-layout[data-files=true] [data-work-followup]>button:first-of-type{justify-self:end;margin-top:6px}
#work-workspace .work-layout[data-menu] [data-work-followup]>button:first-of-type{grid-area:send;grid-column:auto;grid-row:auto;justify-self:auto}
#work-workspace .work-other-actions{max-width:780px;width:calc(100% - 48px);margin:0 auto;padding:0 0 10px}
#work-workspace .work-turn-history,#work-workspace .work-scope,#work-workspace .work-execution{font-size:12px}
#work-workspace .work-turn-history summary,#work-workspace .work-scope summary,#work-workspace .work-execution summary,#work-workspace .work-other-actions summary{color:var(--color-accent);padding:5px 0}

/* ---- Work: empty, loading, preview ---- */
#work-workspace .work-empty{display:grid;place-content:center;justify-items:center;text-align:center;gap:6px;color:var(--color-muted)}
#work-workspace .work-empty h3{margin:0;color:var(--color-ink);font-size:15px}#work-workspace .work-empty p{margin:0;max-width:420px;font-size:13px;line-height:1.7}
#work-workspace .work-thread>p{font-size:13px;color:var(--color-muted);line-height:1.7}
#work-workspace .work-conversation>p{width:calc(100% - 48px);max-width:780px;margin:12px auto;font-size:13px;color:var(--color-muted)}
#work-workspace .work-loading{margin:24px 0;font-size:13px;color:var(--color-muted)}
#work-workspace .work-file-preview{background:#fbfdfc}
#work-workspace .work-file-preview>header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:14px 16px 14px 56px}
#work-workspace .work-file-preview>header button{font-size:11px;min-height:30px;padding:4px 10px}
#work-workspace .work-file-preview>[data-scroll-key]{padding:22px}

/* ---- Work: keyboard focus ---- */
#work-workspace :is(select,summary,input,button,a):focus-visible{outline:2px solid var(--color-accent);outline-offset:2px}
@media(prefers-reduced-motion:reduce){#work-workspace .work-task[data-state=running]>small:first-of-type::before{animation:none}}
@media(pointer:coarse){#work-workspace .work-menu-toggle,#work-workspace .work-task,#work-workspace .work-task-header button,#work-workspace .work-file-preview>header button{min-height:44px}#work-workspace .work-menu-toggle{width:44px}}

/* ---- Work: 390px and 320px ---- */
@media(max-width:760px){
  #work-workspace .work-layout{height:calc(100dvh - 210px);min-height:440px}
  #work-workspace .work-thread{padding:16px 14px}
  #work-workspace .work-task-header{padding:12px 14px 12px 58px}
  #work-workspace .work-task-header h3{font-size:14px}
  #work-workspace [data-work-followup]{width:calc(100% - 24px);margin:6px 12px 10px;padding:8px 10px 8px 14px}
  #work-workspace .work-other-actions{width:calc(100% - 24px)}
  #work-workspace .work-layout[data-menu] [data-work-followup]{grid-template-columns:minmax(0,1fr) auto!important;grid-template-areas:"text text" "mode mode" "ver ver" "cost cost" "opts send"}
  #work-workspace .work-layout[data-menu] [data-work-followup]>button:first-of-type{justify-self:end;margin-top:6px;max-width:132px}
  #work-workspace .work-task-header .actions{max-width:none}
  #work-workspace .work-result-card>div{flex-basis:100%}
  /* Never let a tall composer squeeze the thread away: the session scrolls instead. */
  #work-workspace .work-session-body{overflow-y:auto}
  #work-workspace .work-conversation{flex:1 0 auto;min-height:100%}
  #work-workspace .work-thread{flex:1 0 160px}
  #work-workspace [data-work-followup] textarea{min-height:36px}
}
@media(max-width:360px){
  #work-workspace .work-layout[data-menu] [data-work-followup]{grid-template-columns:minmax(0,1fr)!important;grid-template-areas:"text" "mode" "ver" "cost" "send" "opts"}
  #work-workspace .work-layout[data-menu] [data-work-followup]>button:first-of-type{max-width:none;padding:7px 14px}
  #work-workspace .work-task-header{flex-wrap:wrap}
  #work-workspace .work-heading{gap:8px}
}

/* ---- Onboarding: Village setup before the organisation exists ---- */
#village-host.v-centred .v-header{justify-content:space-between}
#village-host.v-centred .v-header strong{font-size:13px;font-weight:600;color:var(--color-muted)}
#village-host .v-mode{margin:0 0 6px;font-size:11px;text-align:center}
#village-host.v-centred .v-thread{max-height:none;flex:1 1 auto;scrollbar-gutter:auto;scrollbar-width:thin}
#village-host.v-centred .v-intro{padding:20px 0 14px}
#village-host.v-centred .v-thread:has(.v-setup) .v-intro{padding-top:6px}
#village-host.v-centred .v-thread:has(.v-setup) .v-mark{margin-bottom:14px}
#village-host .v-composer button{color:var(--color-ink);background:var(--color-citron);border-color:var(--color-citron-line)}
#village-host .v-composer button:disabled{background:var(--color-leaf);border-color:var(--color-line)}
#village-host .v-setup{border-radius:14px;background:#fbfdfb;padding:18px}
#village-host .v-setup>strong{display:block;margin-bottom:6px}
#village-host .v-setup p{font-size:13px;line-height:1.65;color:var(--color-muted);margin:6px 0}
#village-host .v-setup button{font-size:12px;margin:8px 8px 0 0;padding:8px 12px;background:#fff;color:var(--color-ink);border-color:var(--color-line)}
#village-host .v-setup button:first-of-type{background:var(--color-ink);color:#fff;border-color:var(--color-ink)}
#village-host .v-cost{color:var(--color-muted)}
#village-host .v-composer:focus-within{border-color:var(--color-accent);box-shadow:0 0 0 3px var(--color-leaf)}
#village-host .v-composer textarea:focus-visible{outline:none}
@media(max-width:620px){#village-host.v-centred .v-header strong{font-size:12px}#village-host.v-centred .v-thread:has(.v-setup) .v-intro h1{font-size:26px;margin-bottom:12px}}
/* canvas.css re-shows the header on phones with higher specificity; onboarding hides it at every width. */
body.has-shell.v-onboarding .app-header{display:none}

/* Work exposes the same Village action in its toolbar, outside the composer. */
body:has(.company-content[data-view=work]) #village-host.v-minimised .v-launch{display:none}
#work-workspace .work-heading>.actions{display:flex;gap:8px;flex-wrap:wrap}
@media(max-height:720px){
 #work-workspace .work-layout{min-height:430px;max-height:none}
 #work-workspace .work-session-body{overflow-y:auto}
 #work-workspace .work-conversation{flex:1 0 auto;min-height:100%}
 #work-workspace .work-thread{flex:1 0 150px;padding-top:12px;padding-bottom:12px}
 #work-workspace [data-work-followup]{margin-top:4px;margin-bottom:6px}
 #work-workspace .work-task-header{padding-top:10px;padding-bottom:10px}
}

#work-workspace .work-conversation h4{margin:10px 0}
#work-workspace .work-composer .work-draft-version{margin:2px 0}
/* Reclaim the generic 80px page footer in Work; consent remains in normal flow. */
body:has(.company-content[data-view=work]) main{padding-bottom:12px}
@media(min-width:761px) and (max-height:720px){#work-workspace .work-layout{height:calc(100dvh - 100px);min-height:500px}}

/* Conversational Work: the company budget is enforced at admission, outside the composer. */
#work-workspace [data-work-followup]{position:relative;display:block;margin:12px 24px 20px;padding:14px 56px 14px 16px;border-radius:20px}
#work-workspace [data-work-followup] textarea{display:block;width:100%;min-height:72px;max-height:200px;margin:0;padding:0;border:0;background:transparent;box-shadow:none;resize:vertical;font:inherit;line-height:1.6}
#work-workspace [data-work-followup] textarea:focus{outline:none}
#work-workspace [data-work-followup]:focus-within{border-color:var(--color-accent);box-shadow:0 0 0 3px var(--color-leaf)}
#work-workspace [data-work-followup]>.work-send{position:absolute;right:12px;bottom:12px;display:grid;place-items:center;width:36px;height:36px;margin:0;padding:8px;border-radius:10px;background:var(--color-lime,#e9f684)}
#work-workspace .work-reply-status{display:flex;align-items:center;gap:12px;color:var(--color-muted);font-size:13px}
#work-workspace .work-revision-note{display:block;margin-bottom:10px;font-size:12px;color:var(--color-muted)}
#work-workspace .work-revision-note button{border:0;padding:0 6px;background:transparent}
@media(max-width:760px){#work-workspace [data-work-followup]{margin:10px 12px 16px}}
#work-workspace .work-session-body{flex:1;min-height:0;overflow:hidden}
#work-workspace .work-conversation{flex:1 1 0;min-height:0}
#work-workspace .work-thread{flex:1 1 0;min-height:0}

/* Saved work is the agent's response, followed by its file attachment. */
#work-workspace .work-brief{max-width:85%;margin:0 0 30px auto;padding:14px 18px;border-radius:16px;background:var(--color-mist,#e8f3f6)}
#work-workspace .work-brief>small{display:none}
#work-workspace .work-brief p{margin:0;font-size:14px;line-height:1.7}
#work-workspace .work-conversation .artifact-markdown{margin:14px 0 20px;white-space:normal}
#work-workspace .work-conversation .artifact-markdown h1{font-size:23px;line-height:1.35}
#work-workspace .work-conversation .artifact-markdown h2{font-size:18px;margin-top:26px}
#work-workspace .work-conversation .artifact-markdown h3{font-size:16px}
#work-workspace .work-conversation .artifact-markdown p{margin:10px 0;line-height:1.75}
#work-workspace .work-file-card{display:flex;flex-wrap:nowrap;gap:14px;background:var(--color-surface,#fff);margin:24px 0 12px;padding:14px 16px;border-radius:14px;max-width:100%}
#work-workspace .work-file-icon{display:grid;place-items:center;flex:none;width:40px;height:44px;border-radius:10px;background:var(--color-mist,#e8f3f6);color:var(--color-accent);font-size:24px}
#work-workspace .work-file-card .work-file-open{display:block;flex:1;min-width:0;text-align:left;border:0;padding:0;background:transparent;border-radius:4px;font-size:14px;white-space:normal;overflow-wrap:anywhere}
#work-workspace .work-file-open strong{display:block;font-weight:650}
#work-workspace .work-file-open small{display:block;margin-top:5px;font-size:12px;color:var(--color-muted)}
#work-workspace .work-file-card .work-file-download{display:grid;place-items:center;flex:none;padding:8px;border:0;border-radius:8px;background:transparent}
#work-workspace .work-file-open:hover strong{text-decoration:underline}
@media(max-width:760px){#work-workspace .work-brief{max-width:95%}#work-workspace .work-file-card{padding:12px;gap:10px}}
#work-workspace .work-conversation .artifact-markdown{background:transparent;padding:0;border:0;border-radius:0}
/* No redundant title/status/files header above the conversation. */
#work-workspace .work-controls{display:flex;justify-content:flex-end;gap:8px;padding:8px 18px 0 50px}
#work-workspace .work-controls button{font-size:12px}
/* File preview: only the Markdown body and a dismiss control. */
#work-workspace .work-file-preview>header{display:flex;justify-content:flex-end;border:0;padding:10px 16px 0}
#work-workspace .work-file-preview .artifact-markdown{margin:0;background:transparent;padding:0;border:0}
/* New work starts with the conversation composer, never an assignment form. */
#work-workspace .work-chat-welcome{display:grid;place-content:center;text-align:center;min-height:180px;color:var(--color-muted)}
#work-workspace .work-chat-welcome h3{font-size:22px;font-weight:600;color:var(--color-ink)}
#work-workspace .work-composer-actions{position:absolute;right:12px;bottom:10px;display:flex;align-items:center;gap:10px;max-width:calc(100% - 24px)}
#work-workspace .work-composer-actions select{width:auto;max-width:190px;border:0;background:transparent;padding:6px 24px 6px 8px;font:inherit;font-size:12px;color:var(--color-muted);min-height:32px}
#work-workspace .work-composer-actions .work-send{display:grid;place-items:center;width:36px;height:36px;padding:8px;background:var(--color-lime,#e9f684);border-radius:10px}
#work-workspace .work-start-composer .select-field{width:auto;max-width:190px}
#work-workspace .work-start-composer .select-trigger{font-size:12px;padding:6px 28px 6px 8px;border:0;min-height:32px}
#work-workspace [data-work-start-chat]{position:relative;flex:none;display:block;width:calc(100% - 48px);max-width:780px;margin:12px auto 20px;padding:12px 16px 48px;border:1px solid var(--color-line);border-radius:20px;background:var(--color-surface,#fff)}
#work-workspace [data-work-start-chat] textarea{display:block;box-sizing:border-box;width:100%;min-height:32px;max-height:200px;margin:0;padding:0;border:0;outline:none;box-shadow:none;resize:vertical;background:transparent;font:inherit;line-height:1.6}
#work-workspace [data-work-start-chat]:focus-within{border-color:var(--color-accent);box-shadow:0 0 0 3px var(--color-leaf)}
@media(max-width:760px){#work-workspace [data-work-start-chat]{width:calc(100% - 24px);margin:10px auto 16px}}
@media(max-width:760px){#work-workspace .work-layout:has(.work-chat-session){height:calc(100dvh - 320px);min-height:360px}}
/* Reserve the collapsed menu control's row instead of covering the first avatar. */
#work-workspace .work-layout[data-menu=false] .work-chat-session::before{content:"";display:block;flex:0 0 42px}

#village-host .v-chat-status{font-size:12px;color:var(--color-muted);line-height:1.6;margin:10px 2px 0}
