/* Rec – baut auf Primer (primer.css) auf. Alle Farben und Maße kommen aus Primers Tokens,
   hell und dunkel schaltet Primer selbst über data-color-mode="auto" um.
   Hier stehen nur Bausteine, die Primer als reines CSS nicht mehr mitliefert. */

/* ABC Areal (Dinamo, Free Fonts License), selbst gehostet */
@font-face {
  font-family: "ABC Areal";
  src: url("fonts/ABCArealVariable.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --fontStack-sansSerif: "ABC Areal", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --rec-red: #e5493a;
}

html, body { margin: 0; }
body {
  background: var(--bgColor-default);
  color: var(--fgColor-default);
  font-family: var(--fontStack-sansSerif);
  font-size: 14px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: var(--fontStack-monospace); font-size: 85%; padding: .2em .4em; border-radius: var(--borderRadius-medium); background: var(--bgColor-neutral-muted); }
.btn { font-family: inherit; }
.btn .rec-dot { margin-right: 6px; }
.btn-primary .rec-dot { background: currentColor; }

/* Roter Aufnahme-Punkt */
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--rec-red); flex: none; }
.rec-dot-sm { width: 8px; height: 8px; }
.rec-dot-lg { width: 40px; height: 40px; }

/* Kopfzeile */
.AppHeader {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px;
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  background: var(--bgColor-inset);
  border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted);
}
.AppHeader-brand { margin: 0; display: inline-flex; align-items: center; gap: 8px; color: var(--fgColor-default); text-decoration: none; font-size: 16px; }
.AppHeader-brand:hover { text-decoration: none; }
.AppHeader-owner { color: var(--fgColor-muted); }
.AppHeader-sep { color: var(--fgColor-muted); }

