:root {
	--bg: #f8f8f6;
	--ink: #111111;
	--muted: #616161;
	--line: #d9d9d6;
	--surface: #ffffff;
	--yellow: #ffbb00;
}

@font-face {
	font-family: "Space Grotesk";
	src: url("../fonts/SpaceGrotesk.woff2") format("woff2");
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
	height: auto;
	display: flex;
	flex-direction: column;
	font-family: "Space Grotesk", "Segoe UI", sans-serif;
	color: var(--ink);
	background: var(--bg);
	overflow-x: hidden;
	overflow-y: auto;
}

.app-shell {
	width: min(1400px, 96vw);
	height: auto;
	margin: 1rem auto;
	display: grid;
	grid-template-rows: auto;
	gap: 0.9rem;
}

.hero {
	margin-bottom: 0;
}

.top-nav {
	display: flex;
	gap: 0.5rem;
}

.nav-link {
	border: 1px solid var(--line);
	color: var(--ink);
	text-decoration: none;
	padding: 0.45rem 0.75rem;
	font-size: 0.84rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.nav-link:hover {
	border-color: var(--ink);
}

.nav-link.nav-download {
  font-weight: bold;
	border-color: var(--ink);
	color: var(--ink);
  background: var(--yellow);
	display: inline-flex;
	align-items: center;
}

.nav-link.nav-download img {
	width: 16px;
	height: 16px;
	vertical-align: middle;
	margin-right: 0.3rem;
}

.nav-link.current {
	background: var(--ink);
	border-color: var(--ink);
	color: #fff;
}

.eyebrow {
	margin: 0;
	font-weight: 500;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--muted);
	font-size: 0.78rem;
}

h1 {
	margin: 0.35rem 0 0.75rem;
	font-size: clamp(2rem, 4.4vw, 4rem);
	line-height: 1.05;
	max-width: 14ch;
}

.subtitle {
	margin: 0;
	max-width: 58ch;
	color: var(--muted);
	font-size: 1rem;
}

.panel-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 300px;
	gap: 1rem;
	align-items: stretch;
	min-height: 0;
}

.editor-panels {
	margin-bottom: 7rem;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem;
	min-height: 0;
}

.panel {
	border: 1px solid var(--line);
	background: var(--surface);
	border-radius: 0;
	padding: 1rem;
	display: grid;
	grid-template-rows: auto 1fr auto;
	gap: 0.75rem;
	min-height: 0;
}

.panel-head h2 {
	margin: 0;
	font-size: 0.85rem;
	font-weight: 500;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.tools-panel {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	align-content: start;
	overflow: auto;
	height: fit-content;
}

.tools-panel .tool-section {
	gap: 0.6rem;
}

.tools-panel .tool-section + .tool-section {
	padding-top: 1rem;
	border-top: 1px solid var(--line);
}

.tool-section {
	display: grid;
	gap: 0.55rem;
}

.tool-section h3 {
	margin: 0;
	font-size: 1rem;
}

.tool-help {
	margin: 0 0 0.4rem;
	font-size: 0.88rem;
	color: var(--muted);
}

.tool-section label {
	font-size: 0.78rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--muted);
}

input[type="text"] {
	width: 100%;
	border-radius: 0;
	border: 1px solid var(--line);
	background: #fff;
	padding: 0.6rem 0.7rem;
	font:
		500 0.95rem/1.4 "Space Grotesk",
		"Segoe UI",
		sans-serif;
	color: var(--ink);
}

select {
	width: 100%;
	border-radius: 0;
	border: 1px solid var(--line);
	background: #fff;
	padding: 0.6rem 0.7rem;
	font:
		500 0.95rem/1.4 "Space Grotesk",
		"Segoe UI",
		sans-serif;
	color: var(--ink);
}

input[type="text"]:focus {
	outline: none;
	border-color: var(--ink);
}

select:focus {
	outline: none;
	border-color: var(--ink);
}

.inline-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.inline-actions button {
	flex: 1 1 120px;
}

.hidden {
	display: none;
}

.mapper-section {
	margin-top: 0;
	padding-top: 0;
}

.tool-meta {
	margin: 0;
	min-height: 1.1em;
	font-size: 0.84rem;
	color: var(--muted);
}

.option-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 0.86rem;
	color: var(--muted);
}

.option-toggle input[type="checkbox"] {
	width: 1rem;
	height: 1rem;
	margin: 0;
}

.grouping-controls {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 0.5rem;
}

.grouping-controls label {
	font-size: 0.78rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--muted);
}

#customGroupSize {
	width: 5.25rem;
	border-radius: 0;
	border: 1px solid var(--line);
	background: #fff;
	padding: 0.6rem 0.55rem;
	font:
		500 0.95rem/1.4 "Space Grotesk",
		"Segoe UI",
		sans-serif;
	color: var(--ink);
}

#customGroupSize:focus {
	outline: none;
	border-color: var(--ink);
}

