* { box-sizing: border-box; }

body.uieg-single {
	margin: 0;
	background: #101012;
	color: #eaeaea;
	font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	height: 100vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	-webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.uieg-topbar {
	display: flex;
	align-items: center;
	gap: 18px;
	padding: 14px 22px;
	background: #0a0a0b;
	border-bottom: 1px solid #232326;
	flex-shrink: 0;
}
.uieg-back {
	display: flex;
	align-items: center;
	gap: 6px;
	color: #9a9aa2;
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	transition: color .15s ease;
}
.uieg-back:hover { color: #fff; }

/* ---------- Byline: categoría · usuario · vistas · favoritos ---------- */
.uieg-byline {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: #9a9aa2;
}
.uieg-byline-heading {
	margin: 0;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	font-weight: 400;
	line-height: 1;
}
.uieg-byline-cat { color: #9a9aa2; }
.uieg-byline-user { color: #fff; font-weight: 700; }
.uieg-byline-stat {
	display: flex;
	align-items: center;
	gap: 4px;
	color: #9a9aa2;
	padding-left: 8px;
	border-left: 1px solid #2c2c31;
}

.uieg-topbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

.uieg-icon-btn {
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #18181b;
	border: 1px solid #232326;
	border-radius: 9px;
	color: #cfcfd4;
	cursor: pointer;
	transition: color .15s ease, border-color .15s ease;
}
.uieg-icon-btn:hover { color: #fff; border-color: #4b4b52; }
.uieg-icon-btn.is-copied { color: #7ee787; border-color: #1f7a3f; }

/* ---------- Exportar ---------- */
.uieg-export-wrap { position: relative; }
.uieg-export-btn {
	display: flex;
	align-items: center;
	gap: 7px;
	height: 34px;
	background: #18181b;
	border: 1px solid #232326;
	border-radius: 9px;
	color: #e8e8ea;
	font-family: 'Space Grotesk', sans-serif;
	font-size: 13px;
	font-weight: 600;
	padding: 0 13px;
	cursor: pointer;
	transition: border-color .15s ease;
}
.uieg-export-btn:hover { border-color: #4b4b52; }
.uieg-export-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	width: 200px;
	background: #1c1c1f;
	border: 1px solid #2c2c31;
	border-radius: 12px;
	padding: 6px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
	z-index: 20;
}
.uieg-export-menu[hidden] { display: none; }
.uieg-export-item {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 8px;
	background: transparent;
	border: none;
	color: #dcdce0;
	font-family: 'Space Grotesk', sans-serif;
	font-size: 13px;
	font-weight: 500;
	text-align: left;
	padding: 9px 10px;
	border-radius: 8px;
	cursor: pointer;
}
.uieg-export-item:hover { background: #26262b; color: #fff; }
.uieg-export-sep { height: 1px; background: #2c2c31; margin: 5px 4px; }

/* ---------- Hashtags del elemento: franja inferior, debajo de todo lo demás ---------- */
.uieg-tags-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 12px 22px;
	background: #0a0a0b;
	border-top: 1px solid #232326;
	flex-shrink: 0;
}
.uieg-tag-chip {
	font-size: 12px;
	font-weight: 500;
	color: #b6b6bd;
	background: #18181b;
	border: 1px solid #232326;
	padding: 4px 11px;
	border-radius: 20px;
}

.uieg-editor {
	flex: 1;
	display: grid;
	grid-template-columns: 1.1fr 1fr;
	min-height: 0;
}
@media (max-width: 800px) {
	.uieg-editor { grid-template-columns: 1fr; grid-template-rows: 48vh 1fr; }
}
@media (max-width: 700px) {
	.uieg-topbar { flex-wrap: wrap; gap: 10px; }
	.uieg-byline { margin-left: 0; order: 3; width: 100%; }
	.uieg-byline-cat { display: none; }
}

/* ---------- Panel de vista previa (izquierda) ---------- */
.uieg-preview-pane {
	position: relative;
	background: #1a1a1c;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.uieg-preview-toolbar {
	position: absolute;
	top: 18px;
	right: 22px;
	left: 22px;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 10px;
	z-index: 5;
}

.uieg-hex-box {
	margin-right: auto;
	font-family: 'Space Grotesk', monospace;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .3px;
	color: #e4e4e8;
	background: rgba(20, 20, 22, .75);
	backdrop-filter: blur(6px);
	padding: 7px 12px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, .08);
}

/* ---------- Toggle claro/oscuro ---------- */
.uieg-toggle-theme {
	display: flex;
	align-items: center;
	gap: 6px;
	background: rgba(20, 20, 22, .75);
	backdrop-filter: blur(6px);
	border: 1px solid rgba(255, 255, 255, .08);
	border-radius: 20px;
	padding: 6px 10px;
	cursor: pointer;
	color: #cfcfd4;
	transition: color .15s ease;
}
.uieg-toggle-theme:hover { color: #fff; }
.uieg-icon-sun, .uieg-icon-moon { flex-shrink: 0; transition: opacity .15s ease; }
.uieg-toggle-theme:not(.is-dark) .uieg-icon-moon { opacity: .35; }
.uieg-toggle-theme.is-dark .uieg-icon-sun { opacity: .35; }
.uieg-toggle-track {
	width: 32px;
	height: 18px;
	border-radius: 20px;
	background: #3a3a40;
	position: relative;
	transition: background .2s ease;
	flex-shrink: 0;
}
.uieg-toggle-dot {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #fff;
	transition: transform .2s ease;
}
.uieg-toggle-theme.is-dark .uieg-toggle-track { background: #4b8bf4; }
.uieg-toggle-theme.is-dark .uieg-toggle-dot { transform: translateX(14px); }

/* ---------- Botón cuadriculado ---------- */
.uieg-checker-btn {
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(20, 20, 22, .75);
	backdrop-filter: blur(6px);
	border: 1px solid rgba(255, 255, 255, .08);
	border-radius: 8px;
	cursor: pointer;
}
.uieg-checker-btn.is-active { border-color: #4b8bf4; }
.uieg-square-icon {
	width: 13px;
	height: 13px;
	border-radius: 3px;
	display: block;
	background-image:
		linear-gradient(45deg, #6b6b72 25%, transparent 25%),
		linear-gradient(-45deg, #6b6b72 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #6b6b72 75%),
		linear-gradient(-45deg, transparent 75%, #6b6b72 75%);
	background-size: 6px 6px;
	background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
}

/* ---------- Selector de color (fondo) ---------- */
.uieg-color-picker { position: relative; }

.uieg-swatch-btn {
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(20, 20, 22, .75);
	backdrop-filter: blur(6px);
	border: 1px solid rgba(255, 255, 255, .08);
	border-radius: 8px;
	cursor: pointer;
	padding: 0;
}
.uieg-swatch-fill {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	background: var(--swatch-color, #e8e8e8);
	border: 1px solid rgba(255, 255, 255, .25);
	display: block;
}

.uieg-color-popover {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	width: 240px;
	background: #1c1c1f;
	border: 1px solid #2c2c31;
	border-radius: 14px;
	padding: 14px;
	box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
	z-index: 10;
}
.uieg-color-popover[hidden] { display: none; }

.uieg-sl-field {
	position: relative;
	width: 100%;
	height: 130px;
	border-radius: 10px;
	overflow: hidden;
	cursor: crosshair;
	margin-bottom: 12px;
}
.uieg-sl-hue-layer { position: absolute; inset: 0; }
.uieg-sl-white-layer {
	position: absolute; inset: 0;
	background: linear-gradient(to right, #fff, rgba(255,255,255,0));
}
.uieg-sl-black-layer {
	position: absolute; inset: 0;
	background: linear-gradient(to top, #000, rgba(0,0,0,0));
}
.uieg-sl-thumb {
	position: absolute;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 2px solid #fff;
	box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.4);
	transform: translate(-50%, -50%);
	pointer-events: none;
}

.uieg-popover-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
}
.uieg-eyedropper-btn {
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #26262b;
	border: 1px solid #333338;
	border-radius: 8px;
	color: #cfcfd4;
	cursor: pointer;
}
.uieg-eyedropper-btn:hover { color: #fff; border-color: #4b8bf4; }
.uieg-eyedropper-btn[disabled] { opacity: .35; cursor: not-allowed; }
.uieg-popover-preview {
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: 2px solid #333338;
	background: var(--preview-color, #e8e8e8);
}
.uieg-hue-slider {
	flex: 1;
	-webkit-appearance: none;
	appearance: none;
	height: 10px;
	border-radius: 20px;
	background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
	cursor: pointer;
}
.uieg-hue-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid #1c1c1f;
	box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}
.uieg-hue-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid #1c1c1f;
}

.uieg-rgb-row {
	display: flex;
	gap: 8px;
}
.uieg-rgb-row label {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}
.uieg-rgb-row input {
	width: 100%;
	text-align: center;
	background: #26262b;
	border: 1px solid #333338;
	border-radius: 8px;
	color: #fff;
	font-family: 'Space Grotesk', sans-serif;
	font-size: 13px;
	font-weight: 600;
	padding: 7px 0;
}
.uieg-rgb-row input:focus { outline: none; border-color: #4b8bf4; }
.uieg-rgb-row span {
	font-size: 10.5px;
	color: #7c7c85;
	text-transform: uppercase;
	letter-spacing: .5px;
}

/* ---------- Escenario de la vista previa ---------- */
.uieg-preview-stage {
	flex: 1;
	position: relative;
	transition: background .2s ease;
}
.uieg-preview-stage.is-checker {
	background-image:
		linear-gradient(45deg, #3a3a40 25%, transparent 25%),
		linear-gradient(-45deg, #3a3a40 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #3a3a40 75%),
		linear-gradient(-45deg, transparent 75%, #3a3a40 75%);
	background-size: 22px 22px;
	background-position: 0 0, 0 11px, 11px -11px, -11px 0px;
}

.uieg-preview-iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* ---------- Panel de código (derecha) ---------- */
.uieg-code-pane {
	background: #0f0f11;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border-left: 1px solid #232326;
}

.uieg-tabs {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	border-bottom: 1px solid #232326;
	flex-shrink: 0;
}

.uieg-tab {
	display: flex;
	align-items: center;
	gap: 7px;
	background: transparent;
	border: none;
	color: #8b8b93;
	font-family: 'Space Grotesk', sans-serif;
	font-size: 13px;
	font-weight: 500;
	padding: 7px 12px;
	border-radius: 8px;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.uieg-tab:hover { color: #dcdce0; }
.uieg-tab.is-active {
	color: #fff;
	background: #202024;
}
.uieg-tab-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	display: inline-block;
}
.uieg-dot-html   { background: #ff7a59; }
.uieg-dot-css    { background: #4da3ff; }
.uieg-dot-js     { background: #f4d03f; }
.uieg-dot-cdn    { background: #7ee787; }
.uieg-dot-prompt { background: #a78bfa; }

.uieg-reset-btn {
	margin-left: auto;
	background: transparent;
	color: #8b8b93;
	border: 1px solid #2c2c31;
	padding: 7px 14px;
	border-radius: 8px;
	font-family: 'Space Grotesk', sans-serif;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
}
.uieg-reset-btn:hover { color: #fff; border-color: #4b4b52; }

.uieg-copy-btn {
	background: #26262b;
	color: #fff;
	border: 1px solid #333338;
	padding: 7px 16px;
	border-radius: 8px;
	font-family: 'Space Grotesk', sans-serif;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
.uieg-copy-btn:hover { background: #303036; }
.uieg-copy-btn.is-copied { background: #1f7a3f; border-color: #1f7a3f; }

.uieg-code-body {
	flex: 1;
	overflow: hidden;
	position: relative;
}

.uieg-code-editor {
	display: none;
	position: absolute;
	inset: 0;
	overflow: auto;
}
.uieg-code-editor.is-active { display: block; }

.uieg-cdn-readonly {
	margin: 0;
	padding: 16px 20px;
	font-family: 'JetBrains Mono', 'Space Grotesk', monospace;
	font-size: 16px;
	line-height: 1.45;
	color: #d8d8d8;
	white-space: pre-wrap;
	word-break: break-word;
}

/* ---------- Modal emergente de código (exportaciones React/Vue/Svelte/Lit) ---------- */
.uieg-code-modal[hidden] { display: none; }
.uieg-code-modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}
.uieg-code-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(6, 6, 8, .72);
	backdrop-filter: blur(3px);
}
.uieg-code-modal-box {
	position: relative;
	width: 100%;
	max-width: 720px;
	max-height: 82vh;
	display: flex;
	flex-direction: column;
	background: #17171a;
	border: 1px solid #2c2c31;
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
	overflow: hidden;
}
.uieg-code-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid #232326;
	flex-shrink: 0;
}
.uieg-code-modal-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 16px;
	font-weight: 700;
	color: #fff;
}
.uieg-code-modal-note {
	margin: 0;
	padding: 10px 20px;
	font-size: 12.5px;
	line-height: 1.6;
	color: #9a9aa2;
	background: #101012;
	border-bottom: 1px solid #232326;
	flex-shrink: 0;
}
.uieg-code-modal-note code {
	background: #232326;
	color: #dcdce0;
	padding: 1px 6px;
	border-radius: 5px;
	font-family: 'JetBrains Mono', Consolas, Menlo, monospace;
}
.uieg-code-modal-note a { color: #4b8bf4; }
.uieg-code-modal-note[hidden] { display: none; }
.uieg-code-modal-body {
	position: relative;
	overflow: auto;
	flex: 1;
	min-height: 0;
}
.uieg-code-modal-copy {
	position: sticky;
	float: right;
	top: 12px;
	right: 12px;
	margin: 0 12px 0 0;
	z-index: 2;
}
.uieg-code-modal-pre {
	margin: 0;
	padding: 20px;
	font-family: 'JetBrains Mono', 'Space Grotesk', Consolas, Menlo, monospace;
	font-size: 14px;
	line-height: 1.55;
	color: #e2e2e6;
	white-space: pre;
	overflow: auto;
}

/* ---------- CodeMirror: encaja con la paleta del editor ---------- */
/* Texto más grande pero con interlineado compacto: se lee bien sin huecos de más */
.CodeMirror {
	height: 100%;
	font-family: 'JetBrains Mono', 'Space Grotesk', Consolas, Menlo, monospace;
	font-size: 16px;
	line-height: 1.45;
	background: transparent;
	padding: 4px 0;
}
.CodeMirror-lines { padding: 0; }
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like { padding: 0 4px; }
.CodeMirror-gutters {
	background: transparent;
	border-right: 1px solid #232326;
}
.CodeMirror-linenumber { color: #4a4a52; }
.CodeMirror-cursor { border-left: 2px solid #4b8bf4; }
.CodeMirror-selected { background: rgba(75, 139, 244, .18) !important; }
.cm-s-material-darker.CodeMirror { background: transparent !important; }
