/* ═══════════════════════════════════════════════════
   Sketch Tech Studio v2 — CSS thème sombre doré
   Palette : fond #1a1a2e / #16213e, accent #f5a623 / #ffd166
   ═══════════════════════════════════════════════════ */

.sts-app {
	--gold:      #f5a623;
	--gold-lt:   #ffd166;
	--gold-dk:   #c47d0e;
	--teal:      #00d4d4;
	--pink:      #ff6b9d;
	--lime:      #a8e063;
	--danger:    #ff4757;
	--bg:        #12131f;
	--bg-soft:   #1a1b2e;
	--panel:     #1e2035;
	--panel-lt:  #252740;
	--line:      rgba(245,166,35,.18);
	--line-soft: rgba(255,255,255,.07);
	--muted:     #8892b0;
	--text:      #e8eaf6;
	--text-dim:  #b0b8d4;

	all: initial;
	display: block;
	box-sizing: border-box;
	width: 100%;
	padding: clamp(12px, 2vw, 22px);
	color: var(--text);
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
	font-size: 13px;
	line-height: 1.4;
	background: var(--bg);
	border-radius: 14px;
	border: 1px solid rgba(245,166,35,.2);
	box-shadow: 0 20px 80px rgba(0,0,0,.6);
}

.sts-app *, .sts-app *::before, .sts-app *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font-family: inherit;
	color: inherit;
	/* Reset thème */
	-webkit-text-fill-color: unset !important;
}

/* ── Shell ── */
.sts-shell {
	display: grid;
	grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
	gap: clamp(12px, 1.8vw, 20px);
	align-items: start;
	max-width: 1360px;
	margin: 0 auto;
}

/* ── Panels ── */
.sts-toolbar,
.sts-workspace {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.04);
}

.sts-toolbar {
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: rgba(245,166,35,.2) transparent;
}

.sts-workspace {
	padding: clamp(12px,1.8vw,18px);
	display: flex;
	flex-direction: column;
	gap: 14px;
}

/* ── Brand ── */
.sts-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--line);
}

.sts-brand-mark {
	flex: 0 0 48px;
	width: 48px;
	height: 48px;
	display: grid;
	place-items: center;
	border-radius: 10px;
	background: linear-gradient(135deg, var(--gold), var(--gold-lt));
	color: #12131f !important;
	font-size: 14px;
	font-weight: 900;
	box-shadow: 0 0 20px rgba(245,166,35,.35);
	animation: sts-pulse 3s ease-in-out infinite;
}
@keyframes sts-pulse {
	0%,100% { box-shadow: 0 0 20px rgba(245,166,35,.35); }
	50%      { box-shadow: 0 0 36px rgba(245,166,35,.65); }
}

.sts-kicker {
	display: block;
	color: var(--gold) !important;
	font-size: 10px !important;
	font-weight: 800 !important;
	text-transform: uppercase !important;
	letter-spacing: .08em !important;
	line-height: 1.2 !important;
}

.sts-title {
	display: block;
	margin-top: 3px;
	font-size: clamp(16px, 1.5vw, 20px) !important;
	font-weight: 800 !important;
	line-height: 1.1 !important;
	color: var(--text) !important;
	background: none !important;
	-webkit-background-clip: unset !important;
	-webkit-text-fill-color: var(--text) !important;
	background-clip: unset !important;
}

/* ── Section ── */
.sts-section { display: flex; flex-direction: column; gap: 7px; }

.sts-section-title {
	display: flex;
	align-items: center;
	gap: 6px;
	color: var(--gold) !important;
	font-size: 10px !important;
	font-weight: 800 !important;
	text-transform: uppercase !important;
	letter-spacing: .08em !important;
}
.sts-section-title::after {
	content: '';
	flex: 1;
	height: 1px;
	background: linear-gradient(90deg, rgba(245,166,35,.3), transparent);
}

/* ── Grids ── */
.sts-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sts-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }

/* ── Buttons ── */
.sts-btn {
	display: flex !important;
	flex-direction: column !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 5px !important;
	padding: 9px 6px !important;
	min-height: 52px !important;
	width: 100% !important;
	background: var(--panel-lt) !important;
	border: 1px solid rgba(245,166,35,.22) !important;
	border-radius: 8px !important;
	color: var(--text-dim) !important;
	font-size: 11px !important;
	font-weight: 700 !important;
	cursor: pointer !important;
	transition: border-color .14s, box-shadow .14s, transform .14s, color .14s, background .14s !important;
	text-align: center !important;
	text-decoration: none !important;
	text-transform: none !important;
	line-height: 1.2 !important;
}
.sts-btn svg { color: var(--muted) !important; transition: color .14s; flex-shrink: 0; }

