:root {
	color-scheme: light;
	--bg: #f6f4fb;
	--panel: #ffffff;
	--panel-alt: #f9f7fd;
	--subpanel: #f3effc;
	--text: #211a2f;
	--muted: #6c6383;
	--accent: #7443da;
	--accent-soft: #ede6fb;
	--border: #ddd5ef;
	--success: #0d8f4f;
	--danger: #b63a59;
	--shadow: 0 18px 40px rgba(43, 29, 76, 0.08);
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: linear-gradient(180deg, #faf8ff 0%, var(--bg) 100%);
	color: var(--text);
}

button,
input,
textarea,
select {
	font: inherit;
}

button {
	border: none;
	border-radius: 12px;
	padding: 0.8rem 1rem;
	background: var(--accent);
	color: white;
	font-weight: 700;
	cursor: pointer;
}

button:hover {
	filter: brightness(1.03);
}

button:disabled {
	opacity: 0.6;
	cursor: progress;
}

.button-secondary {
	background: var(--accent-soft);
	color: var(--accent);
}

.button-danger {
	background: #fbe7ed;
	color: var(--danger);
}

.button-compact {
	padding: 0.55rem 0.8rem;
	border-radius: 10px;
	font-size: 0.9rem;
}

.page-shell {
	max-width: 1600px;
	margin: 0 auto;
	padding: 2rem;
	padding-bottom: 4rem;
}

.hero,
.status-bar,
.card {
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 24px;
	box-shadow: var(--shadow);
}

.hero {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.5rem 1.75rem;
	align-items: end;
	margin-bottom: 1rem;
}

.eyebrow {
	margin: 0 0 0.5rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-size: 0.78rem;
	font-weight: 800;
	color: var(--accent);
}

.hero h1 {
	margin: 0;
	font-size: clamp(2rem, 4vw, 3rem);
}

.hero-copy {
	margin: 0.75rem 0 0;
	max-width: 70ch;
	color: var(--muted);
	line-height: 1.55;
}

.hero-actions {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	flex-wrap: wrap;
}

.status-bar {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.95rem 1.25rem;
	margin-bottom: 1rem;
	color: var(--muted);
	font-size: 0.95rem;
}

.layout-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1rem;
	align-items: start;
}

.editor-shell {
	display: grid;
	grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
	gap: 1rem;
	align-items: start;
}

.span-2,
.dataset-card {
	grid-column: 1 / -1;
}

.card {
	padding: 1.25rem;
}

.card h2,
.card h3,
.card h4 {
	margin: 0;
}

.section-copy {
	margin: 0.35rem 0 0;
	color: var(--muted);
	font-size: 0.95rem;
	line-height: 1.5;
}

.section-heading {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	align-items: center;
	margin-bottom: 1rem;
}

.form-grid {
	display: grid;
	gap: 1rem;
	margin-bottom: 1rem;
}

.two-up {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-up {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
	display: grid;
	gap: 0.45rem;
	margin-bottom: 1rem;
}

label span {
	font-weight: 700;
	font-size: 0.95rem;
}

input,
textarea,
select {
	width: 100%;
	border-radius: 14px;
	border: 1px solid var(--border);
	background: var(--panel-alt);
	padding: 0.9rem 1rem;
	color: var(--text);
	line-height: 1.5;
	resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
	outline: 2px solid rgba(116, 67, 218, 0.18);
	border-color: var(--accent);
}

.summary-strip,
.mini-note {
	padding: 0.9rem 1rem;
	border-radius: 16px;
	border: 1px solid var(--border);
	background: #fcfbff;
	color: var(--muted);
	margin-bottom: 1rem;
	line-height: 1.5;
}

.question-toolbar {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	margin-bottom: 1rem;
	padding: 0.9rem 1rem;
	border: 1px solid var(--border);
	border-radius: 18px;
	background: #fcfbff;
}

.question-toolbar-group {
	display: flex;
	gap: 0.6rem;
	align-items: center;
	flex-wrap: wrap;
}

.question-toolbar-label {
	font-size: 0.86rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted);
}

.question-toolbar .button-secondary.is-active {
	background: var(--accent);
	color: white;
}

.question-stack {
	display: grid;
	gap: 1rem;
}

.question-card {
	padding: 1rem;
	border-radius: 20px;
	border: 1px solid var(--border);
	background: var(--panel-alt);
	display: grid;
	gap: 0.8rem;
}

.question-card.is-collapsed {
	gap: 0.4rem;
}

.question-card-header {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	align-items: start;
}

.question-card-header p {
	margin: 0.35rem 0 0;
	color: var(--muted);
	line-height: 1.5;
}

.question-card-heading {
	display: grid;
	gap: 0.45rem;
	min-width: 0;
}

.question-heading-topline {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	flex-wrap: wrap;
}

.question-card-actions {
	justify-content: flex-end;
}

.question-status-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
}

.question-card-body {
	display: grid;
	gap: 0.8rem;
}

.question-card-body[hidden] {
	display: none;
}

.subpanel {
	padding: 1rem;
	border-radius: 18px;
	border: 1px solid var(--border);
	background: var(--subpanel);
}

.subpanel h4 {
	margin-bottom: 0.8rem;
	font-size: 1rem;
}

.dataset-actions {
	justify-content: flex-end;
}

