/* Playground layout */

.playground-layout {
	display: flex;
	flex-direction: column;
	height: calc(100vh - 160px);
	min-height: 500px;
}

.playground-toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.5rem 0;
	gap: 0.5rem;
}

.toolbar-left {
	display: flex;
	gap: 0.5rem;
}

.toolbar-left button {
	--pico-form-element-spacing-vertical: 0.25rem;
	--pico-form-element-spacing-horizontal: 0.75rem;
	font-size: 0.8125rem;
	margin-bottom: 0;
}

#status {
	font-size: 0.8125rem;
	color: var(--pico-muted-color);
}

/* ── Panels ── */

.playground-panels {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	flex: 1;
	min-height: 0;
}

@media (max-width: 768px) {
	.playground-panels {
		grid-template-columns: 1fr;
		grid-template-rows: 1fr 1fr;
	}
}

.panel-editor {
	border: 1px solid var(--pico-muted-border-color);
	border-radius: 4px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.panel-editor #editor {
	flex: 1;
	overflow: auto;
}

.panel-editor .cm-editor {
	height: 100%;
}

.panel-output {
	border: 1px solid var(--pico-muted-border-color);
	border-radius: 4px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* ── Tabs ── */

[role="tablist"] {
	display: flex;
	border-bottom: 1px solid var(--pico-muted-border-color);
	padding: 0;
	gap: 0;
}

[role="tablist"] button {
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	padding: 0.5rem 1rem;
	font-size: 0.8125rem;
	color: var(--pico-muted-color);
	cursor: pointer;
	margin-bottom: 0;
	border-radius: 0;
	box-shadow: none;
}

[role="tablist"] button:hover {
	color: inherit;
	transform: none;
}

[role="tablist"] button[aria-selected="true"] {
	color: var(--pico-primary);
	border-bottom-color: var(--pico-primary);
	font-weight: 600;
}

/* ── Tab content ── */

.output-content {
	flex: 1;
	overflow: auto;
	position: relative;
}

.tab-panel {
	display: none;
	padding: 0.75rem;
	height: 100%;
	overflow: auto;
}

.tab-panel.active {
	display: block;
}

.tab-panel pre {
	margin: 0;
	white-space: pre-wrap;
	font-size: 0.8125rem;
}

/* ── Generated files ── */

#tab-generated {
	display: none;
	flex-direction: column;
}

#tab-generated.active {
	display: flex;
}

#generated-summary {
	display: block;
	font-size: 0.75rem;
	color: var(--pico-muted-color);
	padding: 0.375rem 0.5rem;
	border-bottom: 1px solid var(--pico-muted-border-color);
}

#generated-summary:empty {
	display: none;
}

#generated-tree {
	border-bottom: 1px solid var(--pico-muted-border-color);
	padding: 0.5rem;
	max-height: 280px;
	overflow-y: auto;
	font-size: 0.8125rem;
}

.folder-header {
	padding: 0.125rem 0.375rem;
	cursor: pointer;
	border-radius: 3px;
	white-space: nowrap;
	user-select: none;
	color: var(--pico-color);
}

.folder-header:hover {
	background: color-mix(in srgb, var(--pico-primary), transparent 92%);
}

.folder-toggle {
	display: inline-block;
	width: 1em;
	text-align: center;
	font-size: 0.75rem;
}

.folder-count {
	color: var(--pico-muted-color);
	font-size: 0.6875rem;
}

.file-tree-item {
	padding: 0.125rem 0.375rem;
	cursor: pointer;
	border-radius: 3px;
	white-space: nowrap;
}

.file-tree-item:hover {
	background: color-mix(in srgb, var(--pico-primary), transparent 92%);
}

.file-tree-item.selected {
	background: color-mix(in srgb, var(--pico-primary), transparent 85%);
	font-weight: 600;
}

#generated-filename {
	display: block;
	font-size: 0.75rem;
	color: var(--pico-primary);
	padding: 0.25rem 0.5rem;
	border-bottom: 1px solid var(--pico-muted-border-color);
	background: color-mix(in srgb, var(--pico-primary), transparent 95%);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#generated-filename:empty {
	display: none;
}

#generated-content {
	flex: 1;
	overflow: auto;
	padding: 0.75rem;
	margin: 0;
}

/* ── Diagnostics ── */

.diagnostic-error {
	color: var(--pico-del-color, #c62828);
}

.diagnostic-warning {
	color: #f57f17;
}