.sts-btn:hover,
.sts-btn:focus {
	background: rgba(245,166,35,.1) !important;
	border-color: var(--gold) !important;
	box-shadow: 0 0 14px rgba(245,166,35,.2) !important;
	color: var(--gold) !important;
	transform: translateY(-1px) !important;
	outline: none !important;
}
.sts-btn:hover svg { color: var(--gold) !important; }

.sts-btn.is-active {
	background: linear-gradient(135deg, rgba(245,166,35,.22), rgba(255,209,102,.12)) !important;
	border-color: var(--gold) !important;
	color: var(--gold-lt) !important;
	box-shadow: 0 0 16px rgba(245,166,35,.25) !important;
}
.sts-btn.is-active svg { color: var(--gold-lt) !important; }

.sts-btn--wide {
	flex-direction: row !important;
	gap: 8px !important;
	min-height: 40px !important;
	padding: 9px 14px !important;
	font-size: 12px !important;
}

.sts-btn--danger {
	border-color: rgba(255,71,87,.35) !important;
	color: var(--muted) !important;
}
.sts-btn--danger:hover {
	background: rgba(255,71,87,.1) !important;
	border-color: var(--danger) !important;
	color: var(--danger) !important;
	box-shadow: 0 0 12px rgba(255,71,87,.2) !important;
}
.sts-btn--danger:hover svg { color: var(--danger) !important; }

/* ── Fields ── */
.sts-field {
	display: flex !important;
	align-items: center !important;
	justify-content: space-between !important;
	gap: 10px !important;
	padding: 8px 11px !important;
	background: var(--bg-soft) !important;
	border: 1px solid var(--line-soft) !important;
	border-radius: 8px !important;
	cursor: default !important;
}
.sts-field span,
.sts-field label {
	color: var(--text-dim) !important;
	font-size: 11.5px !important;
	font-weight: 700 !important;
	-webkit-text-fill-color: var(--text-dim) !important;
}
.sts-field--range {
	flex-direction: column !important;
	align-items: stretch !important;
	gap: 7px !important;
}
.sts-field input[type="color"] {
	width: 40px !important;
	height: 26px !important;
	padding: 0 !important;
	background: none !important;
	border: 1px solid rgba(245,166,35,.3) !important;
	border-radius: 5px !important;
	cursor: pointer !important;
}
.sts-field input[type="range"] {
	width: 100% !important;
	accent-color: var(--gold) !important;
	cursor: pointer !important;
}
.sts-field output {
	color: var(--gold-lt) !important;
	-webkit-text-fill-color: var(--gold-lt) !important;
	font-size: 11px !important;
	font-weight: 800 !important;
	text-align: right !important;
}

/* ── Stickers ── */
.sts-sticker {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	min-height: 46px !important;
	font-size: 20px !important;
	background: var(--panel-lt) !important;
	border: 1px solid rgba(255,255,255,.08) !important;
	border-radius: 8px !important;
	cursor: pointer !important;
	transition: transform .14s, border-color .14s, box-shadow .14s !important;
	position: relative !important;
}
.sts-sticker:hover {
	transform: scale(1.12) !important;
	border-color: var(--gold) !important;
	box-shadow: 0 0 12px rgba(245,166,35,.3) !important;
}
.sts-sticker--new::after {
	content: 'NEW';
	position: absolute;
	top: -5px; right: -5px;
	background: var(--gold);
	color: #12131f !important;
	font-size: 8px !important;
	font-weight: 900 !important;
	padding: 2px 4px;
	border-radius: 4px;
	letter-spacing: .04em;
}

/* ── BG swatches ── */
.sts-bg-row { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; }
.sts-bg-swatch {
	aspect-ratio: 1;
	border-radius: 7px;
	border: 2px solid transparent !important;
	cursor: pointer !important;
	transition: transform .14s, border-color .14s, box-shadow .14s;
	position: relative;
}
.sts-bg-swatch:hover { transform: scale(1.08); border-color: var(--gold) !important; }
.sts-bg-swatch.is-active {
	border-color: var(--gold) !important;
	box-shadow: 0 0 10px rgba(245,166,35,.4) !important;
}
.sts-bg-swatch.is-active::after {
	content: '✓';
	position: absolute; inset: 0;
	display: flex; align-items: center; justify-content: center;
	font-size: 13px; font-weight: 900;
	color: #fff !important;
	text-shadow: 0 0 6px #000;
}

