:root {
  --bg: #f6f3ef; --card: #fff; --ink: #1d1a22; --muted: #6f6977; --line: #e6e0d8;
  --accent: #e2574c; --accent-ink: #fff; --ok: #2f9e6b; --warn: #c98a12; --danger: #c43d3d;
  --dark: #14121a; --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body.noscroll { overflow: hidden; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .pad { padding: 2rem 1rem; }
.nowrap { white-space: nowrap; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--dark); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.top nav { display: flex; align-items: center; gap: 14px; font-size: .92rem; }
.top nav a, .linkbtn { color: #ddd; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.top nav a:hover, .linkbtn:hover { color: #fff; }
.top form { margin: 0; }

main { padding-bottom: 80px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px; }
.page-h { margin: 6px 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 22px auto; }
.card.empty { text-align: center; color: var(--muted); }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 12px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; font-size: 16px;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
details { margin: 4px 0 14px; } summary { cursor: pointer; color: var(--accent); margin-bottom: 10px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-form .span2 { grid-column: span 2; }
.actions { display: flex; gap: 10px; }
.row-links { text-align: center; font-size: .92rem; margin: 14px 0 0; }
@media (max-width: 560px) { .grid-form { grid-template-columns: 1fr; } .grid-form .span2 { grid-column: auto; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; font: inherit;
  font-weight: 600; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #efc9c9; background: #fff; }
.btn.small { padding: 6px 11px; font-size: .85rem; }
.btn.wide { width: 100%; padding: 13px; margin-top: 4px; }
.pill { font: inherit; font-size: .8rem; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: #f1eeea; color: var(--muted); cursor: pointer; }
.pill.on { background: #e3f4ec; border-color: #bfe3d0; color: var(--ok); font-weight: 600; }
form.inline { display: inline; }

.flashes { max-width: 640px; margin: 12px auto 0; padding: 0 16px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: .92rem; }
.flash.ok { background: #e3f4ec; color: #1d6b48; } .flash.err { background: #fbe6e4; color: #9c2b22; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr.off td { opacity: .5; }

/* activity list */
.acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.act { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; transition: transform .15s; }
.act:hover { transform: translateY(-2px); }
.act-cover { position: relative; aspect-ratio: 16/9; background: linear-gradient(135deg, #3b2f4a, #e2574c) center/cover; }
.act-body { padding: 12px 14px; } .act-body p { margin: 2px 0; }
.live, .archived { position: absolute; top: 10px; left: 10px; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.live { background: var(--accent); color: #fff; } .archived { background: rgba(0, 0, 0, .55); color: #fff; }
.act-head .live, .act-head .archived { position: static; }

/* activity page */
.act-head { max-width: 1100px; margin: 0 auto; padding: 14px 16px 6px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.act-head h1 { margin: 0; } .act-head p { margin: 2px 0 0; }
.tabs { max-width: 1100px; margin: 0 auto; padding: 6px 16px; display: flex; gap: 8px; }
.tab { flex: 1; max-width: 220px; padding: 10px; font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; color: var(--muted); }
.tab.on { background: var(--dark); color: #fff; border-color: var(--dark); }
.badge { font-size: .75rem; background: var(--accent); color: #fff; border-radius: 99px; padding: 1px 7px; margin-left: 4px; }
.badge:empty { display: none; }
.panel { max-width: 1100px; margin: 0 auto; padding: 8px 16px; }

/* camera */
.cam { position: relative; max-width: 560px; margin: 0 auto; aspect-ratio: 3/4; max-height: calc(100vh - 220px);
  background: #000; border-radius: var(--radius); overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam video.mirror { transform: scaleX(-1); }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: flash .25s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.cam-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 8px; }
.upl, .rec { font-size: .8rem; font-weight: 600; padding: 5px 10px; border-radius: 99px; background: rgba(0, 0, 0, .55); color: #fff; }
.upl.busy { background: rgba(201, 138, 18, .85); } .upl.warn { background: rgba(196, 61, 61, .9); }
.rec { background: var(--danger); margin-right: auto; }
.cam-msg { position: absolute; inset: 30% 18px auto; color: #fff; text-align: center; font-size: .95rem; background: rgba(0, 0, 0, .6); padding: 14px; border-radius: 12px; }
.cam-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 22px 20px; display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.cam-mode, .cam-flip { width: 64px; height: 44px; border-radius: 22px; border: 0; font: inherit; font-weight: 700; font-size: .85rem;
  background: rgba(255, 255, 255, .22); color: #fff; cursor: pointer; backdrop-filter: blur(6px); }
.cam-flip { font-size: 1.4rem; width: 48px; height: 48px; border-radius: 50%; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; cursor: pointer; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: all .2s; }
.shutter:active span { transform: scale(.88); }
.shutter.video span { background: var(--danger); }
.shutter.recording span { border-radius: 8px; transform: scale(.55); background: var(--danger); }
.strip { display: flex; gap: 6px; overflow-x: auto; max-width: 560px; margin: 10px auto 0; min-height: 4px; }
.shot { flex: 0 0 54px; height: 54px; border-radius: 8px; background: #ccc center/cover; position: relative; display: grid; place-items: center; color: #fff; font-size: 1rem; }
.shot::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; }
.shot.pending::after { background: var(--warn); } .shot.ok::after { background: var(--ok); } .shot.err::after { background: var(--danger); }
.native { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 12px auto 4px; max-width: 560px; }

/* gallery */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.toolbar select { width: auto; margin: 0; padding: 7px 10px; font-size: .9rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-size: .88rem; padding: 7px 12px; border: 0; background: none; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--dark); color: #fff; }
.chip { font: inherit; font-size: .88rem; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.grp { font-size: .95rem; margin: 16px 0 8px; } .grp span { color: var(--muted); font-weight: 400; font-size: .85rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; }
@media (max-width: 480px) { .tiles { grid-template-columns: repeat(3, 1fr); gap: 3px; } }
.tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: #ddd; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .noimg { display: grid; place-items: center; height: 100%; font-size: 2rem; }
.tile .play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; font-size: .9rem; }
.tile .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: .7rem; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tick { display: none; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff;
  background: rgba(0, 0, 0, .3); color: transparent; font-size: .8rem; place-items: center; }
.selecting .tile .tick { display: grid; }
.tile.sel .tick { background: var(--accent); color: #fff; }
.tile.sel img { opacity: .75; }
.selbar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; background: var(--dark); color: #fff; border-radius: 99px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3); white-space: nowrap; }
.selbar .btn { border: 0; } .selbar .btn.ghost { color: #ddd; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 7, 10, .96); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 50px 0 90px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-close { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 2; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.2rem; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 44px; height: 64px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 2rem; cursor: pointer; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
.lb-nav[hidden] { display: none; }
.lb-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; color: #ddd; font-size: .85rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, .8)); }
.lb-actions { display: flex; gap: 8px; }
.lb-actions .btn { background: rgba(255, 255, 255, .14); color: #fff; border: 0; }
.lb-actions .btn.danger { background: rgba(196, 61, 61, .85); }

/* profile face */
.face-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.face-box form { margin: 0; }
.face-state { font-size: .88rem; padding: 6px 12px; border-radius: 99px; background: #f1eeea; color: var(--muted); }
.face-state.on { background: #e3f4ec; color: var(--ok); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); z-index: 60; background: var(--dark); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; transition: all .25s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
[hidden] { display: none !important; }
@media (max-width: 480px) { .top nav { gap: 10px; font-size: .84rem; } .brand { font-size: 1rem; } .linkbtn { white-space: nowrap; } }

/* about page */
.hero { text-align: center; padding: 34px 16px 10px; max-width: 760px; margin: 0 auto; }
.hero img { width: 132px; height: 132px; border-radius: 24px; box-shadow: 0 10px 40px rgba(226, 150, 40, .35); }
.hero h1 { font-size: 2rem; margin: 10px 0 6px; }
.hero p { font-size: 1.08rem; color: var(--muted); margin: 0 0 18px; }
.hero .cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.about { max-width: 960px; margin: 0 auto; padding: 10px 16px; }
.about h2 { margin: 28px 0 12px; text-align: center; }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.cards3 .card { margin: 0; }
.cards3 .ico { font-size: 1.7rem; }
.cards3 h3 { margin: 6px 0 4px; font-size: 1rem; }
.cards3 p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.45; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 58px; position: relative; line-height: 1.45; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 13px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; }
.steps li b { display: block; }
.steps li span { color: var(--muted); font-size: .92rem; }
.uses { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.uses span { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 7px 14px; font-size: .92rem; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 0 0 8px; }
.faq summary { color: var(--ink); font-weight: 600; margin: 0; }
.faq p { color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

/* QR poster */
.poster { max-width: 520px; margin: 20px auto; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px; }
.poster .qr svg { width: 100%; max-width: 340px; height: auto; }
.poster h1 { font-size: 1.7rem; }
.poster .link { word-break: break-all; color: var(--muted); font-size: .85rem; }
@media print { .top, .noprint, .flashes { display: none !important; } body, html { background: #fff; } .poster { border: 0; margin: 0 auto; } }
@media (max-width: 480px) { .hide-sm { display: none; } .hero h1 { font-size: 1.6rem; } }

/* delete-activity confirmation */
.danger-card { border-color: #efc9c9; }
.danger-card h1 { color: var(--danger); }
.del-list { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.del-list li { background: #faf6f2; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: .92rem; }
.warn-box { background: #fbe6e4; color: #9c2b22; border-radius: 10px; padding: 11px 14px; font-size: .92rem; line-height: 1.45; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
