html,
body.beauty-camera-shell {
  height: 100%;
  margin: 0 !important;
  overflow: hidden !important;
}

body.beauty-camera-shell > header,
body.beauty-camera-shell > footer {
  display: none;
}

body.beauty-camera-shell .container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

body.beauty-camera-shell main[role="main"] {
  padding: 0 !important;
}

body.beauty-camera-shell .sd-funnel-widget {
  left: auto !important;
  right: -360px !important;
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

.beauty-camera-root {
  --line: rgba(148, 182, 206, 0.35);
  --panel-bg: rgba(255, 255, 255, 0.96);
  --text: #1c2938;
  --muted: #61788e;
  --primary: #2082f2;
  --primary-dark: #0a66d8;

  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Avenir Next", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: #0f1720;
  color: var(--text);
}

.beauty-stage {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, #2f4f6c 0%, #17232f 58%, #0e151e 100%);
}

#cameraVideo,
#webglCanvas,
#processedCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

#cameraVideo {
  opacity: 0;
  pointer-events: none;
}

#webglCanvas {
  display: block;
  background: radial-gradient(circle at 30% 20%, #2f4f6c 0%, #17232f 58%, #0e151e 100%);
  z-index: 1;
}

#processedCanvas {
  display: block;
  background: transparent;
  z-index: 2;
  pointer-events: none;
}

.beauty-hidden {
  display: none !important;
}

.beauty-top-bar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.beauty-status-stack {
  display: grid;
  gap: 6px;
}

.beauty-top-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.beauty-home-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(193, 222, 249, 0.34);
  background: rgba(8, 19, 30, 0.58);
  color: #f6fbff !important;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  backdrop-filter: blur(6px);
}

.beauty-home-link:hover {
  background: rgba(14, 31, 48, 0.82);
}

.beauty-icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

.beauty-icon-button span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: #2e4358;
}

.beauty-status-badge {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #f4f7fb;
  background: rgba(8, 19, 30, 0.7);
  backdrop-filter: blur(6px);
}

.beauty-warp-guide {
  position: absolute;
  right: 12px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 58px);
  z-index: 6;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(219, 58, 58, 0.92);
}

.beauty-debug-panel {
  position: absolute;
  left: 12px;
  top: calc(max(12px, env(safe-area-inset-top)) + 72px);
  z-index: 6;
  margin: 0;
  width: min(88vw, 390px);
  max-height: min(40dvh, 260px);
  overflow: auto;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(128, 171, 199, 0.48);
  background: rgba(8, 18, 31, 0.73);
  color: #e8f0f7;
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: pre-wrap;
  backdrop-filter: blur(4px);
}

.beauty-error-message {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(max(12px, env(safe-area-inset-top)) + 56px);
  z-index: 4;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: #fff;
  background: rgba(182, 58, 58, 0.92);
}

.beauty-bottom-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
}

.beauty-action {
  border: 0;
  min-height: 48px;
  border-radius: 999px;
  padding: 0 14px;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.93rem;
}

.beauty-action.capture {
  min-width: 84px;
  color: #fff;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 10px 26px rgba(13, 95, 198, 0.5);
}

.beauty-action.secondary {
  color: #2f4a63;
  background: rgba(255, 255, 255, 0.92);
}

.beauty-action.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #16a176;
}

.beauty-action.download.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.beauty-backdrop {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: rgba(7, 14, 22, 0.48);
}

.beauty-settings-panel {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  width: min(92vw, 410px);
  height: 100dvh;
  max-height: 100dvh;
  background: var(--panel-bg);
  box-shadow: -14px 0 34px rgba(0, 0, 0, 0.24);
  border-left: 1px solid var(--line);
  transform: translateX(106%);
  transition: transform 200ms ease;
  overflow-y: auto;
  overflow-x: hidden;
  padding: max(12px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
}

.beauty-settings-panel.is-open {
  transform: translateX(0%);
}

.beauty-settings-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -2px -2px 8px;
  padding: 4px 2px 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-bottom: 1px solid rgba(133, 167, 192, 0.22);
}

.beauty-settings-header h1 {
  margin: 0;
  font-size: 1.08rem;
}

.beauty-close-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: #edf5fc;
  color: #35506b;
  font-size: 1.3rem;
  line-height: 1;
}

.beauty-settings-section {
  margin-bottom: 12px;
  border: 1px solid rgba(151, 183, 206, 0.38);
  border-radius: 12px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.75);
}

