/*
 * Physics Chat Widget — UI styles.
 * Uses theme tokens from themes.css (dark default).
 * RTL-first, mobile-first.
 */

#pcw-root {
	font-family: -apple-system, "Segoe UI", "Heebo", "Rubik", Arial, sans-serif;
	color: var(--pcw-text, #1a2b4a);
	direction: rtl;
}

#pcw-root *,
#pcw-root *::before,
#pcw-root *::after {
	box-sizing: border-box;
}

/* ── Floating launcher ───────────────────────────────────────────────── */
.pcw-launcher {
	position: fixed;
	width: 80px;
	height: 80px;
	border: none;
	border-radius: 50%;
	background: var(--pcw-header-bg);
	cursor: pointer;
	box-shadow: 0 12px 40px rgba(26, 43, 74, 0.28);
	z-index: 999990;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	padding: 0;
	display: grid;
	place-items: center;
	overflow: hidden;
}
.pcw-launcher:hover { transform: translateY(-3px) scale(1.04); }
.pcw-launcher:focus-visible { outline: 3px solid var(--pcw-accent); outline-offset: 3px; }
.pcw-launcher[data-position="bottom-right"] { right: 24px; bottom: 24px; }
.pcw-launcher[data-position="bottom-left"]  { left:  24px; bottom: 24px; }
.pcw-launcher[data-position="middle-right"] { right: 24px; top: 50%; transform: translateY(-50%); }
.pcw-launcher[data-position="middle-left"]  { left:  24px; top: 50%; transform: translateY(-50%); }
.pcw-launcher__character { display: grid; place-items: center; width: 100%; height: 100%; }
.pcw-launcher__character img { width: 72px; height: 72px; display: block; user-select: none; pointer-events: none; }
.pcw-launcher__character--fallback {
	font-size: 38px;
	color: var(--pcw-accent);
	background: linear-gradient(135deg, var(--pcw-accent) 0%, #c97b5e 100%);
}
.pcw-launcher[hidden] { display: none; }

/* ── Chat panel ──────────────────────────────────────────────────────── */
.pcw-panel {
	position: fixed;
	right: 24px;
	bottom: 24px;
	width: min(440px, calc(100vw - 32px));
	height: min(70vh, 720px);
	background: var(--pcw-bg);
	background-image: var(--pcw-bg-image);
	background-repeat: repeat;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 999991;
	transform-origin: bottom right;
	animation: pcw-pop 0.22s ease-out;
	color: var(--pcw-text);
}
/* The floating composer group lives inside .pcw-panel via position:absolute
 * so messages stay in the normal flow and can scroll independently. */
.pcw-panel { }
.pcw-panel[data-position="bottom-left"]  { right: auto; left: 24px; transform-origin: bottom left; }
.pcw-panel[data-position="middle-right"] { bottom: auto; top: 50%; transform: translateY(-50%); transform-origin: right center; }
.pcw-panel[data-position="middle-left"]  { right: auto; left: 24px; bottom: auto; top: 50%; transform: translateY(-50%); transform-origin: left center; }

@keyframes pcw-pop {
	from { opacity: 0; transform: scale(0.94) translateY(8px); }
	to   { opacity: 1; transform: scale(1)    translateY(0);    }
}
.pcw-panel[hidden] { display: none; }

/* Fullscreen */
.pcw-panel.pcw-panel--fullscreen {
	top: 0; left: 0; right: 0; bottom: 0;
	width: 100vw; height: 100vh;
	max-width: none; max-height: none;
	border-radius: 0; transform: none; animation: none;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.pcw-panel__header {
	background: var(--pcw-header-bg);
	color: var(--pcw-header-text);
	padding: 12px 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 0 0 auto;
}
.pcw-panel__avatar {
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: linear-gradient(135deg, #c97b5e, var(--pcw-accent));
	display: grid;
	place-items: center;
	overflow: hidden;
	flex: 0 0 auto;
}
.pcw-panel__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcw-panel__avatar--fallback { font-size: 22px; color: #1a2b4a; }
.pcw-panel__title { flex: 1 1 auto; min-width: 0; }
.pcw-panel__title strong { display: block; font-size: 16px; line-height: 1.2; }
.pcw-panel__title span   { display: block; font-size: 12px; opacity: 0.75; margin-top: 2px; }

.pcw-panel__icon-btn {
	background: transparent;
	border: none;
	color: var(--pcw-header-text);
	line-height: 1;
	cursor: pointer;
	padding: 0;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	transition: background 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-panel__icon-btn svg {
	width: 18px;
	height: 18px;
	display: block;
}
.pcw-panel__icon-btn:hover {
	background: rgba(157, 217, 184, 0.18);
	transform: scale(1.05);
}
.pcw-panel__icon-btn:active {
	background: rgba(157, 217, 184, 0.28);
	transform: scale(0.95);
}
.pcw-panel__icon-btn:focus-visible { outline: 2px solid var(--pcw-accent); outline-offset: 2px; }
.pcw-panel__fs[aria-pressed="true"] { background: rgba(255, 255, 255, 0.18); }

/* Config-missing banner */
.pcw-panel__notice {
	background: var(--pcw-accent);
	color: var(--pcw-accent-ink);
	font-size: 12px;
	padding: 6px 16px;
	text-align: center;
	flex: 0 0 auto;
}
.pcw-panel__notice--warn { background: #fde68a; color: #5b3a00; }

/* ── Messages ────────────────────────────────────────────────────────── */
/* Padding-bottom reserves room for the floating composer group that sits
 * absolutely positioned above the messages area. Keeps the last message
 * visible when scrolled to bottom. */
.pcw-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 16px 180px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 100%;
	max-width: 760px;
	margin: 0 auto;
}
#pcw-root .pcw-empty {
	color: var(--pcw-text-muted) !important;
	font-size: 14px;
	text-align: center;
	padding: 24px;
	margin: 30vh auto auto; /* sit at ~40% from top, Claude-style */
}

.pcw-msg-row {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	max-width: 100%;
}
.pcw-msg-row--bot  { align-self: flex-end;   flex-direction: row-reverse; }
.pcw-msg-row--user { align-self: flex-start; }

.pcw-msg {
	max-width: min(100%, 560px);
	padding: 12px 16px;
	border-radius: 16px;
	font-size: var(--pcw-msg-size, 16px);
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
}
/* !important on color guards against host-theme paragraph/inheritance rules
 * that would otherwise repaint the bubble text (e.g. dark text on a dark bubble). */
#pcw-root .pcw-msg--user {
	background: var(--pcw-bubble-user);
	color: var(--pcw-bubble-user-text) !important;
	border-top-right-radius: 4px;
}
#pcw-root .pcw-msg--bot {
	background: var(--pcw-bubble-bot);
	color: var(--pcw-bubble-bot-text) !important;
	border-top-left-radius: 4px;
}
#pcw-root .pcw-msg,
#pcw-root .pcw-msg * { color: inherit; }
.pcw-msg--error {
	background: var(--pcw-error-bg, #fee2e2);
	color: var(--pcw-error-text, #7f1d1d);
}
.pcw-msg__cta {
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px dashed currentColor;
	font-size: 13px;
	font-weight: 600;
	opacity: 0.92;
}

/* Typing indicator (replaces old blinking dot) */
.pcw-msg--pending {
	color: var(--pcw-text-muted);
	font-style: italic;
	min-height: 24px;
}
.pcw-typing {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	vertical-align: middle;
	margin-inline-start: 6px;
}
.pcw-typing span {
	width: 6px; height: 6px; border-radius: 50%;
	background: currentColor;
	opacity: 0.5;
	animation: pcw-bounce 1.2s infinite ease-in-out;
}
.pcw-typing span:nth-child(2) { animation-delay: 0.15s; }
.pcw-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes pcw-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
	40%           { transform: translateY(-4px); opacity: 1; }
}

.pcw-msg__avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	overflow: hidden;
	flex: 0 0 auto;
	background: linear-gradient(135deg, #c97b5e, var(--pcw-accent));
	display: grid;
	place-items: center;
}
.pcw-msg__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcw-msg__avatar--fallback { font-size: 18px; color: #1a2b4a; }

/* Attachments in message bubbles (history) */
.pcw-msg__atts { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.pcw-msg__att {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 8px;
	background: rgba(0, 0, 0, 0.1);
	border-radius: 8px;
	font-size: 12px;
	color: inherit;
	text-decoration: none;
	max-width: 220px;
}
.pcw-msg--bot .pcw-msg__att  { background: rgba(255, 255, 255, 0.08); }
.pcw-msg--user .pcw-msg__att { background: rgba(26, 43, 74, 0.12); }
.pcw-msg__att:hover { filter: brightness(1.1); }
.pcw-msg__att--image { padding: 0; background: transparent; }
.pcw-msg__att--image img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; display: block; }
.pcw-msg__att-icon {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
	display: inline-grid;
	place-items: center;
}
.pcw-msg__att-icon svg { width: 16px; height: 16px; display: block; }
.pcw-msg__att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Floating bottom group (previews + progress + composer) ──────────── */
.pcw-bottom-wrap {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 24px;
	z-index: 3;
	pointer-events: none; /* only inner children catch clicks */
	padding: 0 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}
.pcw-bottom-wrap > * { pointer-events: auto; width: 100%; max-width: 760px; }

/* ── Previews strip (above composer) ─────────────────────────────────── */
.pcw-previews {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 6px 12px;
	background: var(--pcw-composer-bg);
	border: var(--pcw-composer-border);
	border-radius: 16px;
	box-shadow: var(--pcw-composer-shadow);
}
.pcw-previews--empty { display: none; }
#pcw-root .pcw-preview {
	position: relative;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 8px 4px 28px;
	background: var(--pcw-bubble-bot);
	color: var(--pcw-bubble-bot-text) !important;
	border: 1px solid var(--pcw-border);
	border-radius: 10px;
	font-size: 12px;
	max-width: 180px;
}
#pcw-root .pcw-preview__name { color: inherit; }
.pcw-preview--image { padding-inline-start: 4px; padding-inline-end: 28px; }
.pcw-preview__thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.pcw-preview__icon {
	width: 24px;
	height: 24px;
	flex: 0 0 auto;
	display: inline-grid;
	place-items: center;
	color: var(--pcw-icon-ink);
}
.pcw-preview__icon svg { width: 20px; height: 20px; display: block; }
.pcw-preview__name  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.pcw-preview__remove {
	position: absolute; inset-inline-start: 4px; top: 50%; transform: translateY(-50%);
	width: 20px; height: 20px; border: none; border-radius: 50%;
	background: rgba(0, 0, 0, 0.25); color: #fff;
	font-size: 14px; cursor: pointer; line-height: 1; padding: 0;
	display: grid; place-items: center;
}
.pcw-preview__remove:hover { background: #c97b5e; }
.pcw-preview--error {
	background: var(--pcw-error-bg, #fee2e2);
	color: var(--pcw-error-text, #7f1d1d);
	border-color: transparent;
	max-width: 100%;
	font-weight: 500;
}

/* Upload progress */
.pcw-progress {
	height: 3px;
	background: var(--pcw-border);
	border-radius: 3px;
	overflow: hidden;
}
.pcw-progress[hidden] { display: none; }
.pcw-progress__bar {
	height: 100%;
	width: 0;
	background: var(--pcw-accent);
	transition: width 0.12s ease-out;
}

/* Drop-hint overlay */
.pcw-drop-hint {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(157, 217, 184, 0.92);
	color: #1a2b4a;
	font-size: 18px;
	font-weight: 600;
	z-index: 5;
	pointer-events: none;
	border: 3px dashed #1a2b4a;
	border-radius: inherit;
}
.pcw-panel.pcw-dropzone-active .pcw-drop-hint { display: flex; }

/* ── Composer (Claude.ai-style floating card) ────────────────────────── */
.pcw-composer {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 14px 18px 10px;
	min-height: 110px;
	background: var(--pcw-composer-bg);
	border: var(--pcw-composer-border);
	border-radius: 24px;
	box-shadow: var(--pcw-composer-shadow);
	color: var(--pcw-text);
}

/* Textarea text is guarded against host-theme overrides — some WordPress
 * themes (like the one on simple-physics.schooly.land) ship global CSS like
 * `textarea { color: #333 !important }` that beats normal class rules and
 * makes the input invisible on the dark theme. We use #pcw-root for id
 * specificity plus !important on color-critical properties. */
#pcw-root .pcw-composer__textarea {
	flex: 1 1 auto;
	resize: none;
	border: none;
	outline: none;
	padding: 4px 2px;
	font: inherit;
	font-size: 15px;
	color: var(--pcw-input-text) !important;
	-webkit-text-fill-color: var(--pcw-input-text); /* Safari/iOS override */
	caret-color: var(--pcw-accent);
	max-height: 144px; /* ~6 lines */
	min-height: 44px;
	line-height: 1.5;
	background: transparent !important;
	direction: rtl;
	width: 100%;
}
#pcw-root .pcw-composer__textarea::placeholder {
	color: var(--pcw-text-muted) !important;
	opacity: 1; /* Firefox lowers placeholder opacity by default */
}
#pcw-root .pcw-composer__textarea::selection {
	background: var(--pcw-accent);
	color: var(--pcw-bubble-user-text);
}
#pcw-root .pcw-composer__textarea:focus { outline: none; }

.pcw-composer__row {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: auto; /* glue the action row to the bottom of the card */
}

.pcw-composer__attach {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	cursor: pointer;
	color: var(--pcw-icon-ink);
	display: grid;
	place-items: center;
	border-radius: 10px;
	padding: 0;
	transition: background 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-composer__attach svg { width: 20px; height: 20px; display: block; }
.pcw-composer__attach:hover  { background: rgba(157, 217, 184, 0.1);  transform: scale(1.05); }
.pcw-composer__attach:active { background: rgba(157, 217, 184, 0.22); transform: scale(0.95); }
.pcw-composer__attach:focus-visible { outline: 2px solid var(--pcw-accent); outline-offset: 1px; }

.pcw-composer__spacer { flex: 1 1 auto; }

.pcw-composer__send {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--pcw-accent);
	color: var(--pcw-accent-ink);
	border: none;
	cursor: pointer;
	display: grid;
	place-items: center;
	padding: 0;
	transition: transform 0.12s ease, background 0.12s ease;
}
.pcw-composer__send svg { width: 18px; height: 18px; display: block; }
.pcw-composer__send:hover  { transform: scale(1.06); }
.pcw-composer__send:active { transform: scale(0.95); }
.pcw-composer__send[disabled] {
	background: #555;
	color: rgba(255, 255, 255, 0.55);
	cursor: not-allowed;
	transform: none;
}

/* ── Settings modal (inside panel) ───────────────────────────────────── */
.pcw-settings {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999995;
}
.pcw-settings[hidden] { display: none; }
.pcw-settings__overlay {
	position: absolute; inset: 0;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(2px);
}
.pcw-settings__body {
	position: relative;
	width: min(440px, calc(100vw - 32px));
	max-height: 90vh;
	overflow-y: auto;
	background: var(--pcw-panel-bg);
	color: var(--pcw-text);
	border-radius: 16px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
	padding: 18px 20px;
	direction: rtl;
}
.pcw-settings__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 14px;
	font-size: 16px;
}
.pcw-settings__close {
	background: transparent; border: none; color: inherit;
	cursor: pointer;
	width: 32px; height: 32px;
	border-radius: 8px;
	display: grid; place-items: center;
	padding: 0;
	transition: background 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-settings__close svg { width: 18px; height: 18px; }
.pcw-settings__close:hover  { background: rgba(157, 217, 184, 0.18); transform: scale(1.05); }
.pcw-settings__close:active { transform: scale(0.95); }

.pcw-settings__section {
	margin: 14px 0;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--pcw-border);
}
.pcw-settings__section:last-child,
.pcw-settings__section--end { border-bottom: none; }

.pcw-settings__label {
	font-size: 13px;
	color: var(--pcw-text-muted);
	margin-bottom: 8px;
}
.pcw-settings__row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

/* Generic chip (text-size row) */
.pcw-chip {
	flex: 1 1 auto;
	padding: 8px 12px;
	border-radius: 10px;
	border: 1px solid var(--pcw-border);
	background: var(--pcw-input-bg);
	color: var(--pcw-text);
	cursor: pointer;
	font: inherit;
	font-size: 14px;
	min-width: 80px;
	text-align: center;
	transition: background 0.15s ease-out, border-color 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-chip:hover  { filter: brightness(1.08); }
.pcw-chip:active { transform: scale(0.97); }
.pcw-chip.is-active {
	background: var(--pcw-accent);
	color: var(--pcw-accent-ink);
	border-color: var(--pcw-accent);
	font-weight: 600;
}

/* Theme chip — icon stacked over label, mint ring when active */
.pcw-chip--theme {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 12px 8px;
	min-height: 72px;
}
.pcw-chip--theme .pcw-chip__icon {
	width: 24px;
	height: 24px;
	display: inline-grid;
	place-items: center;
	color: var(--pcw-text);
	transition: color 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-chip--theme .pcw-chip__icon svg { width: 22px; height: 22px; display: block; }
.pcw-chip--theme .pcw-chip__label {
	font-size: 13px;
	font-weight: 500;
}
/* Override the solid-mint .is-active for theme chips — use a ring instead */
.pcw-chip--theme.is-active {
	background: var(--pcw-input-bg);
	color: var(--pcw-text);
	border-color: var(--pcw-accent);
	box-shadow: inset 0 0 0 1px var(--pcw-accent);
	font-weight: 500;
}
.pcw-chip--theme.is-active .pcw-chip__icon {
	color: var(--pcw-accent);
	transform: scale(1.1);
}

/* Toggle switch (replaces the old raw checkbox) */
.pcw-settings__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	font-size: 14px;
	cursor: pointer;
}
.pcw-settings__toggle-label { flex: 1 1 auto; }

.pcw-switch {
	position: relative;
	width: 40px;
	height: 22px;
	flex: 0 0 auto;
}
.pcw-switch input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
	z-index: 2;
}
.pcw-switch__track {
	position: absolute;
	inset: 0;
	background: #555;
	border-radius: 999px;
	transition: background 0.2s ease-out;
	z-index: 0;
}
.pcw-switch__thumb {
	position: absolute;
	width: 18px;
	height: 18px;
	top: 2px;
	inset-inline-start: 2px;
	background: #ffffff;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease-out;
	pointer-events: none;
	z-index: 1;
}
.pcw-switch input:checked ~ .pcw-switch__track { background: var(--pcw-accent); }
/* RTL: thumb starts on the right; checked slides it 18px to the left */
#pcw-root .pcw-switch input:checked ~ .pcw-switch__thumb { transform: translateX(-18px); }

.pcw-settings__reset {
	width: 100%;
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid var(--pcw-border);
	background: transparent;
	color: var(--pcw-text);
	cursor: pointer;
	font: inherit;
	font-size: 14px;
	transition: background 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-settings__reset:hover  { background: rgba(157, 217, 184, 0.1); }
.pcw-settings__reset:active { transform: scale(0.98); }

/* ── Mobile (< 768px) ────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
	.pcw-launcher { width: 64px; height: 64px; }
	.pcw-launcher__character img { width: 58px; height: 58px; }
	.pcw-launcher__character--fallback { font-size: 30px; }
	.pcw-launcher[data-position="bottom-right"] { right: 16px; bottom: 16px; }
	.pcw-launcher[data-position="bottom-left"]  { left:  16px; bottom: 16px; }

	/* Panel: take the full dynamic viewport; reserve space at the bottom
	 * for Schooly's floating accessibility button so the send button isn't
	 * hidden by it or by the browser chrome. */
	.pcw-panel {
		top: 0; left: 0; right: 0; bottom: 0;
		width: 100vw;
		height: 100dvh;
		max-width: none; max-height: none;
		border-radius: 0;
		transform: none; animation: none;
		padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
	}
	.pcw-panel[data-position="middle-right"],
	.pcw-panel[data-position="middle-left"],
	.pcw-panel[data-position="bottom-left"] {
		top: 0; left: 0; right: 0; bottom: 0;
		transform: none;
	}
	.pcw-panel__fs { display: none; }

	/* Floating bottom group — take near-full width on mobile, with side insets
	 * matching the 12px spec, and keep away from Schooly's accessibility fab. */
	.pcw-bottom-wrap {
		bottom: 12px;
		padding: 0 12px 0 calc(70px + 12px);
		align-items: stretch;
	}
	.pcw-bottom-wrap > * { max-width: 100%; }

	.pcw-composer {
		min-height: 96px;
		border-radius: 20px;
		padding: 10px 14px;
	}
}

/* ── Snipping tool overlay ──────────────────────────────────────────── */
html.pcw-snip-active,
html.pcw-snip-active body { overflow: hidden !important; }

.pcw-snip-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.3);
	z-index: 999999;
	cursor: crosshair;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
	direction: rtl;
}

