/* Agent Desk components. All color, type, and shape come from themes.css tokens.
   Structure: flat rows and thin rules; bordered boxes only for working surfaces (editors, composers, menus). */
* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--text); text-underline-offset: 4px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: currentColor; }
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.2; }
h2 { font-size: 1rem; line-height: 1.4; letter-spacing: -.01em; }
h3 { font-size: .93rem; letter-spacing: -.01em; }
p { margin: 0; }
::selection { background: var(--line-strong); color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; 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: 400 .78rem/1.3 var(--label-font); color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
/* chevron-left is the only chevron glyph; forward affordances rotate it. */
.desk-row > .icon:last-child, .step-go .icon, .brain-row-read > .icon:last-child { transform: rotate(180deg); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border-radius: var(--btn-radius); border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font: 500 .82rem/1 var(--mono); white-space: nowrap; text-decoration: none; transition: background-color .15s, border-color .15s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.quiet { border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--text); background: var(--hover); }
.btn.small { min-height: 32px; padding: 0 10px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.small.icon-only { width: 32px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--sidebar-active); border-color: var(--line-strong); color: var(--text); }
.field { display: grid; gap: 6px; }
.field > span, .field > legend { font: 400 .8rem/1.3 var(--mono); color: var(--muted); }
.input, .textarea, .select { width: 100%; min-height: 38px; padding: 8px 11px; border-radius: var(--radius); border: 1px solid var(--field-line);
  background: var(--panel); color: var(--text); caret-color: var(--text); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.textarea { resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--soft); }
.input[disabled], .textarea[disabled] { opacity: .7; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }

/* Status: text with a dot. Never styled as a button. */
.chip { display: inline-flex; align-items: center; gap: 7px; font: 400 .78rem/1.3 var(--mono); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; }
.chip.ok { color: var(--ok); } .chip.ok::before { background: var(--ok); }
.chip.warn { color: var(--warn); } .chip.warn::before { background: var(--warn); }
.chip.bad { color: var(--bad); } .chip.bad::before { background: var(--bad); }
.chip.plain::before { display: none; }

/* App frame */
.app { display: grid; grid-template-rows: 56px minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 16px 0 12px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.home-link { padding: 0 8px; }
.wordmark { font: 500 .98rem/1 var(--mono); letter-spacing: -.03em; color: var(--text); display: inline-flex; align-items: center; white-space: nowrap; }
.wordmark .cursor { color: var(--muted); margin-left: 1px; }
.topbar .grow { flex: 1; }
.topbar .sep { width: 1px; height: 20px; background: var(--line); flex: none; }
.mode-pill { font: 400 .75rem/1 var(--mono); color: var(--soft); white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface); color: var(--text);
  font: 500 .72rem/1 var(--mono); border: 1px solid var(--line-strong); flex: none; }
button.avatar:hover { background: var(--hover); }
.menu-btn { display: none; }

.body { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 0; }
.body.with-assistant { grid-template-columns: 232px minmax(0, 1fr) 320px; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-line); padding: 18px 12px 16px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.desk-id { display: flex; align-items: center; gap: 12px; padding: 0 8px 18px; border-bottom: 1px solid var(--sidebar-line); min-width: 0; }
.desk-id > div { min-width: 0; }
.desk-mark { width: 36px; height: 36px; border-radius: var(--mark-radius); display: grid; place-items: center; flex: none;
  font: 500 .72rem/1 var(--mono); color: #fbf9f3; letter-spacing: .02em; }
.desk-id strong { display: block; font: 500 .93rem/1.3 var(--sans); overflow-wrap: anywhere; }
.desk-mark-image { background: #fff; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(36, 35, 31, .12); }
.desk-mark-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.desk-id small { color: var(--sidebar-muted); font: 400 .78rem/1.4 var(--mono); text-transform: capitalize; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px; border-radius: var(--radius); color: var(--sidebar-muted); text-decoration: none; font: 400 .86rem/1.3 var(--mono); }
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav a[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-text); }
.nav .count { margin-left: auto; font: 400 .75rem/1 var(--mono); color: var(--sidebar-muted); }
.sidebar .bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--sidebar-line); }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--sidebar-muted); text-decoration: none; font: 400 .8rem/1 var(--mono); padding: 0 8px; }
.back-link:hover { color: var(--sidebar-text); }

