:root {
  color-scheme: light;
  --ground: #edf2f6;
  --sheet: #fff;
  --well: #f3f6f8;
  --line: #e1e7eb;
  --ink: #18232d;
  --muted: #506171;
  --accent: #256383;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
body { margin: 0 auto; max-width: 1280px; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: 22px; line-height: 1.2; }
h2 { font-size: 16px; }
.top { min-height: 64px; padding: 10px 24px; display: flex; gap: 16px; align-items: center; }
.heading span { color: var(--muted); }
button { color: inherit; font: inherit; padding: 6px 12px; min-height: 36px; background: white; border: 1px solid #bfcbd5; border-radius: 6px; cursor: pointer; }
button:hover:not(:disabled) { background: #e9eff4; }
button:disabled { color: var(--muted); cursor: default; }
button.primary { background: var(--ink); color: white; border-color: var(--ink); }
button.primary:hover:not(:disabled) { background: #304454; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0 auto 16px; width: calc(100% - 32px); max-width: 760px; }
.controls, .preview { min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--sheet); padding: 18px; }
.controls { grid-row: 1; align-self: start; padding: 0 18px; }
.controls[open] { padding-bottom: 18px; }
.controls:not([open]) > :not(summary) { display: none; }
.controls summary { cursor: pointer; padding: 11px 0; font-weight: 600; }
.controls section:first-of-type { margin-top: 8px; }
.controls section + section { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.controls h2 { margin-bottom: 10px; }
.segments { display: flex; gap: 5px; }
.effects { justify-content: center; margin: 0 0 12px; }
.segments button[aria-pressed="true"] { background: #e0ebf2; border-color: #7f9caf; font-weight: 600; }
p { color: var(--muted); font-size: 13px; }
.controls p { margin: 8px 0; }
.range, .colors, dl div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
output, dd { font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 26px; margin: 0 0 5px; accent-color: var(--accent); }
.colors { margin: 5px 0 8px; }
.colors label, .check { display: flex; gap: 5px; align-items: center; }
input[type="color"] { width: 29px; height: 28px; padding: 2px; border: 1px solid #bfcbd5; border-radius: 4px; background: white; }
dl div + div { margin-top: 4px; }
.preview { background: var(--well); }
.heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stage { position: relative; width: min(100%, 360px); aspect-ratio: 9/16; margin: auto; overflow: hidden; border-radius: 8px; background: #1b1c1e; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage[data-camera-lobby] canvas { visibility: hidden; }
.camera-controls { position: absolute; right: 10px; bottom: 10px; left: 10px; display: flex; align-items: center; gap: 8px; justify-content: space-between; pointer-events: none; }
.stage[data-camera-live] .camera-controls { display: none; }
.camera-controls p { padding: 4px 7px; border-radius: 4px; color: white; background: #222428; }
.camera-controls button { flex: none; pointer-events: auto; background: #36383c; border-color: #57595e; }
.stage[data-camera-lobby] .camera-controls { inset: 0; flex-direction: column-reverse; justify-content: center; text-align: center; padding: 20px; }
.stage[data-camera-lobby] .camera-controls button { color: #fff; }
.stage[data-camera-lobby] .camera-controls p { background: transparent; color: rgb(255 255 255 / 72%); }
@media (min-width: 850px) {
  main { grid-template-columns: 306px minmax(0, 1fr); max-width: 1040px; }
  .controls { grid-column: 1; }
  .preview { grid-area: 1 / 2; }
}
@media (max-width: 680px), (max-height: 600px) and (pointer: coarse) {
  .top, .heading, .controls { display: none; }
  main { display: block; width: 100%; max-width: none; margin: 0; }
  .preview { position: relative; padding: 0; border: 0; border-radius: 0; }
  .stage {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    background: #000;
  }
  .stage canvas { object-fit: cover; pointer-events: none; }
  .effects {
    position: absolute;
    z-index: 1;
    inset-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    gap: 8px;
  }
  .effects button, .camera-controls button {
    min-height: 44px;
    padding-inline: 16px;
    font-size: 16px;
  }
  .stage:not([data-camera-lobby]) .camera-controls {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  @media (orientation: landscape) {
    .stage canvas { object-fit: contain; }
  }
}
