:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5393b);
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
       overflow-x: hidden; padding-bottom: env(safe-area-inset-bottom); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 96px; }
h1 { font-size: 22px; margin: 4px 0 12px; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em;
     color: var(--hint); margin: 20px 4px 6px; }
p { margin: 8px 4px; }
.hint { color: var(--hint); font-size: 14px; }
.loading, .empty { color: var(--hint); text-align: center; padding: 32px 8px; }

.head { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.head h1 { margin: 0; flex: 1; min-width: 0; }
.head .sub { color: var(--hint); font-size: 14px; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--section);
            font-size: 18px; cursor: pointer; }
.head-edit { margin-bottom: 12px; }
.head-edit .head { margin-bottom: 8px; }

.avatar { flex: none; border-radius: 50%; object-fit: cover; display: grid; place-items: center;
          font-weight: 600; color: #fff; background: var(--btn); overflow: hidden; }

.list { background: var(--section); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px;
       width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left;
       position: relative; cursor: pointer; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 1px solid var(--sep); }
.row .main { flex: 1; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .sub { color: var(--hint); font-size: 14px; }
.row .chev { color: var(--hint); flex: none; }
.row:active { background: var(--bg2); }
.row.static { cursor: default; }
.row.static:active { background: none; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--section); border-radius: var(--radius); padding: 14px; border: 0; color: inherit;
        font: inherit; text-align: left; min-height: 88px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.tile .ico { font-size: 24px; }
.tile .sub { color: var(--hint); font-size: 13px; }

.btn { display: block; width: 100%; min-height: 48px; padding: 12px 16px; margin: 10px 0 0; border: 0;
       border-radius: var(--radius); background: var(--btn); color: var(--btn-text); font: inherit; font-weight: 600;
       cursor: pointer; }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--section); color: var(--link); }
.btn.danger { background: var(--section); color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; width: auto; display: inline-block; font-weight: 500; }
.sticky { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
          background: color-mix(in srgb, var(--bg2) 92%, transparent); backdrop-filter: blur(8px); }
.sticky .btn { max-width: 608px; margin: 0 auto; }

.field { display: block; padding: 10px 14px; position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 1px solid var(--sep); }
.field span { display: block; font-size: 13px; color: var(--hint); margin-bottom: 2px; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: transparent; border: 0;
                          width: 100%; padding: 4px 0; outline: none; }
select { appearance: none; }
input::placeholder, textarea::placeholder { color: var(--hint); }
.check { display: flex; align-items: center; gap: 12px; }
.check input { width: 22px; height: 22px; accent-color: var(--btn); flex: none; }

.item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px 8px 6px; position: relative; background: var(--section); }
.item + .item::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; border-top: 1px solid var(--sep); }
.item .grip { flex: none; width: 28px; min-height: 40px; display: grid; place-items: center; color: var(--hint);
              cursor: grab; touch-action: none; font-size: 18px; }
.item .type { flex: none; width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--bg2);
              font-size: 20px; cursor: pointer; }
.item .body { flex: 1; min-width: 0; }
.item .body input.t { padding: 8px 0 2px; }
.item .body input.h { font-size: 14px; color: var(--hint); padding: 0 0 6px; }
.item .x { flex: none; width: 36px; height: 40px; border: 0; background: none; color: var(--hint); font-size: 20px; cursor: pointer; }
.item .moves { display: flex; flex-direction: column; }
.item .moves button { border: 0; background: none; color: var(--hint); width: 28px; height: 20px; padding: 0; cursor: pointer; }
.sortable-ghost { opacity: .4; }
.adders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--hint); }
.linkbox { font-size: 14px; word-break: break-all; padding: 12px 14px; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
         max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: rgba(30, 30, 32, .92); color: #fff;
         font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: rgba(200, 40, 40, .95); }


[hidden] { display: none !important; }
.st { font-size: 12px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: none; background: var(--bg2); color: var(--text); }
.st-ontime { background: color-mix(in srgb, #2ea043 18%, var(--section)); }
.st-late { background: color-mix(in srgb, #f08c00 20%, var(--section)); }
.st-missed { background: color-mix(in srgb, #e5393b 18%, var(--section)); }
.st-in_progress { background: color-mix(in srgb, #f5c400 22%, var(--section)); }
.row.fill { min-height: 60px; }
.row.fill:disabled { cursor: default; color: inherit; opacity: 1; }
.row .box { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--hint); display: grid;
            place-items: center; font-weight: 700; color: var(--btn-text); }
.row .box.on { background: var(--btn); border-color: var(--btn); }
.thumb { flex: none; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--bg2);
         display: grid; place-items: center; font-size: 24px; cursor: zoom-in; }
.badge { flex: none; font-size: 18px; }
.sub.err { color: var(--danger); }
.cam { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: flex; flex-direction: column; }
.cam-top { display: flex; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
.cam-icon { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 20px; cursor: pointer; }
.cam-icon.on { background: #ffd54a; color: #000; }
.cam-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.cam-video { width: 100%; height: 100%; object-fit: contain; }
.cam-msg { position: absolute; left: 20px; right: 20px; text-align: center; line-height: 1.5; }
.cam-msg:empty { display: none; }
.cam-play { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); }
.cam-bottom { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
.cam-shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.cam-shutter:active { background: #fff; }
.cam-shutter:disabled { opacity: .4; }
.cam-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 480px; }
.cam-actions .btn { margin: 0; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.presets { display: flex; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.presets .btn { margin: 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.chip-field { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 44px; padding: 0 12px;
              background: var(--section); border-radius: 12px; }
.chip-field.wide { grid-column: 1 / -1; }
.chip-field span { flex: none; font-size: 14px; color: var(--hint); }
.chip-field input, .chip-field select { flex: 1; min-width: 0; width: auto; padding: 0; min-height: 0; text-align: left; }
.chip-field input::-webkit-date-and-time-value { text-align: left; }
.pct { font-size: 18px; flex: none; }
.pct.good { color: #2ea043; } .pct.mid { color: #d98a00; } .pct.bad { color: var(--danger); }
.venue-label { font-weight: 600; margin: 14px 4px 6px; }

textarea { resize: vertical; min-height: 96px; }
.static-tile { cursor: default; min-height: 72px; }
.big { font-size: 24px; }
.shot { display: block; max-width: 100%; border-radius: 12px; margin-top: 10px; cursor: zoom-in; }
.ctx { margin: 0; padding: 12px 14px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

.adders { grid-template-columns: 1fr 1fr 1fr; }
.adders .btn { padding: 12px 6px; }
.item.zone { background: color-mix(in srgb, var(--btn) 10%, var(--section)); }
.item.zone .type { background: transparent; font-size: 20px; display: grid; place-items: center; }
.item.zone input.t { font-weight: 700; padding: 8px 0; }
.zone-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 18px 4px 6px; font-weight: 700; }
.zone-head span:first-child { overflow-wrap: anywhere; }
.zone-count { flex: none; color: var(--hint); font-weight: 500; font-size: 14px; }
.zone-count.full { color: #2ea043; }

.btn-link { display: block; width: 100%; max-width: 608px; margin: 6px auto 0; padding: 6px; border: 0; background: none;
            color: var(--link); font: inherit; font-size: 14px; cursor: pointer; }
main { padding-bottom: 140px; }