.main { overflow-y: auto; min-width: 0; }
.page { max-width: 1080px; margin: 0 auto; padding: 32px 32px 72px; display: grid; gap: 28px; align-content: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding-bottom: 4px; }
.page-head > div:first-child { min-width: 0; max-width: 68ch; }
.page-head .sub { color: var(--muted); margin-top: 8px; }
.crumb { font: 400 .78rem/1.3 var(--label-font); color: var(--soft); margin-bottom: 10px; }

/* Sections and lists: flat rows between thin rules */
.section { display: grid; gap: 12px; }
.panel { background: transparent; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; 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; }
.list-row > .icon:first-child { color: var(--muted); }
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); border-radius: 0; }
button.list-row:first-child { border-top: 0; }
.empty { padding: 20px 4px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--muted); font-size: .88rem; }
.note .icon { margin-top: 3px; }

/* Home */
.home { max-width: 780px; }
.home-hero { display: grid; gap: 8px; }
.desk-row .desk-mark { width: 40px; height: 40px; }
.desk-row > .icon:last-child { color: var(--soft); }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }

/* Overview: one summary strip, not a tile grid */
.attention { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.tile { padding: 16px 18px 16px 4px; display: grid; gap: 4px; text-decoration: none; color: inherit; min-width: 0; }
.tile + .tile { border-left: 1px solid var(--line); padding-left: 18px; }
.tile:hover { background: var(--hover); }
.tile .big { font: 500 1.35rem/1.2 var(--num-font); font-variant-numeric: tabular-nums; }
.tile .big .muted { font-size: .9rem; }
.tile > .muted { font-size: .84rem; }

/* Content studio */
.studio { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.markup-panel { overflow: hidden; }
.markup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 14px 4px; flex-wrap: wrap; }
.markup-head h2 { margin-bottom: 4px; }
.markup-head p { font-size: .86rem; }
.markup-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.markup-actions .select { width: min(240px, 100%); min-height: 32px; padding: 4px 8px; }
#markup-canvas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 250px); gap: 14px; padding: 4px 4px 16px; min-width: 0; }
.markup-tools { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.markup-tools button, .comment-card button { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); color: var(--muted); padding: 7px 9px; font: 500 .76rem/1 var(--mono); }
.markup-tools button:hover, .comment-card button:hover { color: var(--text); background: var(--hover); }
.markup-tools button[aria-pressed="true"] { color: var(--primary-ink); background: var(--primary); border-color: var(--primary); }
.markup-stage { position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; line-height: 0; }
.markup-stage img { display: block; width: 100%; object-fit: contain; }
.markup-stage canvas { position: absolute; inset: 0; width: 100%; cursor: crosshair; }
.markup-text { display: none; position: absolute; z-index: 2; width: min(50%, 280px); min-height: 48px; line-height: 1.35; resize: both; border: 2px solid var(--mark-ink); border-radius: var(--radius); background: #fbf9f3; color: #24231f; padding: 6px; transform: translateY(-1.25em); }
.comment-rail { display: grid; align-content: start; gap: 8px; min-width: 0; max-height: 540px; overflow: auto; padding-right: 2px; }
.comment-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; gap: 8px; min-width: 0; }
.comment-card.selected { border-color: var(--text); }
.comment-card button[data-select] { display: flex; gap: 8px; align-items: center; text-transform: capitalize; text-align: left; }
.comment-card b { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: var(--mark-ink); color: #fff; font: 500 .72rem/1 var(--mono); }
.comment-card textarea { width: 100%; min-height: 60px; resize: vertical; border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 7px; font: .84rem/1.4 var(--sans); }
.comment-card .comment-list { display: grid; gap: 6px; }
.comment-card .comment-list p { margin: 0; overflow-wrap: anywhere; font-size: .84rem; line-height: 1.4; }
.markup-save-state { padding: 0 4px 14px; color: var(--soft); font: .76rem/1 var(--mono); }
.draft-list .list-row { padding: 12px 10px; }
.draft-list .list-row[aria-current="true"] { background: var(--sidebar-active); }
.draft-list .title { font-size: .92rem; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; font: 400 .84rem/1.3 var(--mono); color: var(--muted); border-bottom: 1px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.editor { display: grid; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.editor-head .row { gap: 12px; }
.editor-body { padding: 20px; display: grid; gap: 18px; }
.title-input { font: var(--heading-weight) 1.35rem/1.3 var(--display); letter-spacing: var(--heading-track); border: 0; border-bottom: 1px solid transparent; background: transparent; padding: 2px 0 6px; width: 100%; border-radius: 0; }
.title-input:hover { border-bottom-color: var(--line); }
.title-input:focus-visible { outline: 0; border-bottom-color: var(--focus); }
.platforms { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 12px; border-radius: var(--btn-radius); border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font: 400 .82rem/1 var(--mono); }
.toggle:hover { color: var(--text); background: var(--hover); }
.toggle[aria-pressed="true"] { border-color: var(--text); color: var(--text); background: var(--sidebar-active); }
.caption { min-height: 200px; font-size: .95rem; }
.counts { display: flex; gap: 16px; flex-wrap: wrap; font: .76rem/1.3 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); }
.proof-confirmation { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface); font-size: .88rem; }
.checks { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; }
.check .icon { margin-top: 3px; }
.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: var(--radius); 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); }
/* Inbox chrome is neutral; the desk's own identity comes only from the preview model. */
.email-inbox-preview { display: grid; gap: 10px; min-width: 0; }
.email-preview-toolbar, .gallery-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.email-preview-toolbar p, .gallery-head p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.email-preview-modes { display: inline-flex; gap: 4px; flex: none; }
.inbox-chrome { overflow: hidden; border: 1px solid #d9d6ce; border-radius: var(--radius); background: #f3f2ef; color: #24231f; min-width: 0; }
.inbox-chrome.dark { border-color: #3d3c39; background: #1f1f1e; color: #e8e6e1; }
.inbox-topline { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-bottom: 1px solid #d9d6ce; font: 500 .78rem/1 var(--mono); }
.dark .inbox-topline { border-bottom-color: #3d3c39; }
.inbox-dot { width: 7px; height: 7px; border-radius: 50%; background: #6c695f; }
.dark .inbox-dot { background: #aaa8a2; }
.inbox-count { margin-left: auto; color: #6c695f; } .dark .inbox-count { color: #aaa8a2; }
.inbox-envelope { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 11px 14px; border-bottom: 1px solid #d9d6ce; background: #fff; font-size: .82rem; }
.dark .inbox-envelope { border-bottom-color: #3d3c39; background: #292928; }
.inbox-avatar { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: #3b3a35; color: #fbf9f3; font: 500 .55rem/1 var(--mono); }
.inbox-sender, .inbox-copy { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-sender { flex: 1 1 38%; font-weight: 500; }
.inbox-copy { flex: 1 1 27%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.inbox-copy:hover { text-decoration: underline; }
.inbox-copy:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.inbox-snippet { flex-basis: 35%; color: #6c695f; } .dark .inbox-snippet { color: #aaa8a2; }
.email-preview-canvas { width: min(640px, 100%); max-width: 100%; margin: 0 auto; background: #F2EEE6; }
.email-preview-frame { display: block; width: 100%; height: 580px; border: 0; background: #FBF9F4; }
.email-preview-help { margin: 0; color: var(--muted); font-size: .82rem; }
.draft-preview-full { min-width: 0; }
.email-header-gallery { display: grid; gap: 10px; padding-top: 6px; }
.header-variants { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.email-header-variant { min-width: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.variant-art { position: relative; display: grid; align-content: space-between; min-height: 88px; padding: 10px; background: #FBF9F4; color: #06182D; font: 700 .66rem/1.1 Georgia, 'Times New Roman', serif; }
.variant-art strong { font: 700 1.3rem/1 Arial, Helvetica, sans-serif; }
.signal .variant-art { border-top: 8px solid #06182D; box-shadow: inset 0 -6px #CF1637; }
.masthead .variant-art { border: 7px solid #F2EEE6; border-top-color: #CF1637; }
.ribbon .variant-art { background: #06182D; color: #FBF9F4; }.ribbon .variant-art::after { content: ""; position: absolute; right: 0; bottom: 0; width: 55%; height: 13px; background: #CF1637; }
.banner .variant-art { background: #F2EEE6; box-shadow: inset 0 22px #06182D; padding-top: 31px; }.banner .variant-art strong { color: #CF1637; }
.email-header-variant figcaption { display: grid; gap: 3px; padding: 8px; font-size: .72rem; overflow-wrap: anywhere; }
.email-header-variant figcaption span { color: var(--muted); font: .7rem/1 var(--mono); }

/* Work */
.composer { display: flex; gap: 8px; padding: 10px; }
.composer .input { flex: 1; }
.evidence { font: .76rem/1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.work-result-summary { display: grid; gap: 10px; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.work-result-summary h3 { font: 500 .84rem/1.3 var(--sans); }
.work-result-totals { display: flex; gap: 14px; flex-wrap: wrap; font: .78rem/1.3 var(--mono); color: var(--muted); }
.work-result-totals strong { color: var(--text); font-weight: 500; }
.work-result-page { white-space: pre-wrap; overflow-wrap: anywhere; }
.analytics-card { overflow: hidden; }
.analytics-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.analytics-head .meta { margin-top: 4px; color: var(--muted); font-size: .84rem; }
.analytics-empty { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 4px; }
.analytics-empty p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; max-width: 68ch; }
.analytics-scroll { overflow-x: auto; }
.analytics-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
.analytics-table th, .analytics-table td { padding: 10px 12px 10px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.analytics-table tr:last-child td { border-bottom: 0; }
.analytics-table th { color: var(--muted); font: 400 .76rem/1.2 var(--mono); white-space: nowrap; }
.analytics-value { font-family: var(--mono); font-weight: 500; white-space: nowrap; }
.analytics-unavailable { color: var(--muted); font-style: italic; min-width: 220px; }

/* Brain inventory */
.brain-connection { display: flex; gap: 12px; align-items: flex-start; padding: 14px 4px; }
.brain-connection .icon { color: var(--muted); margin-top: 3px; flex: none; }
.brain-connection strong { display: block; font-weight: 500; }
.brain-connection p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.brain-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.brain-totals > div { display: grid; gap: 4px; padding: 14px 16px 14px 4px; min-width: 0; }
.brain-totals > div + div { border-left: 1px solid var(--line); padding-left: 16px; }
.brain-totals strong { font: 500 1.2rem/1.2 var(--num-font); overflow-wrap: anywhere; }
.brain-search { flex: 1; max-width: 320px; min-width: 0; }
.brain-breakdowns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.brain-breakdown { padding: 12px 4px; display: grid; gap: 8px; }
.brain-breakdown > div { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; }
.brain-breakdown span { color: var(--muted); overflow-wrap: anywhere; }
.brain-breakdown strong { font: 500 .82rem/1.4 var(--mono); flex: none; }
.brain-row { padding: 0; gap: 4px; }
.brain-row-read { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; padding: 14px 4px; text-align: left; border: 0; background: transparent; color: inherit; cursor: pointer; }
.brain-row-read:hover { background: var(--hover); }
.brain-row-read > .icon:first-child { color: var(--muted); }
.brain-row-read > .icon:last-child { color: var(--soft); flex: none; }
.brain-notion-link { flex: none; margin-right: 4px; white-space: nowrap; }
.brain-page { overflow: hidden; }
.brain-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.brain-page-head .crumb { margin-bottom: 6px; }
.brain-page-head h2 { overflow-wrap: anywhere; }
.markdown { padding: 20px; line-height: 1.7; overflow-wrap: anywhere; max-width: 78ch; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3 { margin: 1.2em 0 .45em; line-height: 1.25; }
.markdown h1 { font-size: 1.35rem; }.markdown h2 { font-size: 1.15rem; }.markdown h3 { font-size: 1rem; }
.markdown p { margin: 0 0 1em; }.markdown ul { margin: 0 0 1em; padding-left: 1.25em; }
.markdown code { padding: .12em .32em; border-radius: var(--radius); background: var(--surface); font-family: var(--mono); font-size: .9em; }

/* Chat */
.chat-thread { display: grid; overflow: hidden; }
.chat-message { display: grid; gap: 6px; padding: 16px 4px; min-width: 0; }
.chat-message + .chat-message { border-top: 1px solid var(--line); }
.chat-meta { display: flex; gap: 10px; align-items: baseline; color: var(--muted); font: 400 .78rem/1.3 var(--mono); min-width: 0; }
.chat-meta strong { color: var(--text); font-weight: 500; }
.chat-message.agent .chat-meta strong::before { content: "› "; color: var(--muted); }
.chat-meta span { overflow-wrap: anywhere; }
.chat-message p { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 78ch; }
.chat-composer { display: grid; gap: 10px; padding: 12px; }
.chat-composer .textarea { min-height: 88px; }
.chat-composer .lock-note { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: .8rem; }
.chat-composer-state { margin-top: 4px; color: var(--muted); font-size: .78rem; }
.chat-composer-state.warn { color: var(--bad); }

/* Assistant */
.assistant { border-left: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.assistant-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.assistant-head .muted { font-size: .82rem; }
.assistant-body { padding: 16px; display: grid; gap: 12px; overflow-y: auto; align-content: start; flex: 1; }
.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); }

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

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + 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: .88rem; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* Menus */
.popover { position: absolute; top: 48px; right: 12px; z-index: 40; width: 248px; padding: 6px; display: grid; gap: 1px; box-shadow: var(--shadow); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.popover button, .popover a { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius); background: transparent; text-align: left; color: inherit; text-decoration: none; font-size: .88rem; }
.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: .84rem; color: var(--muted); overflow-wrap: anywhere; }
.popover .label { padding: 8px 10px 2px; }
.popover [aria-checked="false"] .icon { visibility: hidden; }
.switcher { position: relative; min-width: 0; }
.switcher > .btn { max-width: 100%; gap: 10px; font: 500 .86rem/1 var(--sans); color: var(--text); }
.switcher .desk-mark { width: 24px; height: 24px; font-size: .55rem; }
.desk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.switcher .popover { left: 0; right: auto; top: 44px; }

/* Desk settings */
.desk-settings { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 16px; padding: 18px 4px; align-items: end; }
.desk-settings .swatches, .desk-settings .row:last-child, .desk-settings .field:nth-child(3) { grid-column: 1 / -1; }
.swatches { border: 0; padding: 0; margin: 0; }
.swatches legend { margin-bottom: 8px; padding: 0; }
.swatch { width: 28px; height: 28px; border-radius: 50%; background: var(--c); display: inline-grid; place-items: center; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.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(--bg), 0 0 0 3px var(--text); }
.swatch input[type=radio]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.swatch.custom { background: conic-gradient(#b8483e, #a8742a, #5c7a4f, #2f7a74, #76736c, #8a5a9e, #b8483e); }
.swatch.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* 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: 500; }
.image-slot .thumb { width: 88px; height: 88px; object-fit: cover; border-radius: var(--radius); 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(--focus); }
.app-footer { padding: 10px 32px; border-top: 1px solid var(--line); color: var(--soft); font: .75rem/1.4 var(--mono); text-align: center; }

/* Admin directory: a start page over existing pages, not a second workspace store. */
.admin-page { max-width: 1240px; width: 100%; }
.directory-toolbar { display: flex; align-items: center; gap: 12px; }
.search-field { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 560px; min-height: 42px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--panel); color: var(--muted); }
.search-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.search-field input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 10px 0; font: .88rem/1.3 var(--mono); color: var(--text); }
.search-field input::placeholder { color: var(--soft); }
.directory-count { margin-left: auto; font: .78rem/1.3 var(--mono); color: var(--soft); white-space: nowrap; }
.directory { border-top: 1px solid var(--line-strong); }
.directory-head, .directory-row { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 32px; }
.directory-head { padding: 10px 4px; border-bottom: 1px solid var(--line); font: .76rem/1.3 var(--mono); color: var(--soft); }
.directory-row { padding: 20px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.directory-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.directory-identity > div { min-width: 0; }
.directory-identity h2 { font: 500 .98rem/1.3 var(--sans); letter-spacing: 0; overflow-wrap: anywhere; }
.directory-identity p { font: .78rem/1.4 var(--mono); margin-top: 4px; }
.directory-mark, .directory-identity .desk-mark { width: 40px; height: 40px; flex: none; }
img.directory-mark { object-fit: contain; background: #fff; border-radius: var(--mark-radius); box-shadow: inset 0 0 0 1px rgba(36, 35, 31, .12); }
.directory-pages { display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; margin-left: -10px; }
.directory-pages a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; border-radius: var(--radius); color: var(--muted); font: 400 .84rem/1 var(--mono); text-decoration: none; }
.directory-pages a:hover { color: var(--text); background: var(--hover); }
.directory-pages a:first-child { color: var(--text); }
.directory-pages a.external::after { content: "↗" / ""; margin-left: 5px; color: var(--soft); }
.directory-hint { font-size: .84rem; max-width: 80ch; }
.directory-tools { border-top: 1px solid var(--line); padding-top: 20px; display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap; }
.directory-tools h2 { font: 400 .78rem/1.3 var(--mono); color: var(--soft); }
.directory-tools a { min-height: 40px; display: inline-flex; align-items: center; font-size: .86rem; }
.directory-tools > span { font-size: .8rem; }

/* New desk */
.new-desk-page { max-width: 640px; width: 100%; }
.new-desk-form { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 20px 16px; padding-top: 24px; border-top: 1px solid var(--line-strong); }
.new-desk-form > p, .new-desk-form > .form-foot, .new-desk-preview { grid-column: 1 / -1; }
.new-desk-form .input { min-height: 42px; }
.new-desk-preview { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-block: 1px solid var(--line); }
.new-desk-preview .desk-mark { background: #76736c; }
.new-desk-preview strong { font-weight: 500; }
.new-desk-preview span:last-child { display: block; font: .78rem/1.4 var(--mono); color: var(--soft); }
.form-foot { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.form-foot .btn { min-height: 40px; }
.form-foot p { font-size: .84rem; }
.facts { display: grid; gap: 6px; padding-left: 18px; margin: 0; color: var(--muted); font-size: .88rem; }

/* Setup */
.onboarding-intro { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 4px; border-top: 1px solid var(--line-strong); }
.onboarding-intro > div { display: flex; gap: 14px; align-items: center; min-width: 0; }
.onboarding-intro h2 { font: 500 1rem/1.3 var(--sans); letter-spacing: 0; }
.onboarding-intro p { font-size: .86rem; margin-top: 2px; }
.setup-meter { display: flex; gap: 3px; margin-top: 8px; }
.setup-meter i { width: 28px; height: 3px; background: var(--line-strong); }
.setup-meter i.done { background: var(--text); }
.onboarding-steps { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.onboarding-steps > a { display: grid; grid-template-columns: 32px minmax(0, 1fr) 150px 20px; align-items: center; gap: 16px; padding: 18px 4px; color: var(--text); text-decoration: none; }
.onboarding-steps > a + a { border-top: 1px solid var(--line); }
.onboarding-steps > a:hover { background: var(--hover); }
.step-number { font: 400 .84rem/1 var(--mono); color: var(--soft); }
.onboarding-steps h2 { font: 500 .95rem/1.3 var(--sans); letter-spacing: 0; }
.onboarding-steps p { font-size: .86rem; margin-top: 3px; }
.step-go { color: var(--soft); display: grid; place-items: center; }
.onboarding-steps > a:hover .step-go { color: var(--text); }
.setup-notes { max-width: 72ch; display: grid; gap: 12px; }
.setup-notes p { font-size: .9rem; color: var(--muted); }

/* Connections */
.connect-agent { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 16px 4px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.connect-agent p { color: var(--muted); font-size: .88rem; margin-top: 4px; max-width: 64ch; }

/* Responsive */
@media (max-width: 1180px) {
  .body.with-assistant { grid-template-columns: 232px 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); }
  .directory-head { display: none; }
  .directory-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}
@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: 272px; z-index: 30; transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow); visibility: hidden; }
  .sidebar.open { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: 56px 0 0 272px; background: rgba(0, 0, 0, .35); z-index: 25; border: 0; }
  .page { padding: 22px 16px 56px; gap: 22px; }
  h1 { font-size: 1.45rem; }
  .attention, .brain-totals { grid-template-columns: minmax(0, 1fr); }
  .tile + .tile, .brain-totals > div + div { border-left: 0; border-top: 1px solid var(--line); padding-left: 4px; }
  .inline-form { grid-template-columns: minmax(0, 1fr) !important; }
  .mode-pill, .topbar .sep, .admin-link, .topbar .surface-switch { display: none; }
  .assistant { width: 100%; }
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar .desk-name, .hide-sm { display: none; }
  .switcher > .btn { padding: 0 6px; gap: 4px; }
  .page-head .btn.primary, .page-head > .btn { width: 100%; }
  .page-head > .row { width: 100%; } .page-head > .row .btn { flex: 1; }
  .title-input { font-size: 1.1rem; }
  .editor-body { padding: 16px; }
  #markup-canvas { grid-template-columns: minmax(0, 1fr); }
  .comment-rail { max-height: none; }
  .markup-actions { width: 100%; }
  .markup-actions .select { width: 100%; }
  .brain-breakdowns { grid-template-columns: minmax(0, 1fr); }
  .brain-search { max-width: none; width: 100%; }
  .brain-page-head { padding: 16px; }
  .markdown { padding: 16px; }
  .email-preview-frame { height: 540px; }
  .header-variants { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desk-settings, .new-desk-form { grid-template-columns: minmax(0, 1fr); }
  .directory-toolbar { flex-wrap: wrap; }
  .search-field { flex-basis: 100%; max-width: none; }
  .directory-count { margin-left: 0; }
  .onboarding-intro { flex-direction: column; align-items: flex-start; }
  .onboarding-steps > a { grid-template-columns: 24px minmax(0, 1fr) 16px; gap: 12px; }
  .onboarding-steps > a .chip { grid-column: 2; grid-row: 2; }
  .step-go { grid-column: 3; grid-row: 1 / span 2; }
  .app-footer { padding: 10px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.previews > .email-inbox-preview { grid-column: 1 / -1; }
.admin-link[aria-current="page"] { color: var(--text); }

/* User / Dev surface switch (operators only) */
.surface-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 2px; gap: 2px; }
.surface-switch button { border: 0; background: transparent; color: var(--muted); min-height: 28px; padding: 0 10px; border-radius: var(--radius); font: 500 .78rem/1 var(--mono); }
.surface-switch button:hover { color: var(--text); }
.surface-switch button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }

/* Dev surface: dense key/value lists and tables over thin rules */
.dev-subnav { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: -8px; }
.dev-subnav a { padding: 8px 12px; font: 400 .84rem/1.3 var(--mono); color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; margin-bottom: -1px; }
.dev-subnav a:hover { color: var(--text); }
.dev-subnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); margin: 0; border-top: 1px solid var(--line-strong); }
.kv dt, .kv dd { margin: 0; padding: 9px 4px; border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.kv dt { font: 400 .8rem/1.5 var(--mono); color: var(--muted); }
.kv dd { font-size: .88rem; }
.kv code, .dev-table code { font: .8rem/1.4 var(--mono); }
.dev-table { font-size: .84rem; border-top: 1px solid var(--line-strong); }
.dev-table td { overflow-wrap: anywhere; }
.dev-json { display: block; max-width: 360px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.dev-desk { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.dev-desk .desk-mark { width: 22px; height: 22px; font-size: .5rem; }
.swatch-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.dev-raw { border-top: 1px solid var(--line-strong); padding-top: 12px; }
.dev-raw summary { cursor: pointer; font: 400 .84rem/1.3 var(--mono); color: var(--muted); min-height: 32px; }
.dev-raw pre { margin: 10px 0 0; padding: 14px; max-height: 480px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font: .76rem/1.5 var(--mono); }
@media (max-width: 760px) {
  .surface-switch button { padding: 0 7px; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { border-bottom: 0; padding-bottom: 0; }
}

/* Hand-customized Overview parts */
.welcome { display: grid; gap: 8px; padding: 18px 4px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.welcome p { color: var(--muted); max-width: 72ch; }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 761px) { .attention { grid-template-columns: repeat(var(--tiles, 3), minmax(0, 1fr)); } }
.page > * { min-width: 0; }
.dev-raw pre { white-space: pre-wrap; overflow-wrap: anywhere; }
