﻿* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html,
body {
	height: 100%;
	background: radial-gradient(circle at top left, rgba(18, 26, 44, 0.92), rgba(7, 10, 18, 0.96));
	color: #f5f5f5;
	font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
	overflow-x: hidden;
}

body {
	display: block;
	margin: 0;
	padding: 16px;
}

body,
button,
input,
textarea {
	font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
}

.hidden {
	display: none !important;
}

.app {
	width: 100%;
	max-width: 1180px;
	margin: 32px auto 40px;
	display: flex;
	flex-direction: column;
	gap: 32px;
	padding: 32px;
}

.app-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 20px;
	flex-wrap: wrap;
}

.app-header-text h1 {
	font-size: 28px;
	font-weight: 700;
	margin-bottom: 6px;
}

.app-header-text p {
	color: rgba(245, 245, 245, 0.65);
	font-size: 15px;
}

#loading.center-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(5, 7, 12, 0.92);
	z-index: 300;
}

.overlay-panel {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	padding: 28px;
	border-radius: 18px;
	background: rgba(18, 18, 30, 0.96);
	border: 1px solid rgba(255, 255, 255, 0.08);
	color: rgba(245, 245, 245, 0.88);
}

.spinner {
	width: 32px;
	height: 32px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: rgba(76, 130, 255, 0.8);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.upload-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 0 20px;
	height: 44px;
	font-size: 15px;
	border-radius: 12px;
	background: rgba(76, 130, 255, 0.16);
	border: 1px solid rgba(76, 130, 255, 0.5);
	color: #dbe7ff;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease;
}

.upload-btn:hover {
	background: rgba(76, 130, 255, 0.26);
	border-color: rgba(76, 130, 255, 0.7);
}

.upload-btn input {
	position: absolute;
	inset: 0;
	opacity: 0;
	cursor: pointer;
}

.app-nav {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	padding: 12px 0 4px;
}

.nav-btn {
	height: 38px;
	padding: 0 18px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid transparent;
	color: rgba(245, 245, 245, 0.82);
	font-size: 14px;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease;
}

.nav-btn:hover {
	background: rgba(76, 130, 255, 0.18);
	border-color: rgba(76, 130, 255, 0.4);
}

.nav-btn.active {
	background: rgba(76, 130, 255, 0.28);
	border-color: rgba(76, 130, 255, 0.5);
	color: #f5f8ff;
}

.app-main {
	flex: 1;
	width: 100%;
}

.app-page {
	display: none;
}

.app-page.active {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

#editorPage.app-page.active {
	align-items: center;
}

#editorPage .preview-card {
	width: min(100%, 420px);
}

#promptPage.app-page.active {
	gap: 20px;
}

#promptPage .prompt-card {
	width: min(100%, 860px);
	align-self: center;
}

.preview-card,
.prompt-card {
	background: rgba(26, 26, 36, 0.88);
	border: 1px solid rgba(255, 255, 255, 0.06);
	border-radius: 18px;
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: 20px;
	width: 100%;
	box-sizing: border-box;
}

.preview-expand-controls {
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	padding-top: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.preview-expand-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 10px;
}

.preview-expand-field {
	padding: 10px;
	gap: 8px;
	background: rgba(15, 15, 25, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-expand-field .offset-control {
	justify-content: space-between;
}

.preview-expand-field .offset-stepper {
	width: 100%;
	justify-content: space-between;
}

.preview-expand-field .offset-step-unit {
	min-width: 16px;
}

.preview-expand-input {
	width: 56px;
	height: 32px;
	font-size: 13px;
}

.preview-expand-step-btn {
	width: 32px;
	height: 32px;
}

.preview-expand-label {
	font-size: 13px;
	color: rgba(245, 245, 245, 0.7);
}

.preview-expand-controls .preview-actions {
	margin-top: 4px;
	justify-content: flex-start;
}

.card-header {
	display: flex;
	align-items: center;
	gap: 10px;
}

.card-header h2 {
	font-size: 20px;
	font-weight: 600;
}

.badge {
	padding: 2px 10px;
	border-radius: 999px;
	background: rgba(76, 130, 255, 0.18);
	border: 1px solid rgba(76, 130, 255, 0.35);
	font-size: 13px;
	color: #dbe7ff;
}

.preview-frame {
	position: relative;
	width: 100%;
	aspect-ratio: 3 / 4;
	border-radius: 14px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(12, 12, 18, 0.86);
	overflow: hidden;
}

.file-input-hidden {
	display: none;
}

.preview-upload-btn {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 8px 16px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: rgba(255, 255, 255, 0.08);
	color: #f5f5f5;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease;
	z-index: 5;
}

.preview-upload-btn:hover {
	background: rgba(76, 130, 255, 0.22);
	border-color: rgba(76, 130, 255, 0.5);
}

.preview-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 16px;
	color: rgba(245, 245, 245, 0.55);
	font-size: 14px;
	z-index: 1;
	cursor: pointer;
}

.preview-placeholder-content {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
}

.preview-image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #000;
}

