/**
 * Shared image tool shell — ShoutingNow pro workspace.
 */

.sn-img {
	--sn-img-primary: #f5c518;
	--sn-img-primary-hover: #e0b310;
	--sn-img-secondary: #2b7ddb;
	--sn-img-secondary-hover: #1f6bc4;
	--sn-img-surface: #f8fafc;
	--sn-img-border: #e2e8f0;
	--sn-img-text: #0f172a;
	--sn-img-muted: #64748b;
	--sn-img-good: #16a34a;
	--sn-img-warn: #dc2626;
	padding: 1.25rem 1rem 1.75rem;
}

@media (min-width: 640px) {
	.sn-img {
		padding: 1.5rem 1.5rem 2rem;
	}
}

.sn-img-hint {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	margin: 0 0 1.25rem;
	padding: 0.85rem 1rem;
	border-radius: 0.875rem;
	background: linear-gradient(135deg, #1e3a5f 0%, #2b7ddb 100%);
	color: #fff;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.5;
	box-shadow: 0 4px 14px rgba(30, 58, 95, 0.18);
}

.sn-img-hint__icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.2);
	font-size: 0.75rem;
}

.sn-img-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	min-height: 260px;
	padding: 2rem 1.25rem;
	border: 2px dashed #94a3b8;
	border-radius: 1.125rem;
	background: linear-gradient(180deg, #fff 0%, var(--sn-img-surface) 100%);
	text-align: center;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.sn-img-drop:hover,
.sn-img-drop.is-dragover,
.sn-img-drop:focus-visible {
	border-color: var(--sn-img-secondary);
	background: #eef6ff;
	box-shadow: 0 0 0 4px rgba(43, 125, 219, 0.12);
	outline: none;
}

.sn-img-drop.is-dragreject {
	border-color: var(--sn-img-warn);
	background: #fef2f2;
	box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.sn-img-drop.is-dragreject .sn-img-drop__reject {
	display: block;
}

.sn-img-drop__zone {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.65rem;
}

.sn-img-drop__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	border-radius: 999px;
	background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
	color: #1e3a5f;
	font-size: 1.35rem;
	font-weight: 700;
}

.sn-img-drop__title {
	margin: 0;
	font-size: 1.0625rem;
	font-weight: 700;
	color: var(--sn-img-text);
}

.sn-img-drop__hint {
	margin: 0;
	max-width: 32rem;
	font-size: 0.875rem;
	color: var(--sn-img-muted);
	line-height: 1.55;
}

.sn-img-drop__or {
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--sn-img-muted);
}

.sn-img-drop__reject {
	display: none;
	margin: 0;
	max-width: 28rem;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--sn-img-warn);
	line-height: 1.45;
}

.sn-img-drop__browse {
	flex-shrink: 0;
}

.sn-img-workspace {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1rem;
	margin-top: 0.25rem;
}

@media (min-width: 960px) {
	.sn-img-workspace {
		grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
		align-items: start;
	}
}

.sn-img-workspace__preview,
.sn-img-workspace__controls {
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
}

.sn-img-workspace__controls {
	padding: 1rem;
	border: 1px solid var(--sn-img-border);
	border-radius: 1rem;
	background: #fff;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sn-img-workspace--sidebar-meta .sn-img-workspace__controls {
	display: flex;
	flex-direction: column;
	gap: 0;
	padding: 0;
	overflow: hidden;
}

.sn-img-workspace--sidebar-meta .sn-img-workspace__controls-fields {
	padding: 1rem 1rem 0.85rem;
}

.sn-img-workspace--sidebar-meta .sn-img-workspace__meta {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 0 1rem 1rem;
}

.sn-img-workspace--sidebar-meta .sn-img-section {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.sn-img-stats {
	padding: 0.85rem 1rem;
	border: 1px solid var(--sn-img-border);
	border-radius: 0.875rem;
	background: #fff;
	font-size: 0.875rem;
}

.sn-img-workspace--sidebar-meta .sn-img-stats {
	border-radius: 0.75rem;
}

.sn-img-stats__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	padding: 0.55rem 0;
	border-bottom: 1px solid var(--sn-img-border);
}

.sn-img-stats__row:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

.sn-img-stats__row:first-child {
	padding-top: 0;
}

.sn-img-stats__row span {
	flex-shrink: 0;
	color: var(--sn-img-muted);
	font-size: 0.875rem;
}

.sn-img-stats__row strong {
	flex: 1;
	min-width: 0;
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--sn-img-text);
	text-align: right;
	word-break: break-word;
}

.sn-img-compare {
	display: block;
}

.sn-img-compare__card {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
	gap: 0.5rem 0.65rem;
	align-items: center;
	padding: 0.9rem 1rem;
	border: 1px solid var(--sn-img-border);
	border-radius: 0.875rem;
	background: #fff;
}

.sn-img-workspace--sidebar-meta .sn-img-compare__card {
	border-radius: 0.75rem;
}

.sn-img-compare__col {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	min-width: 0;
}

