/* --------------------------------------------------------------------
   werkstatt.css — Guilloche-Werkstatt
   Gestaltung im Stil einer Stichdruck-Plattenwerkstatt:
   dunkle Plattenbühne, Kupferakzent, Papierfenster in der Mitte.
   -------------------------------------------------------------------- */

:root {
	--ink:      #090d12;
	--plate:    #121a23;
	--plate-2:  #182330;
	--rule:     #26343f;
	--copper:   #c58a4e;
	--copper-d: #8d5f31;
	--text:     #cfd8e0;
	--text-dim: #7f8f9d;

	--font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
	--font-ui: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
	--font-num: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

	--kopfhoehe: 56px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
	margin: 0;
	background: var(--ink);
	color: var(--text);
	font-family: var(--font-ui);
	font-size: 14px;
	-webkit-font-smoothing: antialiased;
}

/* --- Kopfzeile ------------------------------------------------------- */

header {
	display: flex;
	align-items: baseline;
	gap: 16px;
	padding: 14px 22px;
	border-bottom: 1px solid var(--rule);
	background: var(--plate);
	height: var(--kopfhoehe);
}
header h1 {
	margin: 0;
	font-family: var(--font-display);
	font-size: 20px;
	font-weight: 400;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--copper);
	white-space: nowrap;
}
header .sub {
	font-size: 12px;
	color: var(--text-dim);
	letter-spacing: .04em;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* --- Grundraster ----------------------------------------------------- */

main {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 330px;
	height: calc(100% - var(--kopfhoehe));
}

/* --- Bühne ----------------------------------------------------------- */

#stage {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	background: radial-gradient(ellipse at 50% 40%, #16202b 0%, var(--ink) 70%);
}

/* `min-height: 0` ist entscheidend: Ohne das wächst der Bereich als
   Flex-Kind mit seinem Inhalt, statt zu schrumpfen — dann schiebt ein
   großes Motiv die Signaturzeile aus dem Fenster. */
#viewport {
	position: relative;
	flex: 1 1 0;
	min-height: 0;
	overflow: hidden;
	cursor: grab;
	touch-action: none;
}
#viewport.zieht { cursor: grabbing; }

#canvasWrap {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: 0 0;
	line-height: 0;
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--rule), 0 18px 50px -20px #000;
	transition: opacity .18s;
}
#canvasWrap svg { display: block; width: 100%; height: 100%; }
#canvasWrap.laedt { opacity: .35; }

/* --- Zoomleiste ------------------------------------------------------- */

#zoombar {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 5px 6px;
	background: rgba(18, 26, 35, .88);
	border: 1px solid var(--rule);
	border-radius: 4px;
	backdrop-filter: blur(6px);
}
#zoombar button {
	padding: 4px 8px;
	font-size: 11.5px;
	background: transparent;
	border-color: transparent;
}
#zoombar button:hover:not(:disabled) { border-color: var(--copper-d); }
#zoombar button:disabled { color: var(--rule); cursor: default; }
#zoomAus, #zoomEin { min-width: 26px; font-size: 14px; padding: 2px 6px; }
#zoomWert {
	min-width: 54px;
	text-align: center;
	font-family: var(--font-num);
	font-size: 11.5px;
	color: var(--copper);
}
#zoombar .trenner {
	width: 1px;
	align-self: stretch;
	background: var(--rule);
	margin: 0 3px;
}

/* Im Vollbild trägt die Bühne den Grund selbst. */
#stage:fullscreen { background: var(--ink); }

/* Legendenzeile — die „Plattensignatur“ */
#legend {
	border-top: 1px solid var(--rule);
	background: var(--plate);
	padding: 9px 22px;
	font-family: var(--font-num);
	font-size: 11.5px;
	letter-spacing: .05em;
	color: var(--text-dim);
	display: flex;
	gap: 20px;
	flex-wrap: wrap;
	min-height: 34px;
}
#legend b { color: var(--copper); font-weight: 500; }
#legend .warn { color: #e0a35a; }

/* --- Bedienfeld ------------------------------------------------------ */

#panel {
	border-left: 1px solid var(--rule);
	background: var(--plate);
	overflow-y: auto;
	padding: 0 0 40px;
}