.empty-state {
	padding: 1rem 1.1rem;
	border: 1px dashed var(--border);
	border-radius: 16px;
	background: #fcfbff;
	color: var(--muted);
}

.dataset-list {
	display: grid;
	gap: 0.9rem;
}

.dataset-item {
	display: grid;
	gap: 0.8rem;
	padding: 1rem 1.1rem;
	border: 1px solid var(--border);
	border-radius: 18px;
	background: var(--panel-alt);
}

.dataset-item.active {
	border-color: var(--accent);
	box-shadow: inset 0 0 0 1px rgba(116, 67, 218, 0.15);
}

.dataset-item-header {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	align-items: start;
}

.dataset-item-title {
	font-size: 1rem;
	font-weight: 800;
}

.dataset-item-meta {
	margin: 0.25rem 0 0;
	color: var(--muted);
	font-size: 0.92rem;
	line-height: 1.45;
}

.dataset-item-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
}

.dataset-pill {
	padding: 0.35rem 0.6rem;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent);
	font-size: 0.82rem;
	font-weight: 700;
}

.pill-success {
	background: #e3f6ec;
	color: var(--success);
}

.pill-warning {
	background: #fff1d9;
	color: #a46a00;
}

.pill-muted {
	background: #efedf5;
	color: var(--muted);
}

.dataset-item-actions {
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.workspace-nav-card {
	display: grid;
	gap: 1rem;
	position: sticky;
	top: 1rem;
	max-height: calc(100vh - 2rem);
	overflow: hidden;
}

.workspace-toolbar {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	align-items: start;
}

.workspace-controls {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 160px;
	gap: 0.85rem;
	align-items: end;
}

.control-field {
	margin-bottom: 0;
}

.control-field-compact span {
	font-size: 0.85rem;
}

.workspace-search-field input,
.control-field select {
	padding-block: 0.8rem;
}

.workspace-meta-row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	align-items: center;
	flex-wrap: wrap;
}

.compact-strip {
	margin-bottom: 0;
	padding: 0.75rem 0.9rem;
	font-size: 0.92rem;
}

.workspace-actions {
	display: flex;
	gap: 0.55rem;
	flex-wrap: wrap;
}

.draft-list {
	display: grid;
	gap: 0.65rem;
	overflow: auto;
	padding-right: 0.2rem;
}

.draft-item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 0.85rem;
	padding: 0.9rem 0.95rem;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--panel-alt);
	align-items: start;
}

.draft-item.active {
	border-color: var(--accent);
	box-shadow: inset 0 0 0 1px rgba(116, 67, 218, 0.15);
	background: #f8f4ff;
}

.draft-item-main {
	display: grid;
	gap: 0.45rem;
	min-width: 0;
	cursor: pointer;
}

.draft-item-row {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	align-items: baseline;
}

.draft-item-title {
	font-size: 0.98rem;
	font-weight: 800;
	margin: 0;
	line-height: 1.3;
}

.draft-item-meta {
	margin: 0;
	color: var(--muted);
	font-size: 0.88rem;
	line-height: 1.4;
}

.draft-item-updated {
	margin: 0;
	color: var(--muted);
	font-size: 0.82rem;
	white-space: nowrap;
}

.draft-item-actions {
	display: flex;
	justify-content: flex-end;
}

.draft-item-actions button {
	min-width: 82px;
}

.draft-empty-state {
	margin-top: 0.25rem;
}

.editor-card {
	min-width: 0;
}

.dataset-item-actions button {
	padding: 0.65rem 0.9rem;
	font-size: 0.92rem;
}

pre {
	margin: 0;
	padding: 1rem;
	border-radius: 16px;
	border: 1px solid var(--border);
	background: #171222;
	color: #f2ecff;
	overflow: auto;
	max-height: 520px;
	font-size: 0.9rem;
	line-height: 1.5;
}

code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.footer-note {
	margin-top: 1rem;
	color: var(--muted);
	background: #fcfbff;
	line-height: 1.5;
}

.toast {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	padding: 0.9rem 1.1rem;
	border-radius: 12px;
	background: var(--text);
	color: white;
	box-shadow: var(--shadow);
	max-width: 360px;
	z-index: 10;
}

.toast.hidden {
	display: none;
}

.toast.error {
	background: var(--danger);
}

.toast.success {
	background: var(--success);
}

@media (max-width: 1200px) {
	.layout-grid {
		grid-template-columns: 1fr;
	}

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

	.span-2,
	.dataset-card {
		grid-column: auto;
	}

	.workspace-nav-card {
		position: static;
		max-height: none;
	}

	.four-up {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 800px) {
	.page-shell {
		padding: 1rem;
		padding-bottom: 3rem;
	}

	.hero,
	.status-bar,
	.section-heading,
	.dataset-item-header,
		.workspace-meta-row,
		.workspace-toolbar,
		.draft-item-row,
		.question-card-header {
		flex-direction: column;
		align-items: stretch;
	}

	.workspace-controls,
	.draft-item {
		grid-template-columns: 1fr;
	}

	.draft-item-actions {
		justify-content: flex-start;
	}

	.question-toolbar,
	.question-toolbar-group,
	.question-heading-topline {
		flex-direction: column;
		align-items: stretch;
	}

	.two-up,
	.three-up,
	.four-up {
		grid-template-columns: 1fr;
	}
}
