/* Bot Doctor workdesks — components. All color, type, and shape come from themes.css tokens. */
* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; transition: background-color .2s ease; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: var(--heading-weight); letter-spacing: var(--heading-track); text-wrap: balance; margin: 0; }
h1 { font-size: var(--h1); line-height: 1.15; }
h2 { font-size: 1.08rem; }
h3 { font-size: .95rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.label { font: 600 .7rem/1.2 var(--label-font); text-transform: uppercase; letter-spacing: .08em; color: var(--soft); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

.topbar .desk-mark { width: 26px; height: 26px; border-radius: 6px; font-size: .58rem; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: var(--btn-radius); border: 1px solid var(--line-strong); background: transparent; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.quiet { border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--text); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: .88rem; }
.btn.icon-only { width: 38px; padding: 0; }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; color: var(--muted); }
.input, .textarea, .select { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--panel); }
.textarea { resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--soft); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }

/* State chips */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font: 600 .7rem/1 var(--mono); letter-spacing: .03em; background: var(--surface); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.plain::before { display: none; }

/* App frame */
.app { display: grid; grid-template-rows: 56px minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.wordmark { font: 650 1.05rem/1 var(--display); letter-spacing: -.02em; color: var(--text); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.wordmark .cursor { width: 8px; height: 8px; border-radius: var(--mark-dot-radius); background: var(--mark-dot); display: inline-block; }
:root[data-style="signal"] .wordmark .cursor { box-shadow: 0 0 0 4px color-mix(in srgb, var(--mark-dot) 25%, transparent); }
.topbar .grow { flex: 1; }
.mode-pill { font: 600 .7rem/1 var(--mono); color: var(--soft); border: 1px solid var(--line); padding: 6px 8px; border-radius: 999px; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface); color: var(--text);
  font: 600 .72rem/1 var(--sans); border: 1px solid var(--line); flex: none; }
.menu-btn { display: none; }

.body { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 0; }
.body.with-assistant { grid-template-columns: 224px minmax(0, 1fr) 320px; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-line); padding: 16px 12px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.desk-id { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.desk-mark { width: 34px; height: 34px; border-radius: var(--mark-radius); display: grid; place-items: center; flex: none;
  font: 500 .72rem/1 var(--mono); color: #fff; letter-spacing: .02em; }
.desk-id strong { display: block; font-size: .92rem; line-height: 1.25; }
.desk-id small { color: var(--sidebar-muted); font-family: var(--label-font); font-size: .74rem; text-transform: capitalize; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--sidebar-muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav a[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-text); box-shadow: var(--active-shadow); }
.nav a[aria-current="page"] .icon { color: var(--accent); }
:root[data-style="signal"] .nav a[aria-current="page"] .icon { color: var(--primary); }
.nav .count { margin-left: auto; font: 600 .72rem/1 var(--mono); color: var(--sidebar-muted); }
.sidebar .bottom { margin-top: auto; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--sidebar-muted); text-decoration: none; font-size: .88rem; padding: 4px 6px; }
.back-link:hover { color: var(--sidebar-text); }

.main { overflow-y: auto; min-width: 0; }
.page { max-width: 1040px; margin: 0 auto; padding: 28px 28px 64px; display: grid; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.crumb { font: 500 .76rem/1 var(--label-font); color: var(--soft); margin-bottom: 10px; letter-spacing: .02em; }

/* Sections and lists */
.section { display: grid; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); }
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); min-width: 0; }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 500; overflow-wrap: anywhere; }
.list-row .meta { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
a.list-row { color: inherit; text-decoration: none; }
a.list-row:hover, button.list-row:hover { background: var(--hover); }
button.list-row { width: 100%; text-align: left; border: 0; background: transparent; border-top: 1px solid var(--line); }
button.list-row:first-child { border-top: 0; }
.empty { padding: 20px 16px; color: var(--muted); }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: .9rem; }
.note .icon { margin-top: 2px; }

/* Home */
.home { max-width: 760px; }
.home-hero { display: grid; gap: 8px; padding-top: 12px; }
.home-hero h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.desk-row .desk-mark { width: 40px; height: 40px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--line); }

