/* (WORKERS) Dashob Workers - the worker surfaces that cannot be on screen at first paint: the
 * appearance popover on the New worker screen, the Change appearance dialog of a worker that
 * exists, the Telegram dialog and Worker settings, which all open on a click.
 *
 * This sheet is lazy (media="print", promoted on window load, or by workers.js the first time it
 * draws the form that owns the popover). Everything a restored tab can show - the sidebar rows, the
 * Character, the New worker screen, the overview, the home strip - is in shell.css with the --wk-*
 * tokens, because a reload restores exactly those and a lazy sheet would leave them unstyled until
 * load (SPEC section 8).
 *
 * Scoped under .cos-root and coloured from the shell's tokens, so light, dark and the user's own
 * accent all apply. `npm run lint:theme` reads this file too. */

.cos-root .wk-pop { position: absolute; top: calc(100% + 8px); left: 50%; z-index: 5; width: 380px; max-width: calc(100vw - 32px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--cos-line-2); border-radius: var(--cos-radius-card); background: var(--cos-surface); box-shadow: var(--cos-shadow-pop); }
.cos-root .wk-pop[hidden] { display: none; }
.cos-root .wk-seg { display: flex; gap: 6px; padding: 3px; border-radius: var(--cos-radius-ctl); background: var(--cos-surface-2); }
.cos-root .wk-seg-b { flex: 1 1 0; height: 28px; border-radius: calc(var(--cos-radius-ctl) - 2px); font-size: 12.5px; color: var(--cos-ink-3); }
.cos-root .wk-seg-b:hover { color: var(--cos-ink-1); }
.cos-root .wk-seg-b.is-on { font-weight: 600; color: var(--cos-ink-1); background: var(--cos-surface); box-shadow: var(--cos-shadow-card); }
.cos-root .wk-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cos-root .wk-thumb { display: flex; justify-content: center; padding: 1px; border: 2px solid transparent; border-radius: calc(var(--cos-radius-card) - 3px); }
.cos-root .wk-thumb:hover { border-color: var(--cos-line-2); }
.cos-root .wk-thumb.is-on { border-color: var(--cos-accent); }
/* the field itself carries the boundary and the focus ring; the glyph is laid over its left pad */
.cos-root .wk-look { position: relative; display: block; color: var(--cos-muted); }
.cos-root .wk-look input::placeholder { color: var(--cos-muted); font-weight: 400; opacity: 1; }
.cos-root .wk-look svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.cos-root .wk-look input { display: block; width: 100%; height: 36px; padding: 0 10px 0 34px; border: 1px solid var(--cos-line-ctl); border-radius: var(--cos-radius-ctl); background: transparent; font: inherit; font-size: 13px; color: var(--cos-ink-1); outline: none; transition: border-color .12s ease, box-shadow .12s ease; }
.cos-root .wk-look input:focus { border-color: rgba(var(--cos-accent-rgb), .6); box-shadow: 0 0 0 3px var(--cos-accent-soft); }
.cos-root .wk-pop-foot { display: flex; justify-content: flex-end; }
.cos-root .wk-done { height: 28px; padding: 0 10px; border-radius: var(--cos-radius-ctl); font-size: 13px; font-weight: 600; color: var(--cos-accent-text); }
.cos-root .wk-done:hover { background: var(--cos-accent-soft); color: var(--wk-on-soft); }

/* Change appearance, for a worker that already exists: the same picker, in a dialog over the page.
   (Its buttons are the cards' .wk-btn, styled in shell.css.)
   The scrim's class is this sheet's own. It was .wk-ov, which is also the Workers overview page in
   shell.css: once this sheet was promoted the overview itself became a fixed, dimmed layer over
   the tab strip, the sidebar and the address bar. A rule here may only name a class shell.css
   styles when it is scoped under one shell.css does not (hub/test/workers-shell-foundation).
   Its layer is UNDER the shell's own question (.cos-promptov, 300 in shell.css): a dialog here
   asks "Disconnect Telegram?" through the house confirm, and at 320 the question was painted
   beneath the dialog that asked it - the buttons looked dead and Enter answered a question nobody
   had seen. Over the page, the palette and the tab strip (260 at most); under every prompt. */