.sn-img-compare__col strong {
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.2;
}

.sn-img-compare__col.is-good strong {
	color: var(--sn-img-good);
}

.sn-img-compare__col.is-warn strong {
	color: var(--sn-img-warn);
}

.sn-img-compare__label {
	font-size: 0.6875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--sn-img-muted);
}

.sn-img-compare__col small {
	font-size: 0.75rem;
	color: var(--sn-img-muted);
	line-height: 1.35;
}

.sn-img-compare__arrow {
	flex-shrink: 0;
	font-size: 1.125rem;
	color: #94a3b8;
	text-align: center;
}

.sn-img-compare__badge {
	flex-shrink: 0;
	justify-self: end;
	padding: 0.3rem 0.55rem;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1.2;
	background: #e2e8f0;
	color: var(--sn-img-text);
	white-space: nowrap;
}

.sn-img-compare__badge.is-good {
	background: #dcfce7;
	color: #166534;
}

.sn-img-compare__badge.is-warn {
	background: #fee2e2;
	color: #991b1b;
}

.sn-img-compare__note {
	margin: 0.5rem 0 0;
	padding: 0 0.15rem;
	font-size: 0.8125rem;
	color: var(--sn-img-warn);
	line-height: 1.45;
}

.sn-img-panel {
	border: 1px solid var(--sn-img-border);
	border-radius: 1rem;
	background: #fff;
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.sn-img-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.65rem 0.85rem;
	border-bottom: 1px solid var(--sn-img-border);
	background: var(--sn-img-surface);
}

.sn-img-panel__title {
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--sn-img-muted);
}

.sn-img-preview {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 240px;
	padding: 0.75rem;
	background:
		linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
		linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
		linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
	background-size: 16px 16px;
	background-position: 0 0, 0 8px, 8px -8px, -8px 0;
	background-color: #f1f5f9;
}

.sn-img-preview--output {
	min-height: 180px;
}

.sn-img-preview__placeholder {
	margin: 0;
	padding: 1rem;
	color: var(--sn-img-muted);
	font-size: 0.875rem;
	text-align: center;
}

.sn-img-preview__img,
.sn-img-preview__canvas {
	display: block;
	max-width: 100%;
	max-height: 480px;
	width: auto;
	height: auto;
	border-radius: 0.35rem;
	box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
}

.sn-img-section {
	margin-bottom: 1rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--sn-img-border);
}

.sn-img-section:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.sn-img-section__title {
	margin: 0 0 0.75rem;
	font-size: 0.8125rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #1e3a5f;
}

.sn-img-field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	margin-bottom: 0.75rem;
}

.sn-img-field:last-child {
	margin-bottom: 0;
}

.sn-img-field__label {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--sn-img-text);
}

.sn-img-field__hint {
	margin: 0;
	font-size: 0.75rem;
	color: var(--sn-img-muted);
	line-height: 1.45;
}

.sn-img-input,
.sn-img-select,
.sn-img-textarea {
	width: 100%;
	min-height: 2.75rem;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--sn-img-border);
	border-radius: 0.75rem;
	background: #fff;
	font-size: 0.9375rem;
	color: var(--sn-img-text);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sn-img-input:focus,
.sn-img-select:focus,
.sn-img-textarea:focus {
	border-color: var(--sn-img-secondary);
	box-shadow: 0 0 0 3px rgba(43, 125, 219, 0.15);
	outline: none;
}

.sn-img-textarea {
	min-height: 7rem;
	resize: vertical;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	font-size: 0.8125rem;
	line-height: 1.45;
}

.sn-img-textarea--tall {
	min-height: 10rem;
}

.sn-img-range-wrap {
	display: flex;
	align-items: center;
	gap: 0.65rem;
}

.sn-img-range {
	flex: 1;
	accent-color: var(--sn-img-secondary);
}

.sn-img-range-value {
	min-width: 2.75rem;
	padding: 0.2rem 0.45rem;
	border-radius: 0.4rem;
	background: var(--sn-img-surface);
	font-size: 0.8125rem;
	font-weight: 700;
	text-align: center;
}

.sn-img-check,
.sn-img-radio {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	margin-bottom: 0.65rem;
	font-size: 0.875rem;
	cursor: pointer;
}

.sn-img-check input,
.sn-img-radio input {
	accent-color: var(--sn-img-secondary);
}

.sn-img-grid-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.65rem;
}

.sn-img-preset-group,
.sn-img-ratio-group,
.sn-img-tab-group {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	margin-bottom: 0.75rem;
}

.sn-img-preset-btn,
.sn-img-ratio-btn,
.sn-img-tab-btn {
	padding: 0.4rem 0.7rem;
	border: 1px solid var(--sn-img-border);
	border-radius: 0.55rem;
	background: #fff;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--sn-img-text);
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sn-img-preset-btn:hover,
.sn-img-ratio-btn:hover,
.sn-img-tab-btn:hover {
	border-color: #94a3b8;
	background: var(--sn-img-surface);
}

.sn-img-preset-btn.is-active,
.sn-img-ratio-btn.is-active,
.sn-img-tab-btn.is-active {
	border-color: var(--sn-img-secondary);
	background: #eef6ff;
	color: #1e3a5f;
	box-shadow: inset 0 0 0 1px rgba(43, 125, 219, 0.25);
}

.sn-img-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.55rem;
	margin-top: 1.25rem;
}