.preview-edit-button {
	position: absolute;
	inset: auto 16px 16px;
	height: 40px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(0, 0, 0, 0.6);
	color: #f5f5f5;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease, border 0.2s ease;
}

.preview-edit-button:hover:not(:disabled) {
	background: rgba(76, 130, 255, 0.26);
	border-color: rgba(76, 130, 255, 0.6);
}

.preview-edit-button:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.preview-actions {
	display: flex;
	gap: 12px;
	margin-top: 12px;
}

.action-btn {
	flex: 1;
	height: 40px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: rgba(255, 255, 255, 0.08);
	color: #f5f5f5;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease, transform 0.15s ease;
}

.action-btn:hover:not(:disabled) {
	background: rgba(76, 130, 255, 0.22);
	border-color: rgba(76, 130, 255, 0.5);
}

.action-btn:active:not(:disabled) {
	transform: scale(0.97);
}

.action-btn:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.action-btn.primary {
	background: #4c82ff;
	border-color: transparent;
	color: #ffffff;
}

.action-btn.primary:hover:not(:disabled) {
	background: #6898ff;
}

.hint {
	font-size: 13px;
	color: rgba(245, 245, 245, 0.5);
}

.section-title {
	font-size: 17px;
	font-weight: 600;
	margin-bottom: 12px;
}

.prompt-divider {
	height: 1px;
	margin: 16px 0;
	background: rgba(255, 255, 255, 0.06);
}

.prompt-groups,
.prompt-optional-panels {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.prompt-group {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	border-radius: 14px;
	background: rgba(18, 18, 28, 0.8);
	border: 1px solid rgba(255, 255, 255, 0.05);
}

.prompt-group-title {
	font-size: 15px;
	font-weight: 600;
	color: rgba(245, 245, 245, 0.85);
}

.prompt-options,
.prompt-toggle-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.prompt-option-btn,
.prompt-toggle-btn {
	padding: 10px 14px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	background: rgba(12, 12, 20, 0.7);
	color: rgba(245, 245, 245, 0.85);
	font-size: 13px;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
	min-width: 82px;
	text-align: center;
}

.prompt-option-btn:hover,
.prompt-toggle-btn:hover {
	background: rgba(76, 130, 255, 0.16);
	border-color: rgba(76, 130, 255, 0.4);
}

.prompt-option-btn.active,
.prompt-toggle-btn.active {
	background: rgba(76, 130, 255, 0.28);
	border-color: rgba(76, 130, 255, 0.6);
	color: #f5f8ff;
}

.prompt-actions {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 12px;
	margin: 8px 0 4px;
	width: 100%;
}


.prompt-output-fields {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
	width: 100%;
}

.output-field {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.output-field textarea {
	min-height: 120px;
}

.prompt-output-primary,
.prompt-output-secondary {
	width: 100%;
	min-width: 0;
}

@media (max-width: 960px) {
	.prompt-output-fields {
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	}
}

.prompt-tab-bar {
	display: flex;
	flex-wrap: nowrap;
	gap: 10px;
	margin-bottom: 8px;
	overflow-x: auto;
	padding-bottom: 4px;
	scrollbar-width: none;
}

.prompt-tab-bar::-webkit-scrollbar {
	display: none;
}

.prompt-tab-btn {
	padding: 8px 14px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(12, 12, 20, 0.6);
	color: rgba(245, 245, 245, 0.78);
	font-size: 13px;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease;
}

.prompt-tab-btn:hover {
	background: rgba(76, 130, 255, 0.18);
	border-color: rgba(76, 130, 255, 0.4);
}

.prompt-tab-btn.active {
	background: rgba(76, 130, 255, 0.32);
	border-color: rgba(76, 130, 255, 0.5);
	color: #f5f8ff;
}

.prompt-optional-panel {
	display: none;
	flex-direction: column;
	gap: 16px;
	padding: 16px;
	border-radius: 14px;
	background: rgba(18, 18, 28, 0.8);
	border: 1px solid rgba(255, 255, 255, 0.05);
}

.prompt-optional-panel.active {
	display: flex;
}

.prompt-optional-header {
	font-size: 15px;
	font-weight: 600;
	color: rgba(245, 245, 245, 0.85);
}

.prompt-actions .action-btn {
	width: 100%;
	min-width: 0;
	justify-content: center;
}

.record-command-btn {
	padding: 0 28px;
}

.form-field {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-width: 0;
	width: 100%;
}

.form-field span {
	font-size: 14px;
	color: rgba(245, 245, 245, 0.75);
}

textarea {
	width: 100%;
	max-width: 100%;
	min-height: 80px;
	padding: 12px;
	border-radius: 12px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(15, 15, 25, 0.86);
	color: #f5f5f5;
	resize: vertical;
	font-size: 14px;
}

textarea[readonly] {
	background: rgba(12, 12, 20, 0.66);
	color: rgba(245, 245, 245, 0.85);
}

textarea::placeholder {
	color: rgba(245, 245, 245, 0.4);
}

.input-error {
	border-color: rgba(255, 107, 107, 0.7) !important;
	box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2);
}

@media (max-width: 960px) {
	.app {
		padding: 24px;
	}

	.app-nav {
		flex-wrap: wrap;
	}

	.app-page.active {
		gap: 20px;
	}
}

@media (max-width: 768px) {
	.app {
		width: 100%;
		margin: 16px auto 24px;
		padding: 20px 16px;
		gap: 24px;
	}

	.preview-card,
	.prompt-card {
		padding: 18px;
		border-radius: 16px;
		gap: 18px;
	}

	.prompt-actions {
		grid-template-columns: 1fr;
	}

	.prompt-optional-panel {
		padding: 12px;
	}
}

@media (max-width: 540px) {
	.prompt-output-fields {
		grid-template-columns: 1fr;
	}

	.offset-grid {
		grid-template-columns: 1fr;
	}

	.app-nav {
		gap: 8px;
	}

	.prompt-tab-bar {
		gap: 8px;
	}
}

.offset-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 12px;
	width: 100%;
}