.cos-root .wk-scrim { position: fixed; inset: 0; z-index: 290; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: rgba(8, 11, 16, .42); }
.cos-root .wk-dlg { width: 380px; max-width: 100%; min-width: 0; max-height: min(86dvh, 720px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px; border: 1px solid var(--cos-line-1); border-radius: var(--cos-radius-card); background: var(--cos-surface); box-shadow: var(--cos-shadow-pop); color: var(--cos-ink-1); }
.cos-root .wk-dlg-t { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.1px; color: var(--cos-ink-1); }
.cos-root .wk-dlg-sub { margin: -8px 0 0; font-size: 12.5px; color: var(--cos-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cos-root .wk-dlg-stage { display: flex; justify-content: center; }
.cos-root .wk-dlg .wk-err:empty { display: none; }
.cos-root .wk-dlg-foot { display: flex; justify-content: flex-end; gap: 8px; }
.cos-root .wk-dlg .wk-btn[aria-busy="true"] { opacity: .65; pointer-events: none; }

/* (WORKERS-5) Telegram: the two steps, the token field, the link. In the house dialog (.wk-dlg). */
.cos-root .wk-dlg.wk-tg { width: 440px; }
.cos-root .wk-tg-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--cos-ink-2); }
.cos-root .wk-tg-steps b { font-weight: 600; color: var(--cos-ink-1); }
.cos-root .wk-tg-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--cos-ink-3); }
.cos-root .wk-tg-in, .cos-root .wk-set-in { display: block; width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--cos-line-ctl); border-radius: var(--cos-radius-ctl); background: transparent; font: inherit; font-size: 14px; font-weight: 400; color: var(--cos-ink-1); outline: none; transition: border-color .12s ease, box-shadow .12s ease; }
.cos-root .wk-tg-in:focus { border-color: rgba(var(--cos-accent-rgb), .6); box-shadow: 0 0 0 3px var(--cos-accent-soft); }
.cos-root .wk-set-in:focus { border-color: rgba(var(--cos-accent-rgb), .6); box-shadow: 0 0 0 3px var(--cos-accent-soft); }
.cos-root .wk-tg-in::placeholder { color: var(--cos-muted); opacity: 1; }
.cos-root .wk-tg-in:disabled { opacity: .6; }
/* (The bot token's field is drawn as dots by a style on the element itself, workers.js tgBodyHTML:
   this sheet is lazy, and a token must never wait for it to be hidden.) */
.cos-root .wk-tg-ok, .cos-root .wk-tg-wait, .cos-root .wk-tg-bad { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 14px; line-height: 1.45; color: var(--cos-ink-1); }
.cos-root .wk-tg-ok svg { flex: none; margin-top: 1px; color: var(--cos-green-text); }
.cos-root .wk-tg-bad { font-size: 13px; color: var(--cos-red-text); }
.cos-root .wk-tg-bad svg { flex: none; margin-top: 1px; }
.cos-root .wk-tg-wait .wk-spin { flex: none; margin-top: 2px; color: var(--cos-muted); }
.cos-root .wk-tg-open { align-self: flex-start; text-decoration: none; }
.cos-root .wk-tg-open svg { color: inherit; }
.cos-root .wk-tg-url { margin: 0; padding: 8px 10px; border-radius: var(--cos-radius-ctl); background: var(--cos-surface-2); font-size: 12px; line-height: 1.4; color: var(--cos-ink-3); overflow-wrap: anywhere; user-select: all; }
.cos-root .wk-tg [data-wktgbody] .wk-dlg-sub { margin: 0; white-space: normal; }
.cos-root .wk-tg [data-wktgbody] { display: flex; flex-direction: column; gap: 12px; }
.cos-root .wk-dlg .wk-btn-danger { color: var(--cos-red-text); border-color: color-mix(in srgb, var(--cos-red) 45%, transparent); }
.cos-root .wk-dlg .wk-btn-danger:hover { border-color: var(--cos-red); }
.cos-root .wk-dlg .wk-btn-danger:disabled { border-color: var(--cos-line-2); color: var(--cos-muted); }
.cos-root .wk-tg .wk-dlg-foot .wk-btn-danger { margin-right: auto; }