.beauty-settings-section h2 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #2b445e;
}

.beauty-settings-note {
  margin: 0 0 8px;
  font-size: 0.76rem;
  color: #516a82;
}

.beauty-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.84rem;
}

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

.beauty-switch-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.beauty-select-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.beauty-select-row label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #304a63;
}

.beauty-select-row select {
  width: 100%;
  border: 1px solid rgba(143, 181, 210, 0.62);
  border-radius: 12px;
  min-height: 38px;
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2c455f;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(241, 248, 255, 0.95) 100%);
}

.beauty-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 10px;
  margin-bottom: 11px;
}

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

.beauty-advanced-panel {
  margin-top: 8px;
  border: 1px solid rgba(151, 183, 206, 0.44);
  border-radius: 11px;
  background: rgba(245, 251, 255, 0.84);
}

.beauty-advanced-panel > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #2f4e67;
}

.beauty-advanced-panel > summary::-webkit-details-marker {
  display: none;
}

.beauty-advanced-panel > summary::after {
  content: "＋";
  float: right;
  color: #4c6982;
}

.beauty-advanced-panel[open] > summary::after {
  content: "−";
}

.beauty-advanced-body {
  padding: 0 9px 9px;
  border-top: 1px solid rgba(151, 183, 206, 0.36);
}

.beauty-mobile-tabbar {
  display: none;
  gap: 8px;
  margin: 0 0 10px;
}

.beauty-mobile-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(125, 165, 196, 0.48);
  border-radius: 999px;
  background: rgba(248, 252, 255, 0.96);
  color: #34556f;
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.beauty-mobile-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.beauty-mobile-tab-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.beauty-mobile-tab.is-active {
  border-color: rgba(34, 126, 232, 0.52);
  background: linear-gradient(180deg, rgba(56, 149, 255, 0.14) 0%, rgba(108, 179, 255, 0.2) 100%);
  color: #165b9b;
}

.beauty-control-row label {
  grid-column: 1 / -1;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.45;
  color: #304a63;
}

.beauty-control-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(90deg, #8fd2ff 0%, #4e9eff 52%, #2382f5 100%);
  box-shadow: inset 0 0 0 1px rgba(74, 127, 164, 0.24), 0 2px 8px rgba(24, 99, 171, 0.2);
}

.beauty-control-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: linear-gradient(180deg, #2f95ff 0%, #0f70df 100%);
  box-shadow: 0 4px 12px rgba(17, 85, 161, 0.45);
  cursor: pointer;
}

.beauty-control-row input[type="range"]::-moz-range-track {
  height: 7px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(90deg, #8fd2ff 0%, #4e9eff 52%, #2382f5 100%);
  box-shadow: inset 0 0 0 1px rgba(74, 127, 164, 0.24), 0 2px 8px rgba(24, 99, 171, 0.2);
}

.beauty-control-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: linear-gradient(180deg, #2f95ff 0%, #0f70df 100%);
  box-shadow: 0 4px 12px rgba(17, 85, 161, 0.45);
  cursor: pointer;
}

.beauty-control-row input[type="range"]:focus-visible {
  outline: 2px solid rgba(32, 130, 242, 0.4);
  outline-offset: 3px;
}

.beauty-control-row input[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.beauty-control-row output {
  min-width: 40px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #1d4569;
  background: rgba(208, 232, 252, 0.75);
  border: 1px solid rgba(139, 185, 219, 0.45);
  font-variant-numeric: tabular-nums;
}

.beauty-ui-hidden,
.beauty-dev-only {
  display: none !important;
}

.beauty-tools-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.beauty-tools-row--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.beauty-mini-button {
  min-height: 32px;
  border: 1px solid rgba(125, 165, 196, 0.58);
  border-radius: 9px;
  background: rgba(247, 251, 255, 0.98);
  color: #28445e;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0 8px;
  cursor: pointer;
}

.beauty-mini-button:hover {
  background: rgba(234, 244, 252, 1);
}

.beauty-mini-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.beauty-danger-button {
  border-color: rgba(192, 74, 74, 0.58);
  color: #8b2222;
  background: rgba(255, 241, 241, 0.96);
}

.beauty-danger-button:hover {
  background: rgba(255, 230, 230, 1);
}

.beauty-install-hint {
  margin: 8px 0 0;
}

.beauty-preview {
  border: 1px solid rgba(151, 183, 206, 0.38);
  border-radius: 12px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.75);
}

.beauty-preview h2 {
  margin: 0 0 7px;
  font-size: 0.9rem;
}

.beauty-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.beauty-preview-loading {
  margin: 0 0 8px;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(32, 130, 242, 0.88);
}

.beauty-preview #previewImage {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(151, 183, 206, 0.38);
  background: #fff;
}

