/* SiteStamp look. Light or dark follows the phone's setting; camera and viewer are always dark. */
:root {
  --bg: #f3f4f6; --card: #ffffff; --text: #15181d; --muted: #667085; --line: #e2e5ea; --soft: #eef0f3;
  --accent: #ffb400; --ink: #1d1600; --link: #a86b00; --danger: #d92d20; --ok: #067647;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 6px rgba(16, 24, 40, .06);
  --st: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1115; --card: #191c22; --text: #eef0f3; --muted: #98a2b3; --line: #2a2f37; --soft: #22262d; --link: #ffc233; --danger: #ff6b5f; --ok: #47cd89; --shadow: none; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0f1115; --card: #191c22; --text: #eef0f3; --muted: #98a2b3; --line: #2a2f37; --soft: #22262d; --link: #ffc233; --danger: #ff6b5f; --ok: #47cd89; --shadow: none; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
a { color: var(--link); }
[hidden] { display: none !important; }
body:has(.cam, .viewer, .report) { overflow: hidden; }
.ic { width: 22px; height: 22px; flex: none; }
#app { max-width: 920px; margin: 0 auto; min-height: 100dvh; }

/* header, tabs */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: calc(var(--st) + 8px) 10px 8px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.bar-title { flex: 1; min-width: 0; }
.bar-title b, .bar-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title b { font-size: 18px; }
.bar-title small { color: var(--muted); font-size: 13px; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 12px; padding: 0; flex: none; }
.icon:hover { background: var(--soft); }
.logo { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--ink); display: grid; place-items: center; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 16px; border: 1.5px solid var(--accent); background: transparent; font-size: 14px; font-weight: 700; }
.pill .ic { width: 16px; height: 16px; }
.tabs { position: sticky; top: calc(var(--st) + 61px); z-index: 9; display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 6px 9px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .ic { width: 19px; height: 19px; }

/* page bits */
.pad { padding: 16px 14px 120px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 16px; }
.card h4 .ic { width: 18px; height: 18px; color: var(--muted); }
.card p { margin: 0 0 12px; }
.note { background: color-mix(in srgb, var(--accent) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 20px 0; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.err { color: var(--danger); font-size: 14px; margin: 10px 0 0; }
.err.ok { color: var(--ok); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ic { width: 44px; height: 44px; opacity: .6; }
.empty p { margin: 6px 0; }
.empty b { color: var(--text); font-size: 17px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow); }
.li { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.li:last-child { border-bottom: 0; }
button.li:hover { background: var(--soft); }
.li-main { flex: 1; min-width: 0; }
.li-main b, .li-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main small, .li-end small { color: var(--muted); font-size: 13px; }
.li-end { text-align: right; }
.li-end b { display: block; font-size: 18px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: color-mix(in srgb, var(--accent) 25%, var(--card)); }
.avatar.sq { border-radius: 12px; }
.avatar .ic { width: 20px; height: 20px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); color: var(--ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; }
.btn .ic { width: 19px; height: 19px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.row > .btn { flex: 1 1 140px; }
.link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 10px 0 0; color: var(--link); font-weight: 600; font-size: 15px; }
.link .ic { width: 16px; height: 16px; }
.input { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea.input { resize: vertical; min-height: 80px; }
select.input { width: auto; padding-right: 8px; }
.input.sm { min-height: 38px; font-size: 14px; padding: 6px 8px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
label > .input { margin-top: 6px; font-weight: 400; }
.form h3, .form h4 { margin-top: 0; }
.seg { display: flex; gap: 3px; padding: 3px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.seg button { flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); padding: 0 6px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.togs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tog { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px; background: var(--soft); border-radius: 10px; font-weight: 500; }
.tog input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); }
.swatches button.on { outline: 3px solid var(--text); outline-offset: 2px; }

/* sign in */
.auth { max-width: 430px; margin: 0 auto; padding: calc(var(--st) + 44px) 18px 40px; }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo, .splash .logo { width: 68px; height: 68px; border-radius: 20px; margin: 0 auto; }
.brand .logo .ic, .splash .logo .ic { width: 34px; height: 34px; }
.brand h1 { margin: 12px 0 4px; font-size: 28px; }
.brand p { margin: 0; color: var(--muted); }
.auth-tabs { margin-bottom: 12px; }
.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash .logo { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* photos */
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.search { position: relative; flex: 1 1 220px; }
.search .ic { position: absolute; left: 11px; top: 12px; width: 20px; height: 20px; color: var(--muted); }
.search .input { padding-left: 38px; }
.tools select.input { flex: 0 1 auto; max-width: 46%; }
.day { margin: 18px 2px 8px; font-size: 14px; }
.day span { color: var(--muted); font-weight: 500; margin-left: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 4px; }
.tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--soft); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile img:not([src]) { visibility: hidden; }
.t-time { position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .55); padding: 1px 6px; border-radius: 6px; }
.t-up { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--ink); display: grid; place-items: center; }
.t-up .ic { width: 14px; height: 14px; }
.t-check { position: absolute; top: 5px; left: 5px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .3); color: transparent; display: grid; place-items: center; }
.t-check .ic { width: 16px; height: 16px; }
.tile.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.sel img { opacity: .75; }
.tile.sel .t-check { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.selbar { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--sb) + 14px); display: flex; align-items: center; gap: 6px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); white-space: nowrap; max-width: calc(100vw - 16px); }
.selbar > span { font-weight: 700; font-size: 14px; padding: 0 6px; }
.fab { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: calc(var(--sb) + 18px); display: flex; align-items: center; gap: 10px; height: 62px; padding: 0 28px; border: 0; border-radius: 31px; background: var(--accent); color: var(--ink); font-weight: 800; font-size: 17px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.fab .ic { width: 26px; height: 26px; }

/* map, team */
.map-main { position: relative; }
#map { height: calc(100dvh - 112px - var(--st)); }
.map-msg { position: absolute; z-index: 500; top: 14px; left: 50%; transform: translateX(-50%); background: var(--card); padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; }
.pop { text-align: center; font: 13px/1.4 system-ui, sans-serif; }
.pop img { width: 160px; height: 120px; object-fit: cover; border-radius: 8px; display: block; margin: 0 auto 6px; background: #ddd; }
.pop .btn { margin-top: 6px; color: #1d1600; }
.invite .code { font: 800 34px/1 ui-monospace, "Cascadia Mono", Menlo, monospace; letter-spacing: .18em; text-align: center; padding: 16px 8px; margin: 4px 0 12px; background: var(--soft); border-radius: 12px; }

/* sheets (pop-up panels) */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .45); animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--card); color: var(--text); border-radius: 20px 20px 0 0; padding: 18px 18px calc(var(--sb) + 18px); animation: up .2s ease-out; }
.sheet h3 { margin: 0 0 12px; font-size: 19px; }
.sheet h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sheet-head h3 { margin: 0; }
.menu { display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-weight: 600; }
.menu button:last-child { border-bottom: 0; }
.menu .danger { color: var(--danger); }
.code-in { font: 700 26px ui-monospace, Menlo, monospace; text-align: center; letter-spacing: .15em; text-transform: uppercase; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; padding-bottom: 18px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

#toast { position: fixed; z-index: 1000; left: 50%; bottom: calc(var(--sb) + 100px); transform: translate(-50%, 20px); max-width: 90vw; padding: 10px 16px; border-radius: 12px; background: rgba(20, 22, 26, .92); color: #fff; font-size: 15px; text-align: center; opacity: 0; pointer-events: none; transition: .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* camera */
.cam { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; overflow: hidden; touch-action: manipulation; }
.cam-view { position: absolute; inset: 0; }
.cam-view video { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-view video.mirror { transform: scaleX(-1); }
.cam-overlay { position: absolute; pointer-events: none; }
.cam-msg { position: absolute; top: 38%; left: 20px; right: 20px; text-align: center; background: rgba(0, 0, 0, .7); padding: 16px; border-radius: 14px; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .3s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.cam .icon { color: #fff; }
.cam .icon:hover { background: rgba(255, 255, 255, .12); }
.cam .icon.on { color: var(--accent); }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 2px; padding: calc(var(--st) + 6px) 8px 14px; background: linear-gradient(rgba(0, 0, 0, .6), transparent); }
.cam-title { flex: 1; min-width: 0; padding: 0 4px; }
.cam-title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-gps { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #888; }
.dot.good { background: #32d74b; } .dot.ok { background: #ffd60a; } .dot.bad { background: #ff453a; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 16px calc(var(--sb) + 12px); background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.cam-tags { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.cam-tags::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 13px; border-radius: 17px; border: 1px solid rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .35); color: #fff; font-size: 14px; font-weight: 600; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #1d1600; }
.cam-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.cam-last { justify-self: start; position: relative; width: 56px; height: 56px; padding: 0; border: 2px solid #fff; border-radius: 13px; background: rgba(255, 255, 255, .15); }
.cam-last img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; display: block; }
.cam-last img:not([src]) { visibility: hidden; }
.badge { position: absolute; top: -8px; right: -8px; min-width: 22px; padding: 2px 6px; border-radius: 11px; background: var(--accent); color: #1d1600; font-size: 12px; font-weight: 800; }
.shutter { width: 80px; height: 80px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .08s; }
.shutter:active span { transform: scale(.88); background: #ddd; }
.cam-note { justify-self: end; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .55); background: rgba(0, 0, 0, .35); color: #fff; font-size: 12px; font-weight: 600; }
.cam-note.on { background: var(--accent); border-color: var(--accent); color: #1d1600; }
.cam-alt { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 12px 0 0; font-size: 13px; font-weight: 500; opacity: .85; cursor: pointer; }
.cam-alt .ic { width: 16px; height: 16px; }
.cam .sheet textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
@media (orientation: landscape) and (max-height: 560px) {
  .cam-top { right: 150px; }
  .cam-bottom { top: 0; left: auto; width: 150px; display: flex; flex-direction: column; justify-content: flex-end; padding: calc(var(--st) + 10px) calc(env(safe-area-inset-right) + 10px) calc(var(--sb) + 10px) 10px; background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .6)); }
  .cam-tags { flex-direction: column; align-items: center; flex: 0 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 0; margin-bottom: 14px; }
  .cam-row { grid-template-columns: 1fr; justify-items: center; gap: 14px; }
  .cam-last, .cam-note { justify-self: center; }
  .cam-alt { display: none; }
}

/* photo viewer */
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer .icon { color: #fff; }
.viewer .icon:hover { background: rgba(255, 255, 255, .12); }
.v-top { display: flex; align-items: center; gap: 4px; padding: calc(var(--st) + 4px) 6px 4px; }
.v-count { flex: 1; text-align: center; font-weight: 600; font-size: 15px; }
.v-stage { position: relative; flex: 1; min-height: 0; }
.v-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.v-img.loading { opacity: .85; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; }
.v-nav.prev { left: 8px; } .v-nav.next { right: 8px; }
.v-info { max-height: 42dvh; overflow: auto; background: #15181d; padding: 14px 16px calc(var(--sb) + 16px); font-size: 15px; }
.v-when { font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.v-when small { display: block; font-weight: 400; font-size: 13px; color: #98a2b3; }
.v-row { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #2a2f37; }
.v-row > span { color: #98a2b3; font-size: 13px; padding-top: 2px; }
.v-row a { color: #ffc233; }
.v-row .link { color: #ffc233; padding: 4px 0 0; display: flex; }
.v-row code { font-size: 12px; }
@media (min-width: 900px) {
  .viewer { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr; }
  .v-top { grid-column: 1 / -1; }
  .v-info { max-height: none; }
}

/* report */
.report { position: fixed; inset: 0; z-index: 70; overflow: auto; background: #e9ebee; color: #111; color-scheme: light; }
.r-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: calc(var(--st) + 8px) 12px 8px; background: #fff; border-bottom: 1px solid #ddd; }
.r-bar .btn { background: #fff; color: #111; border-color: #ddd; }
.r-bar .btn.primary { background: var(--accent); color: #1d1600; border-color: transparent; }
.r-prog { flex: 1; text-align: center; color: #555; font-size: 14px; }
.r-page { max-width: 820px; margin: 16px auto 40px; background: #fff; padding: 28px; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.r-head h1 { margin: 0 0 4px; font-size: 26px; }
.r-head p { margin: 2px 0; color: #444; font-size: 14px; }
.r-item { margin: 22px 0 0; break-inside: avoid; page-break-inside: avoid; }
.r-item img { display: block; width: 100%; max-height: 540px; min-height: 160px; object-fit: contain; background: #f2f2f2; }
.r-item figcaption { margin-top: 6px; font-size: 13px; line-height: 1.5; color: #222; }
@media print {
  body.printing > *:not(.report) { display: none !important; }
  body.printing { background: #fff; overflow: visible !important; }
  .report { position: static; overflow: visible; background: #fff; }
  .r-bar { display: none; }
  .r-page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .r-item img { max-height: 11.5cm; }
  @page { margin: 12mm; }
}
