:root {
	--bg: #f4f5f7;
	--surface: #fff;
	--border: #e2e4e9;
	--text: #1d2330;
	--muted: #6b7280;
	--accent: #2f5bea;
	--accent-soft: #e8eefd;
	--error: #b42318;
	--error-soft: #fdecea;
	--warning: #8a5a00;
	--warning-soft: #fff4d6;
	--radius: 8px;
	--sidebar: 300px;
	--topbar: 56px;
	color-scheme: light;
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--text);
	background: var(--bg);
}

h1,
h2,
h3 {
	margin: 0;
	font-weight: 600;
}

a {
	color: var(--accent);
}

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

[hidden] {
	display: none !important;
}

/* Buttons & Formulare */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
}

.btn:hover {
	border-color: #c7cbd3;
}

.btn:focus-visible,
input:focus-visible,
.tree a:focus-visible,
.tree button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.btn-primary:hover {
	background: #2549c6;
	border-color: #2549c6;
}

.btn-ghost {
	background: transparent;
}

.btn-small {
	padding: 4px 10px;
	font-size: 13px;
}

input[type="password"],
input[type="search"] {
	width: 100%;
	padding: 9px 11px;
	font: inherit;
	color: inherit;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
}

.alert {
	padding: 10px 12px;
	border-radius: 6px;
	margin: 12px 0;
}

.alert-error {
	background: var(--error-soft);
	color: var(--error);
}

.alert-warning {
	background: var(--warning-soft);
	color: var(--warning);
}

