/* GPS camera (loaded inside the camera's own shadow root) */

:host {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: #000;
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  line-height: normal;
  font-size: 16px;
  text-align: left;

  --font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, system-ui, sans-serif;
  --yellow: #ffd60a;
  --green: #30d158;
  --red: #ff453a;
  --blue: #0a84ff;
  --orange: #ff9f0a;
  --label: #fff;
  --label2: rgba(235, 235, 245, 0.6);
  --label3: rgba(235, 235, 245, 0.3);
  --sep: rgba(84, 84, 88, 0.6);
  --fill: rgba(118, 118, 128, 0.24);
  --fill2: rgba(118, 118, 128, 0.36);
  --grouped: #000;
  --cell: #1c1c1e;
  --cell2: #2c2c2e;
  --glass: rgba(30, 30, 30, 0.62);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
:host(.open) {
  display: block;
}
button,
a {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: none;
}
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar (iOS Camera) ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(var(--safe-t) + 8px) 16px 8px;
  gap: 8px;
}
.tl,
.tr {
  display: flex;
  gap: 10px;
  align-items: center;
}
.tr {
  justify-content: flex-end;
}
.circ {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill);
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.15s;
}
.circ:active {
  transform: scale(0.9);
}
.circ.on {
  background: var(--yellow);
  color: #000;
}
.circ svg {
  width: 19px;
  height: 19px;
}
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  background: var(--fill);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill svg {
  width: 13px;
  height: 13px;
}
.pill.ok {
  color: var(--green);
}
.pill.warn {
  color: var(--orange);
}
.pill.bad {
  color: var(--red);
}
.pill.warn svg {
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* ---------- viewfinder ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.vf {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #000;
}
.vf video {
  display: block;
  max-width: 100vw;
  max-height: calc(100vh - 296px);
  max-height: calc(100dvh - 296px - var(--safe-t) - var(--safe-b));
  width: auto;
  height: auto;
}
.vf video.mirror {
  transform: scaleX(-1);
}
.vf canvas#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background:
    linear-gradient(
      to right,
      transparent calc(33.33% - 0.5px),
      #fff calc(33.33% - 0.5px),
      #fff calc(33.33% + 0.5px),
      transparent calc(33.33% + 0.5px),
      transparent calc(66.66% - 0.5px),
      #fff calc(66.66% - 0.5px),
      #fff calc(66.66% + 0.5px),
      transparent calc(66.66% + 0.5px)
    ),
    linear-gradient(
      to bottom,
      transparent calc(33.33% - 0.5px),
      #fff calc(33.33% - 0.5px),
      #fff calc(33.33% + 0.5px),
      transparent calc(33.33% + 0.5px),
      transparent calc(66.66% - 0.5px),
      #fff calc(66.66% - 0.5px),
      #fff calc(66.66% + 0.5px),
      transparent calc(66.66% + 0.5px)
    );
}
.flash {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}
.flash.go {
  animation: fl 0.28s ease-out;
}
@keyframes fl {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}
.sitechip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  font-size: 12.5px;
  font-weight: 600;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.nocam {
  max-width: 360px;
  text-align: center;
  padding: 30px 24px;
}
.nocam .ic {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 14px;
  background: var(--cell);
  display: grid;
  place-items: center;
}
.nocam h3 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.nocam p {
  margin: 0 0 22px;
  color: var(--label2);
  font-size: 15px;
  line-height: 1.4;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 16px;
  background: var(--fill);
  color: var(--blue);
  transition: opacity 0.15s;
}
.btn:active {
  opacity: 0.6;
}
.btn.fill {
  background: var(--blue);
  color: #fff;
}
.btn:disabled {
  opacity: 0.35;
}

/* ---------- bottom controls ---------- */
.bottom {
  padding: 6px 0 calc(var(--safe-b) + 22px);
}
.mode {
  display: flex;
  justify-content: center;
  gap: 22px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
  color: var(--label2);
}
.mode span.on {
  color: var(--yellow);
}
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  max-width: 460px;
  margin: 0 auto;
}
.thumb {
  width: 50px;
  height: 50px;
  border-radius: 9px;
  background: #1c1c1e center/cover no-repeat;
  position: relative;
  transition: transform 0.15s;
}
.thumb:active {
  transform: scale(0.92);
}
.thumb .count {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid #000;
}
.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid #fff;
  display: grid;
  place-items: center;
  padding: 0;
}
.shutter span {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.12s;
}
.shutter:active span {
  transform: scale(0.88);
}
.shutter:disabled {
  opacity: 0.35;
}
.flip {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--fill);
  display: grid;
  place-items: center;
  transition: transform 0.35s;
}
.flip svg {
  width: 24px;
  height: 24px;
}
.flip.spin {
  transform: rotate(180deg);
}

