/* PSB Stick-Studio: Start in der Lesespalte; bei der Arbeit so breit wie das Fenster, Rahmen links, Einstellungen rechts.
   Am Handy wie die Foto-Apps: Rahmen oben, darunter die Einstellungen, die für sich scrollen (Robert, 26.11.2026). */
.psb-stick {
	--st-akzent: var(--global-palette1, #1d4f91);
	--ed-akzent: var(--st-akzent);
	--st-linie: var(--psb-linie, #d8dee8);
	--st-leise: var(--psb-leise, #5a6678);
	margin: 1.5rem 0;
}

.psb-stick--arbeit {
	position: relative;
	left: 50%;
	width: min(calc(100vw - 1.5rem), 2200px);
	transform: translateX(-50%);
}

.psb-st__start {
	display: grid;
	gap: 0.75rem;
}

.psb-st__start[hidden],
.psb-st__arbeit[hidden] {
	display: none;
}

.psb-st__gross {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3rem;
	padding: 1.75rem 1rem;
	border-radius: 0.9rem;
	background: var(--st-akzent);
	color: #fff;
	font-size: 0.9rem;
	text-align: center;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(29, 79, 145, 0.3);
}

.psb-st__gross strong {
	font-size: 1.25rem;
}

.psb-st__gross input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}

.psb-st__gross--klein {
	padding: 0.9rem 0.75rem;
	box-shadow: none;
}

.psb-st__gross--klein strong {
	font-size: 1rem;
}

.psb-st__raster {
	display: grid;
	gap: 0.5rem;
	margin: 0.5rem 0;
}

.psb-st__raster--1 { grid-template-columns: minmax(0, 1fr); }
.psb-st__raster--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.psb-st__raster--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.psb-st__raster--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.psb-stick .psb-editor__knopf {
	box-sizing: border-box;
	width: 100%;
	min-width: 0;
	margin: 0;
	white-space: normal;
	overflow-wrap: anywhere;
}

/* Arbeit */
.psb-st__arbeit {
	display: grid;
	grid-template-columns: minmax(0, 1fr) clamp(21rem, 24vw, 26rem);
	grid-template-rows: auto minmax(0, 1fr);
	gap: 0.75rem;
	padding: 0.75rem;
	border: 1px solid var(--st-linie);
	border-radius: 0.9rem;
	background: #fff;
}

.psb-st__schritte {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 0.5rem;
}

.psb-st__schritte button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 2.75rem;
	border: 2px solid var(--st-linie);
	border-radius: 0.6rem;
	background: #f5f7fa;
	color: #14233a;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
}

.psb-st__schritte button b {
	display: inline-grid;
	place-items: center;
	width: 1.6rem;
	height: 1.6rem;
	border-radius: 50%;
	background: #fff;
	color: var(--st-akzent);
	font-size: 0.9rem;
}

.psb-st__schritte button[aria-selected="true"] {
	border-color: var(--st-akzent);
	background: var(--st-akzent);
	color: #fff;
}

.psb-st__flaeche {
	position: relative;
	min-height: 28rem;
	height: max(28rem, calc(100vh - 9rem));
	height: max(28rem, calc(100dvh - 9rem));
	border-radius: 0.6rem;
	overflow: hidden;
}

.psb-st__canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
	outline: none;
}

.psb-st__canvas:focus-visible {
	box-shadow: inset 0 0 0 3px var(--st-akzent);
}

.psb-st__leiste {
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	display: grid;
	grid-template-columns: repeat(5, 2.6rem);
	gap: 0.3rem;
}

.psb-st__leiste button {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 2.6rem;
	padding: 0;
	border: 1px solid var(--st-linie);
	border-radius: 0.5rem;
	background: rgba(255, 255, 255, 0.95);
	color: #14233a;
	font-size: 1.2rem;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(20, 35, 58, 0.12);
}

.psb-st__leiste button:hover,
.psb-st__leiste button:focus-visible {
	border-color: var(--st-akzent);
	color: var(--st-akzent);
}

.psb-st__status {
	position: absolute;
	left: 0.8rem;
	bottom: 0.5rem;
	margin: 0;
	padding: 0.25rem 0.6rem;
	border-radius: 1rem;
	background: rgba(255, 255, 255, 0.92);
	color: var(--st-leise);
	font-size: 0.85rem;
}

