/* JRAKE - dark, modern UI */

:root {
	--bg: #0b0b12;
	--bg-2: #12121c;
	--card: rgba(255, 255, 255, 0.045);
	--card-border: rgba(255, 255, 255, 0.09);
	--text: #f2f2f7;
	--muted: #9a9ab0;
	--accent: #8b5cf6;
	--accent-2: #ec4899;
	--accent-3: #f59e0b;
	--danger: #f43f5e;
	--success: #10b981;
	--radius: 18px;
	--radius-sm: 12px;
	--shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
	--grad: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-3) 100%);
	color-scheme: dark;
}

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

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--text);
	font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
	font-size: 15px;
	line-height: 1.55;
	overflow-x: hidden;
}

body.no-scroll {
	overflow: hidden;
}

a {
	color: #c4b5fd;
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

h1,
h2,
h3 {
	line-height: 1.2;
	margin: 0 0 0.4em;
}

.hidden {
	display: none !important;
}

.muted {
	color: var(--muted);
}

.small {
	font-size: 13px;
}

.glow {
	position: fixed;
	inset: -30vh -10vw auto;
	height: 80vh;
	background:
		radial-gradient(40% 50% at 25% 40%, rgba(139, 92, 246, 0.22), transparent 70%),
		radial-gradient(35% 45% at 75% 30%, rgba(236, 72, 153, 0.16), transparent 70%);
	pointer-events: none;
	z-index: 0;
}

/* ---- layout ---- */

.topbar,
.container,
.footer {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 1120px;
	margin: 0 auto;
	padding-left: 16px;
	padding-right: 16px;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-top: 18px;
	padding-bottom: 18px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-weight: 700;
	letter-spacing: 0.08em;
}

.brand:hover {
	text-decoration: none;
}

.brand-mark {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 10px;
	background: var(--grad);
	color: #fff;
	font-size: 18px;
	box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.nav {
	display: flex;
	gap: 4px;
}

.nav a {
	color: var(--muted);
	padding: 8px 14px;
	border-radius: 999px;
	font-weight: 500;
	font-size: 14px;
	transition: background 0.15s, color 0.15s;
}

.nav a:hover {
	color: var(--text);
	background: var(--card);
	text-decoration: none;
}

.nav a.active {
	color: var(--text);
	background: rgba(139, 92, 246, 0.18);
}

.container {
	flex: 1;
	padding-bottom: 48px;
}

.footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 8px;
	padding-top: 24px;
	padding-bottom: 28px;
	border-top: 1px solid var(--card-border);
	color: var(--muted);
	font-size: 13px;
}

.card {
	background: var(--card);
	border: 1px solid var(--card-border);
	border-radius: var(--radius);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
}

/* ---- hero ---- */

.hero {
	text-align: center;
	padding: 36px 0 26px;
}

.hero h1 {
	font-size: clamp(30px, 5.5vw, 54px);
	font-weight: 700;
	letter-spacing: -0.02em;
}

.hero .sub,
.page-head .sub {
	color: var(--muted);
	font-size: clamp(15px, 2vw, 18px);
	margin: 0 auto;
	max-width: 560px;
}

.hero.narrow {
	padding: 80px 0;
}

.grad {
	background: var(--grad);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* ---- composer ---- */

.composer {
	padding: 18px;
	box-shadow: var(--shadow);
	max-width: 860px;
	margin: 0 auto;
}

.prompt-wrap {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-sm);
	padding: 14px 16px;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.prompt-wrap:focus-within {
	border-color: rgba(139, 92, 246, 0.7);
	box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.prompt-icon {
	width: 22px;
	height: 22px;
	flex: none;
	margin-top: 3px;
	fill: #a78bfa;
}

#prompt {
	flex: 1;
	min-height: 52px;
	resize: none;
	border: 0;
	outline: 0;
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 17px;
	line-height: 1.5;
}

#prompt::placeholder {
	color: #6b6b80;
}

.composer-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 14px;
}

.composer-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: auto;
}