/* ---------- sheets (iOS modal) ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 20;
}
.scrim.show {
  opacity: 1;
  pointer-events: auto;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--grouped);
  border-radius: 12px 12px 0 0;
  transform: translateY(105%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 21;
  display: flex;
  flex-direction: column;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}
.sheet.show {
  transform: none;
}
.grab {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--fill2);
  margin: 6px auto 0;
}
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 16px 6px;
}
.nav h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}
.nav .r {
  justify-self: end;
  color: var(--blue);
  font-size: 17px;
  font-weight: 600;
}
.nav .l {
  justify-self: start;
  color: var(--blue);
  font-size: 17px;
}
.sheet .body {
  overflow: auto;
  padding: 8px 16px calc(var(--safe-b) + 28px);
}
.large {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 2px 4px 10px;
}

/* inset grouped list */
.gh {
  font-size: 13px;
  color: var(--label2);
  text-transform: uppercase;
  margin: 22px 16px 7px;
  letter-spacing: 0.01em;
}
.gh:first-child {
  margin-top: 6px;
}
.gf {
  font-size: 13px;
  color: var(--label2);
  margin: 7px 16px 0;
  line-height: 1.35;
}
.group {
  background: var(--cell);
  border-radius: 10px;
  overflow: hidden;
}
.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 16px;
  position: relative;
  font-size: 17px;
}
.cell + .cell:before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: var(--sep);
}
.cell.ic + .cell:before,
.cell.ic:before {
  left: 58px;
}
.cell .k {
  flex: none;
}
.cell .grow {
  flex: 1;
  min-width: 0;
}
.cell input[type="text"],
.cell input:not([type]) {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  color: var(--label);
  font: inherit;
  text-align: right;
  padding: 11px 0;
}
.cell input::placeholder {
  color: var(--label3);
}
.cell select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  color: var(--label2);
  font: inherit;
  text-align: right;
  outline: none;
  padding: 11px 18px 11px 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='13' viewBox='0 0 8 13'%3E%3Cpath d='M1 1.5l3 3-3 3M7 6.5' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3Cpath d='M1 7.5l3 3 3-3M1 5.5l3-3 3 3' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}
.cell select option {
  background: #1c1c1e;
  color: #fff;
}
.sq {
  width: 29px;
  height: 29px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: none;
  color: #fff;
}
.sq svg {
  width: 17px;
  height: 17px;
}
.cell .v {
  color: var(--label2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.cell.link {
  color: var(--blue);
  cursor: pointer;
}
.cell.link:active {
  background: var(--cell2);
}

/* iOS switch */
.sw {
  position: relative;
  width: 51px;
  height: 31px;
  flex: none;
  margin-left: auto;
}
.sw input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.sw i {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: var(--fill2);
  transition: background 0.25s;
}
.sw i:after {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.15),
    0 3px 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.sw input:checked + i {
  background: var(--green);
}
.sw input:checked + i:after {
  transform: translateX(20px);
}

/* gallery */
.gal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 2px;
  border-radius: 10px;
  overflow: hidden;
}
.gal button {
  aspect-ratio: 1;
  background: #1c1c1e center/cover no-repeat;
  border-radius: 0;
}
.empty {
  color: var(--label2);
  text-align: center;
  padding: 60px 10px;
  font-size: 15px;
  grid-column: 1/-1;
  background: var(--cell);
}
.galbar {
  display: flex;
  gap: 8px;
  margin: 4px 0 14px;
}
.galbar .btn {
  flex: 1;
  font-size: 15px;
  padding: 10px 8px;
}
.btn.red {
  color: var(--red);
}

/* viewer (Photos app) */
.viewer {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 30;
  display: none;
  flex-direction: column;
}
.viewer.show {
  display: flex;
}
.vtop {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(var(--safe-t) + 8px) 12px 8px;
  background: rgba(22, 22, 22, 0.75);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.vtop .back {
  color: var(--blue);
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 2px;
  justify-self: start;
}
.vtop .back svg {
  width: 12px;
  height: 20px;
}
.vtitle {
  text-align: center;
  line-height: 1.2;
}
.vtitle b {
  display: block;
  font-size: 15px;
  font-weight: 600;
}
.vtitle small {
  display: block;
  font-size: 12px;
  color: var(--label2);
}
.vimg {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vimg img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.vbar {
  display: flex;
  justify-content: space-around;
  padding: 10px 20px calc(var(--safe-b) + 12px);
  background: rgba(22, 22, 22, 0.75);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.vbar button {
  color: var(--blue);
  padding: 6px 14px;
  display: grid;
  place-items: center;
}
.vbar button svg {
  width: 24px;
  height: 24px;
}
.vbar button.del {
  color: var(--blue);
}

/* action sheet */
.action {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 8px calc(var(--safe-b) + 8px);
  z-index: 41;
  transform: translateY(110%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: 500px;
  margin: 0 auto;
}
.action.show {
  transform: none;
}
.action .grp {
  background: rgba(44, 44, 46, 0.82);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 8px;
  text-align: center;
}
.action .msg {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--label2);
  line-height: 1.35;
}
.action .msg b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--label2);
  margin-bottom: 2px;
}
.action button {
  display: block;
  width: 100%;
  padding: 17px;
  font-size: 20px;
  color: var(--blue);
  border-top: 0.5px solid var(--sep);
}
.action button.destructive {
  color: var(--red);
}
.action button.cancel {
  background: #2c2c2e;
  border-radius: 14px;
  border: 0;
  font-weight: 600;
}
.action button:active {
  background: rgba(255, 255, 255, 0.08);
}
.ascrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.ascrim.show {
  opacity: 1;
  pointer-events: auto;
}

/* HUD toast */
.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 60px);
  transform: translate(-50%, -10px) scale(0.96);
  background: rgba(44, 44, 46, 0.85);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 50;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.hidden {
  display: none !important;
}
@media (min-width: 900px) {
  .vf {
    border-radius: 14px;
  }
  .vf video {
    max-height: calc(100vh - 266px);
  }
}

/* ---------- zoom, timer, countdown ---------- */
.zoom {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}
.zoom button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(70, 70, 74, 0.55);
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  transition:
    transform 0.2s,
    color 0.2s;
}
.zoom button.on {
  color: var(--yellow);
  transform: scale(1.14);
}
.circ.txt.on {
  width: auto;
  padding: 0 11px 0 9px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
}
.cd {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 130px;
  font-weight: 200;
  color: #fff;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
* {
  touch-action: manipulation;
}
.sitechip {
  z-index: 2;
}
.circ svg,
.flip svg,
.zoom button,
.thumb,
.cd,
.pill {
  transition: transform 0.3s;
}
.rotL .circ:not(.on) svg,
.rotL .circ.on svg,
.rotL .flip svg,
.rotL .thumb,
.rotL .cd {
  transform: rotate(90deg);
}
.rotR .circ svg,
.rotR .flip svg,
.rotR .thumb,
.rotR .cd {
  transform: rotate(-90deg);
}
.rotL .zoom button {
  transform: rotate(90deg);
}
.rotL .zoom button.on {
  transform: rotate(90deg) scale(1.14);
}
.rotR .zoom button {
  transform: rotate(-90deg);
}
.rotR .zoom button.on {
  transform: rotate(-90deg) scale(1.14);
}
.tapplay {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--yellow);
  color: #000;
  font-size: 16px;
  font-weight: 600;
  z-index: 3;
}