/* ── File input hidden ── */
.sts-file-input {
	position: absolute !important;
	width: 1px !important; height: 1px !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	white-space: nowrap !important;
	clip-path: inset(50%) !important;
}

/* ── KB hint ── */
.sts-kb-hint {
	text-align: center;
	font-size: 10px !important;
	font-weight: 700 !important;
	color: rgba(255,255,255,.2) !important;
	-webkit-text-fill-color: rgba(255,255,255,.2) !important;
	letter-spacing: .04em;
	margin-top: 4px;
}

/* ── Topbar ── */
.sts-topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.sts-status {
	font-size: 12px !important;
	font-weight: 700 !important;
	color: var(--muted) !important;
	-webkit-text-fill-color: var(--muted) !important;
	transition: color .25s;
}
.sts-status.is-active {
	color: var(--gold-lt) !important;
	-webkit-text-fill-color: var(--gold-lt) !important;
}

/* ── Download button ── */
.sts-dl-btn {
	display: flex !important;
	align-items: center !important;
	gap: 8px !important;
	padding: 10px 20px !important;
	background: linear-gradient(135deg, var(--gold), var(--gold-dk)) !important;
	border: none !important;
	border-radius: 8px !important;
	cursor: pointer !important;
	color: #12131f !important;
	-webkit-text-fill-color: #12131f !important;
	font-size: 13px !important;
	font-weight: 800 !important;
	box-shadow: 0 0 20px rgba(245,166,35,.3) !important;
	transition: transform .14s, box-shadow .14s !important;
	text-decoration: none !important;
}
.sts-dl-btn:hover {
	transform: translateY(-1px) !important;
	box-shadow: 0 0 30px rgba(245,166,35,.5) !important;
	color: #12131f !important;
}
.sts-dl-btn svg { color: #12131f !important; }

/* ── Canvas shell ── */
.sts-canvas-shell {
	position: relative;
	width: 100%;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 10px;
	border: 1px solid rgba(245,166,35,.25) !important;
	box-shadow: 0 0 0 1px rgba(0,212,212,.1), 0 0 40px rgba(245,166,35,.08);
	background:
		linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
		#12131f;
	background-size: 54px 54px;
	transition: border-color .4s, box-shadow .4s;
}
.sts-canvas-shell canvas { display: block !important; width: 100% !important; height: 100% !important; }

.sts-canvas-shell.glow-cyan   { border-color: rgba(0,212,212,.5) !important;  box-shadow: 0 0 0 1px rgba(245,166,35,.1), 0 0 50px rgba(0,212,212,.2) !important; }
.sts-canvas-shell.glow-pink   { border-color: rgba(255,107,157,.5) !important; box-shadow: 0 0 0 1px rgba(245,166,35,.1), 0 0 50px rgba(255,107,157,.2) !important; }
.sts-canvas-shell.glow-lime   { border-color: rgba(168,224,99,.5) !important;  box-shadow: 0 0 0 1px rgba(245,166,35,.1), 0 0 50px rgba(168,224,99,.2) !important; }
.sts-canvas-shell.glow-orange { border-color: rgba(245,166,35,.6) !important;  box-shadow: 0 0 0 1px rgba(245,166,35,.15), 0 0 50px rgba(245,166,35,.3) !important; }

/* ── IA Panels ── */
.sts-ai-bg-panel,
.sts-ai-chat-panel {
	padding: 14px;
	background: var(--bg-soft);
	border: 1px solid rgba(245,166,35,.18);
	border-radius: 10px;
}

.sts-ai-panel-header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
}

.sts-ai-badge {
	padding: 3px 8px;
	background: linear-gradient(135deg, rgba(245,166,35,.2), rgba(255,209,102,.15));
	border: 1px solid rgba(245,166,35,.35);
	border-radius: 5px;
	font-size: 11px !important;
	font-weight: 900 !important;
	color: var(--gold) !important;
	-webkit-text-fill-color: var(--gold) !important;
	letter-spacing: .04em;
	white-space: nowrap;
}

