:root {
  --himmel: #d8dbd9;
  --papier: #f6f5f1;
  --tinte: #111;
  --grau: #6b6b66;
  --linie: rgba(17, 17, 17, .14);
  --rand: max(14px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--himmel);
  color: var(--tinte);
  font: 15px/1.5 "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#buehne {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#buehne.zieht { cursor: grabbing; }
#buehne.zeigt { cursor: pointer; }

/* ---------- Schriftzug und Knöpfe ---------- */
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.zug {
  position: fixed;
  z-index: 3;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.zug img { display: block; height: 100%; width: auto; user-select: none; -webkit-user-drag: none; }
.zug:focus-visible, .pfeil:focus-visible { outline: 3px solid #1a55ff; outline-offset: 4px; }
.zug-off { top: max(14px, env(safe-area-inset-top)); left: var(--rand); height: 64px; }
.zug-grid { left: 50%; top: calc(max(14px, env(safe-area-inset-top)) + 10px); transform: translateX(-50%); width: min(32vw, 420px); }
.zug-grid img { width: 100%; height: auto; }
.zug-space { right: max(16px, env(safe-area-inset-right)); top: max(14px, env(safe-area-inset-top)); height: 70px; }

/* Pfeile zum anderen Raum */
.pfeil {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 58px; height: 120px;
  padding: 20px 14px;
  border: 0;
  background: none;
  cursor: pointer;
  z-index: 5;
  transition: opacity .4s, transform .2s;
  -webkit-tap-highlight-color: transparent;
}
.pfeil[hidden] { display: none; }
.pfeil svg { display: block; width: 100%; height: 100%; fill: var(--tinte); }
.pfeil-l { left: max(6px, env(safe-area-inset-left)); }
.pfeil-r { right: max(6px, env(safe-area-inset-right)); }
.pfeil-r:hover { transform: translateY(-50%) translateX(4px); }
.pfeil-l:hover { transform: translateY(-50%) translateX(-4px); }
.drin .pfeil { opacity: 0; pointer-events: none; }

.lade-klein {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  margin: 0;
  font-size: 12px;
  letter-spacing: .04em;
  background: var(--tinte);
  color: #fff;
  padding: 6px 10px;
  z-index: 4;
}
.lade-klein[hidden] { display: none; }
.laden-logo img { display: block; width: auto; }
.knoepfe {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: var(--rand);
  display: flex;
  gap: 8px;
  z-index: 5;
}
.knopf[hidden] { display: none; }

.knopf {
  pointer-events: auto;
  font: inherit;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--tinte);
  background: var(--papier);
  border: 1.5px solid var(--tinte);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.knopf:hover, .knopf[aria-expanded="true"] { background: var(--tinte); color: var(--papier); }
.knopf:focus-visible, .liste button:focus-visible, .werk-bilder button:focus-visible {
  outline: 3px solid #1a55ff;
  outline-offset: 2px;
}
.knopf.rund {
  width: 40px; height: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  display: grid;
  place-items: center;
}

/* ---------- Werkliste ---------- */
.liste {
  position: fixed;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 46px);
  left: var(--rand);
  width: min(320px, calc(100vw - 2 * var(--rand)));
  background: var(--papier);
  border: 1.5px solid var(--tinte);
  border-radius: 14px;
  padding: 6px;
  z-index: 6;
  max-height: calc(100dvh - 160px);
  overflow: auto;
}
.liste button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
}
.liste button:hover { background: rgba(17, 17, 17, .07); }
.liste b { display: block; font-size: 15px; }
.liste span { color: var(--grau); font-size: 13px; }

/* ---------- Schild am Mauszeiger ---------- */
.schild {
  position: fixed;
  left: 0; top: 0;
  z-index: 7;
  pointer-events: none;
  background: var(--tinte);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  padding: 6px 10px;
  white-space: nowrap;
}
.schild[hidden] { display: none; }
.schild b { display: block; font-size: 13px; }

/* ---------- Hinweis ---------- */
.hinweis {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100vw - 28px);
  text-align: center;
  background: rgba(17, 17, 17, .86);
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 16px;
  width: max-content;
  z-index: 4;
  pointer-events: none;
  transition: opacity .6s;
}
.hinweis.weg { opacity: 0; }
.nur-finger { display: none; }
@media (pointer: coarse) {
  .nur-maus { display: none; }
  .nur-finger { display: inline; }
}