.sn-img-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	min-height: 2.75rem;
	padding: 0.55rem 1.1rem;
	border-radius: 0.75rem;
	border: 2px solid transparent;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.sn-img-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.sn-img-btn.is-busy {
	opacity: 0.75;
	pointer-events: none;
}

.sn-img-btn--primary {
	background: var(--sn-img-primary);
	color: #1a1a1a;
}

.sn-img-btn--primary:hover:not(:disabled) {
	background: var(--sn-img-primary-hover);
}

.sn-img-btn--secondary {
	background: var(--sn-img-secondary);
	color: #fff;
}

.sn-img-btn--secondary:hover:not(:disabled) {
	background: var(--sn-img-secondary-hover);
}

.sn-img-btn--ghost {
	background: #fff;
	border-color: var(--sn-img-border);
	color: var(--sn-img-text);
}

.sn-img-btn--ghost:hover:not(:disabled) {
	background: var(--sn-img-surface);
}

.sn-img-btn-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	margin-top: 0.5rem;
}

.sn-img-error {
	margin-top: 0.85rem;
	padding: 0.7rem 0.9rem;
	border-radius: 0.75rem;
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
	font-size: 0.875rem;
	line-height: 1.45;
}

.sn-img-toast {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 9999;
	max-width: min(24rem, calc(100vw - 2rem));
	padding: 0.7rem 1rem;
	border-radius: 0.75rem;
	background: #1e3a5f;
	color: #fff;
	font-size: 0.875rem;
	font-weight: 600;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.2s ease, transform 0.2s ease;
	pointer-events: none;
}

.sn-img-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

/* Interactive cropper */
.sn-img-crop-stage {
	width: 100%;
}

.sn-img-crop-stage__wrap {
	position: relative;
	display: inline-block;
	max-width: 100%;
	line-height: 0;
	user-select: none;
	touch-action: none;
}

.sn-img-crop-stage__img {
	display: block;
	max-width: 100%;
	max-height: 480px;
	width: auto;
	height: auto;
}

.sn-img-crop-stage__shade {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	pointer-events: none;
}

.sn-img-crop-stage__box {
	position: absolute;
	top: 0;
	left: 0;
	border: 2px solid var(--sn-img-primary);
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
	cursor: move;
	touch-action: none;
}

.sn-img-crop-stage__grid {
	position: absolute;
	inset: 0;
	background:
		linear-gradient(to right, rgba(255, 255, 255, 0.35) 1px, transparent 1px),
		linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
	background-size: 33.333% 100%, 100% 33.333%;
	pointer-events: none;
}

.sn-img-crop-stage__handle {
	position: absolute;
	width: 12px;
	height: 12px;
	border: 2px solid #fff;
	border-radius: 2px;
	background: var(--sn-img-secondary);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.sn-img-crop-stage__handle--nw { top: -6px; left: -6px; cursor: nwse-resize; }
.sn-img-crop-stage__handle--n { top: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.sn-img-crop-stage__handle--ne { top: -6px; right: -6px; cursor: nesw-resize; }
.sn-img-crop-stage__handle--e { top: 50%; right: -6px; margin-top: -6px; cursor: ew-resize; }
.sn-img-crop-stage__handle--se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.sn-img-crop-stage__handle--s { bottom: -6px; left: 50%; margin-left: -6px; cursor: ns-resize; }
.sn-img-crop-stage__handle--sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.sn-img-crop-stage__handle--w { top: 50%; left: -6px; margin-top: -6px; cursor: ew-resize; }

.sn-img-crop-mount {
	width: 100%;
	min-height: 240px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.sn-img-output-tabs {
	display: none;
}

.sn-img-output-tabs.is-visible {
	display: block;
}

.sn-img-output-panel {
	margin-top: 0.25rem;
}

.sn-img--base64.is-decode-mode [data-image-drop],
.sn-img--base64.is-decode-mode .sn-img-actions,
.sn-img--base64.is-decode-mode .sn-img-panel--original {
	display: none;
}

.sn-img--base64.is-decode-mode [data-encode-output] {
	display: none !important;
}

.sn-img-field[hidden],
.sn-img-output-panel[hidden],
[data-decode-panel][hidden],
[data-encode-panel][hidden] {
	display: none !important;
}

.sn-img-meta-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-top: 0.35rem;
}

.sn-img-meta-pill {
	padding: 0.2rem 0.5rem;
	border-radius: 999px;
	background: var(--sn-img-surface);
	font-size: 0.6875rem;
	font-weight: 600;
	color: var(--sn-img-muted);
}