.offset-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 12px;
	border-radius: 12px;
	background: rgba(15, 15, 25, 0.7);
	border: 1px solid rgba(255, 255, 255, 0.08);
	min-width: 0;
}

.offset-field.compact {
	gap: 8px;
}

.offset-control {
	display: flex;
	align-items: center;
	gap: 10px;
}

.offset-stepper {
	display: flex;
	align-items: center;
	gap: 6px;
}

.offset-step-btn {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(12, 12, 20, 0.88);
	color: #f5f5f5;
	font-size: 18px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background 0.2s ease, border 0.2s ease, transform 0.15s ease;
}

.offset-step-btn:hover:not(:disabled) {
	background: rgba(76, 130, 255, 0.22);
	border-color: rgba(76, 130, 255, 0.5);
}

.offset-step-btn:active:not(:disabled) {
	transform: scale(0.94);
}

.offset-step-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.offset-step-input {
	width: 52px;
	height: 34px;
	padding: 0 10px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(9, 9, 16, 0.9);
	color: #f5f5f5;
	font-size: 13px;
	text-align: center;
	appearance: textfield;
	-moz-appearance: textfield;
}

.offset-step-input::-webkit-inner-spin-button,
.offset-step-input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.offset-step-input:focus {
	outline: none;
	border-color: rgba(76, 130, 255, 0.6);
	box-shadow: 0 0 0 2px rgba(76, 130, 255, 0.18);
}

.offset-step-unit {
	font-size: 13px;
	color: rgba(245, 245, 245, 0.65);
	min-width: 12px;
	text-align: center;
}