.beauty-preview-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.beauty-preview-compare figure {
  margin: 0;
}

.beauty-preview-compare figcaption {
  margin-bottom: 4px;
  font-size: 0.74rem;
  color: #4b657d;
}

.beauty-preview-compare img {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(151, 183, 206, 0.38);
  background: #fff;
}

.beauty-preview #previewHint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

@supports not (height: 100dvh) {
  .beauty-camera-root {
    height: 100vh;
  }

  .beauty-settings-panel {
    height: 100vh;
    max-height: 100vh;
  }
}

@media (min-width: 768px) {
  .beauty-bottom-bar {
    left: auto;
    width: 430px;
    right: 18px;
    bottom: 16px;
  }

  .beauty-settings-panel {
    width: min(460px, 50vw);
  }
}

@media (max-width: 768px) {
  body.beauty-camera-shell .sd-funnel-widget {
    left: auto !important;
    right: -320px !important;
  }

  .beauty-backdrop {
    background: linear-gradient(180deg, rgba(7, 14, 22, 0.08) 0%, rgba(7, 14, 22, 0.62) 46%, rgba(7, 14, 22, 0.76) 100%);
  }

  .beauty-settings-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: min(42dvh, 360px);
    max-height: calc(100dvh - 120px);
    border-left: 0;
    border-top: 1px solid rgba(174, 203, 226, 0.52);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.36);
    transform: translateY(calc(100% + 18px));
    transition: transform 240ms cubic-bezier(0.2, 0.72, 0.24, 1);
    padding: 14px 12px calc(max(16px, env(safe-area-inset-bottom)) + 8px);
    pointer-events: none;
    background:
      radial-gradient(320px 180px at 12% 6%, rgba(144, 203, 255, 0.22), transparent 68%),
      linear-gradient(180deg, rgba(246, 251, 255, 0.98) 0%, rgba(233, 243, 253, 0.96) 100%);
  }

  .beauty-settings-panel::before {
    content: "";
    position: sticky;
    top: 0;
    display: block;
    width: 44px;
    height: 5px;
    margin: 0 auto 8px;
    border-radius: 999px;
    background: rgba(93, 134, 167, 0.46);
    z-index: 3;
    pointer-events: none;
  }

  .beauty-settings-panel.is-open {
    transform: translateY(0);
    pointer-events: auto;
  }

  .beauty-settings-header {
    margin: 0 0 10px;
    padding: 2px 0 10px;
    background: linear-gradient(180deg, rgba(246, 251, 255, 0.98) 0%, rgba(246, 251, 255, 0.72) 100%);
    border-bottom: 1px solid rgba(145, 178, 206, 0.28);
  }

  .beauty-settings-header h1 {
    font-size: 0.96rem;
    letter-spacing: 0.03em;
    color: #2a4964;
  }

  .beauty-settings-section {
    border-radius: 16px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(151, 183, 206, 0.34);
  }

  .beauty-settings-panel.is-mobile-layout .beauty-mobile-tabbar {
    display: flex;
    position: sticky;
    top: 46px;
    z-index: 3;
    padding: 8px 2px 10px;
    margin: 0 0 8px;
    background: linear-gradient(180deg, rgba(243, 249, 255, 0.96) 0%, rgba(243, 249, 255, 0.84) 100%);
    border-bottom: 1px solid rgba(145, 178, 206, 0.24);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .beauty-settings-panel.is-mobile-layout .beauty-mobile-tabbar::-webkit-scrollbar {
    display: none;
  }

  .beauty-settings-panel.is-mobile-layout .beauty-mobile-tab-panel {
    display: none;
  }

  .beauty-settings-panel.is-mobile-layout .beauty-mobile-tab-panel.is-active {
    display: block;
  }

  .beauty-settings-panel.is-mobile-layout .beauty-mobile-hidden-section {
    display: none !important;
  }

  .beauty-settings-panel.is-mobile-layout .beauty-mobile-tab {
    min-height: 36px;
    padding: 0 11px;
  }

  .beauty-home-link {
    min-height: 32px;
    padding: 0 11px;
    font-size: 0.75rem;
  }

  .beauty-tools-row--triple {
    grid-template-columns: 1fr 1fr;
  }
}
