/* "Build with AI" (web/ai/panel.js): the top-bar button, the drawer (desktop: right side over the picture; phone: a bottom sheet),
   the live timeline, the result report and the composer. Built on style.css's tokens (--panel, --card, --ink…, light and dark). */
:root {
	--ai-a: #6d4dff;
	--ai-b: #2c7bff;
	--ai-c: #12a8a0;
	--ai-grad: linear-gradient(135deg, var(--ai-a), var(--ai-b) 55%, var(--ai-c));
	--ai-soft: color-mix(in srgb, var(--ai-a) 10%, var(--card));
	--ai-ring: color-mix(in srgb, var(--ai-b) 55%, transparent);
	--ai-radius: 14px;
	--ai-w: 440px;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) { --ai-a: #9b87ff; --ai-b: #6aa2ff; --ai-c: #4fd1c5; --ai-soft: color-mix(in srgb, var(--ai-a) 16%, var(--card)); }
}
:root[data-theme="dark"] { --ai-a: #9b87ff; --ai-b: #6aa2ff; --ai-c: #4fd1c5; --ai-soft: color-mix(in srgb, var(--ai-a) 16%, var(--card)); }

/* ---------- the top-bar button ---------- */
.ai-btn {
	position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px 6px 10px; border-radius: 999px; font-weight: 650;
	color: var(--ink); border: 1px solid transparent; white-space: nowrap;
	background: linear-gradient(var(--card), var(--card)) padding-box, var(--ai-grad) border-box;
	box-shadow: 0 1px 2px rgba(40, 32, 20, 0.06), 0 2px 10px color-mix(in srgb, var(--ai-a) 18%, transparent);
	transition: box-shadow 0.2s, transform 0.12s;
}
.ai-btn:hover { box-shadow: 0 1px 2px rgba(40, 32, 20, 0.06), 0 4px 18px color-mix(in srgb, var(--ai-a) 30%, transparent); }
.ai-btn:active { transform: translateY(1px); }
.ai-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.ai-btn .ai-btn-ic { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; background: var(--ai-grad); }
.ai-btn .ai-btn-ic svg { width: 14px; height: 14px; fill: #fff; }
.ai-btn[aria-expanded="true"] { background: linear-gradient(var(--ai-soft), var(--ai-soft)) padding-box, var(--ai-grad) border-box; }
.ai-btn.busy::after {
	content: ""; position: absolute; inset: -3px; border-radius: inherit; padding: 2px; pointer-events: none;
	background: conic-gradient(from var(--ai-turn, 0deg), transparent 0 60%, var(--ai-b) 80%, var(--ai-a));
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
	animation: ai-turn 1.1s linear infinite;
}
.ai-btn.unseen::before { content: ""; position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--ai-c); box-shadow: 0 0 0 2px var(--panel); }
@property --ai-turn { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes ai-turn { to { --ai-turn: 360deg; } }

/* ---------- the drawer ---------- */
.ai-drawer {
	position: fixed; z-index: 45; top: var(--ai-top, 66px); right: 14px; bottom: 14px; width: min(var(--ai-w), calc(100vw - 28px));
	display: flex; flex-direction: column; min-height: 0; color: var(--ink);
	background: color-mix(in srgb, var(--panel) 96%, transparent); backdrop-filter: blur(14px) saturate(1.2);
	border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
	box-shadow: 0 18px 50px rgba(30, 24, 60, 0.18), 0 2px 8px rgba(30, 24, 60, 0.08);
	opacity: 0; transform: translateX(18px) scale(0.985); transform-origin: right center;
	transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
	contain: layout paint;
}
.ai-drawer.in { opacity: 1; transform: none; }
.ai-drawer::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--ai-grad); opacity: 0.9; }
.ai-grip { display: none; }

.ai-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px 16px; }
.ai-mark { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ai-grad); box-shadow: 0 4px 14px color-mix(in srgb, var(--ai-a) 35%, transparent); }
.ai-mark svg { width: 20px; height: 20px; fill: #fff; }
.ai-head-t { flex: 1; min-width: 0; }
.ai-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.ai-sub { margin: 1px 0 0; font-size: 12px; color: var(--ink-3); }
.ai-icon-btn { flex: none; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ink-2); }
.ai-icon-btn:hover { background: var(--card); border-color: var(--line); }
.ai-icon-btn svg, .ai-ic svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.ai-ic { display: inline-grid; place-items: center; flex: none; }

.ai-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px 14px; scroll-padding-bottom: 14px; }
.ai-scroll::-webkit-scrollbar { width: 10px; }
.ai-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- empty state ---------- */
.ai-hero { padding: 18px 6px 6px; text-align: center; }
.ai-hero-art { width: 56px; height: 56px; margin: 4px auto 12px; border-radius: 18px; display: grid; place-items: center; background: var(--ai-grad); box-shadow: 0 10px 30px color-mix(in srgb, var(--ai-a) 35%, transparent); animation: ai-float 5s ease-in-out infinite; }
.ai-hero-art svg { width: 30px; height: 30px; fill: #fff; }
@keyframes ai-float { 50% { transform: translateY(-4px) rotate(-3deg); } }
.ai-hero h3 { margin: 0 0 6px; font-size: 21px; letter-spacing: -0.02em; }
.ai-hero p { margin: 0 auto 16px; max-width: 360px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.ai-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.ai-ex {
	display: flex; align-items: center; gap: 9px; padding: 10px 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
	color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.25; text-align: left; transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.ai-ex:hover { border-color: color-mix(in srgb, var(--ai-b) 50%, var(--line)); box-shadow: 0 4px 16px color-mix(in srgb, var(--ai-a) 14%, transparent); transform: translateY(-1px); }
.ai-ex-ic { width: 30px; height: 30px; border-radius: 9px; background: var(--ai-soft); color: var(--ai-a); }
.ai-ex-ic svg { width: 18px; height: 18px; }

/* ---------- the thread ---------- */
.ai-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ai-turn { animation: ai-in 0.25s ease both; }
@keyframes ai-in { from { opacity: 0; transform: translateY(6px); } }
.ai-user { display: flex; justify-content: flex-end; }
.ai-bubble { max-width: 88%; padding: 9px 12px; border-radius: 14px 14px 4px 14px; background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai-a) 18%, var(--line)); }
.ai-bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-tag { display: inline-block; margin-bottom: 3px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ai-a); }
.ai-bubble-imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.ai-bubble-imgs img { width: 64px; height: 64px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }

.ai-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--ai-radius); box-shadow: var(--shadow); padding: 12px 14px; position: relative; overflow: hidden; }

/* live progress */
.ai-card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.ai-card-head b { flex: 1; font-size: 14px; }
.ai-total { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; }
.ai-orb { width: 14px; height: 14px; border-radius: 50%; background: var(--ai-grad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ai-b) 18%, transparent); animation: ai-pulse 1.4s ease-in-out infinite; }
@keyframes ai-pulse { 50% { transform: scale(0.82); box-shadow: 0 0 0 7px color-mix(in srgb, var(--ai-b) 6%, transparent); } }
.ai-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-step { display: flex; align-items: flex-start; gap: 10px; padding: 6px 4px; border-radius: 8px; color: var(--ink-3); transition: color 0.2s, background 0.2s; }
.ai-step-ic { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; box-sizing: border-box; }
.ai-step-ic svg { width: 12px; height: 12px; fill: #fff; }
.ai-step-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-step-l { font-size: 13px; }
.ai-step-sub { font-size: 11.5px; color: var(--ink-3); min-height: 0; }
.ai-step-sub:empty { display: none; }
.ai-step-t { flex: none; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-3); padding-top: 1px; }
.ai-step.st-active { color: var(--ink); background: color-mix(in srgb, var(--ai-soft) 70%, transparent); }
.ai-step.st-active .ai-step-l { font-weight: 650; }
.ai-step.st-active .ai-step-ic { border-color: color-mix(in srgb, var(--ai-b) 25%, transparent); border-top-color: var(--ai-b); border-right-color: var(--ai-a); animation: ai-spin 0.8s linear infinite; }
.ai-step.st-done { color: var(--ink-2); }
.ai-step.st-done .ai-step-ic { background: var(--ok); border-color: var(--ok); }
.ai-step.st-error .ai-step-ic { background: var(--bad); border-color: var(--bad); }
.ai-step.st-skipped { opacity: 0.55; }
.ai-step.st-skipped .ai-step-ic { border-style: dashed; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-shimmer { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--ai-b), var(--ai-a), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: ai-sweep 1.4s ease-in-out infinite; }
@keyframes ai-sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.ai-timeline-sum { margin: 0 2px 6px; font-size: 12px; color: var(--ink-3); }
.ai-timeline-sum > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.ai-timeline-sum > summary::before { content: "▸"; font-size: 10px; transition: transform 0.15s; }
.ai-timeline-sum[open] > summary::before { transform: rotate(90deg); }
.ai-timeline-sum > summary::-webkit-details-marker { display: none; }
.ai-timeline-sum .ai-steps { margin-top: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }

/* the result */
.ai-result { padding: 14px 14px 10px; }
.ai-res-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.ai-res-head > div { flex: 1; min-width: 0; }
.ai-res-title { margin: 0; font-size: 17px; letter-spacing: -0.015em; line-height: 1.25; }
.ai-res-stats { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
.ai-score { flex: none; display: inline-flex; align-items: baseline; gap: 1px; padding: 4px 9px; border-radius: 10px; font-variant-numeric: tabular-nums; border: 1px solid var(--line); }
.ai-score b { font-size: 17px; }
.ai-score small { font-size: 11px; color: var(--ink-3); }
.ai-score.good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.ai-score.mid { background: color-mix(in srgb, var(--changed) 14%, var(--card)); color: var(--changed); }
.ai-score.low { background: var(--bad-soft); color: var(--bad); }
.ai-score.none { align-self: center; padding: 3px 8px; background: var(--card); color: var(--ink-3); border-style: dashed; }
.ai-score.none small { font-size: 11px; color: inherit; white-space: nowrap; }

/* what went wrong while building (a check that couldn't run, a change that couldn't be made) */
.ai-notice { display: flex; gap: 9px; align-items: flex-start; margin: 4px 0 8px; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; line-height: 1.45;
	color: var(--ink); background: color-mix(in srgb, var(--changed) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--changed) 38%, transparent); }
.ai-notice p { margin: 0; }
.ai-notice p + p { margin-top: 3px; }
.ai-notice-ic { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--changed); }
/* what the run shows did not work */
.ai-problems { margin: 0 0 8px; padding: 8px 10px; border-radius: 10px; background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 28%, transparent); font-size: 12.5px; line-height: 1.45; }
.ai-problems b { display: block; margin-bottom: 2px; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--bad); }
.ai-problems ul { margin: 0; padding-left: 17px; color: var(--ink); }
.ai-plan-notes { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }

.ai-sec { border-top: 1px solid var(--line); padding: 8px 0 6px; }
.ai-sec > summary {
	cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
	font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); user-select: none;
}
.ai-sec > summary::-webkit-details-marker { display: none; }
.ai-sec > summary::after { content: "▾"; margin-left: auto; font-size: 11px; transition: transform 0.15s; }
.ai-sec:not([open]) > summary { margin-bottom: 0; }
.ai-sec:not([open]) > summary::after { transform: rotate(-90deg); }
.ai-list { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.ai-notes li.lv-warn { color: var(--changed); }
.ai-notes li.lv-error { color: var(--bad); }

.ai-goals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.ai-goals li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; font-weight: 600; font-size: 13px; }
.ai-goals li.g-ok { background: var(--ok-soft); color: var(--ok); }
.ai-goals li.g-bad { background: var(--bad-soft); color: var(--bad); }
.ai-goal-ic { width: 20px; height: 20px; border-radius: 50%; background: currentColor; }
.ai-goal-ic svg { width: 14px; height: 14px; fill: var(--card); }
.ai-goals li span:last-child { color: var(--ink); }

