:root {
  color-scheme: dark;
  --light-rgb: 255 246 234;
  --brightness: 0.86;
  --temperature-wash: rgba(255, 240, 213, 0.25);
  --page-ink: #13181c;
  --panel: rgba(21, 26, 30, 0.86);
  --panel-solid: #1b2024;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.25);
  --text: #f8fafb;
  --muted: rgba(248, 250, 251, 0.63);
  --accent: #ffbd76;
  --active-text: #162027;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--text);
  background: var(--page-ink);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

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

.light-stage {
  position: relative;
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  background: #181d20;
}

.light-surface {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    var(--pattern-light),
    radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, 0.42), transparent 41%),
    linear-gradient(140deg, rgba(255, 255, 255, 0.2), var(--temperature-wash)),
    rgb(var(--light-rgb));
  filter: brightness(calc(0.28 + var(--brightness) * 0.9));
  transition:
    background 240ms ease,
    filter 180ms ease;
}

.pattern-ring {
  --pattern-light: radial-gradient(ellipse at 50% 43%, rgba(24, 29, 32, 0.04) 0 22%, transparent 23%, rgba(var(--light-rgb) / 0.96) 55% 100%);
}

.pattern-left {
  --pattern-light: linear-gradient(90deg, rgba(255, 255, 255, 0.78), transparent 47%, rgba(32, 35, 38, 0.16) 100%);
}

.pattern-right {
  --pattern-light: linear-gradient(270deg, rgba(255, 255, 255, 0.78), transparent 47%, rgba(32, 35, 38, 0.16) 100%);
}

.pattern-bottom {
  --pattern-light: linear-gradient(0deg, rgba(255, 255, 255, 0.78), transparent 45%, rgba(32, 35, 38, 0.11) 100%);
}

.app-header {
  position: relative;
  z-index: 6;
  display: flex;
  height: 70px;
  flex: 0 0 auto;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px 7px 9px;
  background: rgba(18, 23, 27, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 7px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 189, 118, 0.6);
}

.brand p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.privacy-pill {
  margin: 0 auto;
  padding: 7px 13px;
  color: rgba(22, 29, 33, 0.76);
  background: rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.app-actions {
  display: flex;
  gap: 8px;
}

.locale-picker {
  position: relative;
}

.locale-button {
  display: flex;
  height: 42px;
  min-width: 72px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  background: rgba(18, 23, 27, 0.25);
  border: 1px solid rgba(24, 30, 34, 0.16);
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

.locale-button:hover {
  background: rgba(18, 23, 27, 0.38);
}

.locale-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 8;
  width: min(270px, calc(100vw - 24px));
  max-height: min(70dvh, 520px);
  overflow-y: auto;
  padding: 7px;
  background: #101a1e;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

.locale-menu[hidden] {
  display: none;
}

.locale-option {
  display: grid;
  width: 100%;
  min-height: 42px;
  grid-template-columns: 18px 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 0.94rem;
  text-align: left;
}

.locale-option:hover,
.locale-option:focus-visible,
.locale-option[aria-checked="true"] {
  background: rgba(255, 255, 255, 0.09);
}

.locale-indicator {
  color: #ffffff;
  font-size: 0.68rem;
}

.locale-flag {
  font-size: 1.08rem;
}

.icon-button,
.restore-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: rgba(18, 23, 27, 0.25);
  border: 1px solid rgba(24, 30, 34, 0.16);
  border-radius: 8px;
  font-size: 1.1rem;
}

.icon-button:hover,
.restore-button:hover {
  background: rgba(18, 23, 27, 0.38);
}

.mirror-preview {
  position: absolute;
  z-index: 1;
  top: 62px;
  left: 50%;
  display: grid;
  width: min(31vw, 326px);
  height: min(calc(100dvh - 344px), 48dvh);
  min-height: 238px;
  place-items: center;
  overflow: hidden;
  background: rgba(28, 34, 39, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 28px;
  box-shadow:
    0 14px 42px rgba(19, 24, 28, 0.22),
    0 0 0 9px rgba(255, 255, 255, 0.09);
  transform: translateX(-50%);
}

#mirrorVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  object-fit: cover;
  transform: scaleX(-1);
}

.mirror-frame {
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 19px;
  pointer-events: none;
}

.camera-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 22px;
  text-align: center;
}

.camera-indicator {
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 50%;
  box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.14);
}

.camera-overlay h2 {
  margin: 0 0 7px;
  font-size: 1.08rem;
  letter-spacing: 0;
}