/* Gruppen sind <details>, damit Auf- und Zuklappen samt Tastaturbedienung
   vom Browser kommt und nicht nachgebaut werden muss. */
.feld {
	border-top: 1px solid var(--rule);
}
.feld:first-of-type { border-top: 0; }
.feld > summary {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 13px 18px;
	cursor: pointer;
	font-family: var(--font-display);
	font-size: 12px;
	letter-spacing: .18em;
	text-transform: uppercase;
	color: var(--copper-d);
	list-style: none;
	user-select: none;
	transition: color .15s;
}
.feld > summary::-webkit-details-marker { display: none; }
.feld > summary:hover { color: var(--copper); }
.feld[open] > summary { color: var(--copper); }
.feld > summary:focus-visible { outline: 2px solid var(--copper); outline-offset: -2px; }

/* Chevron aus zwei Kanten: zu = nach rechts, auf = nach unten. */
.chev {
	width: 6px;
	height: 6px;
	flex: none;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(-45deg);
	margin-left: 1px;
	transition: transform .18s;
}
.feld[open] > summary .chev {
	transform: rotate(45deg);
	margin-top: -3px;
}

/* Eigener Inhaltsrahmen statt Rand an den Kindern — sonst rechnen
   Knöpfe mit width:100% über den Rand hinaus. */
.feld > .inhalt { padding: 0 18px 16px; }

/* Seed und Neu würfeln: gleiche Breite, gleiche Höhe, Knopf rechts. */
.paar {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}
.paar > input,
.paar > button {
	height: 34px;
	padding-top: 0;
	padding-bottom: 0;
	margin: 0;
}

.row { margin-bottom: 12px; }
.row:last-child { margin-bottom: 0; }

.lab {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	margin-bottom: 5px;
}
.lab span { font-size: 12.5px; color: var(--text); }
.lab output {
	font-family: var(--font-num);
	font-size: 11.5px;
	color: var(--copper);
}

input[type=range] {
	width: 100%;
	height: 18px;
	margin: 0;
	background: transparent;
	-webkit-appearance: none;
	appearance: none;
}
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--rule); }
input[type=range]::-moz-range-track { height: 2px; background: var(--rule); }
input[type=range]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 13px; height: 13px; margin-top: -5.5px;
	border-radius: 50%;
	background: var(--copper);
	border: 0;
	cursor: pointer;
}
input[type=range]::-moz-range-thumb {
	width: 13px; height: 13px; border: 0; border-radius: 50%;
	background: var(--copper); cursor: pointer;
}
input[type=range]:focus-visible { outline: 2px solid var(--copper); outline-offset: 4px; }
input[type=range]:disabled::-webkit-slider-thumb { background: var(--rule); cursor: default; }
input[type=range]:disabled::-moz-range-thumb { background: var(--rule); cursor: default; }