.sts-ai-panel-title {
	font-size: 13px !important;
	font-weight: 800 !important;
	color: var(--text) !important;
	-webkit-text-fill-color: var(--text) !important;
}

.sts-ai-panel-hint {
	font-size: 11px !important;
	font-weight: 600 !important;
	color: var(--muted) !important;
	-webkit-text-fill-color: var(--muted) !important;
	margin-left: auto;
}

.sts-ai-bg-form,
.sts-chat-form {
	display: flex;
	gap: 8px;
}

.sts-ai-input {
	flex: 1;
	padding: 9px 12px !important;
	background: var(--panel) !important;
	border: 1px solid rgba(245,166,35,.2) !important;
	border-radius: 7px !important;
	color: var(--text) !important;
	-webkit-text-fill-color: var(--text) !important;
	font-size: 12.5px !important;
	font-weight: 500 !important;
	outline: none !important;
	transition: border-color .14s, box-shadow .14s !important;
}
.sts-ai-input::placeholder { color: var(--muted) !important; opacity: .7; }
.sts-ai-input:focus {
	border-color: var(--gold) !important;
	box-shadow: 0 0 0 3px rgba(245,166,35,.12) !important;
	-webkit-text-fill-color: var(--text) !important;
}

.sts-ai-go-btn {
	display: flex !important;
	align-items: center !important;
	gap: 7px !important;
	padding: 9px 16px !important;
	background: linear-gradient(135deg, var(--gold), var(--gold-dk)) !important;
	border: none !important;
	border-radius: 7px !important;
	color: #12131f !important;
	-webkit-text-fill-color: #12131f !important;
	font-size: 12px !important;
	font-weight: 800 !important;
	cursor: pointer !important;
	white-space: nowrap !important;
	transition: transform .14s, box-shadow .14s, opacity .14s !important;
}
.sts-ai-go-btn svg { color: #12131f !important; }
.sts-ai-go-btn:hover { transform: translateY(-1px) !important; box-shadow: 0 0 16px rgba(245,166,35,.4) !important; }
.sts-ai-go-btn:disabled { opacity: .5 !important; cursor: not-allowed !important; transform: none !important; }

/* ── Chat log ── */
.sts-chat-log {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 180px;
	overflow-y: auto;
	margin-bottom: 10px;
	padding-right: 4px;
	scrollbar-width: thin;
	scrollbar-color: rgba(245,166,35,.15) transparent;
}

.sts-chat-msg { display: flex; max-width: 90%; }
.sts-chat-msg span {
	padding: 8px 12px !important;
	border-radius: 10px !important;
	font-size: 12px !important;
	font-weight: 500 !important;
	line-height: 1.5 !important;
}
.sts-chat-msg em { font-style: normal !important; color: var(--gold) !important; -webkit-text-fill-color: var(--gold) !important; }

.sts-chat-msg--ai  { align-self: flex-start; }
.sts-chat-msg--ai span {
	background: rgba(245,166,35,.07) !important;
	border: 1px solid rgba(245,166,35,.18) !important;
	color: var(--text) !important;
	-webkit-text-fill-color: var(--text) !important;
}

.sts-chat-msg--user { align-self: flex-end; }
.sts-chat-msg--user span {
	background: rgba(0,212,212,.08) !important;
	border: 1px solid rgba(0,212,212,.2) !important;
	color: var(--text) !important;
	-webkit-text-fill-color: var(--text) !important;
}

.sts-chat-msg--typing span {
	background: rgba(255,255,255,.04) !important;
	border: 1px solid rgba(255,255,255,.08) !important;
	color: var(--muted) !important;
	-webkit-text-fill-color: var(--muted) !important;
}

/* ── Broken state ── */
.sts-app.is-broken .sts-workspace::before {
	display: block;
	padding: 14px;
	color: var(--danger) !important;
	font-weight: 800 !important;
	content: "Fabric.js n'a pas pu être chargé.";
	background: rgba(255,71,87,.1);
	border: 1px solid rgba(255,71,87,.3);
	border-radius: 8px;
}

/* ── Responsive ── */
@media (max-width: 960px) {
	.sts-shell { grid-template-columns: 1fr; }
	.sts-toolbar { display: grid; grid-template-columns: repeat(2,1fr); max-height: none; }
	.sts-brand { grid-column: 1 / -1; }
	.sts-ai-panel-hint { display: none; }
}
@media (max-width: 620px) {
	.sts-app { padding: 10px; border-radius: 0; }
	.sts-toolbar { grid-template-columns: 1fr; padding: 12px; }
	.sts-grid-3 { grid-template-columns: 1fr 1fr; }
	.sts-topbar { flex-direction: column; align-items: stretch; }
	.sts-dl-btn { justify-content: center !important; }
}

/* ══════════════════════════════════════
   FIXES SUPPLÉMENTAIRES — iPhone / Astra
   ══════════════════════════════════════ */

/* Force reset sur TOUS les éléments enfants — bloque Astra/Elementor */
.sts-app button,
.sts-app input,
.sts-app label,
.sts-app p,
.sts-app span,
.sts-app div,
.sts-app h2,
.sts-app h3,
.sts-app output {
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif !important;
	-webkit-text-fill-color: unset !important;
	text-transform: none !important;
	letter-spacing: normal !important;
}

/* Corrige le text-fill orange d'Astra sur les boutons */
.sts-app .sts-btn,
.sts-app .sts-btn span,
.sts-app .sts-sticker,
.sts-app .sts-ai-go-btn,
.sts-app .sts-dl-btn {
	-webkit-text-fill-color: currentColor !important;
}
.sts-app .sts-dl-btn,
.sts-app .sts-dl-btn span,
.sts-app .sts-ai-go-btn,
.sts-app .sts-ai-go-btn span {
	-webkit-text-fill-color: #12131f !important;
}

/* iPhone : empêche le zoom auto sur les inputs */
.sts-app .sts-ai-input,
.sts-app input[type="text"],
.sts-app input[type="color"],
.sts-app input[type="range"] {
	font-size: 16px !important; /* iOS ne zoome pas si font-size >= 16px */
	touch-action: manipulation !important;
}
.sts-app .sts-ai-input { font-size: 14px !important; } /* override to readable size post-focus */

/* iPhone : tap highlight */
.sts-app button,
.sts-app .sts-sticker,
.sts-app .sts-bg-swatch {
	-webkit-tap-highlight-color: rgba(245,166,35,.2) !important;
	touch-action: manipulation !important;
}

/* iPhone : curseur crosshair bugue, on neutralise */
@media (pointer: coarse) {
	.sts-canvas-shell { cursor: default !important; }
	.sts-btn { min-height: 48px !important; } /* zone de tap confortable */
	.sts-sticker { min-height: 52px !important; }
	.sts-bg-swatch { min-height: 44px !important; }
}

/* Scroll horizontal global bloqué sur mobile */
.sts-app { overflow-x: hidden !important; }

/* Empêche les boutons de déborder sur petits écrans */
@media (max-width: 400px) {
	.sts-grid-3 { grid-template-columns: 1fr 1fr !important; }
	.sts-bg-row  { grid-template-columns: repeat(5, 1fr) !important; }
	.sts-btn     { font-size: 10px !important; min-height: 44px !important; }
	.sts-title   { font-size: 15px !important; }
	.sts-ai-go-btn { padding: 9px 10px !important; font-size: 11px !important; }
}

/* ══════════════════════════════════════════════════
   CORRECTIFS CRITIQUES v2.2
   ══════════════════════════════════════════════════ */

/* Fabric.js injecte .canvas-container — il faut le dimensionner */
.sts-canvas-shell .canvas-container {
	width: 100% !important;
	height: 100% !important;
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
}
/* Le canvas Fabric (upper-canvas + lower-canvas) */
.sts-canvas-shell .canvas-container canvas {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	width: 100% !important;
	height: 100% !important;
}
/* Le shell doit être en position relative avec une hauteur définie */
.sts-canvas-shell {
	position: relative !important;
	width: 100% !important;
	/* aspect-ratio seul ne suffit pas quand Fabric écrase le layout */
	/* On force une hauteur via padding-bottom trick */
	aspect-ratio: 1 / 1 !important;
	min-height: 200px !important;
	overflow: hidden !important;
}

/* Stickers — forcer la police emoji système, jamais hériter du thème */
.sts-sticker,
.sts-sticker * {
	font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif !important;
	font-size: 22px !important;
	line-height: 1 !important;
	-webkit-text-fill-color: initial !important;
	color: initial !important;
}
.sts-sticker--new::after {
	font-family: Inter, ui-sans-serif, system-ui, sans-serif !important;
	font-size: 8px !important;
	color: #12131f !important;
	-webkit-text-fill-color: #12131f !important;
}