/* Overview */
.attention { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 16px; display: grid; gap: 6px; text-decoration: none; color: inherit; }
.tile:hover { background: var(--hover); }
.tile .big { font: 600 2rem/1 var(--num-font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Content studio */
.studio { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.draft-list .list-row { padding: 12px 14px; }
.draft-list .list-row[aria-current="true"] { background: var(--accent-soft); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font-family: var(--sans); color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
:root[data-style="signal"] .tabs button[aria-selected="true"] { border-bottom-color: var(--primary); }
.editor { display: grid; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.editor-body { padding: 20px; display: grid; gap: 18px; }
.title-input { font: var(--heading-weight) 1.5rem/1.25 var(--display); letter-spacing: var(--heading-track); border: 0; background: transparent; padding: 0; width: 100%; }
.title-input:focus { outline: none; }
.platforms { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--btn-radius); border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font-weight: 500; }
.toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.caption { min-height: 200px; font-size: 1rem; }
.counts { display: flex; gap: 16px; flex-wrap: wrap; font: .76rem/1.2 var(--mono); color: var(--soft); }
.counts .over { color: var(--bad); }
.editor-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.save-state { font: .76rem/1 var(--mono); color: var(--soft); }
.checks { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.check .icon { margin-top: 2px; }
.check.ok .icon { color: var(--ok); }
.check.warn .icon { color: var(--warn); }

/* Post previews (neutral, not platform replicas) */
.previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.preview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: .88rem; }
.preview-head .desk-mark { width: 28px; height: 28px; border-radius: 50%; font-size: .6rem; }
.preview-head .platform { margin-left: auto; color: var(--soft); }
.preview-img { background: var(--surface); display: grid; place-items: center; color: var(--soft); font: .75rem/1.2 var(--mono); }
.preview-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview.fb .preview-img { aspect-ratio: 1.91 / 1; }
.preview.ig .preview-img { aspect-ratio: 1 / 1; }
.preview-text { padding: 10px 12px 14px; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview-text .more { color: var(--soft); }

/* Work */
.composer { display: flex; gap: 10px; padding: 12px; }
.composer .input { flex: 1; }
.evidence { font: .76rem/1.3 var(--mono); color: var(--muted); overflow-wrap: anywhere; }

/* Assistant */
.assistant { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.assistant-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.assistant-body { padding: 16px; display: grid; gap: 18px; overflow-y: auto; align-content: start; flex: 1; }
.assistant-foot { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.action { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; text-align: left; }
.action:hover { background: var(--hover); }
.bubble { padding: 10px 12px; border-radius: var(--radius); background: var(--surface); font-size: .9rem; }
.bubble.me { background: var(--accent-soft); }

/* Sign-in */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.signin-card { width: min(420px, 100%); display: grid; gap: 18px; padding: 28px; }
.signin-card .wordmark { font-size: 1.3rem; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); font-size: .9rem; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* Menus */
.popover { position: absolute; top: 48px; right: 12px; z-index: 40; width: 240px; padding: 8px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.popover button, .popover a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; color: inherit; text-decoration: none; }
.popover button:hover, .popover a:hover { background: var(--hover); }
.popover .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.switcher { position: relative; min-width: 0; }
.switcher > .btn { max-width: 100%; }
.desk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.switcher .popover { left: 0; right: auto; top: 44px; }

/* Responsive */
@media (max-width: 1180px) {
  .body.with-assistant { grid-template-columns: 224px minmax(0, 1fr); }
  .assistant { position: fixed; right: 0; top: 56px; bottom: 0; width: min(360px, 100%); z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 980px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .previews { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .body, .body.with-assistant { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 56px; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 56px 0 0 260px; background: rgba(0, 0, 0, .35); z-index: 25; border: 0; }
  .page { padding: 20px 16px 56px; }
  .attention { grid-template-columns: minmax(0, 1fr); }
  .inline-form { grid-template-columns: minmax(0, 1fr) !important; }
  .mode-pill { display: none; }
  .assistant { width: 100%; }
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar .desk-name, .hide-sm { display: none; }
  .wordmark-text { font-size: .95rem; }
  .page-head .btn.primary { width: 100%; }
  .title-input { font-size: 1.1rem; }
  .editor-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── Direction-specific structure ── */
/* Ink: the desk color marks the top of the page as the desk's only color. */
:root[data-style="ink"] .app[style] .topbar { border-bottom: 2px solid var(--desk); }
:root[data-style="ink"] .nav a[aria-current="page"]::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--desk); margin-left: auto; }
:root[data-style="ink"] .nav a[aria-current="page"] .count { margin-left: 8px; }
/* Signal: operational density, uppercase labels, readout tiles. */
:root[data-style="signal"] .label, :root[data-style="signal"] .crumb { text-transform: uppercase; letter-spacing: .1em; }
:root[data-style="signal"] .page { gap: 18px; }
:root[data-style="signal"] .list-row { padding: 11px 14px; }
:root[data-style="signal"] .tile { border-top: 3px solid var(--line-strong); }
:root[data-style="signal"] .tile:first-child { border-top-color: var(--primary); }
:root[data-style="signal"] .topbar { background: var(--panel); }
:root[data-style="signal"] .sidebar .desk-mark { box-shadow: 0 0 0 2px var(--sidebar-active); }
/* Studio: softer rhythm, larger headings, cards that float on the warm ground. */
:root[data-style="studio"] .page { gap: 28px; padding-top: 36px; }
:root[data-style="studio"] .list-row { border-top-color: var(--line); padding: 16px 18px; }
:root[data-style="studio"] .topbar { border-bottom-color: transparent; }
:root[data-style="studio"] .sidebar { padding-top: 20px; }
:root[data-style="studio"] .note { border-radius: var(--radius-lg); }
:root[data-style="studio"] .preview, :root[data-style="studio"] .input, :root[data-style="studio"] .textarea, :root[data-style="studio"] .select { border-radius: var(--radius); }

/* Style dock (sample-data preview only) */
.style-dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 45; display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.style-dock .label { white-space: nowrap; }
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .85rem; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.style-dock .mode { border: 1px solid var(--line-strong); background: transparent; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
@media (max-width: 760px) { .style-dock { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); padding-left: 8px; } .style-dock .label { display: none; } }

/* Signal vitals strip (monitor readout of the desk's connections) */
.vitals { display: none; }
:root[data-style="signal"] .vitals { display: flex; gap: 4px; margin-right: 6px; }
.vital { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px solid var(--line); border-radius: var(--radius);
  font: 600 .7rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--soft); background: var(--surface); }
.vital::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.vital.ok { color: var(--text); } .vital.ok::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.vital.bad::before { background: var(--bad); }
@media (max-width: 1100px) { :root[data-style="signal"] .vitals { display: none; } }
/* Studio greeting */
.greet { display: none; }
:root[data-style="studio"] .greet { display: block; font: 500 1rem/1.2 var(--sans); color: var(--muted); margin-bottom: -18px; }
:root[data-style="studio"] .page-head h1 { font-size: 2.4rem; }
:root[data-style="studio"] .desk-id .desk-mark { width: 40px; height: 40px; border-radius: 14px; }
:root[data-style="studio"] .chip, :root[data-style="studio"] .mode-pill { font-family: var(--sans); letter-spacing: 0; }
:root[data-style="studio"] .page-head .crumb { display: none; }

/* Image slot */
.image-slot { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); }
.image-slot.drop { border-style: dashed; cursor: pointer; color: var(--muted); }
.image-slot.drop:hover { background: var(--hover); }
.image-slot.drop strong { color: var(--text); font-weight: 600; }
.image-slot .thumb { width: 88px; height: 88px; object-fit: cover; border-radius: calc(var(--radius) - 2px); background: var(--surface); flex: none; display: grid; place-items: center; font-size: .75rem; color: var(--soft); }
label.btn { cursor: pointer; }
input[type=file].sr-only:focus-visible + * { outline: 2px solid var(--accent); }
/* Desk settings */
.desk-settings { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 14px; padding: 16px; align-items: end; }
.desk-settings .swatches, .desk-settings .row:last-child { grid-column: 1 / -1; }
.swatches { border: 0; padding: 0; margin: 0; }
.swatches legend { font-size: .85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.swatch { width: 30px; height: 30px; border-radius: 50%; background: var(--c); display: inline-grid; place-items: center; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.swatch input[type=radio] { appearance: none; margin: 0; width: 100%; height: 100%; border-radius: 50%; cursor: pointer; }
.swatch input[type=radio]:checked { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.swatch input[type=radio]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.swatch.custom { background: conic-gradient(#b8483e, #a8742a, #5c7a4f, #2f7a74, #3d6b8f, #8a5a9e, #b8483e); }
.swatch.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
@media (max-width: 760px) { .desk-settings { grid-template-columns: minmax(0, 1fr); } }