/* Login */
.login-page {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.login-card {
	width: 100%;
	max-width: 380px;
	padding: 32px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
}

.login-card h1 {
	font-size: 20px;
	margin-bottom: 6px;
}

.login-card form {
	display: grid;
	gap: 8px;
	margin-top: 20px;
}

.login-card label {
	font-weight: 500;
}

.login-card .btn {
	justify-content: center;
	margin-top: 8px;
	padding: 10px;
}

/* Grundlayout */
.app {
	display: flex;
	flex-direction: column;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 12px;
	height: var(--topbar);
	padding: 0 16px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

.topbar-title {
	font-size: 16px;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.logout {
	margin: 0;
}

.menu-toggle {
	display: none;
}

.layout {
	flex: 1;
	display: flex;
	min-height: 0;
}

.sidebar {
	width: var(--sidebar);
	flex: none;
	display: flex;
	flex-direction: column;
	background: var(--surface);
	border-right: 1px solid var(--border);
	height: calc(100vh - var(--topbar));
	position: sticky;
	top: var(--topbar);
}

.sidebar-search {
	padding: 12px;
	border-bottom: 1px solid var(--border);
}

.tree {
	flex: 1;
	overflow: auto;
	padding: 8px 0 24px;
}

.tree-empty {
	padding: 8px 16px;
	margin: 0;
}

.main {
	flex: 1;
	min-width: 0;
	padding: 24px;
}

/* Baum */
.tree ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tree ul ul {
	padding-left: 14px;
}

.tree-row {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 0 8px;
}

.tree-caret {
	flex: none;
	width: 22px;
	height: 22px;
	border: 0;
	padding: 0;
	border-radius: 4px;
	background: transparent;
	color: var(--muted);
	cursor: pointer;
	font-size: 11px;
	transition: transform 0.12s;
}

.tree-caret:hover {
	background: var(--bg);
}

.tree-folder.is-open > .tree-row .tree-caret {
	transform: rotate(90deg);
}

.tree-folder:not(.is-open) > ul {
	display: none;
}

.tree a {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 6px;
	color: var(--text);
	text-decoration: none;
}

.tree a:hover {
	background: var(--bg);
}

.tree a.is-active {
	background: var(--accent-soft);
}

.tree-label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tree-folder > .tree-row a {
	font-weight: 600;
}

.tree-banner a {
	padding-left: 30px;
}

.tree-meta {
	flex: none;
	color: var(--muted);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

/* Neu oder geändert und noch nicht angesehen */
.tree-banner.is-changed > .tree-row a,
.tree-folder.is-changed > .tree-row a {
	color: var(--accent);
}

.tree-banner.is-changed > .tree-row a {
	font-weight: 600;
}

.status-dot {
	flex: none;
	width: 8px;
	height: 8px;
	border-radius: 50%;
}

.status-error .status-dot {
	background: var(--error);
}

.status-uploading .status-dot {
	background: #e0a100;
	animation: pulse 1s infinite alternate;
}

@keyframes pulse {

	to {
		opacity: 0.3;
	}
}

/* Hinweisleiste */
.notice {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	padding: 10px 14px;
	margin-bottom: 20px;
	border-radius: var(--radius);
	background: var(--accent-soft);
	color: var(--accent);
	font-weight: 500;
}

/* Ansichten */
.view-head {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 16px;
}

.view-title {
	flex: 1;
	min-width: 200px;
}

.view-title h2 {
	font-size: 20px;
	word-break: break-word;
}

.breadcrumb {
	font-size: 13px;
	color: var(--muted);
	margin-bottom: 4px;
}

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

.meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 14px;
	margin-top: 6px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

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

.hint {
	font-size: 13px;
	color: var(--muted);
	margin: 12px 0 0;
}

/* Vorschau: Originalgröße, bei Bedarf scrollen */
.stage {
	overflow: auto;
	max-width: 100%;
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background-color: #fff;
	background-image:
		linear-gradient(45deg, #f0f1f3 25%, transparent 25%, transparent 75%, #f0f1f3 75%),
		linear-gradient(45deg, #f0f1f3 25%, transparent 25%, transparent 75%, #f0f1f3 75%);
	background-size: 16px 16px;
	background-position: 0 0, 8px 8px;
}

.stage-inner {
	width: max-content;
}

.stage iframe {
	display: block;
	border: 0;
	background: #fff;
	outline: 1px dashed #b8bdc7;
	outline-offset: 0;
}

.stage .fallback {
	display: block;
	outline: 1px dashed #b8bdc7;
}

.stage .fallback:hover,
.stage .fallback:focus-visible {
	outline: 2px solid var(--accent);
}

.stage .fallback img {
	display: block;
}

.fallback-missing {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 8px;
	background: var(--error-soft);
	color: var(--error);
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	outline: 1px dashed var(--error);
}

.fallback-missing:hover,
.fallback-missing:focus-visible {
	outline: 2px solid var(--error);
}

.grid {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	align-items: flex-start;
}

.card {
	max-width: 100%;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}

/*
 * Name und Infos untereinander. Die Kopfzeile übernimmt die Breite
 * des Banners, lange Namen brechen um.
 */
.card-head {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	width: 0;
	min-width: 100%;
	padding: 10px 12px;
	border-bottom: 1px solid var(--border);
}

.card-head a {
	font-weight: 600;
	text-decoration: none;
	color: var(--text);
	overflow-wrap: break-word;
}

.card-head a:hover {
	color: var(--accent);
}

.card-head .tree-meta {
	font-size: 12px;
}

.card .stage {
	border: 0;
	border-radius: 0;
	padding: 16px;
}

.card .alert {
	margin: 12px;
}

/* Neu oder geändert und noch nicht einzeln angesehen */
.card.is-changed {
	border-color: var(--accent);
	box-shadow: 0 0 0 1px var(--accent);
}

.badge {
	padding: 1px 8px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	color: var(--accent);
	background: var(--accent-soft);
}

.badge-uploading {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--warning);
	background: var(--warning-soft);
}

.badge-uploading .status-dot {
	width: 6px;
	height: 6px;
	background: #e0a100;
	animation: pulse 1s infinite alternate;
}

.folder-list {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0 0 24px;
	padding: 0;
	list-style: none;
}

.folder-list a {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	text-decoration: none;
	color: var(--text);
	font-weight: 500;
}

.folder-list a:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.section-title {
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted);
	margin: 0 0 10px;
}

.empty {
	padding: 48px 24px;
	text-align: center;
	color: var(--muted);
}

.empty h2 {
	color: var(--text);
	font-size: 18px;
	margin-bottom: 8px;
}

/* Schmale Bildschirme: Liste als ausklappbares Menü */
@media (max-width: 800px) {

	.menu-toggle {
		display: inline-flex;
	}

	.sidebar {
		position: fixed;
		left: 0;
		top: var(--topbar);
		z-index: 15;
		width: min(86vw, 340px);
		height: calc(100vh - var(--topbar));
		transform: translateX(-100%);
		transition: transform 0.2s;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
	}

	.sidebar-open .sidebar {
		transform: none;
	}

	.main {
		padding: 16px;
	}

	.stage {
		padding: 12px;
	}
}