textarea {
	width: 100%;
	min-height: 0;
	height: 100%;
	resize: none;
	border-radius: 0;
	border: 1px solid var(--line);
	background: #fff;
	padding: 0.9rem;
	font:
		500 1rem/1.55 "Space Grotesk",
		"Segoe UI",
		sans-serif;
	color: var(--ink);
}

textarea:focus {
	outline: none;
	border-color: var(--ink);
}

.panel-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
}

button {
	border: 1px solid var(--ink);
	border-radius: 0;
	background: var(--ink);
	color: #fff;
	font:
		600 0.9rem "Space Grotesk",
		"Segoe UI",
		sans-serif;
	padding: 0.55rem 1rem;
	cursor: pointer;
	transition:
		background-color 140ms ease,
		color 140ms ease;
}

button:hover {
	background: #303030;
}

button:active {
	background: #000;
}

button.ghost {
	color: var(--ink);
	background: #fff;
}

#statusText {
	margin: 0;
	min-height: 1.2em;
	font-size: 0.86rem;
	color: var(--muted);
}

#statusText.success {
	color: var(--ink);
	font-weight: 500;
}

.story-shell {
	height: auto;
}

body.page-story .app-shell {
	min-height: calc(100vh - 2rem);
}

.story-card {
	border: 1px solid var(--line);
	background: var(--surface);
	padding: 1.2rem;
	display: grid;
	gap: 0.9rem;
	max-width: 76ch;
}

.story-visual {
	margin: 0;
	width: min(76ch, 100%);
}

.story-image {
	display: block;
	width: 100%;
	height: auto;
	border: 1px solid var(--line);
	box-shadow: 0 12px 28px rgba(17, 17, 17, 0.12);
	transition:
		transform 180ms ease,
		box-shadow 180ms ease,
		filter 180ms ease;
}

.story-image:hover {
	transform: translateY(-3px) scale(1.01);
	box-shadow: 0 18px 38px rgba(17, 17, 17, 0.18);
	filter: saturate(1.04) contrast(1.02);
}

.story-image:focus-visible {
	outline: 2px solid var(--ink);
	outline-offset: 3px;
}

.story-card h2 {
	margin: 0.2rem 0 0;
	font-size: 1rem;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.story-card p {
	margin: 0;
	line-height: 1.6;
	color: var(--ink);
}

.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;
}

.feedback-form-container {
	position: fixed;
	left: calc(50% + 38ch + 1rem);
	bottom: 7rem;
	width: 280px;
	max-height: 80vh;
	z-index: 100;
}

.feedback-form {
	background: var(--surface);
	border: 1px solid var(--line);
	padding: 1rem;
	display: grid;
	gap: 0.6rem;
	box-shadow: 0 8px 24px rgba(17, 17, 17, 0.1);
	overflow-y: auto;
}

.feedback-form h3 {
	margin: 0;
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--ink);
}

.feedback-form label {
	margin-top: 0.3rem;
	font-size: 0.75rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--muted);
	font-weight: 500;
}

.feedback-input,
.feedback-textarea {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 0;
	background: #fff;
	padding: 0.5rem;
	font:
		500 0.85rem/1.4 "Space Grotesk",
		"Segoe UI",
		sans-serif;
	color: var(--ink);
	box-sizing: border-box;
}

.feedback-input:focus,
.feedback-textarea:focus {
	outline: none;
	border-color: var(--ink);
	background: #fafafa;
}

.feedback-textarea {
	min-height: 80px;
	resize: vertical;
	font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.feedback-submit {
	width: 100%;
	padding: 0.5rem 0.75rem;
	font-size: 0.8rem;
	margin-top: 0.3rem;
	cursor: pointer;
}

.feedback-status {
	margin: 0;
	font-size: 0.75rem;
	color: var(--muted);
	min-height: 1em;
	text-align: center;
}

.feedback-status.success {
	color: #2d7a3e;
	font-weight: 500;
}

.feedback-status.error {
	color: #b91c1c;
}

.site-footer {
	text-align: center;
	padding: 1.5rem 1rem;
	border-top: 1px solid var(--line);
	margin-top: auto;
	background: var(--surface);
}

.site-footer img {
	width: 24px;
	height: 24px;
	vertical-align: middle;
	margin-right: 0.4rem;
}

.site-footer p {
	margin: 0;
	font-size: 0.8rem;
	color: var(--muted);
	letter-spacing: 0.02em;
}

.footer-link {
	color: var(--muted);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition:
		color 140ms ease,
		border-color 140ms ease;
}

.footer-link:hover {
	color: var(--ink);
	border-bottom-color: var(--ink);
}

@media (max-width: 900px) {
	body {
		height: auto;
		min-height: 100vh;
		overflow: auto;
	}

	.app-shell {
		height: auto;
		margin: 1.25rem auto 1.5rem;
		display: block;
	}

	h1 {
		max-width: 100%;
	}

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

	.editor-panels {
		grid-template-columns: 1fr;
	}

	.story-visual {
		width: 100%;
	}

	textarea {
		min-height: 250px;
		height: auto;
		resize: vertical;
	}

	.tools-panel {
		overflow: visible;
	}
}
