:root{
  --bg: #0c0f14;
  --panel: rgba(255,255,255,0.06);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.60);
  --border: rgba(255,255,255,0.14);
  --shadow: 0 18px 60px rgba(0,0,0,0.55);
  --radius: 18px;

  /* Reserven für Layout (Desktop) */
  --reserve-landscape: 260px; /* Querformat: Platz für Header+Audio+Controls */
  --reserve-portrait: 190px;  /* Hochformat: weniger Reserve -> Bild bekommt mehr Höhe */
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
}

body{
  background:
    radial-gradient(1200px 700px at 50% 10%, rgba(255,255,255,0.07), transparent 55%),
    radial-gradient(900px 600px at 20% 90%, rgba(255,255,255,0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------------- Header ---------------- */

.topbar{
  padding: 18px 18px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

h1{
  margin: 0;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: clamp(18px, 2.6vw, 30px);
  text-align: center;
}

/* ---------------- Audio oben ---------------- */

.audio-bar{
  width: min(1200px, calc(100vw - 36px));
  margin: 0 auto 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;

  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}

.audio-label{
  color: var(--muted);
  font-size: 13px;
  min-width: 60px;
}

.audio-bar audio{
  width: 100%;
}

/* ---------------- Stage ---------------- */

.stage{
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 18px;
}

/* ---------------- Frame ---------------- */

.frame{
  width: min(1200px, calc(100vw - 36px));

  /* Querformat: Reserve größer, damit Controls sichtbar bleiben */
  max-height: calc(100vh - var(--reserve-landscape));

  background: rgba(0,0,0,0.30);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 10px;
}

/* Hochformat: Bild bekommt mehr Höhe */
.frame.portrait{
  max-height: calc(100vh - var(--reserve-portrait));
}

.frame img{
  display: block;
  max-width: 100%;

  /* Querformat: etwas weniger Höhe */
  max-height: calc(100vh - (var(--reserve-landscape) + 20px));

  width: auto;
  height: auto;

  object-fit: contain;
  object-position: center center;

  border-radius: calc(var(--radius) - 10px);
  opacity: 0;
  transition: opacity .25s ease;
}

/* Hochformat: Bild darf höher werden */
.frame.portrait img{
  max-height: calc(100vh - (var(--reserve-portrait) + 20px));
}

.frame img.ready{
  opacity: 1;
}

/* Hint (Dateiname) */
.hint{
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--muted);
  font-size: 13px;
  backdrop-filter: blur(10px);
}

/* ---------------- Controls ---------------- */

.controls{
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}

.controls-bottom{
  width: min(1200px, calc(100vw - 36px));
  margin: 10px auto 18px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 12px 14px;
}

.btn{
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  color: var(--text);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 650;
}

.btn.primary{
  background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.10));
}

.status{
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
  font-size: 13px;
}

/* ---------------- Mobile ---------------- */

@media (max-width:520px){
  :root{
    /* Mobile braucht mehr Platz für UI – aber Hochformat soll trotzdem groß bleiben */
    --reserve-landscape: 320px;
    --reserve-portrait: 240px;
  }

  .audio-bar{
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .audio-label{
    min-width: auto;
  }

  .status{
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    text-align: center;
    width: 100%;
  }
}