/* Seitenleiste */
.psb-st__seite {
	max-height: max(28rem, calc(100vh - 9rem));
	max-height: max(28rem, calc(100dvh - 9rem));
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-gutter: stable;
	padding-right: 0.25rem;
	font-size: 0.92rem;
}

.psb-st__gruppe {
	margin: 0 0 0.6rem;
	border: 1px solid var(--st-linie);
	border-radius: 0.6rem;
	background: #fff;
}

.psb-st__gruppe > summary {
	padding: 0.6rem 0.75rem;
	font-weight: 700;
	cursor: pointer;
	list-style: none;
}

.psb-st__gruppe > summary::-webkit-details-marker {
	display: none;
}

.psb-st__gruppe > summary::after {
	content: "▾";
	float: right;
	color: var(--st-leise);
}

.psb-st__gruppe:not([open]) > summary::after {
	content: "▸";
}

.psb-st__gruppe-inhalt {
	padding: 0 0.75rem 0.75rem;
}

.psb-stick .psb-editor__feld {
	display: grid;
	gap: 0.2rem;
	margin: 0.4rem 0;
}

.psb-stick .psb-editor__feld input:not([type="color"]):not([type="range"]),
.psb-stick .psb-editor__feld select,
.psb-stick .psb-editor__feld textarea {
	box-sizing: border-box;
	width: 100%;
}

.psb-stick input[type="color"] {
	width: 100%;
	height: 2.4rem;
	padding: 0.15rem;
}

.psb-st__eingabe {
	display: flex;
	align-items: center;
	gap: 0.35rem;
}

.psb-st__eingabe input {
	flex: 1 1 auto;
	min-width: 0;
}

.psb-st__eingabe i {
	font-style: normal;
	color: var(--st-leise);
}

.psb-st__haken {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
	margin: 0.5rem 0;
}

.psb-st__erklaerung,
.psb-stick .psb-editor__klein {
	margin: 0.4rem 0;
	color: var(--st-leise);
	font-size: 0.85rem;
	line-height: 1.45;
}

/* Kacheln: Stoffe, Rahmen, Sticharten, Formate */
.psb-st__kachel {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.1rem;
	min-height: 3.2rem;
	padding: 0.35rem 0.3rem;
	border: 2px solid var(--st-linie);
	border-radius: 0.55rem;
	background: #f8fafc;
	color: #14233a;
	font-size: 0.85rem;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	overflow-wrap: anywhere;
	hyphens: auto;
}

.psb-st__kachel small {
	color: var(--st-leise);
	font-size: 0.72rem;
}

.psb-st__kachel[aria-pressed="true"] {
	border-color: var(--st-akzent);
	background: #e6eef8;
}

/* Motive */
.psb-st__themen {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin-bottom: 0.5rem;
}

.psb-st__themen button {
	padding: 0.3rem 0.75rem;
	border: 1px solid var(--st-linie);
	border-radius: 1rem;
	background: #fff;
	font-size: 0.85rem;
	cursor: pointer;
}

.psb-st__themen button[aria-pressed="true"] {
	border-color: var(--st-akzent);
	background: var(--st-akzent);
	color: #fff;
}

.psb-st__motive {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr));
	gap: 0.4rem;
	max-height: 18rem;
	overflow-y: auto;
}

.psb-st__motiv {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
	padding: 0.3rem;
	border: 1px solid var(--st-linie);
	border-radius: 0.5rem;
	background: #fff;
	font-size: 0.68rem;
	line-height: 1.15;
	cursor: pointer;
}

.psb-st__motiv svg {
	width: 2.6rem;
	height: 2.6rem;
	fill: #14233a;
}

.psb-st__motiv span {
	overflow: hidden;
	max-width: 100%;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Teile und Garne */
.psb-st__teile {
	margin: 0;
	padding: 0;
	list-style: none;
}

.psb-st__teile button {
	display: grid;
	grid-template-columns: 1.1rem minmax(0, 1fr) auto;
	align-items: center;
	gap: 0.5rem;
	width: 100%;
	margin: 0 0 0.25rem;
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--st-linie);
	border-radius: 0.45rem;
	background: #fff;
	text-align: left;
	cursor: pointer;
}

.psb-st__teile button[aria-pressed="true"] {
	border-color: var(--st-akzent);
	background: #e6eef8;
}

.psb-st__teile i,
.psb-st__garnreihe i {
	display: inline-block;
	width: 1.1rem;
	height: 1.1rem;
	border: 1px solid rgba(0, 0, 0, 0.2);
	border-radius: 50%;
}