.camera-overlay p {
  max-width: 200px;
  min-height: 38px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.primary-button {
  min-height: 42px;
  padding: 0 20px;
  color: var(--active-text);
  background: #ffffff;
  border: 0;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.live-status {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  left: 12px;
  display: none;
  align-items: center;
  gap: 6px;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #e95355;
  border-radius: 50%;
}

.live-status button {
  margin-left: auto;
  padding: 5px 9px;
  background: rgba(12, 16, 20, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  font-size: 0.68rem;
}

.mirror-preview.is-active #mirrorVideo {
  display: block;
}

.mirror-preview.is-active .live-status {
  display: flex;
}

.mirror-preview.is-active .camera-overlay {
  display: none;
}

.mirror-preview.is-requesting .camera-indicator {
  border-color: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  50% {
    transform: scale(0.88);
    opacity: 0.55;
  }
}

.control-panel {
  position: relative;
  z-index: 3;
  display: grid;
  width: min(1100px, calc(100vw - 24px));
  margin: auto auto 12px;
  padding: 15px;
  grid-template-columns: 2fr 1.2fr 1.65fr 1.65fr;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px) saturate(135%);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.panel-section {
  min-width: 0;
}

.panel-section + .panel-section {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.section-head {
  display: flex;
  min-height: 22px;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.panel-section h2 {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
}

.section-head h2 {
  margin: 0;
}

.badge {
  padding: 3px 7px;
  color: var(--accent);
  border: 1px solid rgba(255, 189, 118, 0.3);
  border-radius: 999px;
  font-size: 0.66rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 11px;
}

.preset {
  min-width: 0;
  min-height: 60px;
  padding: 7px 5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.preset span,
.preset small {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.preset span {
  font-size: 0.74rem;
  font-weight: 700;
}

.preset small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.64rem;
}

.preset.is-active {
  color: var(--active-text);
  background: #ffffff;
  border-color: #ffffff;
}

.preset.is-active small {
  color: rgba(22, 32, 39, 0.62);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.segmented-control button {
  min-height: 39px;
  padding: 5px 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.segmented-control button.is-active {
  color: var(--active-text);
  background: #ffffff;
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(56px, auto) 48px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  font-size: 0.73rem;
  font-weight: 700;
}

.control-row output {
  color: var(--muted);
  font-weight: 500;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  accent-color: #ffffff;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.color-field legend {
  padding: 0;
  font-size: 0.73rem;
  font-weight: 700;
}

.swatches {
  display: flex;
  align-items: center;
  gap: 7px;
}

.swatch,
#customColor {
  width: 27px;
  height: 27px;
  padding: 0;
  border-radius: 50%;
}

.swatch {
  border: 2px solid rgba(255, 255, 255, 0.34);
}

.swatch[data-color="#fff6ea"] { background: #fff6ea; }
.swatch[data-color="#f8fbff"] { background: #f8fbff; }
.swatch[data-color="#ffd8c7"] { background: #ffd8c7; }
.swatch[data-color="#ffffff"] { background: #ffffff; }
.swatch[data-color="#ffe3f1"] { background: #ffe3f1; }

.swatch.is-active,
#customColor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#customColor {
  background: transparent;
  border: 1px solid var(--line-strong);
}

#recipeNotice {
  min-height: 16px;
  color: var(--accent);
  font-size: 0.66rem;
  text-align: right;
}

.recipes {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.recipe {
  display: grid;
  grid-template-columns: minmax(58px, 1fr) auto auto auto;
  align-items: center;
  gap: 5px;
  min-height: 35px;
}

.recipe strong,
.recipe small {
  display: block;
  font-size: 0.69rem;
}

.recipe small {
  color: var(--muted);
}

.recipe button {
  min-height: 30px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.68rem;
  white-space: normal;
}

.recipe .save-recipe {
  background: rgba(255, 255, 255, 0.09);
}

.recipe .clear-recipe {
  color: var(--muted);
}

.recipe.is-confirming .save-recipe {
  color: var(--accent);
  border-color: rgba(255, 189, 118, 0.44);
}

.recipe.is-deleting .clear-recipe {
  color: var(--accent);
  border-color: rgba(255, 189, 118, 0.44);
}

.restore-button {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

body.controls-hidden .control-panel {
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
}

body.controls-hidden .mirror-preview {
  height: min(calc(100dvh - 102px), 73dvh);
}

body.controls-hidden .restore-button {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .app-header {
    height: 60px;
    padding: 9px 12px;
  }

  .privacy-pill {
    display: none;
  }

  .app-actions {
    margin-left: auto;
  }

  .brand h1 {
    font-size: 0.98rem;
  }

  .locale-button {
    min-width: 62px;
    padding: 0 8px;
  }

  .mirror-preview {
    top: 67px;
    width: min(56vw, 250px);
    height: min(calc(47dvh - 85px), 320px);
    min-height: 178px;
    border-radius: 22px;
  }

  .control-panel {
    display: block;
    max-height: 53dvh;
    margin: auto 8px 8px;
    width: calc(100vw - 16px);
    overflow-y: auto;
    padding: 13px;
  }

  .panel-section + .panel-section {
    margin-top: 14px;
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .preset-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .segmented-control {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .adjust-section {
    display: grid;
    grid-template-columns: 1fr;
  }

  .recipes {
    gap: 8px;
  }

  .recipe {
    grid-template-columns: minmax(88px, 1fr) auto auto auto;
  }
}

@media (max-height: 700px) and (min-width: 901px) {
  .mirror-preview {
    height: 38dvh;
    min-height: 190px;
  }

  .control-panel {
    padding: 12px;
  }
}