input[type=number], select {
	width: 100%;
	background: var(--plate-2);
	border: 1px solid var(--rule);
	color: var(--text);
	font-family: var(--font-num);
	font-size: 13px;
	padding: 6px 8px;
	border-radius: 3px;
}
input[type=color] {
	width: 100%; height: 30px; padding: 2px;
	background: var(--plate-2);
	border: 1px solid var(--rule);
	border-radius: 3px;
	cursor: pointer;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.check {
	display: flex; align-items: center; gap: 8px;
	font-size: 12.5px; cursor: pointer; padding: 3px 0;
}
.check input { accent-color: var(--copper); width: 15px; height: 15px; }

button {
	font-family: var(--font-ui);
	font-size: 12.5px;
	letter-spacing: .03em;
	padding: 8px 10px;
	background: var(--plate-2);
	color: var(--text);
	border: 1px solid var(--rule);
	border-radius: 3px;
	cursor: pointer;
	transition: border-color .15s, color .15s;
}
button:hover { border-color: var(--copper-d); color: #fff; }
button.primary {
	background: var(--copper-d);
	border-color: var(--copper);
	color: #14100a;
	font-weight: 600;
}
button.primary:hover { background: var(--copper); }
button:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

.hint { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; margin: 8px 0 0; }
.hint a { color: var(--copper); }

/* --- SweetAlert im selben Ton ---------------------------------------- */

.swal2-popup.gui-swal {
	background: var(--plate);
	color: var(--text);
	border: 1px solid var(--rule);
	font-family: var(--font-ui);
}
.gui-swal .swal2-title {
	font-family: var(--font-display);
	font-weight: 400;
	letter-spacing: .1em;
	text-transform: uppercase;
	font-size: 17px;
	color: var(--copper);
}
/* Sicherheitsnetz: Sollte SweetAlert2 doch einmal ohne heightAuto:false
   aufgerufen werden, bliebe der Aufbau trotzdem stehen. */
body.swal2-height-auto { height: 100% !important; }

/* --- Hilfe ------------------------------------------------------------ */

button.info {
	all: unset;
	display: inline-grid;
	place-items: center;
	width: 14px;
	height: 14px;
	margin-left: 3px;
	vertical-align: 1px;
	border: 1px solid var(--rule);
	border-radius: 50%;
	font-family: var(--font-ui);
	font-size: 9.5px;
	line-height: 1;
	color: var(--text-dim);
	cursor: help;
	transition: color .15s, border-color .15s;
}
button.info:hover,
button.info:focus-visible {
	color: var(--copper);
	border-color: var(--copper-d);
}
button.info:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

#tip {
	position: fixed;
	z-index: 2000;
	max-width: 280px;
	padding: 8px 10px;
	background: var(--plate-2);
	border: 1px solid var(--copper-d);
	border-radius: 3px;
	box-shadow: 0 8px 24px -8px #000;
	font-size: 12px;
	line-height: 1.5;
	color: var(--text);
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity .12s;
}
#tip.an { opacity: 1; visibility: visible; }

.gui-swal .hilfe-text {
	text-align: left;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--text);
}
.gui-swal .hilfe-proben {
	display: flex;
	justify-content: center;
	gap: 14px;
	flex-wrap: wrap;
	margin-top: 18px;
	padding-top: 16px;
	border-top: 1px solid var(--rule);
}
.gui-swal .hilfe-proben figure {
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 7px;
}
/* Schachbrett hinter den Kacheln: Ein transparenter Grund wäre auf dem
   dunklen Modal sonst nicht von einem leeren Bild zu unterscheiden. */
.gui-swal .hilfe-proben img {
	display: block;
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--rule);
	background-color: #e7e1d3;
	background-image:
		linear-gradient(45deg, #cfc7b4 25%, transparent 25%, transparent 75%, #cfc7b4 75%),
		linear-gradient(45deg, #cfc7b4 25%, transparent 25%, transparent 75%, #cfc7b4 75%);
	background-size: 14px 14px;
	background-position: 0 0, 7px 7px;
}
.gui-swal .hilfe-proben figcaption {
	font-family: var(--font-num);
	font-size: 11px;
	color: var(--text-dim);
	text-align: center;
}

/* --- Tabs und Doku im Link-Dialog ------------------------------------- */

.gui-swal .tabs {
	display: flex;
	gap: 2px;
	margin: -4px 0 16px;
	border-bottom: 1px solid var(--rule);
}
.gui-swal .tab {
	padding: 7px 16px;
	background: transparent;
	border: 1px solid transparent;
	border-bottom: 0;
	border-radius: 3px 3px 0 0;
	margin-bottom: -1px;
	font-size: 12.5px;
	color: var(--text-dim);
}
.gui-swal .tab:hover { color: var(--text); }
.gui-swal .tab.an {
	color: var(--copper);
	border-color: var(--rule);
	background: var(--plate-2);
}
.gui-swal .tabinhalt { text-align: left; }
.gui-swal .tabinhalt[hidden] { display: none; }

.gui-swal .doku {
	max-height: 58vh;
	overflow-y: auto;
	padding-right: 6px;
}
.gui-swal .doku h4 {
	margin: 20px 0 8px;
	font-family: var(--font-display);
	font-size: 12px;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--copper-d);
	font-weight: 400;
}
.gui-swal .doku .hinweis {
	margin: 0 0 14px;
	font-size: 12.5px;
	line-height: 1.6;
	color: var(--text-dim);
}
.gui-swal .doku .hinweis strong { color: var(--text); }