.ai-used { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.ai-used-card { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-width: 0; }
.ai-used-prev { display: grid; place-items: center; height: 46px; border-radius: 7px; background: var(--view-bg); overflow: hidden; }
.ai-used-prev canvas { width: 56px; height: 42px; display: block; }
.ai-used-name { font-size: 11.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-used-n { position: absolute; top: 4px; right: 4px; padding: 0 5px; border-radius: 999px; font-size: 10.5px; font-weight: 700; background: var(--ink); color: var(--card); font-variant-numeric: tabular-nums; }

.ai-missing { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-missing li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; background: color-mix(in srgb, var(--changed) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--changed) 35%, transparent); }
.ai-miss-asked { font-weight: 650; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--changed) 60%, transparent); }
.ai-miss-arrow { color: var(--ink-3); }
.ai-miss-sub { font-weight: 650; color: var(--ink); }
.ai-miss-none { color: var(--ink-3); font-size: 11.5px; }

.ai-rounds { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px solid color-mix(in srgb, var(--ai-b) 30%, var(--line)); display: flex; flex-direction: column; gap: 8px; }
.ai-rounds li { position: relative; }
.ai-rounds li::before { content: ""; position: absolute; left: -15px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--ai-grad); }
.ai-round-n { font-size: 12.5px; font-weight: 700; }
.ai-round-n small { font-weight: 500; color: var(--ink-3); }
.ai-rounds p { margin: 2px 0 0; font-size: 12.5px; }
.ai-round-issues { color: var(--ink-3); }
.ai-round-changes { color: var(--ink-2); }
.ai-round-rej { color: var(--changed); }
.ai-rounds li.undone .ai-round-changes { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-3) 70%, transparent); color: var(--ink-3); }
.ai-rounds li.other .ai-round-issues { color: var(--ink-3); } /* (a check of a version that is not on the table: its remarks are about that one) */
.ai-tag-undone { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--changed); background: color-mix(in srgb, var(--changed) 12%, var(--card)); }

.ai-res-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 9px; margin-top: 4px; }
.ai-chip-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font-size: 12.5px; font-weight: 600; }
.ai-chip-btn:hover { border-color: var(--ink-3); }
.ai-chip-btn .ai-ic svg { width: 15px; height: 15px; }
.ai-chip-btn.ai-primary { border-color: transparent; background: var(--ai-grad); color: #fff; }
.ai-res-meta { margin-left: auto; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }

.ai-how { margin: 2px 0 8px; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.ai-reply p, .ai-reply-text { margin: 0 0 6px; font-size: 13.5px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; }
.ai-reply-text { padding: 8px 10px; border-radius: 10px; background: var(--ai-soft); }

/* errors */
.ai-error .ai-err-head { display: flex; align-items: center; gap: 8px; }
.ai-err-ic { width: 22px; height: 22px; border-radius: 50%; background: var(--bad); }
.ai-err-ic svg { width: 14px; height: 14px; fill: #fff; }
.ai-error.ai-k-cancelled .ai-err-ic { background: var(--ink-3); }
.ai-error.ai-k-cancelled { box-shadow: none; background: transparent; }
.ai-err-msg { margin: 6px 0 4px; color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }

/* ---------- the composer ---------- */
.ai-composer { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 92%, transparent); }
.ai-mode { align-self: flex-start; display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); }
.ai-mode button { border: 0; background: transparent; padding: 3px 10px; border-radius: 7px; font-size: 12px; color: var(--ink-3); }
.ai-mode button[aria-checked="true"] { background: var(--card); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }
.ai-box { display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: var(--ai-radius); background: var(--card); transition: border-color 0.15s, box-shadow 0.15s; }
.ai-box:focus-within { border-color: color-mix(in srgb, var(--ai-b) 60%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-b) 16%, transparent); }
.ai-input {
	display: block; width: 100%; min-height: 48px; max-height: 220px; resize: none; border: 0; outline: 0; background: transparent;
	padding: 11px 13px 4px; font: inherit; font-size: 14.5px; line-height: 1.45; color: var(--ink);
}
.ai-input::placeholder { color: var(--ink-3); }
.ai-box-bar { display: flex; align-items: center; gap: 8px; padding: 4px 6px 6px 6px; }
.ai-hint { flex: 1; min-width: 0; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-send {
	flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; color: #fff;
	background: var(--ai-grad); box-shadow: 0 3px 12px color-mix(in srgb, var(--ai-a) 35%, transparent); transition: transform 0.12s, opacity 0.15s, filter 0.15s;
}
.ai-send svg { width: 18px; height: 18px; fill: #fff; }
.ai-send:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.ai-send:disabled { opacity: 0.38; box-shadow: none; cursor: default; }
.ai-send.stop { background: var(--ink); box-shadow: none; }
.ai-send.stop svg { fill: var(--card); }

.ai-attach-row { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 8px 0; }
.ai-attach-row[hidden] { display: none; }
.ai-thumb { position: relative; width: 58px; height: 58px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--view-bg); display: grid; place-items: center; }
.ai-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-thumb-x {
	position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center;
	background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 14px; line-height: 1; opacity: 0.9;
}
.ai-thumb-x:hover { opacity: 1; background: rgba(0, 0, 0, 0.8); }
.ai-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ai-b); animation: ai-spin 0.8s linear infinite; }