/* ---------- Ladebild ---------- */
.laden {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  background: var(--himmel);
  z-index: 20;
  transition: opacity .7s;
  padding: 24px;
  text-align: center;
}
.laden.weg { opacity: 0; pointer-events: none; }
.laden-logo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.laden-logo .logo-off { height: 86px; }
.laden-logo .logo-grid { height: 40px; }
.laden-logo .logo-space { height: 92px; }
.balken { width: min(280px, 70vw); height: 3px; background: var(--linie); overflow: hidden; }
.balken i { display: block; height: 100%; width: 0; background: var(--tinte); transition: width .2s; }
.laden p { margin: 0; font-size: 13px; letter-spacing: .04em; color: var(--grau); }
.laden.fehler .balken { display: none; }
.laden.fehler p { color: var(--tinte); font-size: 15px; max-width: 34em; }

/* ---------- Werk-Popup (mittig) ---------- */
.schleier {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, .32);
  z-index: 9;
  opacity: 0;
  transition: opacity .35s;
}
.schleier.offen { opacity: 1; }
.schleier[hidden] { display: none; }
.werk {
  position: fixed;
  left: 50%; top: 50%;
  width: min(960px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  background: var(--papier);
  border: 1.5px solid var(--tinte);
  z-index: 10;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.86);
  transition: transform .38s cubic-bezier(.2, .8, .2, 1), opacity .3s;
}
.werk.offen { opacity: 1; transform: translate(-50%, -50%); }
.werk[hidden] { display: none; }
.werk-leiste {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--linie);
  flex: none;
}
.zaehler { font-size: 13px; color: var(--grau); min-width: 3.2em; text-align: center; }
.werk-leiste .zu { margin-left: auto; }
.werk-inhalt {
  overflow: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.werk-bilder { display: grid; gap: 10px; }
.werk-bilder:empty { display: none; }
.werk-inhalt:has(.werk-bilder:empty) { grid-template-columns: 1fr; min-width: min(420px, 80vw); }
.werk-bilder button {
  display: block;
  padding: 0;
  border: 0;
  background: #e9e8e3;
  cursor: zoom-in;
  width: 100%;
}
.werk-bilder img { display: block; width: 100%; height: auto; max-height: min(640px, calc(100dvh - 150px)); object-fit: contain; }
.werk-kuenstler { margin: 0; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--grau); }
.werk-titel { margin: 2px 0 12px; font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; }
.werk-daten { margin: 0 0 14px; display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 14px; }
.werk-daten:empty { display: none; }
.werk-daten dt { color: var(--grau); }
.werk-daten dd { margin: 0; }
.werk-text p { margin: 0 0 .9em; max-width: 34em; }

@media (max-width: 760px) {
  .werk { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .werk-inhalt { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
  .werk-worte { order: -1; }                 /* am Handy zuerst Name und Titel, dann das Foto */
  .werk-titel { font-size: 24px; margin-bottom: 4px; }
  .werk-bilder img { max-height: 58dvh; }
  .zug-off { height: 44px; }
  .zug-grid { width: 46vw; top: calc(max(14px, env(safe-area-inset-top)) + 62px); }
  .zug-space { height: 48px; }
  .pfeil { width: 46px; height: 96px; padding: 16px 12px; }
  .knopf { padding: 8px 13px; }
  .hinweis { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 60px); }
  .laden-logo .logo-off { height: 60px; }
  .laden-logo .logo-grid { height: 28px; }
  .laden-logo .logo-space { height: 64px; }
}

/* ---------- Großansicht ---------- */
.gross {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 12, .94);
  z-index: 30;
  display: grid;
  place-items: center;
  cursor: zoom-out;
}
.gross[hidden] { display: none; }
.gross img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.gross .zu { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 14px; }

.ohne { position: fixed; inset: auto 0 40% 0; text-align: center; z-index: 40; }

@media (prefers-reduced-motion: reduce) {
  .werk, .schleier, .laden, .hinweis { transition: none; }
}