/* Box (Primers Container mit Rahmen) */
.Box { background: var(--bgColor-default); border: var(--borderWidth-thin) solid var(--borderColor-default); border-radius: var(--borderRadius-medium); }
.Box-header { padding: 16px; background: var(--bgColor-muted); border-bottom: var(--borderWidth-thin) solid var(--borderColor-default); border-radius: var(--borderRadius-medium) var(--borderRadius-medium) 0 0; }
.Box-title { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.Box-body { padding: 16px; }
.Box-footer { padding: 16px; border-top: var(--borderWidth-thin) solid var(--borderColor-default); }

.Counter {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 2em;
  background: var(--bgColor-neutral-muted); color: var(--fgColor-default);
  font-size: 12px; font-weight: 500; line-height: 18px; text-align: center;
}
.Label {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; height: 22px; border-radius: 2em;
  border: var(--borderWidth-thin) solid var(--borderColor-default); font-size: 12px; font-weight: 500; line-height: 1;
}
.Label--danger { background: var(--bgColor-danger-emphasis); border-color: transparent; color: var(--fgColor-onEmphasis); }
.Label--danger .rec-dot { background: var(--fgColor-onEmphasis); }

.flash { padding: 16px; border-radius: var(--borderRadius-medium); border: var(--borderWidth-thin) solid var(--borderColor-default); }
.flash-warn { background: var(--bgColor-attention-muted); border-color: var(--borderColor-attention-muted); }

/* Formulare */
.FormGroup { display: grid; gap: 6px; min-width: 0; }
.FormLabel { font-weight: 600; font-size: 14px; }
.FormHint { margin: 0; color: var(--fgColor-muted); font-size: 12px; }
.FormHint:empty { display: none; }
.FormHint.ok { color: var(--fgColor-success); }
.FormHint.warn { color: var(--fgColor-attention); }
.FormError { margin: 0; color: var(--fgColor-danger); font-size: 12px; }
.Check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.Check input { margin: 0; accent-color: var(--bgColor-accent-emphasis); }
.form-control, .form-select { font-family: inherit; }

/* Segmentierte Auswahl, wie Primers SegmentedControl */
.Segmented { display: flex; margin: 0; padding: 0; border: 0; background: var(--controlTrack-bgColor-rest); border-radius: var(--borderRadius-medium); }
.Segmented label { flex: 1 1 auto; position: relative; display: flex; }
.Segmented input { position: absolute; opacity: 0; pointer-events: none; }
.Segmented span {
  flex: 1; display: grid; place-items: center; text-align: center; min-height: 32px; padding: 4px 8px;
  border: var(--borderWidth-thin) solid transparent; border-radius: var(--borderRadius-medium);
  font-size: 13px; color: var(--fgColor-muted); cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.Segmented span:hover { color: var(--fgColor-default); }
.Segmented input:checked + span {
  background: var(--controlKnob-bgColor-rest); border-color: var(--controlKnob-borderColor-rest);
  color: var(--fgColor-default); font-weight: 600;
}
.Segmented input:focus-visible + span { outline: 2px solid var(--focus-outlineColor, var(--fgColor-accent)); outline-offset: -2px; }

.Meter { height: 4px; border-radius: 2px; background: var(--bgColor-neutral-muted); overflow: hidden; }
.Meter span { display: block; width: 0; height: 100%; background: var(--bgColor-success-emphasis); transition: width .08s linear; }
.Progress { height: 8px; border-radius: var(--borderRadius-medium); background: var(--bgColor-neutral-muted); overflow: hidden; }
.Progress span { display: block; width: 0; height: 100%; background: var(--bgColor-success-emphasis); transition: width .3s; }
.CopyField { display: flex; gap: 8px; }
.CopyField .form-control { font-family: var(--fontStack-monospace); font-size: 12px; color: var(--fgColor-muted); }

/* Seite */
.Page {
  max-width: 1280px; margin: 0 auto; display: grid; gap: 24px;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px));
}
.Studio { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.Panel-form { display: grid; gap: 16px; }
.Panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.Panel-actions .btn-primary { margin-left: auto; }

/* Bühne mit Vorschau */
.Stage {
  position: relative; aspect-ratio: 16 / 10; max-width: 100%; overflow: hidden; display: grid; place-items: center;
  border: var(--borderWidth-thin) solid var(--borderColor-default); border-radius: var(--borderRadius-medium);
  /* Karomuster wie bei transparenten PNGs */
  background:
    conic-gradient(var(--bgColor-neutral-muted) 25%, transparent 0 50%, var(--bgColor-neutral-muted) 0 75%, transparent 0) 0 0 / 16px 16px,
    var(--bgColor-default);
}
.Stage-screen, .Stage-result { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.Stage-cam {
  position: absolute; left: 3.5%; bottom: 3.5%; width: 26%; aspect-ratio: 1; object-fit: cover; border-radius: 50%;
  transform: scaleX(-1); z-index: 2; box-shadow: var(--shadow-resting-small);
}
.Stage[data-mode="screen+cam"] .Stage-cam { bottom: auto; cursor: grab; touch-action: none; user-select: none; }
.is-dragging, .is-dragging * { user-select: none; -webkit-user-select: none; }
.Stage-cam.dragging { cursor: grabbing; outline: 2px solid var(--fgColor-accent); outline-offset: 2px; }
.Stage[data-mode="cam"] .Stage-cam { inset: 0; width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
.Stage[data-mode="screen"] .Stage-cam { display: none; }
.Stage-empty { position: relative; z-index: 1; text-align: center; padding: 6px 12px; max-width: calc(100% - 32px); background: var(--bgColor-default); border: var(--borderWidth-thin) solid var(--borderColor-default); border-radius: var(--borderRadius-medium); box-shadow: var(--shadow-resting-small); }
.Stage[data-mode="screen+cam"] .Stage-empty { pointer-events: none; }
.Stage-title { margin: 0; font-size: 14px; font-weight: 600; }
.Stage-text { margin: 0; color: var(--fgColor-muted); }
.Stage-countdown { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: var(--overlay-backdrop-bgColor); color: #fff; font-size: clamp(64px, 12vw, 128px); font-weight: 600; font-variant-numeric: tabular-nums; }
.Stage-pill { position: absolute; top: 12px; left: 12px; z-index: 3; font-variant-numeric: tabular-nums; }
.Stage.paused .Stage-pill { background: var(--bgColor-neutral-emphasis, #6e7781); }
.Stage-pill .rec-dot { animation: rec-blink 1.2s infinite; }
.Stage.paused .Stage-pill .rec-dot { animation: none; }
@keyframes rec-blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .Stage-pill .rec-dot { animation: none; } }

/* Videoliste */
.Library-head { display: flex; align-items: center; justify-content: space-between; }
.Library-list { list-style: none; margin: 0; padding: 0; }
.Library-row {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 12px 16px; border-top: var(--borderWidth-thin) solid var(--borderColor-muted);
}
.Library-row:first-child { border-top: 0; }
.Library-row:hover { background: var(--bgColor-muted); }
.Library-row:last-child { border-radius: 0 0 var(--borderRadius-medium) var(--borderRadius-medium); }
.thumb { position: relative; display: block; aspect-ratio: 16 / 10; border-radius: var(--borderRadius-small, 3px); overflow: hidden; background: var(--bgColor-neutral-muted); border: var(--borderWidth-thin) solid var(--borderColor-muted); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.len { position: absolute; right: 4px; bottom: 4px; padding: 0 4px; border-radius: 3px; background: rgba(0,0,0,.75); color: #fff; font-size: 11px; line-height: 16px; font-variant-numeric: tabular-nums; }
.Library-info { display: grid; gap: 2px; min-width: 0; }
.Library-info .title { color: var(--fgColor-accent); font-weight: 600; font-size: 16px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.Library-info .title:hover { text-decoration: underline; }
.Library-info .meta { color: var(--fgColor-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.Library-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.Library-actions .del { color: var(--fgColor-danger); }
.confirm { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fgColor-muted); }
.Blankslate { padding: 32px 16px; text-align: center; }
.Blankslate-title { margin: 0 0 4px; font-size: 16px; font-weight: 600; }

/* Anmelden */
.Login { max-width: 340px; margin: 0 auto; padding: 48px 16px; display: grid; gap: 16px; justify-items: center; text-align: center; }
.Login-title { margin: 8px 0 0; font-size: 24px; font-weight: 300; letter-spacing: -0.5px; }
.Login-box { width: 100%; display: grid; gap: 12px; text-align: left; background: var(--bgColor-muted); }
.Login-note { margin: 0; color: var(--fgColor-muted); font-size: 12px; }

/* Videoseite */
.Watch { max-width: 1012px; margin: 0 auto; display: grid; gap: 16px; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.Watch-player { overflow: hidden; background: #000; border: var(--borderWidth-thin) solid var(--borderColor-default); border-radius: var(--borderRadius-medium); }
.Watch-player video { display: block; width: 100%; max-height: 78vh; background: #000; }
.Watch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted); }
.Watch-title { margin: 0; font-size: 24px; font-weight: 400; text-wrap: balance; }
.Watch-meta { margin: 4px 0 0; color: var(--fgColor-muted); }
.Watch-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.BtnGroup { display: inline-flex; }
.BtnGroup .btn { border-radius: 0; margin-left: -1px; }
.BtnGroup .btn:first-child { border-radius: var(--borderRadius-medium) 0 0 var(--borderRadius-medium); margin-left: 0; }
.BtnGroup .btn:last-child { border-radius: 0 var(--borderRadius-medium) var(--borderRadius-medium) 0; }
.BtnGroup .btn.selected { background: var(--controlKnob-bgColor-rest, var(--bgColor-muted)); font-weight: 600; box-shadow: inset 0 0 0 1px var(--borderColor-default); }
.Watch-wait { max-width: 480px; margin: 10vh auto 0; text-align: center; display: grid; gap: 12px; }

@media (max-width: 1011px) {
  .Studio { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .Library-row { grid-template-columns: 88px minmax(0, 1fr); }
  .Library-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .Stage[data-mode="screen+cam"] .Stage-empty { margin: 0 0 28% 0; }
  .AppHeader-owner, .AppHeader-sep { display: none; }
}