/* (WORKERS-5) Worker settings: one dialog, sections under small caps, Save at the foot. */
.cos-root .wk-dlg.wk-set { width: 560px; gap: 14px; }
.cos-root .wk-dlg.wk-set.is-del { width: 440px; }
/* a dialog taller than the window scrolls; nothing in it is squeezed to make it fit (a column flex
   box shrinks its children first, and the line under the title was shrunk to nothing) */
.cos-root .wk-dlg.wk-set > *, .cos-root .wk-dlg.wk-tg > * { flex: none; }
.cos-root .wk-set-body { display: flex; flex-direction: column; gap: 18px; }
.cos-root .wk-set .wk-rad { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 28px; padding: 2px 0; font-size: 13.5px; color: var(--cos-ink-3); text-align: left; }
.cos-root .wk-set-sec { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cos-root .wk-set-k { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--cos-muted); }
.cos-root .wk-set-f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--cos-ink-2); }
.cos-root .wk-set-f b { font-weight: 600; color: var(--cos-ink-1); }
.cos-root .wk-set-f-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.cos-root .wk-set-sel { width: auto; min-width: 120px; padding-right: 6px; }
.cos-root .wk-set-p { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--cos-ink-3); }
.cos-root .wk-set-p b { font-weight: 600; color: var(--cos-ink-1); }
.cos-root .wk-set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cos-root .wk-set-row .wk-btn { flex: none; }
.cos-root .wk-set-ap { display: flex; align-items: flex-start; gap: 16px; }
.cos-root .wk-set-ap .wk-dlg-stage { flex: none; }
.cos-root .wk-set-pick { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cos-root .wk-set-pick .wk-thumbs { display: none; }   /* the figure beside the radios already shows the pick */
.cos-root .wk-set-devs { display: flex; flex-direction: column; gap: 2px; }
.cos-root .wk-set .wk-dev.is-no { cursor: default; }
.cos-root .wk-set .wk-dev.is-no:hover { background: transparent; }
.cos-root .wk-set .wk-dev.is-no .wk-dev-box { visibility: hidden; }
.cos-root .wk-set-danger { padding-top: 16px; border-top: 1px solid var(--cos-line-3); }
.cos-root .wk-set.is-del .wk-set-danger { padding-top: 0; border-top: 0; }
.cos-root .wk-set.is-del .wk-set-danger > .wk-set-k { display: none; }
.cos-root .wk-set-danger .wk-set-row { justify-content: flex-end; }
@media (max-width: 560px) {
  .cos-root .wk-set-ap { flex-direction: column; align-items: stretch; }
  .cos-root .wk-set-ap .wk-dlg-stage { align-self: center; }
  /* 16px in a field on a phone: anything smaller and iOS zooms the page to it */
  .cos-root .wk-tg-in, .cos-root .wk-set-in { height: 44px; font-size: 16px; }
  .cos-root .wk-dlg .wk-btn { height: 44px; }
  .cos-root .wk-set .wk-rad, .cos-root .wk-set .wk-dev { min-height: 44px; }
}

/* in a narrow tile the popover has no room to float beside anything: it opens in the flow */
@container (max-width: 860px) {
  .cos-root .wk-pop { position: static; width: 100%; max-width: 380px; transform: none; box-shadow: none; }
}

/* 44px under a finger, as a ring: nothing here paints a different size for it (see the block of the
   same shape in shell.css). The look field's ring hangs off its label, which is what focuses it. */
@media (pointer: coarse), (hover: none) {
  .cos-root .wk-pop button, .cos-root .wk-dlg button { min-height: 0; min-width: 0; }
  .cos-root .wk-seg-b, .cos-root .wk-done { position: relative; }
  .cos-root .wk-seg-b::after, .cos-root .wk-done::after, .cos-root .wk-look::after {
    content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%);
  }
}
