/* AutoPilot: Instructions and Data sources. */
.ai-page h1 { margin: 0; }
.ai-page .page-heading { min-height: 44px; margin-bottom: 20px; }
.ai-bar { display: block; height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--line) 75%, transparent); overflow: hidden; }
.ai-bar i { display: block; height: 100%; border-radius: 99px; background: var(--blue); }

/* Instructions: each box has a slim header inside it, so it's clear what can be edited. */
.ai-page, .ai-play { --ai-line: color-mix(in srgb, var(--ink) 13%, transparent); --ai-strip: color-mix(in srgb, var(--ink) 2.5%, var(--surface)); }
html[data-theme="dark"] .ai-page, html[data-theme="dark"] .ai-play { --ai-line: color-mix(in srgb, var(--ink) 11%, transparent); --ai-strip: color-mix(in srgb, #000 24%, var(--surface)); }
.ai-preset { position: relative; display: inline-flex; }
.ai-preset-trigger { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 9px 0 12px; border: 1px solid var(--ai-line); border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: 13.5px; white-space: nowrap; cursor: pointer; transition: border-color .15s; }
.ai-preset-trigger:hover, .ai-preset-trigger[aria-expanded="true"] { border-color: color-mix(in srgb, var(--ink) 30%, transparent); }
.ai-preset-trigger:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.ai-preset-trigger small { color: var(--muted); font-size: inherit; }
.ai-preset-trigger svg { flex: none; width: 15px; height: 15px; color: var(--muted); }
.ai-preset-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: 326px; padding: 6px; color: var(--ink); background: var(--surface); border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); border-radius: 12px; box-shadow: 0 18px 44px #00000030, 0 2px 8px #00000014; }
html[data-theme="dark"] .ai-preset-menu { background: color-mix(in srgb, var(--ink) 5%, var(--surface)); box-shadow: 0 18px 44px #00000080; }
.ai-preset-menu[hidden] { display: none; }
/* Seven presets and Custom: the list scrolls on its own rather than past the Try it panel. */
.ai-preset-menu [role="listbox"] { max-height: min(560px, calc(100vh - 150px)); overflow-y: auto; overscroll-behavior: contain; }
/* A thin line sets your own instructions apart from the ready-made ones. */
.ai-preset-option[data-preset="custom"] { position: relative; margin-top: 9px; }
.ai-preset-option[data-preset="custom"]::before { content: ""; position: absolute; top: -6px; left: 9px; right: 9px; border-top: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.ai-preset-option { display: grid; grid-template-columns: 32px minmax(0, 1fr) 15px; align-items: center; gap: 11px; width: 100%; padding: 9px 10px 9px 9px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ai-preset-option + .ai-preset-option { margin-top: 2px; }
.ai-preset-option:hover, .ai-preset-option:focus-visible { background: color-mix(in srgb, var(--ink) 6%, transparent); outline: 0; }
.ai-preset-option b { display: block; font-size: 13.5px; font-weight: 500; }
.ai-preset-option small { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.ai-preset-tile { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted); }
.ai-preset-tile.is-blue { background: color-mix(in srgb, var(--blue) 17%, transparent); color: color-mix(in srgb, var(--blue) 70%, var(--ink)); }
.ai-preset-tile svg { width: 16px; height: 16px; }
.ai-preset-check { display: flex; color: var(--blue); }
.ai-preset-check svg { width: 15px; height: 15px; stroke-width: 2; }
.ai-preset-ask { padding: 10px; }
.ai-preset-ask b { display: block; font-size: 14px; font-weight: 600; }
.ai-preset-ask p { margin: 5px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.ai-preset-ask div { display: flex; justify-content: flex-end; gap: 8px; }
.ai-preset-ask .button:not(#_) { height: 32px; min-height: 32px; padding: 0 12px; border-radius: 7px; font-size: 13px; }
.ai-field { overflow: hidden; border: 1px solid var(--ai-line); border-radius: 8px; background: var(--surface); transition: border-color .15s; }
.ai-field + .ai-field { margin-top: 12px; }
.ai-field:hover { border-color: color-mix(in srgb, var(--ink) 26%, transparent); }
.ai-field:focus-within { border-color: var(--blue); }
.ai-field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 32px; padding: 0 12px; border-bottom: 1px solid var(--ai-line); background: var(--ai-strip); font-size: 12.5px; }
.ai-field:focus-within .ai-field-head { border-bottom-color: color-mix(in srgb, var(--blue) 40%, var(--ai-line)); }
.ai-field-head label { color: var(--ink); font-weight: 500; }
.ai-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ai-field textarea.ai-box:not(#_) {
  display: block; width: 100%; min-height: 160px; padding: 12px; overflow: hidden; resize: none;
  border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none; color: var(--ink);
  font-size: 14px; line-height: 1.55;
}
.ai-field textarea.ai-box:not(#_):focus { border: 0; outline: 0; box-shadow: none; }

/* Try it: settings beside a preview of the chat, on a dotted canvas. */
.ai-play { display: grid; grid-template-columns: 440px minmax(0, 1fr); height: 100%; min-height: 620px; }
.ai-play-panel { display: flex; flex-direction: column; gap: 28px; padding: 22px 24px; overflow-y: auto; border-right: 1px solid var(--line); }
.ai-play-panel h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.ai-play-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.ai-play-title h2 { margin: 0; }
.ai-play-panel .ai-usage b { font-weight: 500; }
.ai-play-panel .ai-bar { height: 3px; }
.ai-play-panel textarea.ai-box:not(#_) { min-height: 125px; padding: 10px 12px; font-size: 13.5px; }
.ai-play-card { display: flex; flex-direction: column; gap: 12px; }
.ai-play-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 36px; padding: 0 12px; border: 1px solid var(--ai-line); border-radius: 8px; color: var(--ink); font-size: 13.5px; text-decoration: none; }
.ai-play-link:hover { border-color: color-mix(in srgb, var(--ink) 26%, transparent); }
.ai-play-link > span { display: flex; align-items: center; gap: 9px; }
.ai-play-link > span:last-child { gap: 4px; color: var(--muted); font-size: 13px; }
.ai-play-link svg { flex: none; width: 14px; height: 14px; color: var(--muted); }
.ai-canvas { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 28px; background-color: color-mix(in srgb, var(--soft) 45%, transparent); background-image: radial-gradient(color-mix(in srgb, var(--ink) 20%, transparent) 1px, transparent 1.3px); background-size: 22px 22px; overflow: hidden; }
/* Leave room for the floating save bar, so it never covers the message box or the last field. */
.dashboard-page:has(.save-island.is-shown) .ai-play-panel { padding-bottom: 88px; }
@media (max-height: 900px) { .dashboard-page:has(.save-island.is-shown) .ai-canvas { padding-bottom: 80px; } }
.ai-preview { display: flex; flex-direction: column; width: 400px; max-width: 100%; height: 680px; max-height: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 18px 60px #00000033; }
.ai-preview-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--line); }
.ai-preview-head > div { flex: 1; min-width: 0; }
.ai-preview-head b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-preview-head small { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.ai-preview-logo { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #2f5fe6; color: #fff; font-size: 13px; font-weight: 600; }
.ai-preview-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; padding: 16px; overflow-y: auto; }
.ai-q { align-self: flex-end; max-width: 84%; padding: 8px 14px; border-radius: var(--ck-radius) var(--ck-radius) var(--ck-tail) var(--ck-radius); background: var(--ck-sent); color: var(--ck-sent-ink); font-size: 14px; line-height: 1.375; overflow-wrap: anywhere; }
.ai-a { align-self: flex-start; max-width: 92%; display: flex; flex-direction: column; align-items: flex-start; }
.ai-a .ck-line.is-top { align-items: flex-start; }
.ai-bubble { min-width: 0; padding: 8px 14px; border-radius: var(--ck-radius) var(--ck-radius) var(--ck-radius) var(--ck-tail); background: var(--ck-recv); color: var(--ck-recv-ink); font-size: 14px; line-height: 1.375; white-space: pre-line; overflow-wrap: anywhere; }
.ai-bubble b { font-weight: 600; }
.ai-handoff { margin: 7px 0 0 var(--ck-gutter); display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--warning) 9%, transparent); font-size: 13.5px; line-height: 1.4; }
.ai-handoff svg { flex: none; width: 15px; height: 15px; color: var(--warning); }
.ai-suggest { margin-top: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.ai-suggest button { max-width: 100%; padding: 9px 13px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); font-size: 13.5px; line-height: 1.35; text-align: left; }
.ai-suggest button:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.ai-preview-foot { position: relative; padding: 12px; border-top: 1px solid var(--line); }
.ai-preview-foot input:not(#_) { display: block; width: 100%; height: 44px; padding: 0 46px 0 12px; border: 1px solid var(--ai-line); border-radius: 8px; background: var(--surface); box-shadow: none; font-size: 13.5px; }
.ai-preview-foot input:not(#_):focus { border-color: var(--blue); outline: 0; box-shadow: none; }
.ai-preview-foot .button { position: absolute; top: 50%; right: 18px; display: grid; place-items: center; width: 32px; height: 32px; min-height: 32px; margin-top: -16px; padding: 0; border-radius: 6px; }
.ai-preview-foot .button svg { width: 15px; height: 15px; }

/* Data sources */
.ai-cols { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; align-items: start; }
.ai-main { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.ai-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ai-group-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; }
.ai-group-head h2 span { margin-left: 7px; color: var(--muted); font-size: 14px; font-weight: 400; }
.ai-add { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 500; }
.ai-add:hover { background: var(--menu-hover); }
.ai-add svg { width: 14px; height: 14px; }
.ai-none { margin: 0; padding: 14px 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 14px; }
.ai-table { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.ai-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px 158px 66px; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); }
.ai-row:first-child { border-top: 0; }
.ai-row:hover { background: color-mix(in srgb, var(--soft) 55%, transparent); }
.ai-source { display: flex; align-items: center; gap: 13px; min-width: 0; cursor: pointer; }
.ai-tile { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); color: var(--ink); }
.ai-tile svg { width: 15px; height: 15px; }
.ai-name { min-width: 0; }
.ai-name button { display: block; padding: 0; border: 0; background: none; color: var(--ink); font-size: 14.5px; font-weight: 600; line-height: 1.3; text-align: left; overflow-wrap: anywhere; }
.ai-name small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.ai-name small.is-problem { color: var(--danger); }
.ai-chars { font-size: 14px; }
.ai-status { display: flex; align-items: center; gap: 8px; width: max-content; font-size: 14px; line-height: 1.3; white-space: nowrap; }
.ai-status i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.ai-status[data-tone="busy"] i { background: var(--blue); }
.ai-status[data-tone="warn"] i { background: var(--warning); }
.ai-status[data-tone="bad"] i { background: var(--danger); }
.ai-progress { width: 110px; margin-top: 7px; }
.ai-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.ai-icon { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.ai-icon:hover { background: var(--menu-hover); color: var(--ink); }
.ai-icon svg { width: 16px; height: 16px; }

.ai-side { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.ai-side h2 { margin: 0; font-size: 15.5px; font-weight: 600; }
.ai-usage { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 13px; }
.ai-usage b { color: var(--ink); font-weight: 600; }
.ai-usage[data-warning="near_limit"] .ai-bar i { background: var(--warning); }
.ai-usage[data-warning="limit"] .ai-bar i { background: var(--danger); }
.ai-totals { display: flex; flex-direction: column; gap: 11px; padding-top: 15px; border-top: 1px solid var(--line); }
.ai-totals div { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.ai-totals div > span:first-child { display: flex; align-items: center; gap: 9px; }
.ai-totals div > span:last-child { color: var(--muted); font-size: 13.5px; }
.ai-totals svg { flex: none; width: 15px; height: 15px; color: var(--muted); }

/* Adding a website */
.ai-find { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.ai-find .button { height: 44px; }
.ai-address { position: relative; display: block; }
.ai-address > span { position: absolute; left: 13px; top: 14px; display: flex; color: var(--muted); pointer-events: none; }
.ai-address svg { width: 16px; height: 16px; }
.ai-address input:not(#_) { width: 100%; height: 44px; padding-left: 38px; }
.ai-link { width: max-content; padding: 0; border: 0; background: none; color: var(--muted); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.ai-link:hover { color: var(--ink); }
#ai-found { display: contents; }
.ai-pagelist { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ai-pagelist-head { display: flex; align-items: center; gap: 10px; padding: 9px 13px; background: var(--soft); font-size: 13.5px; }
.ai-pagelist-head b { flex: 1; font-weight: 500; }
.ai-pagelist-head > span { color: var(--muted); }
.ai-pagelist-rows { max-height: 300px; overflow-y: auto; }
.ai-pagelist-rows label { display: flex; align-items: center; gap: 10px; padding: 8px 13px; border-top: 1px solid var(--line); font-size: 14px; }
.ai-pagelist-rows label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-pagelist-rows input:not(:checked) + span { color: var(--muted); }
.ai-note { margin: 0; color: var(--muted); font-size: 13px; }
.ai-note:empty { display: none; }

/* Adding files */
.ai-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 128px; padding: 16px; border: 1.5px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 14.5px; text-align: center; cursor: pointer; }
.ai-drop:hover, .ai-drop.is-over { border-color: var(--blue); }
.ai-drop b { color: var(--ink); font-weight: 600; }
.ai-drop svg { width: 21px; height: 21px; }
.ai-drop small { font-size: 13px; }
.ai-uploads { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ai-uploads > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; border-top: 1px solid var(--line); font-size: 14px; }
.ai-uploads > div:first-child { border-top: 0; }
.ai-upload-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ai-upload-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-upload-name svg { flex: none; width: 15px; height: 15px; color: var(--muted); }
.ai-upload-state { flex: none; max-width: 60%; color: var(--muted); font-size: 13px; text-align: right; }
.ai-upload-state.is-problem { color: var(--danger); }
.ai-waiting { width: 70px; }
.ai-waiting i { width: 40%; animation: ai-waiting 1.1s ease-in-out infinite alternate; }
@keyframes ai-waiting { to { transform: translateX(150%); } }
@media (prefers-reduced-motion: reduce) { .ai-waiting i { animation: none; } }

/* Source details: slides in over the page. Above the page, below toasts and the confirm dialog. */
.ai-scrim { position: fixed; inset: 0; z-index: 80; background: #18243440; opacity: 0; transition: opacity .3s var(--ease); }
html[data-theme="dark"] .ai-scrim { background: #00000090; }
.ai-panel[data-open] .ai-scrim { opacity: 1; }
.ai-sheet { position: fixed; z-index: 81; top: 12px; right: 12px; bottom: 12px; width: min(540px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 20px; padding: 24px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: -24px 0 60px #1922381a; color: var(--ink); transform: translateX(calc(100% + 24px)); transition: transform .38s var(--ease); }
html[data-theme="dark"] .ai-sheet { box-shadow: -30px 0 80px #00000080; }
.ai-panel[data-open] .ai-sheet { transform: none; }
.ai-panel[data-closing] .ai-sheet { transition-duration: .3s; transition-timing-function: cubic-bezier(.4, 0, 1, 1); }
.ai-sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ai-sheet-head h2 { margin: 0 0 7px; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; outline: 0; }
.ai-sheet-head .ai-progress { display: block; }
.ai-sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 20px; }
.ai-sheet-problem { margin: 0; color: var(--danger); font-size: 14px; line-height: 1.45; }
.ai-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); }
.ai-stats b { display: block; font-size: 17px; font-weight: 600; }
.ai-stats span { font-size: 13px; color: var(--muted); }
.ai-sheet-actions { display: flex; align-items: center; gap: 8px; }
.ai-with-icon { display: inline-flex; align-items: center; gap: 7px; }
.ai-with-icon svg { width: 15px; height: 15px; }
.ai-pages { flex: 0 1 auto; min-height: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.ai-pages > div { display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.ai-pages > div:first-child { border-top: 0; }
.ai-pages b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-pages small { display: block; margin-top: 1px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-pages > div > span { color: var(--muted); font-size: 13.5px; text-align: right; }
.ai-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.ai-editor > .field { flex: none; }
.ai-sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* The panels the Add buttons open: content in the middle, a note and the buttons at the bottom. */
.ai-sheet.is-wide, .ai-sheet.is-mid { gap: 18px; }
.ai-sheet.is-wide { width: min(820px, calc(100vw - 24px)); }
.ai-sheet.is-mid { width: min(640px, calc(100vw - 24px)); }
.ai-add-head { align-items: center; }
.ai-add-head h2 { margin: 0; }
.ai-add-tools { display: flex; align-items: center; gap: 8px; }
.ai-add-form { --ai-line: color-mix(in srgb, var(--ink) 13%, transparent); --ai-strip: color-mix(in srgb, var(--ink) 2.5%, var(--surface)); flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 18px; }
html[data-theme="dark"] .ai-add-form { --ai-line: color-mix(in srgb, var(--ink) 11%, transparent); --ai-strip: color-mix(in srgb, #000 24%, var(--surface)); }
.ai-add-form > .form-error { margin: 0; }
.ai-add-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }

/* Website: the found pages fill the panel. */
.ai-add-body .ai-find { flex: none; }
.ai-add-body .ai-link { flex: none; }
.ai-found { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ai-found:empty { display: none; }
.ai-add-body .ai-pagelist { flex: 1; min-height: 0; display: flex; flex-direction: column; border-color: var(--ai-line); border-radius: 8px; }
.ai-add-body .ai-pagelist-head { flex: none; background: var(--ai-strip); border-bottom: 1px solid var(--ai-line); }
.ai-add-body .ai-pagelist-rows { flex: 1; max-height: none; }
.ai-add-body .ai-pagelist-rows label { border-top-color: var(--ai-line); }
.ai-add-body .ai-pagelist-rows label:first-child { border-top: 0; }

/* Files: staged in a list until Add. */
.ai-add-body .ai-drop { flex: none; border-color: var(--ai-line); border-radius: 8px; }
.ai-add-body .ai-drop:hover, .ai-add-body .ai-drop.is-over { border-color: var(--blue); }
.ai-add-body .ai-uploads { flex: 0 1 auto; min-height: 0; overflow-y: auto; border-color: var(--ai-line); border-radius: 8px; }
.ai-add-body .ai-uploads > div { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 28px; padding: 7px 6px 7px 13px; border-top-color: var(--ai-line); }
.ai-add-body .ai-uploads[hidden] { display: none; }
.ai-upload-size { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ai-add-body .ai-upload-state { max-width: 260px; text-wrap: pretty; }
.ai-add-body .ai-uploads .ai-icon { width: 28px; height: 28px; }
.ai-add-body .ai-uploads .ai-icon svg { width: 15px; height: 15px; }
.ai-add-body .ai-uploads .ai-icon[hidden] { visibility: hidden; display: grid; }

/* Text: a title box, then the text filling the panel. */
.ai-add-body .ai-field + .ai-field { margin-top: 0; }
.ai-add-body .ai-field { flex: none; }
.ai-add-body .ai-field.is-fill { flex: 1; min-height: 0; display: flex; flex-direction: column; }
html body .ai-field input.ai-box:not(#_) {
  display: block; width: 100%; height: 44px; margin: 0; padding: 0 12px;
  border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none; color: var(--ink); font: inherit; font-size: 14px;
}
html body .ai-field input.ai-box:not(#_):focus { border: 0; outline: 0; box-shadow: none; }
.ai-add-body .ai-field.is-fill textarea.ai-box:not(#_) { flex: 1; min-height: 0; overflow-y: auto; }

/* Questions and answers: a sheet of rows, with an empty one always at the bottom. */
.ai-qa-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--ai-line); border-radius: 8px; }
.ai-qa-th, .ai-qa-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1.35fr) 36px; }
.ai-qa-th { flex: none; align-items: center; height: 34px; border-bottom: 1px solid var(--ai-line); background: var(--ai-strip); color: var(--muted); font-size: 12.5px; }
.ai-qa-th span:nth-child(2), .ai-qa-th span:nth-child(3) { padding-left: 12px; }
.ai-qa-rows { flex: 1; min-height: 0; overflow-y: auto; }
.ai-qa-row { align-items: stretch; border-bottom: 1px solid var(--ai-line); }
.ai-qa-row.is-new { border-bottom: 0; }
.ai-qa-no { padding-top: 11px; color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.ai-qa-row textarea:not(#_) {
  display: block; width: 100%; min-height: 40px; margin: 0; padding: 9px 12px; overflow: hidden; resize: none;
  border: 0; border-left: 1px solid var(--ai-line); border-radius: 0; outline: 0; background: transparent; box-shadow: none;
  color: var(--ink); font: inherit; font-size: 13.5px; line-height: 1.55;
}
.ai-qa-row textarea[data-q]:not(#_) { font-weight: 500; }
.ai-qa-row.is-new textarea[data-q]:not(#_) { font-weight: 400; }
.ai-qa-row textarea:not(#_):focus { border-left-color: var(--ai-line); box-shadow: inset 0 0 0 1px var(--blue); background: color-mix(in srgb, var(--blue) 4%, transparent); }
.ai-qa-row textarea:not(#_)::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); font-weight: 400; }
.ai-qa-row textarea[aria-invalid="true"]:not(#_) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 60%, transparent); background: color-mix(in srgb, var(--danger) 6%, transparent); }
.ai-qa-row textarea[aria-invalid="true"]:not(#_)::placeholder { color: var(--danger); }
.ai-qa-row .ai-icon { width: 28px; height: 28px; margin: 6px 4px 0; }
.ai-qa-row .ai-icon svg { width: 15px; height: 15px; }
.ai-qa-row .ai-icon[hidden] { display: none; }
.ai-add-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-add-notes { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.ai-add-bad { color: var(--danger); }
.ai-add-actions { display: flex; gap: 10px; }
@media (max-width: 640px) {
  .ai-qa-th { display: none; }
  .ai-qa-row { grid-template-columns: 28px minmax(0, 1fr) 36px; }
  .ai-qa-row textarea[data-a]:not(#_) { grid-column: 2; border-top: 1px dashed var(--ai-line); }
  .ai-qa-row .ai-icon { grid-column: 3; grid-row: 1; }
  .ai-add-head .ai-with-icon { display: none; }
}

@media (max-width: 1100px) {
  .ai-play { grid-template-columns: minmax(0, 1fr); height: auto; }
  .ai-play-panel { order: 2; border-right: 0; overflow: visible; }
  .ai-canvas { height: 640px; padding: 16px; }
  .ai-cols { grid-template-columns: minmax(0, 1fr); }
  .ai-side { position: static; order: -1; }
}
@media (max-width: 640px) {
  .ai-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ai-chars { display: none; }
  .ai-state { grid-column: 1; grid-row: 2; }
  .ai-actions { grid-column: 2; grid-row: 1 / span 2; }
  .ai-find { grid-template-columns: minmax(0, 1fr); }
}

/* ---- AutoPilot on channels: AutoPilot › Channels (read-only) and each channel's own page ---- */
.ap-page, .ap-channel { --ap-fill: #1f55dc; }
.ap-group { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 10px; }
.ap-group:first-child { margin-top: 0; }
.ap-group h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.ap-group span { font-size: var(--text-sm); color: var(--muted); }
.ap-list { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ap-row { display: grid; grid-template-columns: 34px minmax(0, 400px) minmax(0, 1fr) 62px 74px; align-items: center; gap: 14px; min-height: 62px; padding: 13px 18px; border-top: 1px solid var(--line); cursor: pointer; transition: background-color .15s var(--ease); }
.ap-row:first-child { border-top: 0; }
.ap-row:hover { background: var(--menu-hover); }
.ap-tile { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--ap-fill); color: #fff; }
.ap-tile svg { width: 16px; height: 16px; }
.ap-tile.is-mail { border: 1px solid var(--line); border-radius: 10px; background: var(--soft); color: var(--muted); }
.ap-row.is-off .ap-tile:not(.is-mail) { background: var(--soft); color: var(--muted); }
.ap-name { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; }
.ap-name b { font-size: 14px; font-weight: 600; color: var(--ink); }
.ap-row.is-off .ap-name b { font-weight: 500; color: var(--muted); }
.ap-name small, .ap-name code { overflow: hidden; padding: 0; background: none; color: var(--muted); font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.ap-name code { font-size: 12.5px; }
.ap-name small a { color: var(--blue); }
.ap-instruction { overflow: hidden; color: var(--muted); font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
.ap-state { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); font-size: var(--text-sm); font-weight: 500; }
.ap-state i { width: 7px; height: 7px; border-radius: 50%; background: #2fa36f; }
.ap-row.is-off .ap-state { color: var(--muted); font-weight: 400; }
.ap-row.is-off .ap-state i { background: color-mix(in srgb, var(--muted) 55%, var(--line)); }
.ap-edit { display: inline-flex; align-items: center; justify-content: center; justify-self: end; gap: 4px; padding: 6px 9px 6px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); font-size: var(--text-sm); font-weight: 500; text-decoration: none; }
.ap-edit:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--line)); }
.ap-edit svg { width: 13px; height: 13px; color: var(--muted); }

.ap-form { max-width: 860px; padding-bottom: 48px; }
.ap-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ap-card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; }
.ap-card-head .ap-name b { font-size: 15px; }
.ap-card-head .ch-switch:has(input:disabled) { opacity: .5; }
.ap-card-head .ch-switch input:disabled { cursor: not-allowed; }
.ap-map { display: flex; align-items: center; padding: 34px 40px; overflow-x: auto; border-top: 1px solid var(--line); background-color: var(--soft); background-image: radial-gradient(color-mix(in srgb, var(--muted) 24%, transparent) 1px, transparent 1.4px); background-size: 16px 16px; }
.ap-node { display: flex; flex: none; align-items: center; gap: 10px; max-width: 240px; padding: 9px 16px 9px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 1px 2px #0000000d; transition: opacity .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease); }
.ap-node-text { min-width: 0; }
.ap-node strong { display: block; overflow: hidden; color: var(--ink); font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ap-node small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ap-mark { display: grid; flex: none; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--ap-fill); color: #fff; }
.ap-mark svg { width: 16px; height: 16px; }
.ap-mark.is-team { background: #1f8a5b; }
.ap-node.is-ai { border-style: dashed; opacity: .55; box-shadow: none; }
.ap-node.is-ai .ap-mark { background: var(--soft); color: var(--muted); }
.ap-wire { flex: 1; min-width: 40px; height: 2px; background: color-mix(in srgb, var(--muted) 45%, var(--line)); transition: background-color .2s var(--ease); }
.ap-card.is-on .ap-node.is-ai { border-style: solid; border-color: var(--blue); opacity: 1; box-shadow: 0 0 0 1px var(--blue), 0 0 22px color-mix(in srgb, var(--blue) 30%, transparent); }
.ap-card.is-on .ap-node.is-ai .ap-mark { background: var(--ap-fill); color: #fff; }
.ap-card.is-on .ap-wire { background: var(--blue); }
.ap-note { margin-top: 22px; }
.ap-note[hidden] { display: none; }
.ap-note label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 14px; font-weight: 600; }
.ap-box { position: relative; overflow: hidden; border: 1px solid color-mix(in srgb, var(--blue) 45%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--surface) 55%, #000); }
html[data-theme="light"] .ap-box { background: #fff; }
.ap-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.ap-box textarea:not(#_):not(#_) { display: block; width: 100%; min-height: 110px; max-height: 260px; padding: 12px 14px 30px; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--ink); font-size: 14px; line-height: 1.55; resize: none; }
.ap-box textarea:not(#_):not(#_):focus { border: 0; outline: 0; box-shadow: none; }
.ap-count { position: absolute; right: 12px; bottom: 9px; color: var(--muted); font-size: 12px; pointer-events: none; }

@media (max-width: 760px) {
  .ap-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .ap-instruction { grid-column: 2; grid-row: 2; }
  .ap-state { grid-column: 3; grid-row: 1; justify-self: end; }
  .ap-edit { grid-column: 3; grid-row: 2; }
  .ap-map { padding: 26px 20px; }
}
