:root {
  --bg: #0d0d12;
  --surface: #16161f;
  --border: #2a2a38;
  --text: #f2f2f5;
  --muted: #8b8b9e;
  --accent: #ff6b35;
  --accent-dim: #c44f28;
  --partner: #7c5cff;
  --success: #3dd68c;
  --danger: #ff4d6d;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: var(--partner);
}

header.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #12121a 0%, var(--bg) 100%);
}

.header-copy {
  min-width: 0;
}

header.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

header.site-header p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 52rem;
  line-height: 1.45;
}

/* Leuchtender, pulsierender Hinweis oben rechts */
.privat-badge {
  justify-self: end;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #2a1844 0%, #4a1a6e 50%, #1a3d4a 100%);
  border: 1px solid rgba(180, 140, 255, 0.55);
  box-shadow:
    0 0 12px rgba(124, 92, 255, 0.65),
    0 0 28px rgba(124, 92, 255, 0.35),
    inset 0 0 12px rgba(255, 255, 255, 0.08);
  animation: privat-glow 2.2s ease-in-out infinite;
}

@keyframes privat-glow {
  0%,
  100% {
    box-shadow:
      0 0 10px rgba(124, 92, 255, 0.5),
      0 0 22px rgba(124, 92, 255, 0.25),
      inset 0 0 10px rgba(255, 255, 255, 0.06);
    transform: scale(1);
    border-color: rgba(180, 140, 255, 0.45);
  }
  50% {
    box-shadow:
      0 0 20px rgba(124, 92, 255, 0.95),
      0 0 42px rgba(255, 107, 53, 0.35),
      inset 0 0 16px rgba(255, 200, 255, 0.12);
    transform: scale(1.04);
    border-color: rgba(255, 180, 220, 0.75);
  }
}

body.login-locked {
  overflow: hidden;
}

/* Vollbild-Login über die gesamte Seite */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(6, 6, 10, 0.94);
  backdrop-filter: blur(16px);
}

.login-overlay[hidden] {
  display: none !important;
}

.login-overlay-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.35rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(124, 92, 255, 0.12);
}

.login-overlay-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.login-overlay-hint {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.login-overlay-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.login-overlay-row label {
  min-width: 4.5rem;
}

.login-overlay-row input[type="password"] {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

.login-overlay-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin: 0 0 0.75rem;
}

.login-overlay-card .primary {
  width: 100%;
}

main {
  flex: 1;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 900px) {
  .stage[data-layout="split"] {
    grid-template-columns: 1fr;
  }
}

/* —— Picture-in-Picture (Layout): ein großes Panel, zweites als Overlay —— */
.stage[data-layout="pip-remote"],
.stage[data-layout="pip-local"] {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(220px, min(70vh, 100vw * 0.56));
  gap: 0;
  position: relative;
}

.stage[data-layout="pip-remote"] > .panel,
.stage[data-layout="pip-local"] > .panel {
  grid-area: 1 / 1;
}

.stage[data-layout="pip-remote"] > .panel:last-child,
.stage[data-layout="pip-local"] > .panel:first-child {
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.stage[data-layout="pip-remote"] > .panel:last-child .video-wrap,
.stage[data-layout="pip-local"] > .panel:first-child .video-wrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: 16 / 9;
}

.stage[data-layout="pip-remote"] > .panel:first-child,
.stage[data-layout="pip-local"] > .panel:last-child {
  width: min(38vw, 300px);
  max-width: calc(100% - 20px);
  z-index: 2;
  margin: 10px;
  height: fit-content;
  align-self: end;
  justify-self: end;
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.55);
  border-radius: var(--radius);
}

.stage[data-layout="pip-remote"] > .panel:first-child .panel-head,
.stage[data-layout="pip-local"] > .panel:last-child .panel-head {
  padding: 0.4rem 0.65rem;
  font-size: 0.68rem;
}

.stage[data-layout="pip-remote"] > .panel:first-child .video-wrap,
.stage[data-layout="pip-local"] > .panel:last-child .video-wrap {
  aspect-ratio: 16 / 10;
}

.stage[data-layout="pip-remote"][data-pip-corner="br"] > .panel:first-child,
.stage[data-layout="pip-local"][data-pip-corner="br"] > .panel:last-child {
  align-self: end;
  justify-self: end;
}

.stage[data-layout="pip-remote"][data-pip-corner="bl"] > .panel:first-child,
.stage[data-layout="pip-local"][data-pip-corner="bl"] > .panel:last-child {
  align-self: end;
  justify-self: start;
}

.stage[data-layout="pip-remote"][data-pip-corner="tr"] > .panel:first-child,
.stage[data-layout="pip-local"][data-pip-corner="tr"] > .panel:last-child {
  align-self: start;
  justify-self: end;
}

.stage[data-layout="pip-remote"][data-pip-corner="tl"] > .panel:first-child,
.stage[data-layout="pip-local"][data-pip-corner="tl"] > .panel:last-child {
  align-self: start;
  justify-self: start;
}

.layout-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.layout-toolbar-label {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.65rem;
}

.layout-toolbar-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

button.layout-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.78rem;
}

button.layout-btn.active {
  border-color: var(--partner);
  background: rgba(124, 92, 255, 0.2);
  color: #e8e0ff;
}

.pip-corner-select {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.pip-corner-select:focus {
  outline: 2px solid rgba(124, 92, 255, 0.35);
  border-color: var(--partner);
}

.layout-toolbar > button#btnPipNativeRemote,
.layout-toolbar > button#btnPipNativeLocal {
  font-size: 0.76rem;
}

.pip-native-msg {
  flex: 1 1 140px;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.panel-head .tag {
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
}

.panel-head .tag.you {
  background: rgba(255, 107, 53, 0.2);
  color: var(--accent);
}

.panel-head .tag.partner {
  background: rgba(124, 92, 255, 0.2);
  color: #b8a8ff;
}

.video-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.toy-pulse {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 107, 53, 0.45) 0%,
    transparent 55%
  );
  transition: opacity 0.15s ease;
}

.toy-pulse.active {
  opacity: 1;
  animation: pulse 0.35s ease-out infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(0.96);
    opacity: 0.35;
  }
  to {
    transform: scale(1.02);
    opacity: 0.85;
  }
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.65rem;
}

.row:last-child {
  margin-bottom: 0;
}

label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 5rem;
}

input[type="text"],
input[type="number"] {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

input:focus {
  outline: 2px solid rgba(124, 92, 255, 0.35);
  border-color: var(--partner);
}

button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--border);
  color: var(--text);
}

button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: #fff;
}

button.secondary {
  background: rgba(124, 92, 255, 0.25);
  color: #e0d8ff;
  border: 1px solid rgba(124, 92, 255, 0.4);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.peer-id-box {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px dashed var(--border);
  color: var(--success);
  margin-top: 0.5rem;
}

.status-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.status-line.ok {
  color: var(--success);
}

.status-line.err {
  color: var(--danger);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.preset-grid button {
  background: var(--bg);
  border: 1px solid var(--border);
}

footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.lovense-hint {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 0.5rem;
}