.offset-direction {
	font-size: 18px;
	min-width: 24px;
	text-align: center;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.offset-field span {
	font-size: 13px;
	color: rgba(245, 245, 245, 0.7);
}

.offset-field input:not(.offset-step-input) {
	width: 100%;
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(9, 9, 16, 0.9);
	color: #f5f5f5;
	font-size: 14px;
}

.offset-field input:not(.offset-step-input):focus {
	outline: none;
	border-color: rgba(76, 130, 255, 0.6);
	box-shadow: 0 0 0 2px rgba(76, 130, 255, 0.18);
}

@media (max-width: 640px) {
	.offset-grid {
		gap: 10px;
	}

	.prompt-actions .action-btn {
		flex: 1 1 100%;
	}
}

.form-hint {
	font-size: 12px;
	color: rgba(245, 245, 245, 0.45);
}

.send-hint {
	text-align: center;
	margin-top: -4px;
	color: rgba(245, 245, 245, 0.58);
}

.editor-overlay {
	position: fixed;
	inset: 0;
	background: rgba(9, 12, 20, 0.92);
	backdrop-filter: blur(6px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	z-index: 200;
}

.editor-wrapper {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	background: rgba(18, 18, 28, 0.98);
	border: none;
	border-radius: 0;
	overflow: hidden;
}


.tool-btn {
	min-width: 28px;
	height: 28px;
	padding: 0 8px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(255, 255, 255, 0.05);
	color: #f5f5f5;
	font-size: 16px;
	cursor: pointer;
	transition: transform 0.15s ease, background 0.2s ease, border 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
}

.tool-btn:active {
	transform: scale(0.96);
}

.tool-btn.active {
	background: #4c82ff;
	border-color: transparent;
	color: #ffffff;
}

.tool-btn:disabled,
.tool-btn.disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.tool-btn.primary {
	background: #4c82ff;
	border-color: transparent;
	color: #ffffff;
}

.tool-btn.primary:hover {
	background: #6898ff;
}


.slider {
	width: 100px;
	height: 4px;
	appearance: none;
	background: rgba(255, 255, 255, 0.18);
	border-radius: 999px;
	outline: none;
}

.slider::-webkit-slider-thumb {
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #4c82ff;
	border: none;
	box-shadow: 0 0 10px rgba(76, 130, 255, 0.35);
	cursor: pointer;
}

.slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #4c82ff;
	border: none;
	box-shadow: 0 0 10px rgba(76, 130, 255, 0.35);
	cursor: pointer;
}

.slider-group {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.slider-icon {
	font-size: 14px;
	color: rgba(245, 245, 245, 0.72);
}

.editor-stage {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	position: relative;
}

.stage {
	position: relative;
	width: min(96vw, calc(96vh * 0.75));
	height: min(96vh, calc(96vw * 1.3333));
	max-width: 100%;
	max-height: 100%;
	background-color: rgba(28, 28, 40, 1);
	background-image:
		linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
		linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
		linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%);
	background-size: 40px 40px;
	background-position: 0 0, 0 20px, 20px -20px, -20px 0;
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 14px;
	overflow: hidden;
}

#editorCanvas {
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	touch-action: none;
	image-rendering: crisp-edges;
}

.floating-panel {
	position: absolute;
	top: 12px;
	left: 12px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0;
	max-width: calc(100% - 24px);
	padding: 0;
	background: rgba(12, 18, 32, 0.68);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	backdrop-filter: blur(10px);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
	z-index: 10;
}

.panel-header {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 6px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.toggle-panel-btn {
	background: transparent;
	border: none;
	color: rgba(255, 255, 255, 0.7);
	font-size: 14px;
	cursor: pointer;
	padding: 4px 12px;
	border-radius: 6px;
	transition: all 0.2s ease;
	line-height: 1;
}

.toggle-panel-btn:hover {
	background: rgba(255, 255, 255, 0.1);
	color: rgba(255, 255, 255, 0.9);
}

.toggle-panel-btn:active {
	transform: scale(0.95);
}

.floating-panel.collapsed .toggle-panel-btn {
	transform: rotate(-90deg);
}

.panel-content {
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	padding: 8px 10px;
	max-height: 500px;
	overflow: hidden;
	transition: max-height 0.3s ease, padding 0.3s ease;
}

.floating-panel.collapsed .panel-content {
	max-height: 0;
	padding-top: 0;
	padding-bottom: 0;
	opacity: 0;
}

.floating-row {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.floating-actions {
	justify-content: flex-start;
}

#doodleControls {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

#doodleColorInput {
	appearance: none;
	-webkit-appearance: none;
	width: 28px;
	height: 28px;
	padding: 0;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(255, 255, 255, 0.05);
	cursor: pointer;
}

#doodleColorInput::-webkit-color-swatch-wrapper {
	padding: 4px;
	border-radius: 10px;
}

#doodleColorInput::-webkit-color-swatch,
#doodleColorInput::-moz-color-swatch {
	border: none;
	border-radius: 8px;
}
