/* PressGo AI Builder — fullscreen view (native WP-admin flavor) */

* { box-sizing: border-box; }
html, body {
	margin: 0; padding: 0; height: 100%;
	background: #f0f0f1;
	color: #1d2327;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
	font-size: 13px;
}
.pg-builder-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ─── Topbar ────────────────────────────────────────────────────────── */
.pg-builder-topbar {
	display: flex; align-items: center; gap: 12px;
	height: 50px; padding: 0 16px;
	background: #fff;
	border-bottom: 1px solid #dcdcde;
	flex-shrink: 0;
	box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.pg-builder-back {
	color: #50575e; text-decoration: none; font-size: 18px;
	width: 30px; height: 30px;
	display: inline-flex; align-items: center; justify-content: center;
	border-radius: 4px;
	border: 1px solid transparent;
	transition: background 0.12s ease, border-color 0.12s ease;
}
.pg-builder-back:hover { background: #f6f7f7; border-color: #c3c4c7; color: #1d2327; }

.pg-builder-title {
	font-size: 14px; font-weight: 600; color: #1d2327;
	flex: 1; min-width: 0;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pg-builder-title::before {
	content: '';
	display: inline-block;
	width: 18px; height: 18px;
	margin-right: 8px; vertical-align: -4px;
	background: linear-gradient(135deg, #5b4fff 0%, #b893ff 100%);
	border-radius: 4px;
	box-shadow: 0 1px 2px rgba(91,79,255,0.3);
}

.pg-builder-actions { display: flex; align-items: center; gap: 10px; }
.pg-credits-pill {
	font-size: 12px; font-weight: 500;
	padding: 5px 12px; border-radius: 999px;
	background: #f0f0f1; color: #50575e;
	border: 1px solid #dcdcde;
	transition: background 0.4s ease, color 0.4s ease, transform 0.25s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}
.pg-status-pill {
	font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
	padding: 3px 10px; border-radius: 999px; cursor: pointer; user-select: none;
	background: #f0f0f1; color: #6b7280; border: 1px solid #dcdcde;
}
.pg-status-pill.is-live { background: #e7f7ee; color: #157347; border-color: #abe3c3; }
#pg-page-title[contenteditable="true"] { outline: 2px solid #5b4fff; border-radius: 4px; padding: 0 6px; }
.pg-brand-panel {
	position: absolute; top: 48px; right: 12px; z-index: 60;
	width: 380px; max-height: calc(100vh - 80px); overflow-y: auto;
	background: #fff; border: 1px solid #dcdcde;
	border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.14);
	padding: 16px 18px; display: flex; flex-direction: column; gap: 12px;
	font-size: 13px; text-align: left;
}
.pg-brand-head { display: flex; justify-content: space-between; align-items: center; }
.pg-brand-head strong { font-size: 15px; }
.pg-brand-dot {
	display: inline-block; width: 8px; height: 8px; border-radius: 50%;
	margin-right: 6px; vertical-align: 1px; background: #9CA3AF;
}
.pg-brand-dot.is-on { background: #22C55E; }
.pg-brand-toggle { font-size: 12px; color: #50575e; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.pg-brand-saved {
	margin: 0; padding: 8px 11px; border-radius: 8px;
	background: #ecfdf5; color: #047857; font-size: 12px; font-weight: 600; line-height: 1.35;
}
.pg-brand-section {
	border-top: 1px solid #f0f0f1; padding-top: 12px; display: flex; flex-direction: column; gap: 8px;
}
.pg-brand-section:first-of-type { border-top: none; padding-top: 0; }
.pg-brand-section-title {
	font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
	color: #9ca3af; margin-bottom: 2px;
}
.pg-brand-row { display: flex; align-items: center; gap: 8px; }
.pg-brand-row > span { width: 64px; color: #6b7280; font-size: 12px; flex-shrink: 0; }
.pg-brand-row input[type="text"], .pg-brand-row textarea {
	flex: 1; border: 1px solid #dcdcde; border-radius: 6px; padding: 5px 8px; font-size: 13px;
}
.pg-brand-row select, .pg-brand-select {
	flex: 1; border: 1px solid #dcdcde; border-radius: 6px; padding: 5px 8px; font-size: 13px;
	background: #fff; cursor: pointer; appearance: none; -webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px;
}
.pg-brand-select optgroup { font-style: normal; font-weight: 600; color: #6b7280; font-size: 11px; }
.pg-brand-select option { font-weight: 400; color: #1a1a1a; padding: 2px 0; }

/* Color swatches v2 */
.pg-brand-color-group-label { font-size: 11px; color: #9ca3af; font-weight: 600; margin-top: 4px; }
.pg-brand-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.pg-brand-swatch2 {
	display: flex; flex-direction: column; align-items: center; gap: 3px;
	width: 72px; cursor: pointer; position: relative;
}
.pg-brand-swatch2 input[type="color"] {
	width: 100%; height: 36px; border: 1px solid #dcdcde; border-radius: 6px; padding: 1px;
	background: #fff; cursor: pointer; opacity: 0; position: absolute; top: 0; left: 0;
}
.pg-brand-swatch2-color {
	width: 100%; height: 36px; border: 1px solid #dcdcde; border-radius: 6px;
	background-size: cover; pointer-events: none;
}
.pg-brand-swatch2-label { font-size: 10px; color: #50575e; text-align: center; line-height: 1.2; }
.pg-brand-swatch2-hex { font-size: 9px; color: #9ca3af; font-family: monospace; }

/* Logo / favicon upload */
.pg-brand-upload {
	display: flex; align-items: center; gap: 10px; padding: 6px 0;
}
.pg-brand-upload-preview {
	width: 40px; height: 40px; border: 1px solid #dcdcde; border-radius: 6px;
	background-size: contain; background-position: center; background-repeat: no-repeat;
	background-color: #f9fafb; flex-shrink: 0;
}
.pg-brand-upload-preview.is-empty {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23d1d5db' stroke-width='2'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='m21 15-5-5L5 21'/%3E%3C/svg%3E");
	background-position: center; background-repeat: no-repeat;
}
.pg-brand-upload-info { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pg-brand-upload-label { font-size: 12px; color: #374151; font-weight: 600; }
.pg-brand-upload-url { font-size: 11px; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-brand-upload-btn {
	font-size: 12px; padding: 4px 10px; border: 1px solid #dcdcde; border-radius: 6px;
	background: #fff; color: #374151; cursor: pointer; flex-shrink: 0;
}
.pg-brand-upload-btn:hover { background: #f9fafb; }
.pg-brand-upload-btn:disabled { opacity: 0.6; cursor: default; }

.pg-brand-foot { display: flex; justify-content: space-between; margin-top: 4px; padding-top: 12px; border-top: 1px solid #f0f0f1; }
.pg-builder-topbar { position: relative; }
select#pg-target-builder {
	font-size: 12px; padding: 4px 8px;
	border: 1px solid #dcdcde; border-radius: 6px;
	background: #fff; color: #50575e; cursor: pointer;
}
.pg-credits-pill.is-low {
	background: #fcf3e6; color: #996800;
	border-color: #f0c33c;
}
.pg-credits-pill.is-low:hover { background: #f7e8c9; }
.pg-msg-note {
	align-self: center;
	font-size: 13px; color: #786300;
	background: #fcf9e8; border: 1px solid #f0e6aa;
	border-radius: 10px; padding: 8px 14px;
	max-width: 85%;
}
.pg-msg-note a { color: #5b4fff; font-weight: 600; }
.pg-next-pages {
	align-self: stretch;
	background: #fafaff; border: 1px solid #e4e1ff;
	border-radius: 12px; padding: 12px 16px;
}
.pg-next-pages-head { font-size: 13px; color: #50575e; }
.pg-credits-pill.is-flash {
	background: linear-gradient(90deg, #5b4fff, #b893ff);
	color: #fff;
	border-color: transparent;
	transform: scale(1.08);
	box-shadow: 0 0 18px rgba(91,79,255,0.45);
	animation: pg-credit-bump 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pg-credit-bump {
	0%   { transform: scale(1); }
	30%  { transform: scale(1.18); }
	60%  { transform: scale(0.96); }
	100% { transform: scale(1.08); }
}

.pg-builder-link {
	font-size: 12px; font-weight: 500;
	color: #fff; text-decoration: none;
	padding: 6px 14px; border-radius: 4px;
	background: #2271b1;
	border: 1px solid #2271b1;
	transition: background 0.12s ease;
}
.pg-builder-link:hover { background: #135e96; color: #fff; }

/* Ghost button — secondary action in topbar (Clear chat). */
.pg-builder-ghost {
	font-size: 12px; font-weight: 500;
	color: #50575e;
	background: transparent;
	border: 1px solid #dcdcde;
	padding: 5px 12px;
	border-radius: 4px;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.pg-builder-ghost:hover {
	background: #f6f7f7;
	border-color: #a7aaad;
	color: #1d2327;
}
.pg-builder-ghost:active { background: #ececef; }

/* ─── Shell ─────────────────────────────────────────────────────────── */
.pg-builder-shell { display: flex; flex: 1; min-height: 0; }

/* ─── Chat panel ────────────────────────────────────────────────────── */
.pg-chat {
	width: 400px; min-width: 340px; max-width: 50%;
	display: flex; flex-direction: column;
	background: #fff;
	border-right: 1px solid #dcdcde;
}
.pg-chat-log {
	flex: 1; overflow-y: auto;
	padding: 20px;
	display: flex; flex-direction: column; gap: 14px;
	scroll-behavior: smooth;
}

/* Bubble entrance — slide up + fade. Applied to every child of #pg-chat-log */
@keyframes pg-bubble-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}
#pg-chat-log > * {
	animation: pg-bubble-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.pg-msg { max-width: 100%; }

.pg-msg-user {
	align-self: flex-end;
	background: linear-gradient(135deg, #2271b1 0%, #3858e9 100%);
	color: #fff;
	padding: 10px 14px;
	border-radius: 14px 14px 4px 14px;
	font-size: 13px; line-height: 1.5;
	max-width: 88%;
	white-space: pre-wrap; word-wrap: break-word;
	box-shadow: 0 1px 2px rgba(34, 113, 177, 0.2);
	display: flex; flex-direction: column; gap: 8px;
}
.pg-msg-user-image {
	max-width: 100%;
	max-height: 240px;
	border-radius: 8px;
	border: 1px solid rgba(255,255,255,0.3);
	display: block;
}

.pg-msg-assistant {
	align-self: flex-start;
	background: #f6f7f7;
	color: #1d2327;
	padding: 10px 14px;
	border-radius: 14px 14px 14px 4px;
	border: 1px solid #e5e7e9;
	font-size: 13px; line-height: 1.55;
	max-width: 92%;
	white-space: pre-wrap; word-wrap: break-word;
}

.pg-msg-system {
	align-self: center;
	background: transparent;
	color: #8c8f94;
	padding: 6px 10px;
	font-size: 12px;
	font-style: italic;
	text-align: center;
	max-width: 80%;
	line-height: 1.5;
}

/* Assistant lines (build notes, questions, suggestions intro). Previously had no
   style at all, so they rendered as flat plain text. */
.pg-msg-ai {
	align-self: flex-start;
	background: #f6f7f7;
	color: #1d2327;
	padding: 10px 14px;
	border-radius: 14px 14px 14px 4px;
	border: 1px solid #e6e7ea;
	font-size: 13px; line-height: 1.55;
	max-width: 92%;
	white-space: pre-wrap; word-wrap: break-word;
}
/* Conversational reply — when Nova is TALKING to you (not confirming a build).
   Softer lavender bubble, roomier type, a small accent mark, so an answer reads
   like a chat, not a terse system note. */
.pg-msg-convo {
	background: linear-gradient(135deg, #f5f3ff 0%, #f7f8fc 100%);
	border: 1px solid #e5e1fb;
	border-radius: 16px 16px 16px 5px;
	padding: 12px 16px;
	font-size: 14px; line-height: 1.62;
	color: #2c2842;
	max-width: 94%;
	box-shadow: 0 1px 2px rgba(91, 79, 255, 0.06);
}
.pg-msg-convo::before {
	content: 'Nova';
	display: block;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #5b4fff;
	opacity: 0.75;
	margin-bottom: 5px;
}

/* Built bubble — celebrate the moment. Purple accent w/ shimmer + sparkle. */
@keyframes pg-built-pop {
	0%   { opacity: 0; transform: scale(0.94) translateY(8px); box-shadow: 0 0 0 rgba(91,79,255,0); }
	50%  { opacity: 1; transform: scale(1.02) translateY(0);   box-shadow: 0 4px 24px rgba(91,79,255,0.28); }
	100% { opacity: 1; transform: scale(1);                    box-shadow: 0 1px 3px rgba(91,79,255,0.12); }
}
@keyframes pg-built-shimmer {
	0%   { background-position: -200% 0; }
	100% { background-position: 200% 0; }
}
.pg-msg-built {
	align-self: stretch;
	position: relative;
	background:
		linear-gradient(#fff, #fff) padding-box,
		linear-gradient(90deg, #5b4fff 0%, #b893ff 25%, #5b4fff 50%, #b893ff 75%, #5b4fff 100%) border-box;
	background-size: 100% 100%, 200% 100%;
	border: 1.5px solid transparent;
	color: #1d2327;
	padding: 12px 16px;
	border-radius: 10px;
	font-size: 13px; line-height: 1.5;
	box-shadow: 0 1px 3px rgba(91,79,255,0.12);
	animation:
		pg-bubble-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both,
		pg-built-pop 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both,
		pg-built-shimmer 2.4s ease-in-out 0.3s 1;
}
.pg-msg-built::before {
	content: '✨';
	display: inline-block;
	margin-right: 8px;
	animation: pg-sparkle 1.4s ease-in-out infinite;
}
@keyframes pg-sparkle {
	0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.85; }
	50%      { transform: scale(1.2) rotate(15deg); opacity: 1; }
}
.pg-msg-built strong { color: #5b4fff; font-weight: 600; }

/* Error bubble */
.pg-msg-error {
	align-self: stretch;
	background: #fcf0f1;
	border: 1px solid #f0b3b8;
	color: #8a1f2a;
	padding: 10px 14px; border-radius: 8px;
	font-size: 13px; line-height: 1.5;
}
.pg-msg-warn {
	align-self: stretch;
	background: #fff8e6;
	border: 1px solid #f3d27a;
	color: #7a5a10;
	padding: 10px 14px; border-radius: 8px;
	font-size: 13px; line-height: 1.5;
}
.pg-error-actions {
	display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.pg-error-btn {
	display: inline-flex; align-items: center;
	padding: 6px 14px; border-radius: 6px;
	font-size: 12px; font-weight: 600;
	text-decoration: none;
	background: #fff;
	color: #8a1f2a;
	border: 1px solid #f0b3b8;
	transition: background 0.12s ease, transform 0.08s ease;
}
.pg-error-btn:hover { background: #fdf3f4; color: #8a1f2a; }
.pg-error-btn:active { transform: scale(0.97); }
.pg-error-btn.is-primary {
	background: linear-gradient(135deg, #5b4fff, #7b6dff);
	color: #fff;
	border-color: transparent;
	box-shadow: 0 1px 3px rgba(91,79,255,0.3);
}
.pg-error-btn.is-primary:hover { background: linear-gradient(135deg, #4a40e0, #6c5fff); color: #fff; }

/* Typing indicator — three breathing dots */
.pg-typing {
	align-self: flex-start;
	background: #f6f7f7;
	border: 1px solid #e5e7e9;
	padding: 12px 16px;
	border-radius: 14px 14px 14px 4px;
	display: inline-flex; align-items: center; gap: 5px;
}
.pg-typing span {
	width: 7px; height: 7px;
	background: #8c8f94; border-radius: 50%;
	animation: pg-typing-bounce 1.2s ease-in-out infinite;
}
.pg-typing span:nth-child(2) { animation-delay: 0.15s; }
.pg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pg-typing-bounce {
	0%, 60%, 100% { transform: translateY(0) scale(0.85); opacity: 0.55; background: #8c8f94; }
	30%           { transform: translateY(-4px) scale(1); opacity: 1; background: #5b4fff; }
}

/* ─── Composer ──────────────────────────────────────────────────────── */

/* Composer tokens — neutral with one accent */
:root {
	--pg-radius-input: 18px;
	--pg-radius-btn: 12px;
	--pg-radius-chip: 9999px;
	--pg-surface: #FFFFFF;
	--pg-surface-alt: #FAFAF8;
	--pg-text-primary: #1A1A1A;
	--pg-text-secondary: #6B7280;
	--pg-border: #E5E5E5;
	--pg-accent: #5b4fff;
	--pg-accent-hover: #4a40e0;
	--pg-error: #DC2626;
	--pg-shadow-focus: 0 4px 16px rgba(0,0,0,0.06);
	--pg-easing: 150ms ease;
}

/* Form wrapper — just pads around the centered composer now; the composer
   container provides the border and focus ring. */
.pg-chat-input {
	padding: 12px 16px 16px;
	border-top: none;
	background: transparent;
}

/* Composer container — the visible "input box". */
.pg-composer {
	max-width: 768px;
	margin: 0 auto;
	background: var(--pg-surface);
	border: 1px solid var(--pg-border);
	border-radius: var(--pg-radius-input);
	padding: 12px 16px 8px;
	transition: border-color var(--pg-easing), box-shadow var(--pg-easing);
}
.pg-composer:focus-within {
	border-color: var(--pg-accent);
	box-shadow: var(--pg-shadow-focus);
}

/* Attachment strip — thumbnails above the textarea. */
.pg-attach-row,
.pg-attach-strip {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 8px;
}
.pg-attach-row:empty,
.pg-attach-strip:empty { display: none; }
.pg-attach-thumb-cell {
	position: relative;
	width: 56px; height: 56px;
	border-radius: 8px;
	border: 1px solid var(--pg-border);
	background: var(--pg-surface-alt);
	overflow: hidden;
}
.pg-attach-thumb-cell img {
	width: 100%; height: 100%;
	object-fit: cover;
	display: block;
}
.pg-attach-thumb-x {
	position: absolute;
	top: 2px; right: 2px;
	width: 18px; height: 18px;
	padding: 0;
	display: flex; align-items: center; justify-content: center;
	border: none; cursor: pointer;
	background: rgba(17, 17, 26, 0.65);
	color: #fff;
	border-radius: var(--pg-radius-chip);
	font-size: 14px; line-height: 1;
}
.pg-attach-thumb-x:hover { background: rgba(17, 17, 26, 0.9); }
/* Filename label under each thumbnail (shown when space allows). */
.pg-attach-thumb-name {
	font-size: 10px;
	color: var(--pg-text-secondary);
	line-height: 1.2;
	margin-top: 3px;
	max-width: 56px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Textarea — borderless; the composer container carries the chrome. */
.pg-chat-input textarea,
.pg-chat-input #pg-chat-text {
	width: 100%;
	resize: none;
	border: none;
	background: transparent;
	color: var(--pg-text-primary);
	font-size: 15px;
	font-family: inherit;
	line-height: 1.5;
	padding: 4px 0;
	min-height: 24px;
	max-height: 200px;
}
.pg-chat-input textarea:focus,
.pg-chat-input #pg-chat-text:focus { outline: none; }

/* Voice bar visible — hide the textarea to avoid layout shift. */
.pg-chat-input.pg-voice-active #pg-chat-text { display: none; }

/* Voice bar — expandable waveform that replaces the textarea. */
.pg-voice-bar {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	height: 36px;
	background: var(--pg-surface-alt);
	border-radius: var(--pg-radius-btn);
	padding: 0 12px;
	margin: 4px 0;
	opacity: 0;
	transform: translateY(-4px) scale(0.98);
	transition: opacity 200ms var(--pg-easing), transform 200ms var(--pg-easing);
	overflow: hidden;
}
.pg-voice-bar.is-visible {
	opacity: 1;
	transform: none;
}
/* Timer (left of waveform). */
.pg-voice-timer {
	font-variant-numeric: tabular-nums;
	font-size: 12px;
	font-weight: 600;
	color: var(--pg-text-secondary);
	flex-shrink: 0;
	min-width: 34px;
}
/* Canvas waveform (center) with soft edge fade. */
.pg-voice-canvas {
	flex: 1;
	height: 24px;
	width: 100%;
	display: block;
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}
/* Hint text (right side — "Listening…" / "Transcribing…"). */
.pg-voice-hint {
	font-size: 11px;
	color: var(--pg-text-secondary);
	flex-shrink: 0;
	transition: opacity 0.2s ease;
}
/* Shimmer overlay while processing. */
.pg-voice-bar.is-processing::after {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, transparent 0%, rgba(91, 79, 255, 0.15) 50%, transparent 100%);
	background-size: 200% 100%;
	animation: pg-voice-shimmer 1.2s linear infinite;
	pointer-events: none;
}
@keyframes pg-voice-shimmer {
	0%   { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* Action bar — left controls / right send. */
.pg-action-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 8px;
	padding-top: 4px;
}
.pg-action-left,
.pg-action-right {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* Icon buttons — attach + mic share this base. */
.pg-icon-btn {
	background: transparent;
	border: none;
	color: var(--pg-text-secondary);
	width: 36px; height: 36px;
	border-radius: var(--pg-radius-btn);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background var(--pg-easing), color var(--pg-easing), transform 100ms ease;
}
.pg-icon-btn:hover {
	background: var(--pg-surface-alt);
	color: var(--pg-text-primary);
}
.pg-icon-btn:active { transform: scale(0.95); }

/* Mic button — states via data-state. */
.pg-mic-btn { position: relative; }
/* idle: default icon button style. */
/* recording: a clear, steady stop button (solid red, white ■). No flashing —
   the live waveform already signals that recording is active. */
.pg-mic-btn[data-state="recording"],
.pg-mic-btn[data-state="recording"]:hover {
	color: #fff;
	background: var(--pg-error);
}
.pg-mic-btn[data-state="transcribing"] {
	opacity: 0.5;
	cursor: wait;
	animation: pg-mic-breathe 1.2s ease-in-out infinite;
}
.pg-mic-btn[data-state="error"] {
	color: var(--pg-error);
	background: rgba(220, 38, 38, 0.08);
}
@keyframes pg-mic-breathe {
	0%, 100% { opacity: 0.5; }
	50%      { opacity: 1; }
}
/* Icon visibility — mic icon by default, stop icon while busy. */
.pg-mic-icon { display: block; }
.pg-mic-stop-icon { display: none; }
.pg-mic-btn[data-state="recording"] .pg-mic-icon,
.pg-mic-btn[data-state="transcribing"] .pg-mic-icon { display: none; }
.pg-mic-btn[data-state="recording"] .pg-mic-stop-icon,
.pg-mic-btn[data-state="transcribing"] .pg-mic-stop-icon { display: block; }

/* Send button. */
.pg-send-btn,
#pg-chat-send {
	background: var(--pg-accent);
	color: #fff;
	border: none;
	border-radius: var(--pg-radius-btn);
	padding: 0 20px;
	height: 36px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
	transition: background var(--pg-easing), opacity var(--pg-easing), transform 100ms ease;
}
.pg-send-btn:hover:not(:disabled),
#pg-chat-send:hover:not(:disabled) { background: var(--pg-accent-hover); }
.pg-send-btn:active:not(:disabled),
#pg-chat-send:active:not(:disabled) { transform: scale(0.97); }
.pg-send-btn:disabled,
#pg-chat-send:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}
/* Responding state — morph to stop icon, no layout shift. */
.pg-send-icon { display: inline-flex; }
.pg-send-label { display: inline; white-space: nowrap; }
.pg-stop-icon { display: none; }
.pg-send-btn.is-responding .pg-send-icon,
.pg-send-btn.is-responding .pg-send-label { display: none; }
.pg-send-btn.is-responding .pg-stop-icon { display: inline-flex; }

/* Composer error toast — calm and plain. */
.pg-composer-error {
	max-width: 768px;
	margin: 8px auto 0;
	padding: 8px 12px;
	background: rgba(220, 38, 38, 0.06);
	border: 1px solid rgba(220, 38, 38, 0.15);
	border-radius: var(--pg-radius-btn);
	color: var(--pg-error);
	font-size: 12px;
	line-height: 1.4;
}
.pg-composer-error .pg-retry-link,
.pg-composer-error a {
	color: var(--pg-error);
	font-weight: 600;
	text-decoration: underline;
	cursor: pointer;
}

/* Drop overlay — adapted to match composer radius. */
.pg-chat { position: relative; }
.pg-drop-overlay {
	position: absolute; inset: 12px;
	background: rgba(91, 79, 255, 0.06);
	border: 2px dashed var(--pg-accent);
	border-radius: var(--pg-radius-input);
	display: none;
	align-items: center; justify-content: center;
	pointer-events: none;
	z-index: 50;
	color: var(--pg-accent);
}
.pg-chat.is-dragover .pg-drop-overlay { display: flex; }
.pg-drop-message {
	display: flex; flex-direction: column; align-items: center; gap: 10px;
	font-size: 14px; font-weight: 600;
	color: var(--pg-accent-hover);
	text-align: center;
}
/* Responsive — mobile: full-width composer with 12px gutters. */
@media (max-width: 640px) {
	.pg-composer,
	.pg-composer-error {
		max-width: none;
		margin-left: 12px;
		margin-right: 12px;
	}
	.pg-chat-input { padding-left: 8px; padding-right: 8px; }
	.pg-icon-btn { width: 40px; height: 40px; }
}

/* Reduced motion — disable all composer animations and transitions. */
@media (prefers-reduced-motion: reduce) {
	.pg-composer,
	.pg-icon-btn,
	.pg-send-btn,
	#pg-chat-send,
	.pg-voice-bar,
	.pg-voice-hint,
	.pg-mic-btn {
		transition: none !important;
		animation: none !important;
	}
	.pg-voice-bar.is-processing::after { animation: none !important; }
}

.pg-vision-toggle {
	display: inline-flex; align-items: center; gap: 8px;
	cursor: pointer;
	user-select: none;
	padding: 5px 7px;
	border-radius: 7px;
	transition: background 0.12s ease;
	position: relative;
}
.pg-vision-toggle:hover { background: #f6f7f7; }

/* Custom tooltip — fires on hover after ~400ms, sits above the toggle
   pointing down. native title= is unreliable on labels that wrap inputs. */
.pg-vision-toggle[data-tooltip]::after {
	content: attr(data-tooltip);
	position: absolute;
	bottom: calc(100% + 8px);
	left: 0;
	min-width: 240px; max-width: 320px;
	padding: 8px 12px;
	background: #1d2327;
	color: #fff;
	font-size: 12px; font-weight: 400; line-height: 1.45;
	border-radius: 6px;
	box-shadow: 0 4px 12px rgba(0,0,0,0.18);
	opacity: 0;
	pointer-events: none;
	transform: translateY(4px);
	transition: opacity 0.18s ease 0s, transform 0.18s ease 0s;
	z-index: 100;
}
.pg-vision-toggle[data-tooltip]::before {
	content: '';
	position: absolute;
	bottom: calc(100% + 2px);
	left: 24px;
	border: 6px solid transparent;
	border-top-color: #1d2327;
	opacity: 0;
	transition: opacity 0.18s ease 0s;
	z-index: 100;
}
.pg-vision-toggle[data-tooltip]:hover::after,
.pg-vision-toggle[data-tooltip]:hover::before {
	opacity: 1;
	transform: translateY(0);
	transition-delay: 0.4s;
}
.pg-vision-input { position: absolute; opacity: 0; pointer-events: none; }
.pg-vision-track {
	position: relative;
	width: 32px; height: 18px;
	background: #c3c4c7;
	border-radius: 999px;
	flex-shrink: 0;
	transition: background 0.18s ease;
}
.pg-vision-thumb {
	position: absolute;
	top: 2px; left: 2px;
	width: 14px; height: 14px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 2px rgba(0,0,0,0.18);
	transition: transform 0.18s ease;
}
.pg-vision-input:checked + .pg-vision-track {
	background: linear-gradient(90deg, #5b4fff, #b893ff);
}
.pg-vision-input:checked + .pg-vision-track .pg-vision-thumb {
	transform: translateX(14px);
}
.pg-vision-input:focus-visible + .pg-vision-track {
	box-shadow: 0 0 0 2px #5b4fff44;
}
.pg-vision-label {
	display: inline-flex; align-items: center; gap: 8px;
	font-size: 12px; color: #50575e;
}
/* Inline SVG eye icon. Gray when off, PressGo purple when on, with a
   subtle scale pop on the transition. fill: currentColor lets us control
   the SVG color via plain CSS color. */
.pg-vision-icon {
	display: inline-flex; align-items: center;
	width: 16px; height: 16px;
	color: #8c8f94;
	transition: color 0.18s ease, transform 0.18s ease;
}
.pg-vision-icon svg { width: 16px; height: 16px; display: block; }
.pg-vision-input:checked ~ .pg-vision-label .pg-vision-icon {
	color: #5b4fff;
	animation: pg-eyes-on 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pg-eyes-on {
	0%   { transform: scale(0.85); }
	50%  { transform: scale(1.3); }
	100% { transform: scale(1); }
}
.pg-vision-name {
	font-weight: 600; color: #1d2327;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.pg-vision-name em {
	font-style: italic;
	font-weight: 600;
	color: #5b4fff;
}
.pg-vision-input:checked ~ .pg-vision-label .pg-vision-name { color: #5b4fff; }
.pg-vision-input:checked ~ .pg-vision-label .pg-vision-name em { color: #4a40e0; }
.pg-vision-hint { color: #8c8f94; font-size: 11px; }

/* "Reviewing…" indicator that appears between build and vision-correction. */
.pg-msg-reviewing {
	align-self: flex-start;
	display: inline-flex; align-items: center; gap: 8px;
	background: #f0eeff;
	border: 1px solid #d4ccff;
	color: #4a40e0;
	padding: 8px 12px;
	border-radius: 12px 12px 12px 4px;
	font-size: 12px; font-weight: 500;
}
.pg-msg-reviewing::before {
	content: '👁';
	font-size: 14px;
	animation: pg-eye-scan 1.4s ease-in-out infinite;
}
@keyframes pg-eye-scan {
	0%, 100% { transform: translateX(0); }
	50%      { transform: translateX(3px); }
}

/* ─── Progressive build checklist ─────────────────────────────────── */
.pg-build-list {
	align-self: flex-start;
	min-width: 220px;
	background: #f7f6ff;
	border: 1px solid #e3def9;
	border-radius: 12px 12px 12px 4px;
	padding: 12px 14px;
	display: flex; flex-direction: column; gap: 7px;
}
.pg-build-head {
	font-size: 12px; font-weight: 600; color: #4a40e0;
	margin-bottom: 2px;
}
.pg-build-row {
	display: flex; align-items: center; gap: 9px;
	font-size: 13px; line-height: 1.2;
	transition: color 0.2s ease;
}
.pg-build-dot {
	width: 15px; height: 15px; flex: 0 0 15px;
	border-radius: 50%;
	display: inline-flex; align-items: center; justify-content: center;
	transition: all 0.2s ease;
}
.pg-build-row.is-pending .pg-build-label { color: #9a93b8; }
.pg-build-row.is-pending .pg-build-dot {
	border: 2px solid #d4ccff;
	animation: pg-build-pulse 1.2s ease-in-out infinite;
}
.pg-build-row.is-done .pg-build-label { color: #1f2937; }
.pg-build-row.is-done .pg-build-dot {
	background: #16a34a; border: 2px solid #16a34a;
}
.pg-build-row.is-done .pg-build-dot::after {
	content: '✓'; color: #fff; font-size: 10px; font-weight: 700; line-height: 1;
}
@keyframes pg-build-pulse {
	0%, 100% { opacity: 0.5; }
	50%      { opacity: 1; }
}

/* ─── Confirm modal (Clear chat etc.) ─────────────────────────────── */
.pg-modal-backdrop {
	position: fixed; inset: 0;
	background: rgba(15, 23, 42, 0.45);
	display: flex; align-items: center; justify-content: center;
	z-index: 1000;
	animation: pg-modal-fade 0.16s ease-out;
}
@keyframes pg-modal-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}
.pg-modal {
	background: #fff;
	border-radius: 10px;
	padding: 22px 24px 18px;
	min-width: 320px;
	max-width: 440px;
	box-shadow: 0 10px 40px rgba(0,0,0,0.18);
	animation: pg-modal-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pg-modal-pop {
	from { opacity: 0; transform: scale(0.94) translateY(8px); }
	to   { opacity: 1; transform: scale(1) translateY(0); }
}
.pg-modal-title { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: #1d2327; }
.pg-modal-body { margin: 0 0 20px; font-size: 13px; color: #50575e; line-height: 1.5; }
.pg-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pg-modal-btn {
	background: #fff; color: #50575e;
	border: 1px solid #c3c4c7;
	padding: 7px 14px; border-radius: 4px;
	font-size: 13px; font-weight: 500;
	font-family: inherit; cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}
.pg-modal-btn:hover { background: #f6f7f7; color: #1d2327; }
.pg-modal-btn.is-danger {
	background: #d63638; color: #fff; border-color: #d63638;
}
.pg-modal-btn.is-danger:hover { background: #b32d2e; border-color: #b32d2e; color: #fff; }
.pg-modal-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─── Preview ───────────────────────────────────────────────────────── */
.pg-preview {
	flex: 1; min-width: 0;
	background: #f0f0f1;
	position: relative;
	display: flex; flex-direction: column;
}

/* Viewport switcher toolbar */
.pg-preview-toolbar {
	flex-shrink: 0;
	padding: 10px 16px 0;
	display: flex; justify-content: center;
}
.pg-vp-group {
	display: inline-flex;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	padding: 3px;
	box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.pg-vp-btn {
	display: inline-flex; align-items: center; gap: 6px;
	background: transparent;
	border: 0;
	padding: 6px 12px;
	font-size: 12px; font-weight: 500;
	color: #50575e;
	border-radius: 5px;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.12s ease, color 0.12s ease;
}
.pg-vp-btn:hover { background: #f6f7f7; color: #1d2327; }
.pg-vp-btn.is-active {
	background: linear-gradient(135deg, #5b4fff, #7b6dff);
	color: #fff;
	box-shadow: 0 1px 3px rgba(91,79,255,0.3);
}
.pg-vp-btn.is-active:hover { color: #fff; }
.pg-vp-btn svg { flex-shrink: 0; }

/* Stage holds the device-sized frame, centers it horizontally. */
.pg-preview-stage {
	flex: 1; min-height: 0;
	padding: 12px 16px 16px;
	display: flex;
	justify-content: center;
	align-items: stretch;
	overflow: auto;
}
.pg-preview-frame-wrap {
	width: 100%; height: 100%;
	background: #fff;
	border-radius: 8px;
	border: 1px solid #dcdcde;
	overflow: hidden;
	box-shadow: 0 4px 16px rgba(0,0,0,0.06);
	position: relative;
	transition: max-width 0.32s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.32s ease;
}
.pg-preview-frame-wrap[data-viewport="tablet"] {
	max-width: 820px;
	box-shadow: 0 8px 28px rgba(0,0,0,0.10);
}
.pg-preview-frame-wrap[data-viewport="mobile"] {
	max-width: 390px;
	box-shadow: 0 8px 28px rgba(0,0,0,0.10);
}
/* Double-buffered preview: two iframes stack in the wrap; exactly one is
   visible. The hidden buffer keeps layout (visibility, not display) so its
   scroll position can be set before it swaps in. */
.pg-preview iframe {
	position: absolute; inset: 0;
	width: 100%; height: 100%; border: 0; display: block;
	transition: opacity 0.25s ease, filter 0.4s ease;
}
.pg-preview iframe.pg-frame-hidden {
	visibility: hidden;
	pointer-events: none;
	z-index: 0;
}
.pg-preview.is-reloading iframe:not(.pg-frame-hidden) {
	opacity: 0.45;
	filter: blur(2px) saturate(0.7);
}

/* Buffered refresh in progress — a quiet 2px shimmer along the top edge,
   never a blank or blurred frame. */
.pg-preview-frame-wrap::before {
	content: '';
	position: absolute; top: 0; left: 0; right: 0; height: 2px;
	background: linear-gradient(90deg, transparent, #5b4fff 50%, transparent);
	background-size: 40% 100%;
	background-repeat: no-repeat;
	opacity: 0;
	pointer-events: none;
	z-index: 7;
	transition: opacity 0.15s ease;
}
.pg-preview.is-refreshing .pg-preview-frame-wrap::before {
	opacity: 1;
	animation: pg-refresh-slide 1.1s linear infinite;
}
@keyframes pg-refresh-slide {
	0%   { background-position: -40% 0; }
	100% { background-position: 140% 0; }
}

/* Reload overlay — pulsing gradient sweep + spinner */
.pg-preview-frame-wrap::after {
	content: '';
	position: absolute; inset: 0;
	background: linear-gradient(90deg, transparent 0%, rgba(91,79,255,0.18) 50%, transparent 100%);
	background-size: 200% 100%;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}
.pg-preview.is-reloading .pg-preview-frame-wrap::after {
	opacity: 1;
	animation: pg-preview-sweep 1.6s ease-in-out infinite;
}
@keyframes pg-preview-sweep {
	0%   { background-position: -100% 0; }
	100% { background-position: 200% 0; }
}

/* ─── Visual editor: Select mode + property panel ───────────────────── */

/* Select toggle — rides the preview toolbar, right edge. */
.pg-preview-toolbar { position: relative; }
.pg-select-toggle {
	position: absolute;
	right: 16px; top: 10px;
	display: inline-flex; align-items: center; gap: 6px;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	padding: 8px 14px;
	font-size: 12px; font-weight: 500;
	color: #50575e;
	cursor: pointer;
	font-family: inherit;
	box-shadow: 0 1px 2px rgba(0,0,0,0.04);
	transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
	z-index: 5;
}
.pg-select-toggle:hover { background: #f7f5ff; color: #5b4fff; border-color: #d9d6ff; }
/* Slide the toggle out from under the open panel so it stays reachable. */
.pg-preview.pg-ed-open .pg-select-toggle { right: 356px; }
.pg-select-toggle { transition: right 0.28s cubic-bezier(0.22, 1, 0.36, 1), background 0.12s ease, color 0.12s ease, border-color 0.12s ease; }
.pg-select-toggle.is-active {
	background: linear-gradient(135deg, #5b4fff, #7b6dff);
	color: #fff;
	border-color: transparent;
	box-shadow: 0 1px 3px rgba(91,79,255,0.3);
}
.pg-select-toggle svg { flex-shrink: 0; }

/* Property panel — slides over the preview's right edge; never covers chat. */
.pg-editor-panel {
	position: absolute;
	top: 0; right: 0; bottom: 0;
	width: 340px; max-width: 85%;
	background: #fff;
	border-left: 1px solid #dcdcde;
	box-shadow: -8px 0 28px rgba(20,16,60,0.12);
	display: flex; flex-direction: column;
	transform: translateX(105%);
	transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
	z-index: 40;
	font-size: 13px; color: #1d2327;
}
.pg-editor-panel.is-open { transform: translateX(0); }

.pg-ed-head {
	display: flex; align-items: flex-start; gap: 8px;
	padding: 14px 16px 12px;
	border-bottom: 1px solid #f0effa;
	flex-shrink: 0;
}
.pg-ed-head-text { flex: 1; min-width: 0; }
.pg-ed-title { font-size: 14px; font-weight: 600; display: block; }
.pg-ed-key {
	display: inline-block;
	margin-top: 3px;
	font-size: 11px; color: #6b7280;
	background: #f3f1ff; border: 1px solid #e4e1ff;
	border-radius: 999px; padding: 1px 8px;
}
.pg-ed-close {
	border: none; background: transparent;
	font-size: 20px; line-height: 1;
	color: #8c8f94; cursor: pointer;
	padding: 0 2px;
	border-radius: 4px;
}
.pg-ed-close:hover { color: #1d2327; background: #f6f7f7; }

.pg-ed-body {
	flex: 1; min-height: 0;
	overflow-y: auto;
	padding: 12px 16px 16px;
	display: flex; flex-direction: column; gap: 14px;
}
.pg-ed-empty { color: #6b7280; line-height: 1.5; padding: 8px 0; }

/* Explanatory section note (e.g. blog auto-pulls posts) — same purple
   family as the rest of the editor chrome. */
.pg-ed-note {
	background: #f7f6ff;
	border: 1px solid #e3def9;
	border-radius: 8px;
	padding: 9px 12px;
	font-size: 12px; line-height: 1.5;
	color: #4a40e0;
}

.pg-ed-field { display: flex; flex-direction: column; gap: 5px; }
.pg-ed-label { font-size: 12px; font-weight: 600; color: #50575e; }
.pg-ed-hint { font-size: 11px; color: #8c8f94; line-height: 1.4; }
.pg-ed-field input[type="text"],
.pg-ed-field input[type="url"],
.pg-ed-field input[type="number"],
.pg-ed-field textarea,
.pg-ed-field select {
	width: 100%;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	padding: 7px 10px;
	font-size: 13px; font-family: inherit;
	color: #1d2327; background: #fff;
	transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.pg-ed-field textarea { resize: vertical; line-height: 1.45; }
.pg-ed-field input:focus,
.pg-ed-field textarea:focus,
.pg-ed-field select:focus {
	outline: none;
	border-color: #5b4fff;
	box-shadow: 0 0 0 1px #5b4fff;
}

/* Click-into-field flash */
@keyframes pg-ed-flash {
	0%   { background: #ede9ff; box-shadow: 0 0 0 3px rgba(91,79,255,0.25); }
	100% { background: transparent; box-shadow: none; }
}
.pg-ed-flash { animation: pg-ed-flash 1.1s ease-out; border-radius: 8px; }

/* Image control: thumb + url input */
.pg-ed-image { display: flex; align-items: center; gap: 8px; }
.pg-ed-image-thumb {
	width: 42px; height: 42px;
	object-fit: cover;
	border-radius: 6px;
	border: 1px solid #e5e1ff;
	background: #f6f4ff;
	flex-shrink: 0;
}
.pg-ed-image input { flex: 1; min-width: 0; }

/* Color control */
.pg-ed-color { display: flex; align-items: center; gap: 8px; }
.pg-ed-color input[type="color"] {
	width: 34px; height: 28px;
	padding: 1px;
	border: 1px solid #dcdcde; border-radius: 6px;
	background: #fff; cursor: pointer;
}
.pg-ed-color-val { font-size: 12px; color: #6b7280; font-family: ui-monospace, Menlo, monospace; }

.pg-ed-checkbox input { width: 16px; height: 16px; cursor: pointer; }

/* CTA pair */
.pg-ed-cta { display: flex; flex-direction: column; gap: 6px; }

/* Repeater */
.pg-ed-rep-list { display: flex; flex-direction: column; gap: 6px; }
.pg-ed-rep-row {
	border: 1px solid #e2e0f4;
	border-radius: 8px;
	overflow: hidden;
	background: #fafaff;
}
.pg-ed-rep-head {
	display: flex; align-items: center; gap: 7px;
	padding: 7px 10px;
	cursor: pointer;
	user-select: none;
	font-size: 12px;
}
.pg-ed-rep-head:hover { background: #f3f1ff; }
.pg-ed-rep-caret { color: #8c8f94; font-size: 10px; flex-shrink: 0; }
.pg-ed-rep-title {
	flex: 1; min-width: 0;
	overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
	font-weight: 500;
}
.pg-ed-rep-tools { display: inline-flex; gap: 2px; flex-shrink: 0; }
.pg-ed-rep-tools button {
	border: none; background: transparent;
	color: #8c8f94; cursor: pointer;
	font-size: 12px; line-height: 1;
	width: 22px; height: 22px;
	border-radius: 4px;
	display: inline-flex; align-items: center; justify-content: center;
}
.pg-ed-rep-tools button:hover:not(:disabled) { background: #ede9ff; color: #5b4fff; }
.pg-ed-rep-tools button:disabled { opacity: 0.3; cursor: default; }
.pg-ed-rep-body {
	padding: 8px 10px 10px;
	border-top: 1px solid #ecebf8;
	background: #fff;
	display: flex; flex-direction: column; gap: 8px;
}
/* [hidden] must beat display:flex or rows render expanded. */
.pg-ed-rep-body[hidden] { display: none; }
.pg-ed-rep-field { display: flex; flex-direction: column; gap: 3px; }
.pg-ed-rep-field > span { font-size: 11px; color: #8c8f94; font-weight: 500; }
.pg-ed-rep-field input,
.pg-ed-rep-field textarea {
	width: 100%;
	border: 1px solid #d5d3e8;
	border-radius: 6px;
	padding: 6px 9px;
	font-size: 12px; font-family: inherit;
}
.pg-ed-rep-field input:focus, .pg-ed-rep-field textarea:focus {
	outline: none; border-color: #5b4fff; box-shadow: 0 0 0 1px #5b4fff;
}
.pg-ed-rep-add {
	align-self: flex-start;
	margin-top: 2px;
	border: 1px dashed #c9c4f5;
	background: transparent;
	color: #5b4fff;
	border-radius: 6px;
	padding: 5px 12px;
	font-size: 12px; font-weight: 500;
	cursor: pointer; font-family: inherit;
}
.pg-ed-rep-add:hover { background: #f3f1ff; border-style: solid; }

/* Panel footer: error + ask-AI + apply */
.pg-ed-foot {
	flex-shrink: 0;
	border-top: 1px solid #f0effa;
	padding: 10px 16px 14px;
	display: flex; flex-direction: column; gap: 8px;
	background: #fff;
}
.pg-ed-error {
	background: #fcf0f1; border: 1px solid #f0b3b8; color: #8a1f2a;
	border-radius: 6px; padding: 7px 10px;
	font-size: 12px; line-height: 1.4;
}
.pg-ed-ask-input {
	width: 100%;
	border: 1px solid #dcdcde;
	border-radius: 999px;
	padding: 7px 14px;
	font-size: 12px; font-family: inherit;
	background: #fafaff;
}
.pg-ed-ask-input:focus { outline: none; border-color: #5b4fff; box-shadow: 0 0 0 1px #5b4fff; background: #fff; }
.pg-ed-actions { display: flex; gap: 8px; justify-content: flex-end; }
.pg-ed-discard {
	background: transparent; color: #6b7280;
	border: 1px solid #dcdcde;
	border-radius: 6px; padding: 8px 14px;
	font-size: 13px; font-weight: 500;
	cursor: pointer; font-family: inherit;
}
.pg-ed-discard:hover { background: #f6f7f7; color: #1d2327; }
/* Secondary affordance now — edits autosave; this just flushes immediately. */
.pg-ed-apply {
	background: #f3f1ff; color: #5b4fff;
	border: 1px solid #d9d6ff;
	border-radius: 6px; padding: 8px 18px;
	font-size: 13px; font-weight: 600;
	cursor: pointer; font-family: inherit;
	display: inline-flex; align-items: center; gap: 7px;
	transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.pg-ed-apply:hover:not(:disabled) { background: #5b4fff; border-color: #5b4fff; color: #fff; }
.pg-ed-apply:disabled { background: #f6f7f7; border-color: #e5e5e8; color: #b0b3b8; cursor: not-allowed; }
.pg-ed-badge {
	background: rgba(91,79,255,0.16);
	border-radius: 999px;
	min-width: 18px; height: 18px;
	padding: 0 5px;
	display: inline-flex; align-items: center; justify-content: center;
	font-size: 11px; font-weight: 700;
}
.pg-ed-apply:hover:not(:disabled) .pg-ed-badge { background: rgba(255,255,255,0.25); }

/* Autosave indicator — quiet "Saving… / Saved" next to the panel title. */
.pg-ed-save {
	display: inline-block;
	margin-left: 8px;
	font-size: 11px; font-weight: 500;
	vertical-align: 1px;
	transition: opacity 0.25s ease;
}
.pg-ed-save.is-saving { color: #8c8f94; }
.pg-ed-save.is-saving::before {
	content: '';
	display: inline-block;
	width: 9px; height: 9px;
	margin-right: 5px;
	border: 1.5px solid #c3c4c7;
	border-top-color: #5b4fff;
	border-radius: 50%;
	vertical-align: -1px;
	animation: pg-save-spin 0.8s linear infinite;
}
@keyframes pg-save-spin { to { transform: rotate(360deg); } }
.pg-ed-save.is-saved { color: #1a8a3c; }
.pg-ed-save.is-saved::before { content: '✓'; margin-right: 4px; font-weight: 700; }
.pg-ed-save.is-error { color: #8a1f2a; font-weight: 600; }

/* Page-token sliders — live-scrub the preview while dragging. The value
   readout updates on every input event (drag AND keyboard arrows); the
   min/max scale sits under the track. */
.pg-ed-slider { display: flex; flex-direction: column; gap: 3px; }
.pg-ed-slider-row { display: flex; align-items: center; gap: 10px; }
.pg-ed-slider-scale {
	display: flex; justify-content: space-between;
	margin-right: 48px; /* clear of the value readout column */
	font-size: 10px; color: #a7aaad;
	font-family: ui-monospace, Menlo, monospace;
	line-height: 1;
	user-select: none;
}
.pg-ed-slider input[type="range"] {
	flex: 1; min-width: 0;
	-webkit-appearance: none;
	appearance: none;
	height: 4px;
	background: #e2e0f4;
	border-radius: 999px;
	cursor: pointer;
	outline: none;
}
/* Keyboard focus — arrows nudge the value; make focus visible. */
.pg-ed-slider input[type="range"]:focus-visible {
	box-shadow: 0 0 0 2px rgba(91,79,255,0.35);
}
.pg-ed-slider input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px; height: 16px;
	border-radius: 50%;
	background: #5b4fff;
	border: 2px solid #fff;
	box-shadow: 0 1px 4px rgba(91,79,255,0.45);
	cursor: grab;
}
.pg-ed-slider input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }
.pg-ed-slider input[type="range"]::-moz-range-thumb {
	width: 14px; height: 14px;
	border-radius: 50%;
	background: #5b4fff;
	border: 2px solid #fff;
	box-shadow: 0 1px 4px rgba(91,79,255,0.45);
	cursor: grab;
}
.pg-ed-slider-val {
	flex-shrink: 0;
	min-width: 38px;
	text-align: right;
	font-size: 12px; color: #50575e;
	font-family: ui-monospace, Menlo, monospace;
}

/* Chat scoping chip — sits above the composer. */
.pg-edit-chip {
	margin: 0 16px;
	padding: 6px 6px 6px 12px;
	display: flex; align-items: center; gap: 8px;
	align-self: flex-start;
	background: #f3f1ff;
	border: 1px solid #d9d6ff;
	border-radius: 999px;
	font-size: 12px; font-weight: 500; color: #4a40e0;
}
.pg-edit-chip-x {
	border: none; background: rgba(91,79,255,0.12);
	color: #5b4fff; cursor: pointer;
	width: 18px; height: 18px;
	border-radius: 999px;
	display: inline-flex; align-items: center; justify-content: center;
	font-size: 13px; line-height: 1; padding: 0;
}
.pg-edit-chip-x:hover { background: #5b4fff; color: #fff; }

/* Toast — bottom-right confirmation after Apply. */
.pg-toast {
	position: fixed;
	right: 20px; bottom: 20px;
	z-index: 100000;
	background: #1d2327; color: #fff;
	border-radius: 8px;
	padding: 10px 16px;
	font-size: 13px; font-weight: 500;
	box-shadow: 0 8px 24px rgba(0,0,0,0.25);
	animation: pg-toast-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
	transition: opacity 0.4s ease, transform 0.4s ease;
}
.pg-toast.is-error { background: #8a1f2a; }
.pg-toast.is-out { opacity: 0; transform: translateY(8px); }
@keyframes pg-toast-in {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ─── Phase 3: variant carousel chip, image picker, AI micro-toolbar ── */

/* Floating section chip — bottom-center of the preview when a section is
   selected. ‹ › flips layout variants; ↑ ↓ moves the section. */
.pg-sec-chip {
	position: absolute;
	bottom: 18px; left: 50%;
	transform: translateX(-50%);
	z-index: 45;
	display: flex; align-items: center; gap: 2px;
	background: rgba(17, 17, 26, 0.92);
	color: #fff;
	border-radius: 999px;
	padding: 5px 8px;
	box-shadow: 0 10px 28px rgba(20, 16, 60, 0.35);
	backdrop-filter: blur(6px);
	font-size: 12px;
	animation: pg-toast-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
	transition: box-shadow 0.25s ease;
}
.pg-sec-chip.is-flash { box-shadow: 0 0 0 3px rgba(91,79,255,0.55), 0 10px 28px rgba(20,16,60,0.35); }
.pg-sec-chip-mid {
	display: flex; flex-direction: column; align-items: center;
	padding: 0 10px; min-width: 130px;
	line-height: 1.25;
}
.pg-sec-chip-label { font-size: 12px; font-weight: 600; white-space: nowrap; }
.pg-sec-chip-variant { font-size: 10.5px; color: #b9b3ff; white-space: nowrap; }
.pg-sec-chip-btn {
	border: none; background: rgba(255,255,255,0.08);
	color: #fff; cursor: pointer;
	width: 26px; height: 26px;
	border-radius: 999px;
	font-size: 15px; line-height: 1;
	display: inline-flex; align-items: center; justify-content: center;
	font-family: inherit;
	transition: background 0.12s ease;
}
.pg-sec-chip-btn:hover:not(:disabled) { background: #5b4fff; }
.pg-sec-chip-btn:disabled { opacity: 0.3; cursor: default; }
.pg-sec-chip-sep {
	width: 1px; height: 18px;
	background: rgba(255,255,255,0.18);
	margin: 0 6px;
}

/* Image hot-swap picker — floats over the preview, under the toolbar. */
.pg-img-picker {
	position: absolute;
	top: 56px; left: 50%;
	transform: translateX(-50%);
	width: 460px; max-width: calc(100% - 32px);
	max-height: calc(100% - 96px);
	background: #fff;
	border: 1px solid #e2e0f4;
	border-radius: 12px;
	box-shadow: 0 18px 48px rgba(20, 16, 60, 0.25);
	z-index: 46;
	display: flex; flex-direction: column;
	overflow: hidden;
	animation: pg-toast-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
	font-size: 13px; color: #1d2327;
}
.pg-imgp-head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 12px 14px 10px;
	border-bottom: 1px solid #f0effa;
	flex-shrink: 0;
}
.pg-imgp-x {
	border: none; background: transparent;
	font-size: 20px; line-height: 1;
	color: #8c8f94; cursor: pointer;
	padding: 0 2px; border-radius: 4px;
}
.pg-imgp-x:hover { color: #1d2327; background: #f6f7f7; }
.pg-imgp-paste {
	display: flex; gap: 8px;
	padding: 10px 14px;
	border-bottom: 1px solid #f0effa;
	flex-shrink: 0;
}
.pg-imgp-paste input {
	flex: 1; min-width: 0;
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	padding: 7px 10px;
	font-size: 12px; font-family: inherit;
}
.pg-imgp-paste input:focus { outline: none; border-color: #5b4fff; box-shadow: 0 0 0 1px #5b4fff; }
.pg-imgp-paste button {
	border: 1px solid #d9d6ff; background: #f3f1ff; color: #5b4fff;
	border-radius: 6px; padding: 7px 14px;
	font-size: 12px; font-weight: 600;
	cursor: pointer; font-family: inherit;
}
.pg-imgp-paste button:hover { background: #5b4fff; border-color: #5b4fff; color: #fff; }
.pg-imgp-body { overflow-y: auto; padding: 10px 14px 14px; }
.pg-imgp-sect {
	font-size: 11px; font-weight: 700; color: #8c8f94;
	text-transform: uppercase; letter-spacing: 0.05em;
	margin: 8px 0 6px;
}
.pg-imgp-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 8px;
}
.pg-imgp-cell {
	border: 2px solid transparent;
	border-radius: 8px;
	padding: 0; background: #f6f4ff;
	cursor: pointer;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	transition: border-color 0.12s ease, transform 0.12s ease;
}
.pg-imgp-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-imgp-cell:hover { border-color: #5b4fff; transform: scale(1.03); }
.pg-imgp-cell.is-current { border-color: #22c55e; }
.pg-imgp-note { color: #8c8f94; font-size: 12px; padding: 6px 0; line-height: 1.5; }

/* Panel image field: clickable thumb + Swap button. */
.pg-ed-image-swappable { cursor: pointer; }
.pg-ed-image-swappable:hover { box-shadow: 0 0 0 2px #5b4fff; }
.pg-ed-image-swap {
	border: 1px solid #d9d6ff; background: #f3f1ff; color: #5b4fff;
	border-radius: 6px; padding: 6px 10px;
	font-size: 11px; font-weight: 600;
	cursor: pointer; font-family: inherit;
	flex-shrink: 0;
}
.pg-ed-image-swap:hover { background: #5b4fff; border-color: #5b4fff; color: #fff; }

/* AI text micro-toolbar — floats above the iframe text selection. */
.pg-ai-tb {
	position: fixed;
	transform: translateX(-50%);
	z-index: 100001;
	display: flex; gap: 2px;
	background: rgba(17, 17, 26, 0.94);
	border-radius: 999px;
	padding: 4px;
	box-shadow: 0 10px 28px rgba(20, 16, 60, 0.4);
	animation: pg-toast-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.pg-ai-tb button {
	border: none; background: transparent;
	color: #fff; cursor: pointer;
	border-radius: 999px;
	padding: 6px 12px;
	font-size: 12px; font-weight: 500;
	font-family: inherit;
	white-space: nowrap;
	transition: background 0.12s ease;
}
.pg-ai-tb button:hover { background: #5b4fff; }

/* Voice input (mic button + voice bar) is now styled in the Composer
   section above, using the shared icon-button base and composer tokens. */
