:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --accent: #ffc72c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #080a0c; }
button, input { font: inherit; }
button { color: inherit; }

.camera-shell { position: relative; width: 100%; height: 100%; height: 100dvh; overflow: hidden; background: radial-gradient(circle at 60% 28%, #323a43, #13171c 58%, #080a0c); }
#camera, #imported-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#camera { --preview-zoom: 1; transform: scale(var(--preview-zoom)); transition: transform .12s ease-out; }
#camera.mirrored { transform: scaleX(-1) scale(var(--preview-zoom)); }
.camera-shell::after { content: ""; pointer-events: none; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.42), transparent 23%, transparent 55%, rgba(0,0,0,.54)); }

.camera-placeholder { position: absolute; z-index: 2; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; background: radial-gradient(circle at 50% 40%, #252b32, #0b0e11 70%); }
.camera-placeholder[hidden] { display: none; }
.placeholder-mark { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; margin-bottom: 18px; color: var(--accent); background: rgba(255,199,44,.12); border: 1px solid rgba(255,199,44,.23); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.placeholder-mark svg { width: 34px; fill: currentColor; }
.camera-placeholder p { margin: 0 0 8px; font-size: 22px; font-weight: 750; }
.camera-placeholder span { max-width: 270px; color: rgba(255,255,255,.56); font-size: 14px; line-height: 1.6; }
.camera-placeholder .primary-button { width: min(76vw, 260px); min-height: 58px; margin-top: 26px; border-radius: 17px; font-size: 17px; box-shadow: 0 10px 30px rgba(255,199,44,.2); touch-action: manipulation; }
.camera-placeholder .primary-button:active { transform: scale(.96); filter: brightness(.92); }
.start-hint { margin-top: 11px; color: rgba(255,255,255,.38); font-size: 11px; }

.topbar { position: absolute; z-index: 4; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 14px) 18px 0; }
.brand-pill, .glass { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); background: rgba(17,20,23,.47); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 8px 32px rgba(0,0,0,.15); }
.brand-pill { height: 40px; padding: 0 15px; display: flex; align-items: center; gap: 9px; border-radius: 999px; font-size: 14px; font-weight: 650; letter-spacing: .02em; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(255,199,44,.14); }
.top-actions { display: flex; gap: 9px; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border-radius: 50%; }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.watermark { position: absolute; z-index: 3; left: clamp(20px, 7vw, 34px); bottom: calc(var(--safe-bottom) + 184px); display: flex; gap: 15px; max-width: calc(100vw - 44px); filter: drop-shadow(0 2px 5px rgba(0,0,0,.72)); transition: opacity .2s, transform .2s; }
.watermark-line { width: 5px; flex: 0 0 5px; border-radius: 5px; background: var(--accent); }
.watermark-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 1px 0; }
.wm-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); align-items: baseline; font-size: clamp(16px, 4.5vw, 23px); font-weight: 620; letter-spacing: .02em; line-height: 1.28; white-space: nowrap; text-shadow: 0 1px 3px #000, 0 0 9px rgba(0,0,0,.35); }
.wm-row[hidden] { display: none; }
.wm-time { font-size: clamp(19px, 5.5vw, 29px); font-weight: 760; margin-bottom: 3px; }
.wm-label { letter-spacing: .12em; }
.wm-note { margin-top: 7px; max-width: 75vw; padding: 6px 10px; width: fit-content; color: #17130a; background: var(--accent); border-radius: 5px; font-size: 13px; font-weight: 750; filter: none; text-shadow: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.zoom-control { position: absolute; z-index: 5; left: 50%; bottom: calc(116px + var(--safe-bottom)); width: min(78vw, 330px); height: 46px; padding: 0 8px; border-radius: 999px; display: grid; grid-template-columns: 38px 1fr 38px 46px; align-items: center; transform: translateX(-50%); }
.zoom-control[hidden] { display: none; }
.zoom-step { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 22px; line-height: 1; touch-action: manipulation; }
.zoom-step:active { background: rgba(255,255,255,.12); }
.zoom-control input { width: 100%; height: 32px; margin: 0; accent-color: var(--accent); touch-action: pan-x; }
.zoom-control output { color: var(--accent); font-size: 13px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

.controls { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; min-height: calc(122px + var(--safe-bottom)); padding: 12px max(28px, calc((100vw - 340px)/2)) calc(14px + var(--safe-bottom)); display: grid; grid-template-columns: 72px 1fr 72px; align-items: center; background: linear-gradient(180deg, transparent, rgba(5,7,9,.72) 35%, rgba(5,7,9,.92)); }
.control-button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 11px; color: rgba(255,255,255,.7); }
.control-button svg { width: 26px; height: 26px; fill: none; stroke: white; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.shutter { justify-self: center; width: 78px; height: 78px; padding: 5px; border: 3px solid white; border-radius: 50%; background: rgba(255,255,255,.12); box-shadow: 0 6px 22px rgba(0,0,0,.3); }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: white; transition: transform .12s, background .12s; }
.shutter:active span { transform: scale(.88); background: var(--accent); }
.shutter:disabled { opacity: .4; }

.sheet { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: white; }
.sheet::backdrop { background: rgba(0,0,0,.48); backdrop-filter: blur(5px); }
.sheet-card { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 10px 20px calc(18px + var(--safe-bottom)); border: 1px solid rgba(255,255,255,.1); border-bottom: 0; border-radius: 26px 26px 0 0; background: #171a1f; box-shadow: 0 -20px 80px rgba(0,0,0,.42); animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(28px); opacity: 0; } }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 16px; border-radius: 4px; background: rgba(255,255,255,.2); }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.sheet-heading h2 { margin: 4px 0 0; font-size: 22px; }
.close-button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 26px; font-weight: 300; line-height: 1; }
.text-field { display: block; margin-bottom: 14px; color: rgba(255,255,255,.62); font-size: 12px; }
.text-field input { display: block; width: 100%; height: 50px; margin-top: 7px; padding: 0 14px; color: white; border: 1px solid rgba(255,255,255,.11); border-radius: 12px; outline: 0; background: rgba(255,255,255,.055); }
.text-field input:focus { border-color: rgba(255,199,44,.6); }
.toggle-list { overflow: hidden; margin-bottom: 18px; border-radius: 14px; background: rgba(255,255,255,.045); }
.toggle-list label { height: 49px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 14px; }
.toggle-list label:last-child { border: 0; }
.toggle-list input { position: absolute; opacity: 0; }
.toggle-list i { position: relative; width: 44px; height: 26px; border-radius: 20px; background: #3c4047; transition: .2s; }
.toggle-list i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.3); transition: .2s; }
.toggle-list input:checked + i { background: var(--accent); }
.toggle-list input:checked + i::after { transform: translateX(18px); }
.primary-button, .secondary-button, .save-settings { height: 52px; border: 0; border-radius: 14px; font-weight: 750; touch-action: manipulation; }
.primary-button, .save-settings { color: #18140a; background: var(--accent); }
.save-settings { width: 100%; }

.result-card { max-height: 92%; overflow-y: auto; }
.result-card > img { display: block; width: min(100%, 460px); max-height: 57vh; margin: 0 auto; border-radius: 15px; object-fit: contain; background: #090a0c; box-shadow: 0 10px 35px rgba(0,0,0,.3); }
.ios-tip { margin: 12px 4px 0; color: rgba(255,255,255,.58); font-size: 12px; text-align: center; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.result-actions button { display: flex; align-items: center; justify-content: center; gap: 7px; }
.result-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.secondary-button { background: rgba(255,255,255,.09); }

.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(145px + var(--safe-bottom)); max-width: calc(100vw - 40px); padding: 10px 16px; border-radius: 999px; color: white; background: rgba(15,17,20,.88); border: 1px solid rgba(255,255,255,.11); backdrop-filter: blur(18px); font-size: 13px; text-align: center; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { display: grid; place-items: center; background: #050607; }
  .camera-shell { width: min(100%, 520px); box-shadow: 0 0 80px rgba(0,0,0,.7); }
  .sheet-card { left: 50%; width: min(520px, 100%); transform: translateX(-50%); }
  @keyframes rise { from { transform: translate(-50%, 28px); opacity: 0; } to { transform: translate(-50%, 0); } }
}

@media (max-height: 650px) {
  .watermark { bottom: calc(var(--safe-bottom) + 142px); }
  .wm-row { font-size: 14px; }
  .wm-time { font-size: 18px; }
  .controls { min-height: calc(96px + var(--safe-bottom)); }
  .shutter { width: 64px; height: 64px; }
  .zoom-control { bottom: calc(92px + var(--safe-bottom)); height: 42px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