.counter {
	color: var(--muted);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

.counter.warn {
	color: var(--accent-3);
}

.ratios {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.ratio {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 12px;
	border-radius: 999px;
	border: 1px solid var(--card-border);
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 13px;
	cursor: pointer;
	transition: all 0.15s;
}

.ratio:hover {
	color: var(--text);
	border-color: rgba(255, 255, 255, 0.2);
}

.ratio.active {
	color: var(--text);
	border-color: var(--accent);
	background: rgba(139, 92, 246, 0.16);
}

.ratio-shape {
	display: inline-block;
	border: 1.5px solid currentColor;
	border-radius: 3px;
}

.adult-panel {
	margin-top: 14px;
	padding: 14px 16px;
	border-radius: var(--radius-sm);
	border: 1px solid rgba(245, 158, 11, 0.4);
	background: rgba(245, 158, 11, 0.08);
	font-size: 14px;
}

.adult-panel.attention {
	animation: shake 0.45s;
}

.adult-reason {
	margin: 0 0 8px;
	color: #fcd34d;
}

.check {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	cursor: pointer;
}

.check input {
	width: 18px;
	height: 18px;
	margin-top: 2px;
	accent-color: var(--accent);
	flex: none;
}

/* ---- buttons ---- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 11px 22px;
	border-radius: 999px;
	border: 1px solid transparent;
	font: inherit;
	font-weight: 600;
	font-size: 15px;
	cursor: pointer;
	white-space: nowrap;
	transition: transform 0.12s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
	text-decoration: none !important;
}

.btn:active {
	transform: translateY(1px);
}

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

.btn-primary {
	background: var(--grad);
	color: #fff;
	box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
}

.btn-primary:hover:not(:disabled) {
	box-shadow: 0 10px 32px rgba(236, 72, 153, 0.4);
}

#create {
	min-width: 132px;
	padding: 12px 28px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.btn-ghost {
	background: rgba(255, 255, 255, 0.06);
	border-color: var(--card-border);
	color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
	background: rgba(255, 255, 255, 0.11);
}

.btn-sm {
	padding: 7px 14px;
	font-size: 13px;
}

.link-btn {
	background: none;
	border: 0;
	padding: 0;
	color: #c4b5fd;
	font: inherit;
	font-size: 14px;
	cursor: pointer;
}

.link-btn:hover {
	text-decoration: underline;
}

.icon {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex: none;
}

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 10px;
	border: 1px solid var(--card-border);
	background: rgba(255, 255, 255, 0.04);
	color: var(--text);
	cursor: pointer;
}

.icon-btn:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* ---- spinners & progress ---- */

.spinner {
	display: inline-block;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: 3px solid rgba(255, 255, 255, 0.15);
	border-top-color: #c4b5fd;
	animation: spin 0.8s linear infinite;
	flex: none;
}

.spinner-sm {
	width: 16px;
	height: 16px;
	border-width: 2px;
	border-top-color: #fff;
}

.spinner-lg {
	width: 64px;
	height: 64px;
	border-width: 4px;
	border-top-color: #f0abfc;
}

.progress {
	position: relative;
	height: 8px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.08);
	overflow: hidden;
}

.progress-fill {
	height: 100%;
	border-radius: inherit;
	background: var(--grad);
	transition: width 0.6s ease;
}

.progress.indeterminate .progress-fill {
	width: 35% !important;
	animation: slide 1.4s ease-in-out infinite;
}

.loading-block {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 40px 16px;
	color: var(--muted);
}

/* ---- result ---- */

.result {
	max-width: 860px;
	margin: 22px auto 0;
}

.building {
	display: flex;
	align-items: center;
	gap: 26px;
	padding: 26px;
}

.building-visual {
	position: relative;
	display: grid;
	place-items: center;
	width: 110px;
	height: 110px;
	flex: none;
}

.orb {
	position: absolute;
	inset: 8px;
	border-radius: 50%;
	background: var(--grad);
	filter: blur(18px);
	opacity: 0.55;
	animation: pulse 2.2s ease-in-out infinite;
}

.building-info {
	flex: 1;
	min-width: 0;
}

.building-status {
	margin: 0 0 12px;
	font-size: 18px;
	font-weight: 600;
}

.building-prompt {
	margin: 14px 0 6px;
	color: #d4d4e0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.done {
	display: grid;
	grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
	gap: 24px;
	padding: 18px;
}

.result-images {
	display: grid;
	gap: 12px;
}

.result-image {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: rgba(255, 255, 255, 0.04);
	cursor: zoom-in;
}

.result-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.4s;
}

.result-image.loaded img {
	opacity: 1;
}

.result-image-loading {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
}

.result-image.loaded .result-image-loading {
	display: none;
}

.result-side {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 6px 4px;
}

.eyebrow {
	margin: 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: #c4b5fd;
}

.result-prompt {
	margin: 0;
	font-size: 16px;
	color: #e4e4ee;
	word-break: break-word;
	max-height: 220px;
	overflow: auto;
}

.result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.failed {
	display: flex;
	gap: 18px;
	align-items: flex-start;
	padding: 22px;
	border-color: rgba(244, 63, 94, 0.35);
}

.failed-icon {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(244, 63, 94, 0.15);
	color: var(--danger);
	font-weight: 700;
	font-size: 20px;
	flex: none;
}

.failed-title {
	margin: 0 0 4px;
	font-weight: 600;
	font-size: 17px;
}

.failed .btn {
	margin-top: 10px;
}

/* ---- suggestions ---- */

.suggestions,
.recent {
	max-width: 1120px;
	margin: 40px auto 0;
}

.section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin: 26px 0 12px;
}

.section-head h2 {
	font-size: 18px;
	font-weight: 600;
	margin: 0;
}

.section-head .link:hover {
	color: var(--text);
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	max-width: 100%;
	padding: 8px 14px;
	border-radius: 999px;
	border: 1px solid var(--card-border);
	background: var(--card);
	color: #d4d4e0;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: all 0.15s;
}

#examples .chip {
	max-width: min(100%, 540px);
}