.psb-st__teile span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.psb-st__teile small {
	color: var(--st-leise);
	font-size: 0.75rem;
}

.psb-st__garne {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(1.7rem, 1fr));
	gap: 0.3rem;
	margin: 0.5rem 0;
}

.psb-st__garn {
	aspect-ratio: 1;
	min-height: 0;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, 0.2);
	border-radius: 50%;
	cursor: pointer;
}

.psb-st__garn[aria-pressed="true"] {
	outline: 3px solid var(--st-akzent);
	outline-offset: 1px;
}

.psb-st__garnreihe {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
}

/* Prüfung und Meldungen */
.psb-st__punkt {
	display: flex;
	gap: 0.5rem;
	margin: 0 0 0.4rem;
	padding: 0.45rem 0.6rem;
	border-left: 4px solid var(--st-farbe, #1d4f91);
	border-radius: 0.45rem;
	background: var(--st-grund, #eff6ff);
	font-size: 0.85rem;
	line-height: 1.4;
}

.psb-st__punkt b {
	flex: 0 0 auto;
	color: var(--st-farbe, #1d4f91);
}

.psb-st__punkt--gut { --st-farbe: #15803d; --st-grund: #f0fdf4; }
.psb-st__punkt--mittel { --st-farbe: #b45309; --st-grund: #fffbeb; }
.psb-st__punkt--schlecht { --st-farbe: #b91c1c; --st-grund: #fef2f2; }

.psb-st__meldung {
	margin: 0 0 0.6rem;
	padding: 0.5rem 0.7rem;
	border-radius: 0.5rem;
	background: #eff6ff;
	font-size: 0.85rem;
	line-height: 1.4;
}

.psb-st__meldung[data-art="gut"] { background: #f0fdf4; }
.psb-st__meldung[data-art="mittel"] { background: #fffbeb; }
.psb-st__meldung[data-art="schlecht"] { background: #fef2f2; }

.psb-st__zahlen p {
	margin: 0.4rem 0;
	font-size: 0.88rem;
	line-height: 1.45;
}

.psb-st__weiter {
	position: sticky;
	bottom: 0;
	padding: 0.4rem 0 0;
	background: #fff;
}

/* Handy und schmale Fenster: Rahmen oben, Einstellungen darunter scrollen für sich, Schritte kompakt */
@media (max-width: 899px) {
	.psb-stick--arbeit {
		width: calc(100vw - 1.25rem);
	}

	.psb-st__arbeit {
		display: flex;
		flex-direction: column;
		gap: 0.4rem;
		height: 100vh;
		height: 100dvh;
		padding: 0.4rem;
		box-sizing: border-box;
	}

	.psb-st__schritte {
		gap: 0.25rem;
	}

	.psb-st__schritte button {
		min-height: 2.3rem;
		gap: 0.25rem;
		font-size: 0.78rem;
	}

	.psb-st__schritte button b {
		width: 1.2rem;
		height: 1.2rem;
		font-size: 0.7rem;
	}

	.psb-st__flaeche {
		flex: 0 0 auto;
		min-height: 0;
		height: 42vh;
		height: 42dvh;
	}

	.psb-st__leiste {
		grid-template-columns: repeat(5, 2.2rem);
	}

	.psb-st__leiste button {
		height: 2.2rem;
		font-size: 1rem;
	}

	.psb-st__status {
		font-size: 0.72rem;
	}

	.psb-st__seite {
		flex: 1 1 0;
		min-height: 0;
		max-height: none;
		font-size: 0.85rem;
	}

	.psb-stick .psb-editor__knopf {
		min-height: 2.3rem;
		padding: 0.2rem 0.35rem;
		font-size: 0.8rem;
	}

	.psb-stick .psb-editor__feld > span {
		font-size: 0.78rem;
	}

	.psb-stick input:not([type="checkbox"]):not([type="range"]):not([type="color"]),
	.psb-stick select,
	.psb-stick textarea {
		min-height: 2.3rem;
		padding-block: 0.2rem;
		font-size: 16px;
	}

	.psb-st__kachel {
		min-height: 2.7rem;
		font-size: 0.78rem;
	}

	.psb-st__gruppe > summary {
		padding: 0.45rem 0.6rem;
		font-size: 0.88rem;
	}

	.psb-st__gruppe-inhalt {
		padding: 0 0.6rem 0.6rem;
	}
}

@media (max-width: 420px) {
	.psb-st__schritte button b {
		display: none;
	}
}

/* Handy-Leiste unten (wie die Foto-Apps): am Rechner unsichtbar */
.psb-st__handyleiste {
	display: none;
}

@media (max-width: 899px) {
	.psb-st__schritte,
	.psb-st__weiter {
		display: none;
	}

	.psb-st__seite .psb-st__gruppe:not(.psb-st__gruppe--handy) {
		display: none;
	}

	.psb-st__seite .psb-st__gruppe--handy > summary {
		display: none;
	}

	.psb-st__seite .psb-st__gruppe--handy {
		border: 0;
	}

	.psb-st__seite .psb-st__gruppe--handy > .psb-st__gruppe-inhalt {
		padding: 0.2rem 0.1rem 0.5rem;
	}

	.psb-st__handyleiste {
		display: flex;
		flex: 0 0 auto;
		gap: 0.15rem;
		margin: 0 -0.4rem -0.4rem;
		padding: 0.25rem 0.3rem calc(0.25rem + env(safe-area-inset-bottom));
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scrollbar-width: none;
		border-top: 1px solid var(--st-linie);
		background: #fff;
	}

	.psb-st__handyleiste::-webkit-scrollbar {
		display: none;
	}

	.psb-st__handyleiste button {
		display: flex;
		flex: 0 0 auto;
		flex-direction: column;
		align-items: center;
		gap: 0.1rem;
		min-width: 3.6rem;
		padding: 0.3rem 0.2rem;
		border: 0;
		border-radius: 0.5rem;
		background: transparent;
		color: var(--st-leise);
		font-size: 0.68rem;
		line-height: 1.1;
		cursor: pointer;
	}

	.psb-st__handyleiste button span {
		font-size: 1.2rem;
		line-height: 1.1;
	}

	.psb-st__handyleiste button[aria-pressed="true"] {
		color: var(--st-akzent);
		font-weight: 700;
		background: #e6eef8;
	}
}

/* Das Theme färbt Knopfschrift weiß: in Listen, Themen und Leisten die Schriftfarbe ausdrücklich setzen */
.psb-stick .psb-st__teile button,
.psb-stick .psb-st__themen button,
.psb-stick .psb-st__motiv,
.psb-stick .psb-st__kachel,
.psb-stick .psb-st__schritte button,
.psb-stick .psb-st__leiste button {
	color: #14233a;
}

.psb-stick .psb-st__themen button[aria-pressed="true"],
.psb-stick .psb-st__schritte button[aria-selected="true"] {
	color: #fff;
}

.psb-stick .psb-st__handyleiste button {
	color: var(--st-leise);
}

.psb-stick .psb-st__handyleiste button[aria-pressed="true"] {
	color: var(--st-akzent);
}

.psb-stick .psb-st__teile button span {
	color: #14233a;
	font-weight: 600;
}

/* Am Handy füllt der Arbeitsbereich genau den Bildschirm; die Seite scrollt nicht mehr dahinter */
@media (max-width: 899px) {
	.psb-stick--arbeit {
		margin-top: 0;
		scroll-margin-top: 0;
	}
}

@media (max-width: 899px) {
	/* Motive scrollen mit dem Bereich, kein zweiter Rollbalken */
	.psb-st__motive {
		max-height: none;
		overflow: visible;
	}
}

/* Ausschnitt fürs Foto: kleines Foto mit Rahmen, Ziehen wählt das Stück, das gestickt wird */
.psb-st__ausschnitt {
	position: relative;
	max-width: 100%;
	margin: 0.5rem auto 0.25rem;
	overflow: hidden;
	border-radius: 0.4rem;
	background: #111;
	touch-action: none;
	cursor: crosshair;
	user-select: none;
}

.psb-stick .psb-st__ausschnitt img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: fill;
	pointer-events: none;
}

.psb-st__ausschnitt i {
	position: absolute;
	box-sizing: border-box;
	border: 2px solid #fff;
	outline: 1px solid rgba(0, 0, 0, 0.5);
	box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.45);
	pointer-events: none;
}

.psb-stick .psb-st__ausschnitt svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	fill: none;
	stroke: rgba(227, 52, 47, 0.7);
	stroke-linecap: round;
	stroke-linejoin: round;
}