/* ---------- customer picker ---------- */
.search {
  background: var(--fill);
  border-radius: 10px;
  padding: 0 10px;
  margin: 2px 0 14px;
}
.search input {
  width: 100%;
  background: none;
  border: 0;
  outline: none;
  color: var(--label);
  font: inherit;
  font-size: 17px;
  padding: 9px 0;
}
.search input::placeholder {
  color: var(--label2);
}
.cell.pc {
  cursor: pointer;
  padding-top: 9px;
  padding-bottom: 9px;
}
.cell.pc:active {
  background: var(--cell2);
}
.cell.pc small {
  display: block;
  color: var(--label2);
  font-size: 13px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- gallery days, viewer extras ---------- */
.gal .gd {
  grid-column: 1/-1;
  background: #000;
  padding: 16px 4px 7px;
  font-size: 15px;
  font-weight: 600;
}
.gal .gd:first-child {
  padding-top: 2px;
}
.vimg {
  position: relative;
}
.vnav {
  position: absolute;
  top: 50%;
  margin-top: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(44, 44, 46, 0.7);
  display: grid;
  place-items: center;
  color: #fff;
}
.vnav svg {
  width: 11px;
  height: 19px;
}
.vnav.p {
  left: 12px;
}
.vnav.n {
  right: 12px;
}
.vnav:disabled {
  opacity: 0;
  pointer-events: none;
}
@media (hover: none) {
  .vnav {
    display: none;
  }
}
.vcount {
  justify-self: end;
  color: var(--label2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding-right: 4px;
}
.vbar button.on {
  color: var(--yellow);
}
.vinfo {
  background: #1c1c1e;
  padding: 6px 16px;
  font-size: 15px;
  max-height: 42vh;
  overflow: auto;
}
.vinfo div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 0.5px solid var(--sep);
}
.vinfo div:first-child {
  border-top: 0;
}
.vinfo span {
  color: var(--label2);
  flex: none;
}
.vinfo b {
  font-weight: 400;
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}
.vinfo a {
  color: var(--blue);
}

/* ---------- phone held sideways ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .app {
    flex-direction: row;
  }
  .top {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 12px 6px 12px calc(env(safe-area-inset-left, 0px) + 12px);
  }
  .tl,
  .tr {
    flex-direction: column;
  }
  .bottom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 calc(env(safe-area-inset-right, 0px) + 16px) 0 8px;
  }
  .zoom {
    flex-direction: column;
    margin: 0;
  }
  .mode {
    display: none;
  }
  .controls {
    flex-direction: column-reverse;
    gap: 20px;
    padding: 0;
    margin: 0;
  }
  .vf video {
    max-height: 100vh;
    max-height: 100dvh;
    max-width: calc(100vw - 270px);
  }
  .toast {
    top: 14px;
  }
}