.dokutabelle {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
}
.dokutabelle thead th {
	text-align: left;
	padding: 5px 8px;
	border-bottom: 1px solid var(--rule);
	font-family: var(--font-display);
	font-size: 11px;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--copper-d);
	font-weight: 400;
}
.dokutabelle tbody th {
	text-align: left;
	font-weight: 400;
	white-space: nowrap;
	vertical-align: top;
}
.dokutabelle td, .dokutabelle tbody th {
	padding: 5px 8px;
	border-bottom: 1px solid rgba(38, 52, 63, .55);
	vertical-align: top;
	line-height: 1.45;
	color: var(--text);
}
.dokutabelle tbody tr:hover td,
.dokutabelle tbody tr:hover th { background: rgba(24, 35, 48, .6); }
.dokutabelle .num { font-family: var(--font-num); color: var(--text-dim); }
.dokutabelle .schritt,
.dokutabelle .schwach { color: var(--text-dim); }
.dokutabelle .schritt { display: block; font-size: 10.5px; margin-top: 1px; }
.dokutabelle code {
	font-family: var(--font-num);
	font-size: 11.5px;
	color: var(--copper);
}
.dokutabelle.beispiele th { white-space: normal; padding-right: 16px; }
.dokutabelle.beispiele td { color: var(--text-dim); }

.gui-swal .gui-radios {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-bottom: 14px;
}
.gui-swal .gui-radios .check {
	align-items: flex-start;
	gap: 10px;
	padding: 8px 10px;
	border: 1px solid var(--rule);
	border-radius: 3px;
	line-height: 1.45;
}
.gui-swal .gui-radios .check:has(input:checked) {
	border-color: var(--copper-d);
	background: var(--plate-2);
}
.gui-swal .gui-radios input { accent-color: var(--copper); margin-top: 1px; flex: none; }
.gui-swal .gui-radios strong { color: var(--text); font-weight: 600; }
.gui-swal .gui-radios code,
.gui-swal .gui-warn code {
	font-family: var(--font-num);
	font-size: .92em;
	color: var(--copper);
}
.gui-swal #swFormatZeile { margin-bottom: 12px; }
.gui-swal #swFormatZeile[hidden] { display: none; }

.gui-swal .gui-link {
	width: 100%;
	font-family: var(--font-num);
	font-size: 11.5px;
	line-height: 1.5;
	background: var(--plate-2);
	color: var(--text);
	border: 1px solid var(--rule);
	border-radius: 3px;
	padding: 8px;
	resize: vertical;
	min-height: 96px;
}
.gui-swal .gui-warn {
	text-align: left;
	font-size: 12.5px;
	line-height: 1.55;
	color: var(--text-dim);
	border-left: 2px solid var(--copper-d);
	padding-left: 10px;
	margin: 14px 0 0;
}
.gui-swal .swal2-actions { gap: 8px; }
.gui-swal .swal2-styled {
	font-family: var(--font-ui);
	font-size: 13px;
	letter-spacing: .03em;
	border-radius: 3px;
	box-shadow: none;
}
.gui-swal .swal2-confirm {
	background: var(--copper-d);
	border: 1px solid var(--copper);
	color: #14100a;
	font-weight: 600;
}
.gui-swal .swal2-confirm:hover { background: var(--copper); }
.gui-swal .swal2-cancel {
	background: var(--plate-2);
	border: 1px solid var(--rule);
	color: var(--text);
}
.gui-swal .swal2-cancel:hover { border-color: var(--copper-d); color: #fff; }
.gui-swal .swal2-styled:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
.gui-swal .swal2-validation-message {
	background: var(--plate-2);
	color: #e0a35a;
}

/* --- Nur-Bild-Ansicht (showOnly) ------------------------------------- */

body.nurbild {
	display: grid;
	place-items: center;
	min-height: 100vh;
	padding: 16px;
	background: #0b1016;
}
body.nurbild img, body.nurbild svg {
	max-width: 100%;
	max-height: calc(100vh - 32px);
	height: auto;
}
body.nurbild .status {
	font-family: var(--font-num);
	font-size: 12px;
	color: var(--text-dim);
}

/* --- Schmale Fenster -------------------------------------------------- */

@media (max-width: 860px) {
	main { grid-template-columns: 1fr; height: auto; }
	#panel { border-left: 0; border-top: 1px solid var(--rule); }
	#viewport { padding: 16px; }
	header .sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; }
}