.pcw-snip-banner {
	position: absolute;
	top: 24px;
	left: 50%;
	transform: translateX(-50%);
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	background: #1a2b4a;
	color: #ffffff;
	border-radius: 12px;
	font: 500 14px/1.35 -apple-system, "Segoe UI", "Heebo", "Rubik", Arial, sans-serif;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
	cursor: default;
	z-index: 2;
	max-width: calc(100vw - 32px);
}
.pcw-snip-cancel {
	width: 26px; height: 26px;
	border: none; background: transparent; color: inherit;
	cursor: pointer; padding: 0;
	border-radius: 50%;
	display: grid; place-items: center;
	transition: background 0.15s ease-out, transform 0.15s ease-out;
}
.pcw-snip-cancel svg { width: 14px; height: 14px; }
.pcw-snip-cancel:hover  { background: rgba(255, 255, 255, 0.15); transform: scale(1.05); }
.pcw-snip-cancel:active { transform: scale(0.95); }

.pcw-snip-rect {
	position: absolute;
	border: 2px dashed #9dd9b8;
	background: rgba(157, 217, 184, 0.12);
	box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.15);
	pointer-events: none;
	box-sizing: border-box;
	z-index: 1;
}

.pcw-snip-toolbar {
	position: absolute;
	display: flex;
	gap: 6px;
	padding: 6px;
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
	z-index: 3;
	direction: rtl;
}
.pcw-snip-btn {
	border: 1px solid transparent;
	background: transparent;
	color: #1a2b4a;
	padding: 6px 14px;
	border-radius: 8px;
	cursor: pointer;
	font: 500 13px/1 -apple-system, "Segoe UI", "Heebo", "Rubik", Arial, sans-serif;
	transition: background 0.12s ease-out, transform 0.12s ease-out;
}
.pcw-snip-btn:hover  { background: rgba(26, 43, 74, 0.08); }
.pcw-snip-btn:active { transform: scale(0.97); }
.pcw-snip-btn--primary {
	background: #9dd9b8;
	color: #1a2b4a;
	font-weight: 600;
}
.pcw-snip-btn--primary:hover  { background: #8fd0ac; }

.pcw-snip-loading {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(0, 0, 0, 0.45);
	color: #ffffff;
	font: 500 15px/1.35 -apple-system, "Segoe UI", "Heebo", "Rubik", Arial, sans-serif;
	z-index: 4;
}
.pcw-snip-spinner {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #9dd9b8;
	animation: pcw-spin 0.9s linear infinite;
}
@keyframes pcw-spin { to { transform: rotate(360deg); } }

@media (max-width: 767.98px) {
	.pcw-snip-banner { font-size: 13px; padding: 8px 12px; top: 16px; }
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
	.pcw-panel,
	.pcw-composer__send,
	.pcw-typing span,
	.pcw-snip-spinner { animation: none !important; transition: none !important; }
}