.chip-text {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.chip:hover {
	color: var(--text);
	border-color: rgba(139, 92, 246, 0.6);
	background: rgba(139, 92, 246, 0.12);
}

.chip .icon {
	width: 14px;
	height: 14px;
}

.chip-accent {
	color: #f0abfc;
}

.chip.skeleton {
	width: 180px;
	height: 36px;
	cursor: default;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
	background-size: 200% 100%;
	animation: shimmer 1.4s infinite;
}

/* ---- image grid ---- */

.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 16px;
}

.image-card {
	display: flex;
	flex-direction: column;
	border-radius: var(--radius);
	border: 1px solid var(--card-border);
	background: var(--card);
	overflow: hidden;
	transition: transform 0.18s, border-color 0.18s;
}

.image-card:hover {
	transform: translateY(-3px);
	border-color: rgba(139, 92, 246, 0.45);
}

.card-image {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
	background-size: 200% 100%;
	animation: shimmer 1.4s infinite;
	cursor: zoom-in;
	overflow: hidden;
}

.card-image.loaded {
	animation: none;
	background: #000;
}

.card-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.35s, transform 0.35s;
}

.card-image.loaded img {
	opacity: 1;
}

.image-card:hover .card-image img {
	transform: scale(1.03);
}

.image-card-body {
	padding: 12px 14px 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	flex: 1;
}

.image-card-prompt {
	margin: 0;
	font-size: 13px;
	color: #d4d4e0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.image-card-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: auto;
	font-size: 12px;
}

.image-card-actions {
	display: flex;
	gap: 6px;
}

/* ---- history page ---- */

.page-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding: 28px 0 22px;
}

.page-head h1 {
	font-size: clamp(26px, 4vw, 38px);
}

.page-head .sub {
	margin: 0;
}

.empty {
	text-align: center;
	padding: 48px 20px;
}

.empty-title {
	font-size: 18px;
	font-weight: 600;
	margin: 0 0 6px;
}

.empty .btn {
	margin-top: 16px;
}

/* ---- terms ---- */

.prose {
	max-width: 820px;
	margin: 28px auto 0;
	padding: 32px clamp(18px, 4vw, 44px);
	color: #d4d4e0;
}

.prose h1 {
	font-size: clamp(26px, 4vw, 36px);
	color: var(--text);
}

.prose h2 {
	font-size: 18px;
	margin-top: 28px;
	color: var(--text);
}

.prose li {
	margin-bottom: 6px;
}

/* ---- lightbox ---- */

.lightbox {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	place-items: center;
	padding: 24px 16px;
	background: rgba(5, 5, 10, 0.88);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	opacity: 0;
	transition: opacity 0.2s;
}

.lightbox.open {
	opacity: 1;
}

.lightbox figure {
	position: relative;
	margin: 0;
	max-width: min(1100px, 100%);
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.lightbox img {
	max-width: 100%;
	max-height: calc(100vh - 140px);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	object-fit: contain;
	margin: 0 auto;
}

.lightbox figcaption {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	color: #d4d4e0;
	font-size: 14px;
}

.lightbox-caption {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.lightbox-loading {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	min-height: 200px;
}

.lightbox-close {
	position: fixed;
	top: 14px;
	right: 14px;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: 1px solid var(--card-border);
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	cursor: pointer;
}

/* ---- toasts ---- */

.toast-stack {
	position: fixed;
	left: 50%;
	bottom: 20px;
	transform: translateX(-50%);
	z-index: 60;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	width: calc(100% - 32px);
	max-width: 440px;
	pointer-events: none;
}

.toast {
	padding: 12px 18px;
	border-radius: var(--radius-sm);
	background: #1d1d2b;
	border: 1px solid var(--card-border);
	box-shadow: var(--shadow);
	font-size: 14px;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.25s, transform 0.25s;
	pointer-events: auto;
}

.toast.show {
	opacity: 1;
	transform: none;
}

.toast-error {
	border-color: rgba(244, 63, 94, 0.5);
}

.toast-success {
	border-color: rgba(16, 185, 129, 0.5);
}

/* ---- animations ---- */

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

@keyframes slide {
	0% {
		transform: translateX(-100%);
	}
	100% {
		transform: translateX(300%);
	}
}

@keyframes pulse {
	0%,
	100% {
		transform: scale(0.85);
		opacity: 0.45;
	}
	50% {
		transform: scale(1.05);
		opacity: 0.75;
	}
}

@keyframes shimmer {
	to {
		background-position: -200% 0;
	}
}

@keyframes shake {
	0%,
	100% {
		transform: none;
	}
	25% {
		transform: translateX(-6px);
	}
	75% {
		transform: translateX(6px);
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

/* ---- responsive ---- */

@media (max-width: 760px) {
	.hero {
		padding: 22px 0 18px;
	}

	.composer {
		padding: 12px;
	}

	.composer-actions {
		width: 100%;
	}

	#create {
		flex: 1;
	}

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

	.building {
		flex-direction: column;
		text-align: center;
		gap: 14px;
	}

	.building-info {
		width: 100%;
	}

	.grid {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		gap: 12px;
	}

	.nav a {
		padding: 8px 10px;
	}

	.lightbox figcaption {
		flex-direction: column;
		align-items: stretch;
	}
}