/* ---------- drop targets ---------- */
.ai-drop { position: absolute; inset: 8px; z-index: 5; border-radius: 14px; border: 2px dashed var(--ai-b); background: color-mix(in srgb, var(--ai-soft) 92%, transparent); display: grid; place-items: center; pointer-events: none; }
.ai-drop-in { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--ink-2); }
.ai-drop-in b { color: var(--ink); font-size: 15px; }
.ai-drop-ic { width: 44px; height: 44px; border-radius: 14px; background: var(--ai-grad); }
.ai-drop-ic svg { width: 24px; height: 24px; fill: #fff; }
.ai-view-drop { position: absolute; inset: 10px; z-index: 12; border-radius: 12px; border: 2px dashed var(--ai-b); background: color-mix(in srgb, var(--ai-soft) 60%, transparent); display: grid; place-items: center; pointer-events: none; backdrop-filter: blur(2px); }
.ai-view-drop > div { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.ai-view-drop .ai-ic { width: 26px; height: 26px; border-radius: 8px; background: var(--ai-grad); }
.ai-view-drop .ai-ic svg { width: 16px; height: 16px; fill: #fff; }

.ai-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.ai-drawer :focus-visible, .ai-btn:focus-visible { outline: 2px solid var(--ai-b); outline-offset: 2px; }
.ai-input:focus-visible { outline: 0; }

/* the view's own floating controls stay clear of the drawer on wide screens (the folded chip sits at the view's lower corner, out of their way) */
@media (min-width: 901px) {
	body.ai-open:not(.ai-folded) .view-tools { right: calc(min(var(--ai-w), 100vw - 28px) + 4px); transition: right 0.2s; }
}

/* ---------- folded (desktop): the drawer as one line at the view's lower right corner, so the scene being built can be watched ---------- */
.ai-mini { display: none; }
.ai-drawer.mini {
	top: var(--ai-mini-top, 76px); bottom: auto; right: var(--ai-mini-right, 14px); width: var(--ai-mini-w, 400px); height: auto;
	border-radius: 12px; box-shadow: 0 8px 24px rgba(30, 24, 60, 0.18), 0 1px 4px rgba(30, 24, 60, 0.08);
}
.ai-drawer.mini::before { height: 2px; }
.ai-drawer.mini > :not(.ai-mini) { display: none !important; }
.ai-drawer.mini > .ai-mini { display: flex; align-items: center; gap: 9px; padding: 6px 7px 5px 12px; }
.ai-mini .ai-chip-btn { padding: 4px 10px; }
body.ai-folded .edit-hint { visibility: hidden; }
.ai-mini .ai-orb { flex: none; }
.ai-mini .ai-orb.still { animation: none; box-shadow: none; }
.ai-mini-t { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.ai-mini-t b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-mini-t span { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.ai-mini .ai-chip-btn { flex: none; }

/* ---------- the draft: the AI's latest version playing in the view while it keeps checking (no editing meanwhile) ---------- */
body.ai-draft #view-3d { pointer-events: none; }
body.ai-draft .edit-hint { visibility: hidden; }
.ai-draft-badge {
	position: absolute; top: 10px; left: 12px; z-index: 7; display: inline-flex; align-items: center; gap: 8px; max-width: calc(100% - 24px);
	padding: 6px 13px 6px 10px; border-radius: 999px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; pointer-events: none;
	background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid color-mix(in srgb, var(--ai-b) 35%, var(--line)); box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.ai-draft-badge b { color: var(--ink); font-size: 12.5px; }
.ai-draft-badge span:last-child { overflow: hidden; text-overflow: ellipsis; }
body.ai-folded .ai-draft-badge { max-width: calc(100% - var(--ai-mini-w, 400px) - 260px); }
.ai-draft-badge .ai-orb { width: 10px; height: 10px; }

/* ---------- phones: a bottom sheet ---------- */
@media (max-width: 900px) {
	.ai-btn { padding: 6px 10px 6px 8px; }
	.ai-btn .ai-btn-t { display: none; }
	.ai-drawer {
		top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(86vh, 760px); max-height: calc(100dvh - 40px);
		border-radius: 18px 18px 0 0; border-bottom: 0; transform: translateY(102%); transform-origin: bottom center;
		box-shadow: 0 -12px 40px rgba(20, 16, 40, 0.24); opacity: 1;
	}
	.ai-drawer.in { transform: none; }
	.ai-grip { display: block; flex: none; height: 22px; margin-bottom: -10px; cursor: grab; touch-action: none; position: relative; }
	.ai-grip::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--line-2); }
	.ai-hint { visibility: hidden; }
	.ai-examples { grid-template-columns: 1fr; }
	.ai-composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
	.ai-drawer, .ai-turn, .ai-hero-art, .ai-orb, .ai-shimmer, .ai-step.st-active .ai-step-ic, .ai-btn.busy::after, .ai-spin { animation: none !important; transition: none !important; }
}
/* phones: the badge sits at the view's lower left, clear of the camera buttons along the top (the old scene's warnings are hidden meanwhile) */
@media (max-width: 900px) {
	.ai-draft-badge { top: auto; bottom: 8px; left: 8px; max-width: calc(100% - 16px); font-size: 12px; }
}
/* (the old scene's warnings are not about the draft playing in the view) */
body.ai-draft .viewport .warnings { display: none; }

/* ---------- round 2: differences up front, goal details, a quick change, the heartbeat of a long step ---------- */
/* what differs from the picture or the request (a mirrored layout, a stand added, a part not built): right under the title, never folded */
.ai-diffs { margin: 4px 0 8px; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; color: var(--ink);
	background: color-mix(in srgb, var(--ai-b) 9%, var(--card)); border: 1px solid color-mix(in srgb, var(--ai-b) 30%, transparent); }
.ai-diffs b { display: block; margin-bottom: 2px; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: color-mix(in srgb, var(--ai-b) 75%, var(--ink)); }
.ai-diffs ul { margin: 0; padding-left: 17px; }
.ai-diffs li + li { margin-top: 2px; }
.ai-goal-detail { font-weight: 500; color: var(--ink-2); }
.ai-goals li.g-unk { background: color-mix(in srgb, var(--changed) 12%, var(--card)); color: var(--changed); }
.ai-score.none.quick { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
/* a long model step's heartbeat: the row glows briefly each time the server says how far it has got */
.ai-step.beat .ai-step-sub { color: var(--ink-2); transition: color 0.2s; }
.ai-step .ai-step-sub { transition: color 0.6s; }
.ai-count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ai-count + .ai-send { margin-left: 0; }
@media (max-width: 900px) {
	.ai-input { font-size: 16px; } /* (iOS Safari zooms into a smaller field on focus) */
}
@media (prefers-reduced-motion: reduce) {
	.ai-step .ai-step-sub, .ai-step.beat .ai-step-sub { transition: none; }
}
.ai-quick-note { margin: 0 0 8px; font-size: 12px; line-height: 1.45; color: var(--ink-2); }
/* (a component's own display must never undo the hidden attribute: an Undo or Restore button that is not offered stays out of sight) */
.ai-drawer [hidden], .ai-draft-badge[hidden], .ai-view-drop[hidden] { display: none !important; }
.ai-ex-li { display: contents; }

/* ---------- Edit with AI (the drawer changes the scene on screen) and New (the "Create new project" dialog: ./new-project.js) ---------- */
/* Clear and Reset live in New now (Blank; Start from an example): their buttons stay in the page for the app's own wiring, never shown */
.top #clear[hidden], .top #reset[hidden] { display: none !important; }
.new-btn { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl-h); padding: 0 12px 0 9px; }
.new-btn svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
@media (max-width: 780px) { .new-btn { width: var(--ctl-h); padding: 0; justify-content: center; } .new-btn span { display: none; } }
/* (a phone's first row holds ☰, the logo, New, Add and Edit with AI: the app's name gives way to them; the logo stays) */
@media (max-width: 440px) { .top .brand h1 { display: none; } }
/* what the drawer works on, over the box */
.ai-editing { display: flex; align-items: baseline; gap: 6px; min-width: 0; margin: 0 2px 8px; font-size: 12.5px; color: var(--ink-2); }
.ai-editing-k { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ai-a); }
.ai-editing b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.ai-link { flex: none; border: 0; background: none; padding: 2px 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; cursor: pointer; }
.ai-link:hover { color: var(--ink); text-decoration-color: currentColor; }
.ai-hero-new { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }
/* the result card says what it was: "Edited: Rube Goldberg machine" or "New scene" */
.ai-res-kind { margin: 0 0 2px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ai-a); }
.ai-res-kind.new { color: color-mix(in srgb, var(--ai-c) 70%, var(--ink)); }
.ai-tag-new { color: color-mix(in srgb, var(--ai-c) 70%, var(--ink)); }
.ai-changes li.ai-same { color: var(--ink-3); list-style: none; margin-left: -14px; }
.ai-changes li.ai-same::before { content: "✓ "; color: var(--ok); }

/* the "Create new project" dialog: ui.css's dialog card, three ways to start, then the chosen one's pane */
dialog.np-dialog { --ui-w: 640px; }
.np-card { overflow-y: auto; }
.np-head { padding: 20px 56px 4px 22px; }
.np-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.np-head p { margin: 4px 0 0; color: var(--ink-2); font-size: var(--fs-md, 13px); }
.np-body { padding: 12px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.np-keep { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.45;
	background: color-mix(in srgb, var(--changed, #b86e00) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--changed, #b86e00) 35%, var(--line)); }
.np-keep p { margin: 0; flex: 1 1 260px; }
.np-keep-acts { display: flex; gap: 6px; }
.np-keep[hidden] { display: none; }
.np-choices .ui-start { text-align: left; min-height: 104px; cursor: pointer; }
.np-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.np-choice.ui-start-ai[aria-pressed="true"] { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ai-a) 40%, transparent), 0 8px 24px color-mix(in srgb, var(--ai-a) 14%, transparent); }
.np-pane[hidden] { display: none; }
.np-lede { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.np-go { display: flex; justify-content: flex-end; margin-top: 10px; }
.np-box { border: 1px solid var(--line-2); border-radius: 14px; background: var(--card); padding: 8px 10px; }
.np-box:focus-within { border-color: var(--ai-b); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-b) 18%, transparent); }
.np-input { width: 100%; box-sizing: border-box; border: 0; outline: 0; resize: vertical; min-height: 72px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; line-height: 1.45; }
.np-attach { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.np-attach[hidden] { display: none; }
.np-thumb { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.np-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.np-thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; }
.np-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.np-hint { flex: 1; font-size: 11.5px; color: var(--ink-3); }
.np-btn, .np-primary { display: inline-flex; align-items: center; gap: 6px; height: var(--ctl-h); padding: 0 12px; border-radius: var(--r-pill); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap; }
.np-btn { border: 1px solid var(--line-2); background: var(--card); color: var(--ink); }
.np-btn:hover { border-color: var(--ink-3); }
.np-primary { border: 0; background: var(--accent); color: var(--on-accent, #fff); padding: 0 16px; }
.np-primary:disabled { opacity: 0.5; cursor: default; }
.np-primary.np-ai { background: var(--ai-grad); color: #fff; }
.np-ic { display: grid; place-items: center; }
.np-ic svg { width: 16px; height: 16px; fill: currentColor; }
.np-ex-t { margin: 14px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.np-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.np-ex-li { display: contents; }
.np-ex { border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); border-radius: var(--r-pill); padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer; }
.np-ex:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ai-a) 45%, var(--line-2)); }
.np-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.np-list > p { grid-column: 1 / -1; }
.np-item { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.np-item:hover { border-color: var(--accent); }
.np-item b { font-size: 13.5px; }
.np-item span { font-size: 11.5px; color: var(--ink-3); }
.np-msg { margin: 0; min-height: 0; font-size: 12.5px; color: var(--bad, #c0392b); }
.np-msg:empty { display: none; }
.np-dialog :focus-visible { outline: 2px solid var(--ai-b); outline-offset: 2px; }
.np-input:focus-visible { outline: 0; }
@media (max-width: 640px) {
	.np-head { padding: 18px 52px 2px 16px; }
	.np-body { padding: 10px 16px max(16px, env(safe-area-inset-bottom)); }
	.np-choices { grid-template-columns: 1fr; gap: 8px; }
	.np-choices .ui-start { display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; row-gap: 1px; align-items: center; padding: 10px 12px; min-height: 0; }
	.np-choices .ui-start .ui-start-ic { grid-row: span 2; }
	.np-choices .ui-start b { margin-top: 0; }
	.np-input { font-size: 16px; }
	.np-hint { display: none; }
	.np-list { grid-template-columns: 1fr; }
}

/* ---------- the reply card: one sentence, a heads-up, next edits to try, then Details (everything else) ---------- */
.ai-chat { padding-top: 12px; }
.ai-lead { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: var(--ink); }
.ai-ok-mark { color: var(--ok); font-weight: 700; }
.ai-bad-mark { color: var(--bad, #c0392b); font-weight: 700; }
.ai-heads { margin: 0 0 10px; padding: 7px 10px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2);
	background: color-mix(in srgb, var(--changed, #b86e00) 9%, var(--card)); border: 1px solid color-mix(in srgb, var(--changed, #b86e00) 28%, transparent); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.ai-sugg { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 11px 6px 8px; border-radius: var(--r-pill, 999px); font: inherit; font-size: 12.5px; line-height: 1.3; text-align: left; cursor: pointer;
	color: var(--ink); background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai-a) 26%, var(--line)); }
.ai-sugg:hover { border-color: color-mix(in srgb, var(--ai-a) 60%, var(--line)); }
.ai-sugg .ai-ic { width: 16px; height: 16px; flex: none; color: var(--ai-a); }
.ai-sugg .ai-ic svg { width: 14px; height: 14px; fill: currentColor; }
.ai-sugg span { overflow: hidden; text-overflow: ellipsis; }
.ai-sugg.fix { background: color-mix(in srgb, var(--ok) 10%, var(--card)); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.ai-sugg.fix .ai-ic { color: var(--ok); }
/* the checked fix: the reply's own offer ("Want me to …?"), one click away */
.ai-sugg.go { color: var(--card); font-weight: 600; background: var(--ok); border-color: color-mix(in srgb, var(--ok) 80%, #000); box-shadow: 0 1px 6px color-mix(in srgb, var(--ok) 30%, transparent); }
.ai-sugg.go .ai-ic { color: var(--card); }
.ai-sugg.go:hover { border-color: color-mix(in srgb, var(--ok) 60%, #000); filter: brightness(1.05); }
.ai-checked { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.ai-fixline { display: flex; align-items: center; gap: 8px; margin: -2px 0 10px; font-size: 13px; color: var(--ink-2); flex-wrap: nowrap; min-width: 0; }
.ai-fixline .ai-spin { width: 14px; height: 14px; flex: none; }
/* (one row in the 410 px drawer: the words cut short with "…", the Stop always on the right: V8820, three cramped columns) */
.ai-fixline-t { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-fixline-n { color: var(--ink-3); font-size: 12px; }
.ai-fixline .ai-fixstop { margin-left: auto; flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; }
.ai-fixline .ai-fixstop .ai-ic, .ai-fixline .ai-fixstop svg { width: 11px; height: 11px; fill: currentColor; }
.ai-tag-fix { color: var(--ok); }
.ai-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; padding-top: 8px; border-top: 1px solid var(--line); }
.ai-link-btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 3px 0; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.ai-link-btn:hover { color: var(--ink); }
.ai-link-btn .ai-ic { width: 15px; height: 15px; }
.ai-link-btn .ai-ic svg { width: 15px; height: 15px; fill: currentColor; }
.ai-details::after { content: "▸"; font-size: 10px; margin-left: 3px; transition: transform 0.15s; display: inline-block; }
.ai-details[aria-expanded="true"]::after { transform: rotate(90deg); }
.ai-foot-score { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
.ai-foot-score.good { color: var(--ok); }
.ai-foot-score.low { color: var(--bad, #c0392b); }
.ai-more-body { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.ai-more-body[hidden] { display: none; }
.ai-more-body .ai-timeline-sum { margin-bottom: 8px; }
.ai-reply-text b { font-weight: 600; color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .ai-details::after { transition: none; } }
/* (next edits, and the button that asks the AI to rework it, are offered on the latest reply only: an older card's ideas were for the scene as
   it was then. The panel marks the older cards (.ai-stale) by turn: anything after the latest card never hides its buttons) */
.ai-thread > li.ai-bot.ai-stale .ai-chips, .ai-thread > li.ai-bot.ai-stale .ai-offer-btn, .ai-thread > li.ai-bot.ai-stale .ai-again-btn, .ai-thread > li.ai-bot.ai-stale .ai-check, .ai-thread > li.ai-bot.ai-stale .ai-retry { display: none; }
/* the checked chip shows once, on the newest live card: an answer after the card that offers it shows it there (.ai-offer-moved) */
.ai-thread > li.ai-bot.ai-offer-moved .ai-chips button.go { display: none; }
.ai-offer-btn { display: inline-flex; align-items: center; gap: 5px; margin: 4px 0 0; padding: 4px 11px 4px 8px; border-radius: var(--r-pill, 999px); font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.3; cursor: pointer; vertical-align: baseline;
	color: var(--ai-a); background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai-a) 35%, var(--line)); }
.ai-offer-btn:hover { border-color: color-mix(in srgb, var(--ai-a) 65%, var(--line)); }
.ai-offer-btn .ai-ic { width: 15px; height: 15px; flex: none; }
.ai-offer-btn .ai-ic svg { width: 13px; height: 13px; fill: currentColor; }
/* (after the search's Stop: the physics again, no AI call) */
.ai-again-btn { display: inline-flex; align-items: center; gap: 5px; margin: 4px 0 0; padding: 4px 11px 4px 8px; border-radius: var(--r-pill, 999px); font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1.3; cursor: pointer; vertical-align: baseline; color: var(--ink-2); background: var(--card); border: 1px solid var(--line-2); }
.ai-again-btn:hover { color: var(--ink); border-color: var(--line); }
.ai-again-btn .ai-ic { width: 15px; height: 15px; flex: none; }
.ai-again-btn .ai-ic svg { width: 13px; height: 13px; fill: currentColor; }

/* ---------- whether the AI can be used here (./access.js): said in place of the box, before anything is typed ---------- */
.ai-access { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 12px 13px; border-radius: var(--ai-radius); border: 1px solid var(--line-2); background: var(--card); }
.ai-access[hidden] { display: none; }
.ai-access-ic { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--ai-soft); color: var(--ai-a); }
.ai-access-ic svg { width: 17px; height: 17px; fill: currentColor; }
.ai-access[data-kind="off"] .ai-access-ic { background: color-mix(in srgb, var(--ink-3) 14%, var(--card)); color: var(--ink-2); }
.ai-access[data-kind="quota"] .ai-access-ic { background: color-mix(in srgb, #d98a00 14%, var(--card)); color: #b06f00; }
.ai-access-t { flex: 1 1 220px; min-width: 0; }
.ai-access-t b { display: block; font-size: 13.5px; line-height: 1.35; }
.ai-access-t p { margin: 3px 0 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.ai-access-acts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; padding-left: 40px; }
.ai-google { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: border-color 0.15s, box-shadow 0.15s; }
.ai-google:hover { border-color: var(--ink-3); box-shadow: var(--shadow); }
.ai-g { display: grid; place-items: center; }
.ai-g svg { width: 17px; height: 17px; display: block; }
.ai-refusal .ai-err-ic { background: var(--ai-soft); }
.ai-refusal .ai-err-ic svg { fill: var(--ai-a); }
.ai-refusal.ai-k-quota .ai-err-ic { background: color-mix(in srgb, #d98a00 16%, var(--card)); }
.ai-refusal.ai-k-quota .ai-err-ic svg { fill: #b06f00; }
.ai-refusal.ai-k-off .ai-err-ic { background: color-mix(in srgb, var(--ink-3) 16%, var(--card)); }
.ai-refusal.ai-k-off .ai-err-ic svg { fill: var(--ink-2); }
.ai-refusal .ai-res-actions { margin-top: 8px; }
/* the top bar's Edit with AI where this deployment has no AI: it still opens, to say why */
.ai-btn.ai-off { opacity: 0.62; filter: saturate(0.2); }
/* the plan's stages on the card */
.ai-stages .ai-stage-n { font-weight: 600; color: var(--ink-3); }

/* New → Build with AI: needs an account (said before anything is typed), or not here / not today */
.np-access { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-bottom: 10px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); }
.np-access[hidden] { display: none; }
.np-access .ai-access-ic { width: 28px; height: 28px; }
.np-access .ai-access-acts { padding-left: 38px; }
.np-choice.np-off { opacity: 0.7; }
.np-choice.np-off span:last-child { color: var(--ink-3); }

/* the empty drawer where the AI can't be used: the welcome gives way to why (muted, no float) */
.ai-hero-art.ai-hero-art-off { background: var(--card); border: 1px solid var(--line-2); box-shadow: none; animation: none; }
.ai-hero-art.ai-hero-art-off svg { fill: var(--ink-3); }

/* ---------- round 3: the concept sketch (New → Build with AI), the edit card per kind, the example gallery ---------- */
/* the concept sketch in the progress card: the picture, said to be AI-made, what it is built from and the idea step by step */
.ai-concept-fig { margin: 10px 0 2px; padding: 0; animation: ai-in 0.3s ease both; }
.ai-concept-frame { position: relative; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); background: var(--view-bg); aspect-ratio: 3 / 2; }
.ai-concept-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ai-concept-tag {
	position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px;
	font-size: 11px; font-weight: 700; letter-spacing: 0.01em; color: #fff; background: rgba(20, 16, 40, 0.72); backdrop-filter: blur(6px);
}
.ai-concept-tag svg { width: 12px; height: 12px; fill: currentColor; display: block; }
.ai-concept-cap { margin: 7px 1px 0; font-size: 12px; line-height: 1.45; color: var(--ink-2); }
.ai-cast { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.ai-cast li { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--ink); background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai-a) 22%, var(--line)); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-story { margin: 8px 0 0; padding-left: 20px; font-size: 12px; line-height: 1.45; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; }
.ai-story li::marker { color: var(--ai-a); font-weight: 700; }

/* the result card: the sketch as a small thumbnail beside the reply; a click shows it next to the scene's start */
.ai-lead-row { display: flex; align-items: flex-start; gap: 12px; }
.ai-lead-row .ai-lead { flex: 1; min-width: 0; }
.ai-cthumb {
	flex: none; position: relative; width: 92px; padding: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; cursor: zoom-in;
	background: var(--view-bg); aspect-ratio: 3 / 2; transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.ai-cthumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ai-cthumb span { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0 3px; font-size: 10.5px; font-weight: 700; text-align: center; color: #fff; background: linear-gradient(transparent, rgba(10, 8, 24, 0.75)); }
.ai-cthumb:hover { border-color: color-mix(in srgb, var(--ai-b) 55%, var(--line)); box-shadow: 0 4px 14px color-mix(in srgb, var(--ai-a) 18%, transparent); transform: translateY(-1px); }

/* concept | the scene's start, side by side */
dialog.ai-cmp {
	width: min(1180px, calc(100vw - 48px)); max-width: none; max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line); border-radius: 16px;
	background: var(--panel); color: var(--ink); box-shadow: 0 24px 70px rgba(20, 16, 40, 0.35);
}
dialog.ai-cmp::backdrop { background: rgba(14, 12, 28, 0.55); backdrop-filter: blur(3px); }
.ai-cmp-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 4px 20px; }
.ai-cmp-head h2 { flex: 1; margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.ai-cmp-body { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 14px; padding: 10px 20px 18px; }
.ai-cmp-body figure { margin: 0; min-width: 0; }
/* (both frames one shape, each picture whole inside it: the 3:2 sketch and the 16:9 start sit side by side and their captions line up) */
.ai-cmp-pic { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--view-bg); aspect-ratio: 16 / 10; display: grid; place-items: center; }
.ai-cmp-pic img { width: 100%; height: 100%; display: block; object-fit: contain; }
.ai-cmp-pic .ai-spin { width: 22px; height: 22px; }
.ai-cmp-pic p { margin: 0; padding: 0 20px; text-align: center; font-size: 13px; color: var(--ink-3); }
.ai-cmp-body figcaption { margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
.ai-cmp-body figcaption b { display: block; margin-bottom: 1px; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.ai-cmp-body figure:first-child figcaption b { color: var(--ai-a); }

/* Edit with AI: one card per kind */
.ai-ask-chips { margin: 4px 0 2px; }
.ai-editcard .ai-res-kind { margin-bottom: 4px; }
.ai-delta { list-style: none; margin: -2px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.45; color: var(--ink); }
.ai-delta li { position: relative; padding-left: 16px; }
.ai-delta li::before { content: ""; position: absolute; left: 3px; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--ai-grad); }
.ai-delta li.skip { color: var(--changed); }
.ai-delta li.skip::before { background: var(--changed); }
.ai-delta li.same { color: var(--ink-3); }
.ai-delta li.same::before { content: "✓"; width: auto; height: auto; top: 0; left: 1px; border-radius: 0; background: none; color: var(--ok); font-weight: 700; font-size: 12px; }
.ai-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 10px; font-size: 12.5px; line-height: 1.45; }
.ai-kv dt { color: var(--ink-3); font-weight: 600; }
.ai-kv dd { margin: 0; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.ai-info { margin: 0 0 8px; font-size: 12px; line-height: 1.45; color: var(--ink-3); }

/* New → Build with AI: the concept sketch setting, one line under the box */
.np-concept { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.np-concept-k { font-weight: 650; color: var(--ink); }
.np-seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--bg, var(--panel)); border: 1px solid var(--line); }
.np-seg button { border: 0; background: transparent; padding: 3px 11px; border-radius: 7px; font: inherit; font-size: 12px; color: var(--ink-3); cursor: pointer; }
.np-seg button:hover:not(:disabled) { color: var(--ink); }
.np-seg button[aria-checked="true"] { background: var(--card); color: var(--ink); font-weight: 650; box-shadow: var(--shadow); }
.np-seg button:disabled { cursor: default; }
.np-concept-hint { color: var(--ink-3); font-size: 12px; }
.np-concept.np-concept-photo .np-seg { opacity: 0.6; }
.np-concept[hidden] { display: none; }

/* Start from an example: the gallery of machines built with AI (web/gallery), then the classic machines */
.np-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.np-gallery[hidden], .np-ex-t[hidden] { display: none; }
.np-gal-head { margin-top: 0; }
.np-gal { width: 100%; height: 100%; display: flex; align-items: stretch; gap: 0; padding: 0; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s; }
.np-gal:hover { border-color: color-mix(in srgb, var(--ai-b) 50%, var(--line-2)); box-shadow: 0 6px 18px color-mix(in srgb, var(--ai-a) 14%, transparent); transform: translateY(-1px); }
.np-gal[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.np-gal-img { position: relative; flex: none; width: 128px; align-self: stretch; min-height: 72px; background: var(--view-bg); border-right: 1px solid var(--line); }
.np-gal-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.np-gal-t { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 7px 10px 8px; min-width: 0; }
.np-gal-t b { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.np-gal-n { position: absolute; left: 5px; bottom: 5px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; color: #fff; background: rgba(20, 16, 40, 0.68); backdrop-filter: blur(4px); white-space: nowrap; }
.np-gal-t > span { font-size: 11.5px; line-height: 1.35; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.np-gal-li { display: contents; }
@media (prefers-reduced-motion: reduce) { .ai-concept-fig, .ai-cthumb, .np-gal { animation: none !important; transition: none !important; } }

/* the progress card's header (what it is doing, the timer, Cancel) stays at the top of the drawer while its steps and the concept sketch scroll */
.ai-card.ai-progress { overflow: clip; }
.ai-progress .ai-card-head { position: sticky; top: 0; z-index: 2; margin: -12px -14px 2px; padding: 12px 14px 6px; background: var(--card); border-radius: var(--ai-radius) var(--ai-radius) 0 0; }

/* an error's own words and the step it stopped at, folded under the card */
.ai-err-more { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.ai-err-more > summary { cursor: pointer; width: max-content; }
.ai-err-more > summary:hover { color: var(--ink-2); }
.ai-err-more p { margin: 4px 0 0; overflow-wrap: anywhere; line-height: 1.45; }
