:root {
  --case: #2b211b;
  --case-hi: #473a30;
  --leather: #1d1714;
  --cream: #efe4ce;
  --muted: #9e9182;
  --amber: #e2a05f;
  --red: #c94f3b;
  --green: #8af0bc;
  --shadow: rgba(5, 3, 2, 0.62);
  color-scheme: dark;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: #17110e; }
body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  color: var(--cream);
  background:
    radial-gradient(65% 40% at 50% -10%, rgba(211, 139, 81, 0.12), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 5px),
    #17110e;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: max(9px, env(safe-area-inset-top)) 14px 9px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(23, 17, 14, 0.88);
  backdrop-filter: blur(18px);
}
.back-link { justify-self: start; color: #d9cfbf; text-decoration: none; font-size: 13px; }
.back-link span { margin-left: 3px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 12px; letter-spacing: .16em; }
.brand small { margin-top: 3px; color: #88796b; font-size: 7px; letter-spacing: .2em; }
.brand-reel {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226,160,95,.5);
  border-radius: 50%;
}
.brand-reel::before, .brand-reel::after, .brand-reel i {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--amber);
}
.brand-reel::before { transform: translateY(-6px); }
.brand-reel::after { transform: translateY(6px); }
.brand-reel i { transform: translateX(6px); }
.mode-light { justify-self: end; display: flex; align-items: center; gap: 6px; color: #8d8175; font-size: 9px; }
.mode-light i { width: 7px; height: 7px; border-radius: 50%; background: #6e3128; }
body.is-live .mode-light i { background: var(--green); box-shadow: 0 0 9px rgba(138,240,188,.75); }

.page {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 28px) 30px;
}

.camera-shell {
  position: relative;
  width: min(500px, 100%);
  margin: 0 auto;
  border-radius: 18px 18px 24px 24px;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px),
    linear-gradient(155deg, #3f3229, #241b16 58%, #17110e);
  border: 1px solid rgba(255,240,211,.14);
  box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.12);
}
.top-plate {
  position: relative;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 19px;
  border-radius: 18px 18px 0 0;
  border-bottom: 1px solid rgba(0,0,0,.42);
  color: #bdae9b;
  background: linear-gradient(180deg, #665448, #362a23 60%, #2c211b);
  box-shadow: inset 0 1px rgba(255,255,255,.18), inset 0 -2px rgba(0,0,0,.4);
}
.engraving { font-size: 7px; font-weight: 700; letter-spacing: .19em; text-shadow: 0 -1px rgba(0,0,0,.7); }
.engraving.right { color: #9f8d7a; }
.rewind { width: 25px; height: 25px; border: 3px solid #211815; border-radius: 50%; background: #17110e; box-shadow: inset 0 0 0 3px #716052, 0 2px 3px rgba(0,0,0,.5); }
.rewind i { display: block; width: 100%; height: 2px; background: #8e7d6c; transform: rotate(32deg); }
.hot-shoe { position: absolute; left: 50%; top: -7px; width: 46px; height: 11px; transform: translateX(-50%); border-radius: 2px 2px 0 0; background: #17110e; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }

.camera-body {
  position: relative;
  padding: 19px 19px 14px 60px;
  background:
    radial-gradient(circle at 12% 25%, rgba(255,255,255,.04), transparent 20%),
    linear-gradient(90deg, #1c1613 0 38px, #211915 38px 100%);
}
.lens-ring {
  position: absolute;
  left: 9px;
  top: 22px;
  width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.lens-glass {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #65544a, #17110f 55%, #070505);
  border: 2px solid #7b6756;
  box-shadow: inset 0 0 8px #000, 0 2px 5px #000;
}
.lens-glass i { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(148,195,191,.7), #102d2b 55%, #020505); }
.lens-ring small { color: #7c6d60; font-size: 5px; letter-spacing: .08em; writing-mode: horizontal-tb; }

.viewfinder-wrap {
  padding: 5px;
  border-radius: 10px;
  background: #0b0908;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 2px 10px rgba(0,0,0,.7);
}
.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 46dvh;
  overflow: hidden;
  border-radius: 5px;
  background:
    radial-gradient(70% 70% at 50% 45%, rgba(117,141,128,.2), transparent 75%),
    #070807;
  isolation: isolate;
}
#cameraVideo, #previewCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#cameraVideo { visibility: hidden; }
#previewCanvas { display: block; background: #070807; }
.viewfinder-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255,255,255,.085), transparent 22%, transparent 75%, rgba(255,255,255,.03)),
    radial-gradient(100% 100% at 50% 50%, transparent 62%, rgba(0,0,0,.38) 100%);
  mix-blend-mode: screen;
}
.frame-corners i { position: absolute; width: 19px; height: 19px; border-color: rgba(243,220,185,.54); border-style: solid; pointer-events: none; }
.frame-corners i:nth-child(1) { left: 9px; top: 9px; border-width: 1px 0 0 1px; }
.frame-corners i:nth-child(2) { right: 9px; top: 9px; border-width: 1px 1px 0 0; }
.frame-corners i:nth-child(3) { left: 9px; bottom: 9px; border-width: 0 0 1px 1px; }
.frame-corners i:nth-child(4) { right: 9px; bottom: 9px; border-width: 0 1px 1px 0; }

.camera-curtain {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(102,80,61,.28), transparent 72%),
    rgba(12,10,8,.94);
  transition: opacity .25s ease, visibility .25s ease;
}
.camera-curtain.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.curtain-mark { width: 44px; height: 44px; margin-bottom: 14px; border: 1px solid rgba(226,160,95,.55); border-radius: 50%; display: grid; place-items: center; }
.curtain-mark::before { content: ""; width: 21px; height: 21px; border-radius: 50%; border: 2px solid var(--amber); }
.eyebrow { margin: 0 0 8px; color: var(--amber); font-size: 8px; font-weight: 700; letter-spacing: .22em; }
.camera-curtain h1 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: clamp(26px, 7vw, 38px); font-weight: 400; }
.camera-curtain > p:not(.eyebrow):not(.camera-error) { max-width: 360px; margin: 10px 0 17px; color: #a89c90; font-size: 10px; line-height: 1.7; }
.start-button { border: 0; border-radius: 999px; padding: 10px 19px; color: #2a1a10; background: linear-gradient(180deg, #f1bc84, #d68a4c); font-weight: 800; font-size: 11px; cursor: pointer; box-shadow: 0 8px 18px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.3); }
.camera-error { min-height: 16px; margin: 9px 0 0; color: #f19587; font-size: 9px; line-height: 1.4; }

.vf-hud { position: absolute; left: 11px; right: 11px; bottom: 9px; z-index: 4; display: flex; justify-content: space-between; color: rgba(250,225,193,.78); font-size: 7px; letter-spacing: .14em; text-shadow: 0 1px 3px #000; pointer-events: none; }
.processing {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  text-align: center;
  background: rgba(10,8,7,.8);
  backdrop-filter: blur(7px);
}
.processing strong { font-family: "Songti SC", "STSong", serif; font-size: 20px; font-weight: 400; }
.processing small { color: #a09487; font-size: 9px; }
.processing-coil { width: 36px; height: 36px; border: 1px solid #7a6553; border-radius: 50%; position: relative; animation: spin 1.2s linear infinite; }
.processing-coil::before, .processing-coil::after, .processing-coil i { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.processing-coil::before { left: 4px; top: 4px; }
.processing-coil::after { right: 4px; top: 4px; }
.processing-coil i { left: 14px; bottom: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.lower-plate {
  position: relative;
  min-height: 110px;
  display: grid;
  grid-template-columns: 1fr 1fr 44px 76px;
  gap: 10px;
  align-items: center;
  padding: 14px 18px 17px;
  border-radius: 0 0 24px 24px;
  background: linear-gradient(180deg, #382c24, #211913);
  border-top: 1px solid rgba(255,255,255,.09);
}
.dial-control { min-width: 0; }
.dial-control > span { display: block; margin-bottom: 5px; color: #948576; font-size: 8px; letter-spacing: .1em; }
.dial-control select {
  width: 100%;
  padding: 9px 23px 9px 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  color: #e9decc;
  background: #16110e;
  font-size: 9px;
  outline: none;
}
.dial-control select:disabled { opacity: .48; }
.round-control, .shutter { align-self: end; border: 0; cursor: pointer; }
.round-control { width: 38px; height: 38px; border-radius: 50%; color: #d9c7b1; background: linear-gradient(145deg, #514135, #211916); box-shadow: inset 0 1px rgba(255,255,255,.18), 0 3px 7px rgba(0,0,0,.45); font-size: 17px; }
.shutter { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(145deg, #d7c6ad, #706053); padding: 6px; box-shadow: 0 5px 12px rgba(0,0,0,.48); }
.shutter-ring { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, #3e332b, #17120f); border: 2px solid #8c7561; }
.shutter-ring i { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 36% 30%, #e27d67, #b74432 54%, #6e2118); box-shadow: inset 0 1px rgba(255,255,255,.3), 0 2px 5px #000; }
.shutter:disabled { opacity: .42; }
.shutter:active:not(:disabled) { transform: scale(.96); }

.camera-notes {
  width: min(500px, 100%);
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.camera-notes > div { padding: 10px 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; background: rgba(255,255,255,.025); }
.camera-notes strong { display: block; margin-top: 4px; font-size: 9px; font-weight: 500; color: #c3b6a6; }
.note-label { color: #7e7063; font-size: 7px; letter-spacing: .13em; }
.camera-notes > p { grid-column: 1 / -1; margin: 0 4px; color: #75695f; font-size: 8px; line-height: 1.65; }

.result-dialog {
  width: min(620px, calc(100vw - 18px));
  max-height: calc(100dvh - 18px);
  padding: 0;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 17px;
  color: var(--cream);
  background: #211a16;
  box-shadow: 0 30px 100px rgba(0,0,0,.7);
}
.result-dialog::backdrop { background: rgba(4,3,3,.82); backdrop-filter: blur(7px); }
.result-card { padding: 16px; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.result-head span { color: var(--amber); font-size: 7px; letter-spacing: .16em; }
.result-head h2 { margin: 4px 0 0; font-family: "Songti SC", serif; font-size: 24px; font-weight: 400; }
.close-result { border: 0; color: #c8bcae; background: transparent; font-size: 27px; cursor: pointer; }
.result-image { display: grid; place-items: center; min-height: 180px; overflow: hidden; border-radius: 8px; background: #0d0b09; }
.result-image img { display: block; max-width: 100%; max-height: 64dvh; object-fit: contain; }
.result-meta { margin: 9px 0 12px; color: #8f8276; font-size: 9px; }
.result-help {
  margin: 0 0 7px;
  padding: 8px 10px;
  border-radius: 7px;
  color: #aa9d90;
  background: rgba(255,255,255,.035);
  font-size: 8px;
  line-height: 1.6;
}
.result-status { min-height: 15px; margin: 0 0 8px; color: var(--amber); font-size: 8px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.save-button, .download-button, .again-button { border: 0; border-radius: 999px; padding: 11px 12px; cursor: pointer; font-size: 11px; font-weight: 750; }
.save-button { color: #25170f; background: linear-gradient(180deg, #f1b87f, #d8894a); }
.download-button { color: #d8cbbc; background: #342b25; }
.again-button { color: #d8cbbc; background: #342b25; }
.result-actions .again-button { grid-column: 1 / -1; background: transparent; border: 1px solid rgba(255,255,255,.1); }

body.no-lut #cameraVideo { visibility: visible; filter: var(--fallback-filter, sepia(.16) contrast(.94) saturate(.9)); }
body.no-lut #previewCanvas { display: none; }

@media (max-width: 430px) {
  .page { padding-inline: 10px; padding-top: 12px; }
  .camera-body { padding-left: 54px; padding-right: 12px; }
  .lower-plate { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px 66px; padding-inline: 12px; gap: 7px; }
  .shutter { width: 58px; height: 58px; }
  .shutter-ring i { width: 30px; height: 30px; }
  .camera-notes { grid-template-columns: 1fr; }
  .camera-notes > p { grid-column: 1; }
  .camera-curtain { padding: 12px 15px; }
  .curtain-mark { width: 30px; height: 30px; margin-bottom: 5px; }
  .curtain-mark::before { width: 14px; height: 14px; }
  .camera-curtain .eyebrow { margin-bottom: 3px; font-size: 6px; }
  .camera-curtain h1 { font-size: 22px; line-height: 1.05; }
  .camera-curtain > p:not(.eyebrow):not(.camera-error) {
    max-width: 250px;
    margin: 5px 0 8px;
    font-size: 8px;
    line-height: 1.45;
  }
  .start-button { padding: 7px 14px; font-size: 9px; }
  .camera-error { margin-top: 4px; font-size: 8px; }
}
