:root { color-scheme: dark; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: #0a0a16;
}

/* Fullscreen animated background */
#bg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at 50% 45%,
      rgba(0,0,0,0.00) 0%,
      rgba(0,0,0,0.24) 72%,
      rgba(0,0,0,0.44) 100%);
  mix-blend-mode: multiply;
}

/* FAB Stack */
.fab-stack {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 26;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* UI Panel */
.panel {
  width: min(300px, calc(100vw - 24px));
  max-height: calc(50dvh - 24px - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(10px) saturate(150%);
  box-shadow: 0 18px 60px rgba(0,0,0,0.25);
  overflow: hidden;
  color: rgba(255,255,255,0.92);
}
.panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}
.panel header > div:first-child {
  flex: 1;
  min-width: 0;
}
.panel header .titleText {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.panel header .hint {
  display: block;
  font-size: 11px;
  opacity: 0.8;
  margin-top: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.panel header .right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.panel button {
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.98);
  border-radius: 999px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 11px;
  transition: background .2s ease, transform .15s ease;
  user-select: none;
}
.panel button:hover { background: rgba(0,0,0,0.6); transform: translateY(-1px); }
.panel button:active { transform: translateY(0) scale(0.98); }

.panel .body {
  padding: 10px;
  display: grid;
  gap: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.row { display: grid; gap: 6px; }
.row-inline .inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row label,
.row .row-label {
  font-size: 11px;
  opacity: 0.86;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.row label span.value,
.row .row-label span.value {
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

select, input[type="range"], input[type="text"] {
  width: 100%;
  accent-color: #ff00d4;
}

datalist#videoResolutionStops {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: rgba(255,255,255,0.6);
  font-size: 10px;
}

.align-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
  background: transparent;
  box-shadow: none;
}

.align-btn {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.92);
  border-radius: 10px;
  padding: 8px 0;
  cursor: pointer;
  transition: background .2s ease, transform .15s ease, border-color .2s ease;
}

.align-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.align-btn[aria-pressed="true"] {
  background: rgba(62, 0, 52, 0.7);
  border-color: rgba(255, 0, 212, 0.55);
  color: #fff;
}

.align-btn:active { transform: scale(0.98); }

input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.25);
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

input[type="text"] {
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  color: rgba(255,255,255,0.96);
  padding: 8px 10px;
}

.panel.collapsed { display: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.ui-hidden .vignette,
body.ui-hidden .fab-stack,
body.panel-collapsed .vignette {
  display: none !important;
}

body.invert-mode {
  background: var(--invert-color, #f4f1ec);
}

body.invert-mode #bg {
  background: var(--invert-color, #f4f1ec);
}

.mobile-actions {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(8px) saturate(140%);
}

.mobile-actions button {
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.94);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
}

.mobile-actions .fab-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.record-btn {
  position: relative;
}

.record-btn .record-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  display: inline-block;
}

.record-btn.is-recording {
  background: rgba(255, 35, 35, 0.2);
  border-color: rgba(255, 35, 35, 0.65);
  color: #fff;
}

.record-btn.is-recording .record-dot {
  background: #ff2b2b;
  box-shadow: 0 0 12px rgba(255, 43, 43, 0.6);
}

.mobile-actions button:active {
  transform: scale(0.98);
}

#actionPanel .fab-icon {
  display: inline-block;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .fab-stack {
    right: 12px;
    bottom: 12px;
  }
  .panel {
    width: min(280px, calc(100vw - 24px));
    max-height: calc(50dvh - 24px - env(safe-area-inset-bottom));
  }
  .panel .body {
    padding: 8px;
    gap: 6px;
  }
  .panel header .titleText { font-size: 13px; }
  .panel header .hint { font-size: 10px; }
  .row label { font-size: 10px; }
  .mobile-actions { display: flex; }
}

@media (max-height: 520px) {
  .fab-stack {
    right: 10px;
    bottom: 10px;
  }
  .panel {
    width: min(240px, calc(100vw - 20px));
    max-height: calc(50dvh - 20px - env(safe-area-inset-bottom));
  }
  .panel .body { padding: 6px; gap: 5px; }
  .panel header .titleText { font-size: 12px; }
  .panel header .hint { font-size: 9px; }
  .row label { font-size: 9px; }
  .mobile-actions { display: flex; }
}
