/* ============================================================
   Detailers Media Hub — design system
   White ground, near-black type, one accent: Automotive
   Acquisitions orange. The system typeface. Rounded cards and
   grouped lists, hairline separators, no ornament. Shops are
   told apart by their logos, never by repainting the interface.
   ============================================================ */

:root {
  --accent:        #f47b27;
  --accent-deep:   #e06c1c;
  --accent-press:  #c95f16;
  --accent-bright: #f47b27;   /* the camera and editor read this name */
  --accent-soft:   #fff1e7;   /* tint behind a selected row */
  --on-accent:     #ffffff;
  --navy:          #002a5a;

  --bg:      #f5f5f7;
  --surface: #ffffff;
  --fill:    #f2f2f7;         /* inputs, secondary buttons */
  --fill-2:  #e8e8ed;
  --text:    #1d1d1f;
  --muted:   #6e6e73;
  --faint:   #8e8e93;
  --line:    rgba(0, 0, 0, 0.08);
  --line-2:  rgba(0, 0, 0, 0.14);
  --ok:      #34c759;
  --warn:    #ff9f0a;
  --danger:  #ff3b30;
  --glow:    255, 255, 255;   /* the dark camera/editor screens mix from this */

  --f-sys: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

  --wrap: 1040px;
  --gut: clamp(16px, 4vw, 32px);
  --header-h: 60px;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -16px rgba(0, 0, 0, 0.18);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.25s;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-sys);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- motion -- */

@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lineUp { from { transform: translateY(102%); } to { transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 50% { opacity: 0.25; } }
@keyframes spin { to { transform: rotate(360deg); } }

.rise { animation: riseIn 0.45s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }
.ln { display: block; overflow: hidden; }
.ln > span { display: block; animation: lineUp 0.6s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 80ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------- primitives -- */

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gut); }
.wrap--narrow { max-width: 760px; }

.page { min-height: 100dvh; display: flex; flex-direction: column; }
.page-head { padding: clamp(22px, 3.5vw, 40px) var(--gut) 8px; }
.page-head--row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.page-body { padding-top: 12px; padding-bottom: clamp(40px, 5vw, 64px); }

.h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 700; letter-spacing: -0.025em; text-wrap: balance; }
.eyebrow { margin-bottom: 4px; font-size: 13px; font-weight: 600; color: var(--accent); }
.lede { margin-top: 6px; max-width: 56ch; font-size: 15px; color: var(--muted); }

/* Grouped-list header: small, uppercase, quiet. */
.section-head {
  margin: 22px 0 8px 4px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--muted);
}
.section-head .n { color: var(--accent); margin-right: 6px; }
.section { padding-top: 6px; }
.section:last-child { padding-bottom: 24px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.list { display: grid; gap: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 0; border-radius: var(--radius-s);
  background: var(--fill); color: var(--text);
  font-size: 15px; font-weight: 600;
  white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background var(--dur) var(--ease), transform 0.15s var(--ease), filter var(--dur);
}
.btn:hover:not(:disabled) { background: var(--fill-2); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { transition: transform var(--dur) var(--ease); }
.btn:hover:not(:disabled) svg { transform: translateX(3px); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn--primary:active:not(:disabled) { background: var(--accent-press); }
.btn--lg { height: 50px; padding-inline: 24px; font-size: 16px; }
.btn--ghost { background: transparent; color: var(--accent); padding-inline: 10px; }
.btn--ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn--danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn--danger:hover:not(:disabled) { background: #fff3f2; }
.btn--tiny { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn.is-on { background: var(--accent-soft); color: var(--accent); }

.field {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--fill); border: 0; border-radius: var(--radius-s);
  color: var(--text); font-size: 16px;
  outline: none;
  transition: box-shadow var(--dur) var(--ease), background var(--dur);
}
.field::placeholder { color: var(--faint); }
.field:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.f-label { display: block; margin: 0 0 6px 2px; font-size: 13px; font-weight: 600; color: var(--muted); }

.hint { margin-top: 12px; font-size: 13.5px; color: var(--faint); max-width: 62ch; }
.hint.is-error { color: var(--danger); }
.note { margin-top: 10px; font-size: 13px; line-height: 1.45; color: var(--faint); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 15px; }

.page-foot {
  margin-top: auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 28px 0 32px;
  font-size: 13px; color: var(--faint);
}
.page-foot i { font-style: normal; }

/* ------------------------------------------------------------- topbar -- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  height: var(--header-h);
  padding-inline: var(--gut);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { display: block; flex: none; }
.brand-logo img { height: 34px; width: auto; display: block; }
.brand-rule { width: 1px; height: 24px; background: var(--line-2); flex: none; }
.brand-mark { height: 15px; width: auto; flex: none; }

.topbar-shop { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.topbar-shop img { width: 28px; height: 28px; border-radius: 7px; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 2px; flex: none; }
.topbar-shop b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn--ghost { height: 36px; font-size: 14px; }
.topbar-user { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.admin-badge { padding: 4px 9px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }

/* ----------------------------------------------------------- selector -- */

.sel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.sel-grid {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 20px; align-items: stretch;
  padding-top: 18px; padding-bottom: 40px;
}

/* ---- the map ---- */
.sel-map {
  position: relative;
  aspect-ratio: 0.8;
  overflow: hidden;
  background: linear-gradient(180deg, #f2f6fb, #e9eff7);   /* water */
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  user-select: none;
}
.sel-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sel-land { fill: #fbfcfd; }
.sel-state { fill: #fbfcfd; transition: fill 0.3s; }
.sel-state.is-home { fill: #fff3ea; }            /* the three states with a shop */
.sel-borders { fill: none; stroke: #dfe4eb; stroke-width: 0.9; }
.sel-outline { fill: none; stroke: #c9d0da; stroke-width: 1.1; }
.sel-wash { opacity: 0.42; mix-blend-mode: multiply; }
.sel-wash--brand { opacity: 0.62; }
.sel-compass { position: absolute; left: 18px; bottom: 14px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; color: var(--faint); }
.sel-compass::after { content: ''; display: block; width: 0; height: 0; margin: 2px auto 0; border: 5px solid transparent; border-bottom: 9px solid var(--faint); border-top: 0; }
.sel-map-chip {
  position: absolute; right: 14px; bottom: 14px;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(6px);
  font-size: 12px; font-weight: 600; color: var(--muted);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* ---- the panel that holds the list ---- */
.sel-panel { display: flex; flex-direction: column; overflow: hidden; }
.sel-panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.sel-panel-head b { font-size: 15px; font-weight: 600; }
.sel-panel-head span { font-size: 13px; color: var(--muted); }
.sel-panel-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--faint); }


.sel-list { display: grid; }
.sel-list > li + li { border-top: 1px solid var(--line); }
.sel-row {
  width: 100%;
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px;
  padding: 14px 18px 14px 16px;
  border: 0; background: transparent; text-align: left; color: inherit; cursor: pointer;
  box-shadow: inset 3px 0 0 transparent;
  transition: background 0.2s, box-shadow 0.2s;
}
.sel-row:hover, .sel-row.is-lit { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sel-row:active { background: #ffe7d6; }
.sel-row-plate { width: 52px; height: 52px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.sel-row-plate img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.sel-row-plate b { font-weight: 700; color: var(--navy); }
.sel-row-text { min-width: 0; display: grid; gap: 3px; }
.sel-row-name { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.sel-row-sub { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.sel-row-sub svg { color: var(--accent); }
.sel-row-chev { color: var(--faint); transition: color 0.2s, transform 0.25s var(--ease-out); }
.sel-row:hover .sel-row-chev, .sel-row.is-lit .sel-row-chev { color: var(--accent); transform: translateX(3px); }

@media (max-width: 900px) {
  .sel-grid { grid-template-columns: 1fr; padding-top: 6px; }
  .sel-map { display: none; }
  .sel-head { flex-direction: column; align-items: flex-start; gap: 14px; padding-bottom: 22px; }
  /* A warm ground at the top so the white doesn't run edge to edge, and the
     panel sits in it with a real shadow. Nothing pictorial. */
  .page:has(.sel-grid) { background: linear-gradient(180deg, #fbf1e8 0, #f8f3ef 220px, var(--bg) 420px); }
  .sel-panel { box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 18px 40px -22px rgba(120, 70, 30, 0.35); }
  .sel-row { padding: 15px 16px; }
  .sel-row-plate { width: 56px; height: 56px; border: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px var(--line); }
}

/* A pin: a dot exactly on the coordinate, a thin leader, and the logo on a
   disc at the end of it. The offset is per shop (see selector.js). */
.sel-pin {
  position: absolute;
  width: 0; height: 0;
  background: transparent; border: 0; padding: 0;
  cursor: pointer;
  z-index: 1;
}
.sel-pin:focus-visible { outline: none; }
.sel-pin-dot {
  position: absolute; left: 0; top: 0;
  width: 9px; height: 9px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--text);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95);
  transition: background 0.25s;
}
.sel-pin-leader {
  position: absolute; left: 0; top: 0;
  width: var(--len); height: 1.5px;
  background: var(--text); opacity: 0.55;
  transform-origin: 0 50%;
  transform: rotate(var(--ang));
  transition: background 0.25s, opacity 0.25s;
}
.sel-pin-plate {
  position: absolute; left: var(--dx); top: var(--dy);
  width: 42px; height: 42px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px var(--line), 0 6px 16px -6px rgba(0, 0, 0, 0.35);
  display: grid; place-items: center;
  transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease-out);
}
.sel-pin-plate img { width: 100%; height: 100%; object-fit: contain; padding: 7px; border-radius: 50%; }
.sel-pin-plate b { font-weight: 700; font-size: 14px; color: var(--navy); }
.sel-pin-label {
  position: absolute; left: calc(100% + 6px); top: 50%;
  transform: translateY(-50%);
  padding: 3px 8px; border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: color 0.25s, background 0.25s;
}
.sel-pin.is-left .sel-pin-label { left: auto; right: calc(100% + 6px); }
.sel-pin:hover, .sel-pin.is-lit { z-index: 2; }
.sel-pin:hover .sel-pin-plate, .sel-pin.is-lit .sel-pin-plate { transform: translate(-50%, -50%) scale(1.06); box-shadow: 0 0 0 3px var(--accent), 0 10px 22px -8px rgba(244,123,39,0.6); }
.sel-pin.is-lit .sel-pin-dot, .sel-pin.is-lit .sel-pin-leader { background: var(--accent); opacity: 1; }
.sel-pin.is-lit .sel-pin-label { background: var(--accent); color: #fff; }

/* ---- the list ---- */
.sel-list { display: grid; gap: 12px; }
.sel-row {
  width: 100%;
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px;
  padding: 14px 16px 14px 14px;
  border: 0; text-align: left; color: inherit; cursor: pointer;
  box-shadow: var(--shadow), 0 0 0 1px transparent;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease);
}
.sel-row:hover, .sel-row.is-lit { transform: translateY(-2px); box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 16px 32px -18px rgba(0,0,0,0.25), 0 0 0 1.5px var(--accent); }
.sel-row:active { transform: scale(0.99); }
.sel-row-plate { width: 56px; height: 56px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.sel-row-plate img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.sel-row-plate b { font-weight: 700; color: var(--navy); }
.sel-row-text { min-width: 0; display: grid; gap: 3px; }
.sel-row-name { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.sel-row-sub { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.sel-row-sub svg { color: var(--accent); }
.sel-row-chev { color: var(--faint); transition: color 0.25s, transform 0.25s var(--ease-out); }
.sel-row:hover .sel-row-chev, .sel-row.is-lit .sel-row-chev { color: var(--accent); transform: translateX(3px); }

@media (max-width: 900px) {
  .sel-grid { grid-template-columns: 1fr; }
  .sel-map { aspect-ratio: 0.85; }
  .sel-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .sel-pin-label { display: none; }
}

/* ---------------------------------------------------------- shop page -- */

.shop-mark { width: 56px; height: 56px; flex: none; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.shop-mark img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.shop-mark b { font-weight: 700; color: var(--navy); }

.newclient { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; margin-bottom: 4px; }
.newclient-label { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.newclient .field { background: var(--fill); }
.newclient--manual { margin-top: 10px; }

/* ---- CRM search on the shop screen ---- */
.crm { padding: 10px 10px 8px; margin-bottom: 4px; }
.crm-box { position: relative; display: flex; align-items: center; }
.crm-ic { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.crm-input { width: 100%; height: 50px; padding-left: 40px; padding-right: 40px; background: var(--fill); font-size: 16px; }
.crm-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.crm-spin { position: absolute; right: 16px; color: var(--muted); }
.crm-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; }
.crm-list li + li { border-top: 1px solid var(--line); }
.crm-row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  transition: background var(--dur);
}
.crm-row:hover:not(:disabled) { background: var(--fill); }
.crm-row:disabled { cursor: default; opacity: 0.6; }
.crm-row.is-busy { opacity: 1; background: var(--accent-soft); }
.crm-av { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 700; }
.crm-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.crm-text b { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-text small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-go { color: var(--faint); flex: none; }
.crm-foot { margin: 8px 6px 4px; font-size: 13px; color: var(--muted); line-height: 1.45; }
.crm-manual { border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.crm-manual:hover { text-decoration: underline; }
.file-crm { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 700; font-style: normal; letter-spacing: 0.04em; vertical-align: 1px; }
.file-contact { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 14px; color: var(--muted); }
.file-contact a { color: var(--muted); text-decoration: none; }
.file-contact a:hover { color: var(--accent); }

.files { display: grid; gap: 10px; }
.file {
  width: 100%;
  display: grid; grid-template-columns: auto 96px 1fr auto auto auto; align-items: center; gap: 14px;
  padding: 12px 16px 12px 16px;
  border: 0; text-align: left; color: inherit; cursor: pointer;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease);
}
.file:hover { transform: translateY(-2px); box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 16px 32px -18px rgba(0,0,0,0.25); }
.file-n { font-size: 13px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.file-thumb { width: 96px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--fill); }
.file-thumb--empty { display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--faint); }
.file-text { min-width: 0; }
.file-name { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.file-state { padding: 5px 10px; border-radius: 999px; background: var(--fill); font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.file-state.is-ready { background: #e9f9ee; color: #1e8b46; }
.file-arrow { color: var(--faint); }
.file-trash {
  width: 36px; height: 36px; margin-left: 2px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--faint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.file-trash:hover { background: #fff3f2; color: var(--danger); }
.file-trash:disabled { opacity: 0.4; cursor: default; }
.file:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------- client file -- */

.file-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: clamp(22px, 3.5vw, 40px) 0 6px; }

.stage {
  background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 9; max-height: none; margin-inline: auto;
  display: grid; place-items: center; position: relative;
  box-shadow: var(--shadow);
}
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; pointer-events: none; transition: opacity 0.15s; }
.stage-cover.is-off { opacity: 0; }
.stage-play {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92); color: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s var(--ease-out);
}
.stage-play:hover { transform: translate(-50%, -50%) scale(1.06); }
.stage--idle { background: var(--surface); color: var(--faint); font-size: 14px; font-weight: 600; aspect-ratio: 16 / 7; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.actions--split { justify-content: space-between; align-items: center; }
.actions-group { display: flex; flex-wrap: wrap; gap: 10px; }
.btn--trash { width: 44px; padding: 0; background: #fff3f2; color: var(--danger); }
.btn--trash:hover:not(:disabled) { background: #ffe5e2; }

.share-band { padding: 18px 18px 18px; }
.share-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.share-title { margin-top: 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.share { display: flex; gap: 10px; margin-top: 14px; }
.share-url {
  flex: 1; min-width: 0; display: flex; align-items: center;
  height: 46px; padding: 0 14px;
  background: var(--fill); border-radius: var(--radius-s);
  font-family: var(--f-mono); font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.share .btn { height: 46px; }
.share-send { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.share-send-l { font-size: 13px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.share-send .btn { height: 40px; padding: 0 14px; font-size: 14px; }
.preview { display: flex; gap: 14px; margin-top: 12px; padding: 12px; max-width: 520px; }
.preview img { width: 140px; height: 80px; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
.preview-t { display: block; font-size: 14px; font-weight: 600; }
.preview-u { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); word-break: break-all; }

.backdrop {
  width: 100%;
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px;
  padding: 10px 16px 10px 12px;
  border: 0; background: transparent; text-align: left; color: inherit; cursor: pointer;
  transition: background var(--dur);
}
.backdrop:hover:not(:disabled) { background: var(--bg); }
.backdrop:disabled { opacity: 0.45; cursor: default; }
.backdrop-plate { width: 44px; height: 44px; border-radius: 10px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.backdrop-plate img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.backdrop-plate b { font-weight: 700; color: var(--navy); }
.backdrop-plate--none { background: var(--fill); color: var(--faint); border: 0; }
.backdrop-name { display: block; font-size: 15px; font-weight: 600; }
.backdrop-sub { display: block; margin-top: 1px; font-size: 13px; color: var(--muted); }
.backdrop-check { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: transparent; }
.backdrop.is-on .backdrop-check { background: var(--accent); color: #fff; }

/* -------------------------------------------------------------- admin -- */

.admin-head { padding: clamp(22px, 3.5vw, 40px) var(--gut) 14px; }
.admin-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--fill); max-width: 100%; overflow-x: auto; }
.admin-tab {
  padding: 8px 16px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  text-decoration: none; white-space: nowrap;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.admin-main { padding-top: 18px; padding-bottom: 56px; min-width: 0; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.bar-count { font-size: 14px; color: var(--muted); }
.bar-count b { font-weight: 600; color: var(--text); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.tile { padding: 16px 18px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile-n { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.tile:first-child .tile-n { color: var(--accent); }
.tile-l { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }

.pane { padding: 18px 20px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.pane--flush { padding: 0; }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.pane--flush .pane-head { padding: 18px 20px 0; }
.pane-head h2 { font-size: 17px; }
.pane-sub { margin-top: 3px; font-size: 13.5px; color: var(--muted); }
.two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 10px; align-items: start; margin-top: 10px; }
.two--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 0; }
.two > * { min-width: 0; }

.inline { display: flex; gap: 8px; align-items: stretch; }
.inline .field, .inline .pw { flex: 1; min-width: 0; }
.inline .btn { flex: none; height: 46px; }
.settings-form .field { margin-bottom: 12px; }
.settings-form .inline .field { margin-bottom: 0; }
.settings-form .reqs { margin: 2px 0 14px; }
.f-label.emp-sub { margin-top: 16px; }

.pw { position: relative; }
.pw .field { padding-right: 44px; }
.pw-btn { position: absolute; top: 0; right: 0; width: 44px; height: 46px; display: grid; place-items: center; background: transparent; border: 0; color: var(--faint); cursor: pointer; }
.pw-btn:hover { color: var(--text); }
.pw-btn.is-on { color: var(--accent); }
.pw-tools { display: flex; gap: 6px; margin-top: 8px; }

.reqs { display: grid; gap: 6px; }
.reqs--row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.req { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--faint); }
.req i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-2); position: relative; flex: none; }
.req.is-met { color: var(--text); }
.req.is-met i { background: var(--ok); border-color: var(--ok); }
.req.is-met i::after { content: ''; position: absolute; left: 4px; top: 1.5px; width: 3px; height: 6.5px; border: solid #fff; border-width: 0 1.6px 1.6px 0; transform: rotate(42deg); }

.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--fill); }
.seg-btn { padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; transition: background var(--dur), color var(--dur); }
.seg-btn.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.seg-btn:disabled { opacity: 0.45; cursor: default; }

.add-panel { padding: 18px 20px; margin-bottom: 10px; }
.add-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 16px; align-items: start; }
.add-reqs { grid-column: 1 / -1; }
.add-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.add-foot .note { margin: 0; }
.add-actions { display: flex; gap: 8px; }

.emp-list { display: grid; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.emp + .emp { border-top: 1px solid var(--line); }
.emp.is-open { background: var(--bg); }
.emp-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 14px; padding: 12px 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--muted); font-size: 12px; font-weight: 700; }
.emp-mail { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emp-mail b { display: block; font-weight: 600; }
.emp-mail small { display: block; font-size: 12.5px; color: var(--muted); }
.you { margin-left: 8px; padding: 2px 7px; border-radius: 6px; background: var(--fill); font-size: 11px; font-weight: 600; color: var(--muted); vertical-align: middle; }
.role { padding: 4px 9px; border-radius: 7px; background: var(--fill); font-size: 12.5px; font-weight: 600; color: var(--muted); }
.role--admin { background: var(--accent-soft); color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status--active i { background: var(--ok); }
.status--invited i { background: var(--warn); }
.emp-date { font-size: 13px; color: var(--faint); white-space: nowrap; }
.emp-edit { padding: 20px 20px 16px; border-top: 1px solid var(--line); }
.emp-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 28px; align-items: start; }
.emp-block { padding: 18px 18px 20px; background: var(--surface); border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--line); }
.emp-h { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.emp-h--sub { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.emp-p { margin: 3px 0 14px; font-size: 13px; line-height: 1.45; color: var(--faint); }
.emp-block .reqs { margin-top: 10px; }
.emp-block .toggles { background: var(--bg); }
.note--tight { margin-top: 6px; }
.emp-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.emp-foot .note { margin: 0; }
.btn--danger-ghost { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn--danger-ghost:hover:not(:disabled) { background: #fff3f2; box-shadow: inset 0 0 0 1px #f3c9c4; }

/* one-of list: the chosen row carries a filled check */
.pick { display: grid; background: var(--surface); border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.emp-block .pick { background: var(--bg); }
.pick-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background var(--dur); }
.pick-row + .pick-row { border-top: 1px solid var(--line); }
.pick-row:hover:not(:disabled) { background: rgba(0, 0, 0, 0.025); }
.pick-row:disabled { opacity: 0.55; cursor: default; }
.pick-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.pick-text b { font-size: 14.5px; font-weight: 500; }
.pick-text small { font-size: 12.5px; color: var(--faint); }
.pick-check { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line-2); color: transparent; transition: background var(--dur), border-color var(--dur), color var(--dur); }
.pick-row.is-on .pick-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.pick-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.shops { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 10px; }
.shopc { padding: 18px 20px; display: grid; gap: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.shopc-top { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.shopc h3 { font-size: 16px; }
.shopc-region { margin-top: 2px; font-size: 13px; color: var(--muted); }
.shopc-plate { position: relative; width: 46px; height: 46px; border-radius: 10px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.shopc-plate img { width: 100%; height: 100%; object-fit: contain; padding: 4px; position: relative; z-index: 1; }
.shopc-plate b { position: absolute; font-weight: 700; color: var(--navy); }
.shopc-figs { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shopc-figs dt { font-size: 12px; color: var(--muted); }
.shopc-figs dd { margin: 0 0 2px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 20px 14px; border-bottom: 1px solid var(--line); }
.field--select {
  height: 38px; width: auto; min-width: 150px; padding-right: 32px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238e8e93' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.feed { display: grid; }
.feed .hint { padding: 20px; margin: 0; }
.ev { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev-dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--line-2); }
.ev--open .ev-dot { background: var(--ok); }
.ev--send .ev-dot { background: var(--accent); }
.ev--warn .ev-dot { background: var(--danger); }
.ev-line { margin: 0; font-size: 14px; line-height: 1.45; }
.ev-line b { font-weight: 600; }
.ev-meta { margin: 3px 0 0; display: flex; gap: 8px; font-size: 12.5px; color: var(--faint); }
.ev-kind::after { content: '·'; margin-left: 8px; }

.chart { margin: 0; position: relative; }
.chart-plot { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.chart-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; outline: none; }
.chart-col::before { content: ''; position: absolute; inset: 0; border-radius: 4px; }
.chart-col:hover::before, .chart-col:focus-visible::before { background: var(--bg); }
.chart-bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.chart-bar[style*="height:0%"] { background: var(--fill-2); }
.chart-peak { position: absolute; top: 0; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--faint); }
.chart-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); padding: 7px 10px; border-radius: 8px; background: var(--text); color: #fff; font-size: 12px; line-height: 1.3; white-space: nowrap; pointer-events: none; z-index: 5; }
.chart-tip b { font-weight: 700; }
.chart-tip span { display: block; opacity: 0.7; font-size: 11px; }

.rank { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 1fr 70px auto; gap: 10px; align-items: center; }
.rank-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 6px; border-radius: 3px; background: var(--fill); display: block; overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--accent); }
.rank-n { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.kv { margin: 0 0 14px; display: grid; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { font-size: 14px; }
.kv dd { margin: 0; font-size: 14px; color: var(--muted); text-align: right; word-break: break-word; }

/* -------------------------------------------------------------- login -- */

.auth { min-height: 100dvh; display: grid; justify-items: center; align-content: center; gap: 18px; padding: 24px var(--gut); }
.auth-brand { display: grid; justify-items: center; gap: 6px; text-align: center; }
.auth-mark { margin: 0; }
.auth-mark img { width: 260px; height: auto; }
.auth-h1, .auth-brand-lede { display: none; }
.auth-brand-foot { order: 1; font-size: 13px; color: var(--faint); }
.auth-panel { width: 100%; max-width: 400px; }
.auth-forms { display: grid; gap: 18px; }
.auth-sec { padding: 26px 24px 24px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); }
.auth-sec-head { display: grid; gap: 4px; margin-bottom: 4px; }
.auth-sec-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.auth-sec-lede { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.auth-form { display: grid; }
.auth-form .field { margin-bottom: 14px; }
.auth-form .pw .field { margin-bottom: 0; }
.auth-form .pw { margin-bottom: 14px; }
.auth-error { margin: -4px 0 12px; font-size: 13.5px; color: var(--danger); }
.auth-form .btn--block { height: 48px; margin-top: 4px; }

/* --------------------------------------------------------------- misc -- */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 11px 16px; border-radius: 12px;
  background: var(--text); color: #fff;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.4);
  z-index: 50;
  animation: toastIn 0.25s var(--ease-out) both;
}
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.15); border-top-color: currentColor; border-radius: 50%; animation: spin 700ms linear infinite; }
.adm-loading { display: grid; place-items: center; min-height: 40vh; color: var(--faint); }
.adm-loading .spinner { width: 22px; height: 22px; border-width: 2.5px; }

/* ---- admin shell: sidebar + main ---- */
.adm { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; background: var(--bg); }
.adm-side {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.adm-logo { display: block; padding: 2px 10px 18px; }
.adm-logo img { height: 30px; width: auto; }
.adm-nav { display: grid; gap: 2px; }
.adm-link {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font-size: 14.5px; font-weight: 500; text-align: left; text-decoration: none;
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.adm-link:hover { background: var(--bg); color: var(--text); }
.adm-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.adm-link-ic { width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
.adm-side-foot { margin-top: auto; display: grid; gap: 2px; padding-top: 14px; border-top: 1px solid var(--line); }
.adm-who { margin: 8px 12px 0; font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.adm-main { min-width: 0; display: flex; flex-direction: column; }
.adm-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 26px 32px 8px; }
.adm-title { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.adm-lede { margin-top: 3px; font-size: 14px; color: var(--muted); }
.adm-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; flex: none; }
.adm-body { padding: 14px 32px 48px; min-width: 0; }

@media (max-width: 900px) {
  .adm { grid-template-columns: 1fr; }
  .adm-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .adm-logo { padding: 4px 8px; }
  .adm-logo img { height: 26px; }
  .adm-nav { display: flex; gap: 2px; width: 100%; overflow-x: auto; }
  .adm-link { width: auto; padding: 8px 10px; font-size: 13.5px; white-space: nowrap; }
  .adm-link-ic { display: none; }
  .adm-side-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; }
  .adm-who { display: none; }
  .adm-head { padding: 18px 16px 6px; }
  .adm-body { padding: 10px 16px 40px; }
}

/* ---- activity analytics ---- */
.an { --s-sent: #2a6df4; --s-opened: #f47b27; display: grid; gap: 12px; }
.an-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.an-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.an-who-label { font-size: 14px; color: var(--muted); white-space: nowrap; }
.an-select {
  height: 40px; width: auto; min-width: 220px; padding-right: 34px; appearance: none; cursor: pointer; font-weight: 500; font-size: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238e8e93' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.an-select--sm { height: 34px; min-width: 0; font-size: 13.5px; padding-inline: 10px 30px; }
/* ---- date range picker ---- */
.rp { position: relative; }
.rp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px 0 12px;
  border: 0; border-radius: 10px;
  background: var(--fill); color: var(--text);
  font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background var(--dur);
}
.rp-btn:hover { background: var(--fill-2); }
.rp-btn[aria-expanded="true"] { background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.rp-btn svg { color: var(--muted); }
.rp-scrim { display: none; }
.rp-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: 312px; padding: 12px 12px 12px;
  border-radius: 16px; background: var(--surface);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.06);
  animation: popIn 0.16s var(--ease-out) both;
}
.rp-pop[hidden] { display: none; }
.rp-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 8px; }
.rp-head b { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.rp-nav { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--accent); cursor: pointer; }
.rp-nav:hover:not(:disabled) { background: var(--fill); }
.rp-nav:disabled { color: var(--faint); cursor: default; }
.rp-dow { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.rp-dow span { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--faint); }
.rp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.rp-day { position: relative; height: 38px; padding: 0; border: 0; background: transparent; color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer; }
.rp-day span { position: relative; z-index: 1; display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; transition: background var(--dur), color var(--dur); }
.rp-day:hover:not(:disabled):not(.is-start):not(.is-end) span { background: var(--fill); }
.rp-day:disabled { color: var(--faint); cursor: default; }
.rp-day--pad { pointer-events: none; }
.rp-day.is-today span { font-weight: 700; color: var(--accent); }
.rp-day.is-in::before { content: ''; position: absolute; left: 0; right: 0; top: 2px; bottom: 2px; background: var(--accent-soft); }
.rp-day.is-start::before { left: 50%; border-radius: 17px 0 0 17px; }
.rp-day.is-end::before { right: 50%; border-radius: 0 17px 17px 0; }
.rp-day.is-start.is-end::before { display: none; }
.rp-day.is-start span, .rp-day.is-end span { background: var(--accent); color: #fff; font-weight: 600; }
.rp-hint { margin: 8px 4px 10px; font-size: 12.5px; color: var(--muted); }
.rp-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px; background: var(--fill); }
.rp-preset { padding: 7px 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background var(--dur), color var(--dur), box-shadow var(--dur); }
.rp-preset.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
@media (max-width: 560px) {
  .rp-scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, 0.3); }
  .rp-scrim[hidden] { display: none; }
  .rp-pop { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; animation: riseIn 0.2s var(--ease-out) both; }
}

.an-person { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--accent-soft); }
.an-person-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.an-person-text b { font-size: 14.5px; font-weight: 600; }
.an-person-text small { font-size: 12.5px; color: var(--muted); }

.an-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.an-kpi { padding: 16px 18px 14px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 6px; }
.an-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.an-kpi-l { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.an-kpi-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--fill); color: var(--muted); }
.an-kpi--sent .an-kpi-ic { background: #e8f0ff; color: var(--s-sent); }
.an-kpi--opened .an-kpi-ic { background: var(--accent-soft); color: var(--s-opened); }
.an-kpi-n { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.an-delta { font-size: 12.5px; font-weight: 600; }
.an-delta--up { color: #1e8b46; }
.an-delta--down { color: var(--danger); }
.an-delta--none { color: var(--faint); font-weight: 500; }

.an-ring { display: grid; grid-template-columns: 128px 1fr; gap: 14px; align-items: center; }
.an-ring-svg { width: 128px; height: 128px; }
.an-ring-track { fill: none; stroke: var(--fill-2); stroke-width: 12; }
.an-ring-arc { fill: none; stroke: var(--s-opened); stroke-width: 12; stroke-linecap: round; }
.an-ring-n { text-anchor: middle; font-size: 24px; font-weight: 700; fill: var(--text); dominant-baseline: middle; }
.an-ring-t { text-anchor: middle; font-size: 10px; fill: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; }
.an-ring-legend { display: grid; gap: 8px; font-size: 13.5px; color: var(--muted); }
.an-ring-legend li { display: flex; align-items: center; gap: 8px; }
.an-ring-legend b { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.an-sw--track { background: var(--fill-2); }

.an-card { padding: 18px 20px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.an-card--flush { padding: 0; }
.an-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.an-card-head--pad { padding: 18px 20px 0; }
.an-card-head h2 { font-size: 16px; font-weight: 600; }
.an-card-head p { margin-top: 2px; font-size: 13px; color: var(--muted); }
.an-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.an-two--wide { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.an-two > * { min-width: 0; }
.an-empty { margin: 0; padding: 18px 0; font-size: 14px; color: var(--faint); }

.an-legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.an-legend span { display: inline-flex; align-items: center; gap: 6px; }
.an-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.an-sw--sent { background: var(--s-sent); }
.an-sw--opened { background: var(--s-opened); }

/* ---- the chart ---- */
.an-fig { margin: 0; position: relative; }
.an-svg { width: 100%; height: auto; display: block; overflow: visible; cursor: crosshair; }
.an-gridline { stroke: var(--line); stroke-width: 1; }
.an-tick { fill: var(--faint); font-size: 10px; text-anchor: end; font-variant-numeric: tabular-nums; }
.an-x { fill: var(--faint); font-size: 10.5px; }
.an-fig--opened { --s: var(--s-opened); }
.an-fig--sent { --s: var(--s-sent); }
.an-area { pointer-events: none; }
.an-line { fill: none; stroke: var(--s); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.an-dot { fill: var(--s); stroke: var(--surface); stroke-width: 2.5; pointer-events: none; }
.an-cursor { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.an-cursor[hidden], .an-dot[hidden] { display: none; }
.seg--mini { grid-template-columns: auto auto; padding: 2px; border-radius: 8px; }
.seg--mini .seg-btn { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.an-tip {
  position: absolute; z-index: 3;
  transform: translateY(-100%);
  display: grid; gap: 3px;
  padding: 8px 11px; border-radius: 9px;
  background: var(--text); color: #fff;
  font-size: 12.5px; line-height: 1.3; white-space: nowrap;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.4);
  pointer-events: none;
}
.an-tip b { font-weight: 600; margin-bottom: 1px; }
.an-tip span { display: inline-flex; align-items: center; gap: 6px; }
.an-tip em { font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- rows with two bars (shops, employees) ---- */
.an-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 14px; padding: 12px 0; width: 100%; background: transparent; border: 0; text-align: left; color: inherit; }
.an-row + .an-row { border-top: 1px solid var(--line); }
.an-row--pick { cursor: pointer; padding-inline: 10px; margin-inline: -10px; width: calc(100% + 20px); border-radius: 10px; transition: background var(--dur); }
.an-row--pick:hover { background: var(--bg); }
.an-row--pick.is-on { background: var(--accent-soft); }
.an-row .avatar { width: 40px; height: 40px; font-size: 13px; }
.an-row-plate { width: 40px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.an-row-plate img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.an-row-plate b { font-weight: 700; font-size: 13px; color: var(--navy); }
.an-row-main { min-width: 0; display: grid; gap: 7px; }
.an-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.an-row-head b { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-row-head small { font-size: 12px; color: var(--faint); white-space: nowrap; }
.an-bars { display: grid; gap: 5px; }
.an-barrow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.an-barfill { display: block; height: 9px; border-radius: 5px; flex: none; transition: width 0.4s var(--ease-out); }
.an-barfill--sent { background: var(--s-sent); }
.an-barfill--opened { background: var(--s-opened); }
.an-barrow em { font-style: normal; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- the stream ---- */
.an-feed-tools { display: flex; gap: 6px; }
.an-feed { padding: 0 20px 8px; }
.an-day { padding-top: 6px; }
.an-day-h { margin: 0; padding: 12px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--faint); }
.an-ev { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.an-day .an-ev:first-of-type { border-top: 0; }
.an-ev-ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--muted); }
.an-ev--open .an-ev-ic { background: #e9f9ee; color: #1e8b46; }
.an-ev--send .an-ev-ic { background: var(--accent-soft); color: var(--accent); }
.an-ev--warn .an-ev-ic { background: #fff3f2; color: var(--danger); }
.an-ev-text { font-size: 14px; line-height: 1.4; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.an-ev-text b { font-weight: 600; color: var(--text); }
.an-ev-time { font-size: 12.5px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 1000px) { .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .an-two, .an-two--wide { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .an-controls { align-items: stretch; flex-direction: column; }
  .an-who { width: 100%; }
  .an-select { flex: 1; min-width: 0; }
  .an-row-nums { column-gap: 10px; }
  .an-card-head { flex-direction: column; }
  .an-feed-tools { width: 100%; }
  .an-feed-tools .an-select--sm { flex: 1; }
}

/* ---- shops (admin) ---- */
.sh { display: grid; gap: 12px; }
.sh-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sh-sum { padding: 14px 18px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; align-items: baseline; gap: 8px; }
.sh-sum b { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sh-sum span { font-size: 13px; color: var(--muted); }
.sh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.sh-card { padding: 18px 20px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 14px; align-content: start; transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease); }
.sh-card:hover { transform: translateY(-2px); box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 16px 32px -18px rgba(0,0,0,0.25); }
.sh-top { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.sh-plate { width: 52px; height: 52px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.sh-plate img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.sh-plate b { font-weight: 700; color: var(--navy); }
.sh-title { min-width: 0; }
.sh-title h3 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-title p { margin-top: 3px; display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.sh-title p svg { color: var(--accent); }
.sh-figs { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sh-figs dd { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sh-figs dt { margin-top: 1px; font-size: 12px; color: var(--muted); }
.sh-recent { font-size: 13px; color: var(--muted); }
.sh-recent b { color: var(--text); font-weight: 600; }
.sh-links { display: flex; flex-wrap: wrap; gap: 6px; }
.sh-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; background: var(--fill); color: var(--text); font-size: 12.5px; font-weight: 500; text-decoration: none; max-width: 100%; }
.sh-chip svg { color: var(--muted); flex: none; }
.sh-chip:hover { background: var(--fill-2); }
.sh-chip--off { color: var(--faint); }
.sh-staff { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sh-staff-l { font-size: 12.5px; color: var(--faint); }
.sh-staff-row { display: flex; }
.sh-av { width: 26px; height: 26px; border-radius: 50%; margin-left: -6px; display: grid; place-items: center; background: var(--fill); border: 2px solid var(--surface); font-size: 9.5px; font-weight: 700; font-style: normal; color: var(--muted); }
.sh-av:first-child { margin-left: 0; }
.sh-av--more { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 900px) { .sh-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- switches ---- */
.toggles { display: grid; background: var(--surface); border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; cursor: pointer; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle-text { display: grid; gap: 1px; min-width: 0; }
.toggle-text b { font-size: 14.5px; font-weight: 500; }
.toggle-text small { font-size: 12.5px; color: var(--faint); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch {
  position: relative; flex: none;
  width: 46px; height: 28px; border-radius: 999px;
  background: #e0e0e5;
  transition: background 0.2s;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.2s var(--ease-out);
}
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.add-access { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 14px 16px; align-items: start; }
.emp-access { font-size: 13px; color: var(--muted); white-space: nowrap; }
.emp-row { grid-template-columns: 36px minmax(0, 1fr) auto auto auto auto auto; }

/* ---- background websites (settings) ---- */
.settings-stack { display: grid; gap: 10px; }
.site-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; margin-bottom: 12px; }
.site-add .btn { height: 46px; }
.sites { display: grid; background: var(--surface); border-radius: var(--radius-s); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.sites:empty { display: none; }
.site { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; }
.site + .site { border-top: 1px solid var(--line); }
.site-ic { width: 36px; height: 36px; border-radius: 9px; background: var(--fill); color: var(--muted); display: grid; place-items: center; }
.site-text { min-width: 0; display: grid; gap: 1px; }
.site-text b { font-size: 14.5px; font-weight: 500; }
.site-text small { font-size: 12.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-text em { font-style: normal; color: var(--warn); }
.backdrop-plate--site { background: var(--fill); color: var(--muted); border: 0; }

/* ---- the question sheet (replaces window.confirm) ---- */
.ask {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px;
  padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.35);
  animation: fadeIn 0.18s var(--ease-out) both;
}
.ask.is-leaving { animation: fadeIn 0.18s var(--ease-out) reverse both; }
.ask-card {
  width: 100%; max-width: 440px;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 14px; overflow: hidden;
  animation: riseIn 0.22s var(--ease-out) both;
}
.ask-msg { margin: 0; padding: 16px 20px; text-align: center; font-size: 14px; color: var(--muted); border-bottom: 1px solid var(--line); }
.ask-btn { display: block; width: 100%; height: 54px; border: 0; background: transparent; font-size: 19px; cursor: pointer; }
.ask-btn--ok { color: var(--accent); font-weight: 600; }
.ask-btn--danger { color: var(--danger); font-weight: 600; }
.ask-btn--cancel { color: var(--text); font-weight: 600; background: rgba(255, 255, 255, 0.96); }
.ask-btn:active { background: var(--fill); }
/* On a desktop it is an alert in the middle of the screen, one block: the
   question, the action, Cancel — not a sheet sliding up from the bottom. */
@media (min-width: 900px) {
  .ask { justify-content: center; gap: 0; padding: 24px; }
  .ask .ask-card { max-width: 340px; animation: popIn 0.18s var(--ease-out) both; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.4); }
  .ask .ask-card:first-child { border-radius: 16px 16px 0 0; }
  .ask .ask-btn--cancel { border-radius: 0 0 16px 16px; border-top: 1px solid var(--line); height: 50px; font-size: 17px; }
  .ask .ask-msg { padding: 22px 22px 18px; font-size: 15px; color: var(--text); line-height: 1.45; }
  .ask .ask-btn { height: 50px; font-size: 17px; }
}
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- narrow -- */

@media (max-width: 900px) {
  .two, .two--even { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-grid { grid-template-columns: minmax(0, 1fr); }
  .emp-edit { padding: 16px 14px; }
  .emp-cols { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .emp-block + .emp-block { padding-top: 16px; border-top: 1px solid var(--line); }
  .emp-row { grid-template-columns: 36px minmax(0, 1fr) auto auto; }
  .emp-date, .emp-row .status, .emp-access { display: none; }
  .add-access, .site-add { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; row-gap: 8px; padding-block: 10px; position: static; }
  .topbar-shop { width: 100%; margin-left: 0; }
  .topbar-user { display: none; }
  .page-head--row .shop-mark { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar-shop b { display: none; }
  .brand-logo img { height: 28px; }
  .newclient { grid-template-columns: 1fr; padding: 12px; }
  .newclient-label { display: none; }
  .file { grid-template-columns: 84px 1fr auto; gap: 10px 12px; padding: 10px 12px; }
  .file-n, .file-arrow { display: none; }
  .file-thumb { width: 84px; height: 48px; grid-row: 1 / 3; }
  .file-text { grid-column: 2; grid-row: 1; }
  .file-state { grid-column: 2; grid-row: 2; justify-self: start; }
  .file-trash { grid-column: 3; grid-row: 1 / 3; color: var(--muted); background: var(--fill); }
  .file-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .share { flex-direction: column; }
  .actions .btn { flex: 1; }
  .preview { flex-direction: column; }
  .preview img { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .admin-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; width: 100%; }
  .admin-tab { text-align: center; padding-inline: 6px; font-size: 13px; }
  .emp-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 12px; }
  .emp-row .avatar { display: none; }
  .add-foot { flex-direction: column; align-items: stretch; }
  .add-actions { justify-content: flex-end; }
  .filters { padding-inline: 14px; }
  .field--select { min-width: 0; flex: 1; }
  .ev { padding-inline: 14px; }
  .pane--flush .pane-head { padding-inline: 14px; }
  .chart-plot { min-width: 420px; }
  .chart { overflow-x: auto; }
  .page-foot i { display: none; }
}


/* ============================================================ camera ==
   The full-screen recorder (public/js/recorder.js). The viewfinder is the
   page; everything else floats over it in the layout of a phone camera:
   close top-left, tools down the right, timer and shutter at the bottom.
   ==================================================================== */

body.rec-open { overflow: hidden; }

.rec {
  position: fixed; inset: 0;
  z-index: 100;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  animation: fadeIn 0.3s var(--ease-out) both;
}
.rec-view { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.rec-view.is-mirrored { transform: scaleX(-1); }
/* Kept in the document (Safari won't record a canvas that isn't), but out of sight. */
.rec-canvas { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; }

.rec button { background: transparent; border: 0; color: #fff; padding: 0; }

.rec-top {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), transparent);
}
.rec-x {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}
/* One pill per finished take, widths in proportion to their length. */
.rec-takes { flex: 1; display: flex; gap: 4px; height: 4px; }
.rec-takes i { display: block; height: 100%; border-radius: 2px; background: #fff; min-width: 6px; box-shadow: 0 0 8px rgba(255,255,255,0.5); }
.rec-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(0,0,0,0.42);
  font-family: var(--f-sys); font-size: 11px; font-weight: 800; letter-spacing: 0.18em;
}
.rec-badge i { width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; animation: pulse 1.1s ease-in-out infinite; }

.rec-rail {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-30%);
  display: grid; gap: 22px;
}
.rec-tool {
  display: grid; justify-items: center; gap: 6px;
  width: 64px;
  font-size: 13px; font-weight: 500;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  cursor: pointer;
  transition: opacity 0.25s;
}
.rec-tool:disabled { opacity: 0.35; cursor: default; }
.rec-tool-ic {
  position: relative;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background 0.25s, box-shadow 0.25s;
}
.rec-tool:not(:disabled):active .rec-tool-ic { background: rgba(255,255,255,0.22); }
.rec-tool.is-on .rec-tool-ic { background: rgba(244,123,39,0.85); box-shadow: 0 0 22px rgba(244,123,39,0.55); }
.rec-tool-ic b {
  position: absolute; right: -2px; top: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: #fff; color: #000;
  font-family: var(--f-sys); font-size: 10.5px; font-weight: 800;
}

.rec-count {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--f-sys); font-size: 140px; font-weight: 800; line-height: 1;
  text-shadow: 0 6px 30px rgba(0,0,0,0.6);
  animation: countPop 1s ease-out infinite;
}
@keyframes countPop { from { transform: translate(-50%, -50%) scale(1.15); opacity: 0.6; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.rec-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; justify-items: center; gap: 14px;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent);
}
.rec-time {
  font-size: 20px; font-weight: 600; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 8px rgba(0,0,0,0.7);
}
.rec[data-state="recording"] .rec-time { color: #ff6b61; }
.rec-row {
  width: 100%; max-width: 420px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.rec-side {
  display: grid; justify-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  cursor: pointer;
}
.rec-side:first-child { justify-self: start; }
.rec-side:last-child { justify-self: end; }
.rec-side-ic {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.rec-done .rec-side-ic { background: var(--accent); color: var(--on-accent); border-radius: 50%; box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 60%, transparent); }
.rec-done { color: #fff; }

/* The shutter: a red disc in a white ring. Recording turns the disc into a
   rounded square — the pause affordance every phone camera uses. */
.rec-shutter {
  grid-column: 2;
  width: 84px; height: 84px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 4px solid #fff;
  cursor: pointer;
  transition: transform 0.15s;
}
.rec-shutter:active { transform: scale(0.94); }
.rec-shutter:disabled { opacity: 0.5; cursor: default; }
.rec-shutter i {
  display: block;
  width: 66px; height: 66px;
  border-radius: 50%;
  background: #ff3b30;
  transition: width 0.25s var(--ease-out), height 0.25s var(--ease-out), border-radius 0.25s var(--ease-out);
}
.rec[data-state="recording"] .rec-shutter i { width: 30px; height: 30px; border-radius: 7px; }
.rec[data-state="paused"] .rec-shutter i { animation: shutterHint 1.6s ease-in-out infinite; }
@keyframes shutterHint { 50% { transform: scale(0.9); } }
.rec-hint { margin: 0; font-size: 13px; color: rgba(255,255,255,0.7); text-shadow: 0 1px 6px rgba(0,0,0,0.7); text-align: center; }

.rec-error {
  position: absolute; left: 16px; right: 16px; top: 50%;
  transform: translateY(-50%);
  margin: 0; padding: 14px 16px;
  border-radius: 10px;
  background: rgba(4, 11, 28, 0.9);
  border: 1px solid rgba(var(--glow), 0.4);
  font-size: 14.5px; text-align: center;
  animation: riseIn 0.3s var(--ease-out) both;
}
.rec.is-counting .rec-rail, .rec.is-counting .rec-side { visibility: hidden; }

@media (min-width: 900px) {
  /* Desktop: the viewfinder stays a phone's shape in the middle, not a wall of webcam. */
  .rec-view { width: min(100%, calc(100vh * 0.5625)); left: 50%; transform: translateX(-50%); }
  .rec-view.is-mirrored { transform: translateX(-50%) scaleX(-1); }
}

/* ============================================================ editor ==
   Trim → Audio → Export (public/js/editor.js). Styled like a phone's own
   editing sheet rather than the hub: black, the system face, a nav bar
   with Cancel and Next, the clip in a rounded preview, one control group
   per step. The shop's accent is the only colour.
   The preview is a fixed box the video is fitted INTO (absolute, not
   intrinsic) — a 4K clip must never size the layout.
   ==================================================================== */

.ed {
  --sys: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  --ed-bg: #000;
  --ed-group: #1c1c1e;
  --ed-sep: rgba(255, 255, 255, 0.14);
  --ed-2: #8e8e93;
  position: fixed; inset: 0;
  height: 100dvh;
  z-index: 100;
  display: flex; flex-direction: column;
  background: var(--ed-bg);
  color: #fff;
  font-family: var(--sys);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  animation: fadeIn 0.25s var(--ease-out) both;
}
.ed button { font-family: inherit; }

.ed-nav {
  flex: none;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 6px 0;
}
.ed-navbtn {
  justify-self: start;
  height: 44px; padding: 0 12px;
  background: transparent; border: 0;
  color: var(--accent-bright);
  font-size: 17px; letter-spacing: -0.01em;
  cursor: pointer;
}
.ed-navbtn--strong { justify-self: end; font-weight: 600; }
.ed-navbtn[hidden] { display: none; }
.ed-title { margin: 0; font-family: var(--sys); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; text-transform: none; }

.ed-stage { flex: 1 1 0; min-height: 160px; padding: 4px 16px 14px; }
.ed-frame {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #0a0a0a;
}
.ed-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ed-play {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: 50%; border: 0;
  background: rgba(30, 30, 30, 0.7); color: #fff;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: opacity 0.2s;
}
.ed.is-playing .ed-play, .ed.is-dragging .ed-play { opacity: 0; pointer-events: none; }
.ed-muted {
  position: absolute; left: 10px; top: 10px;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(30, 30, 30, 0.75);
  font-size: 12px; font-weight: 600; color: var(--ed-2);
}

.ed-panel { flex: none; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); }

/* ---- trim ---- */
.ed-readout {
  display: flex; justify-content: center; align-items: baseline; gap: 10px;
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
  font-size: 15px; color: var(--ed-2);
}
.ed-readout b { font-size: 17px; font-weight: 600; color: #fff; }

.ed-timeline {
  position: relative; height: 60px;
  border-radius: 10px;
  background: var(--ed-group);
  touch-action: none;
}
.ed-strip { position: absolute; inset: 0; display: flex; border-radius: 10px; overflow: hidden; }
.ed-strip canvas { flex: none; height: 100%; display: block; }
.ed-shade { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.ed-shade--l { left: 0; border-radius: 10px 0 0 10px; }
.ed-shade--r { right: 0; border-radius: 0 10px 10px 0; }
/* The selection bracket, as on a phone's own trimmer. */
.ed-sel {
  position: absolute; top: 0; bottom: 0;
  border-top: 3px solid var(--accent-bright);
  border-bottom: 3px solid var(--accent-bright);
  box-sizing: border-box;
  pointer-events: none;
}
.ed-handle {
  position: absolute; top: -3px; bottom: -3px;
  width: 20px;
  will-change: left, right;
  background: var(--accent-bright); color: var(--on-accent);
  display: grid; place-items: center;
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
}
.ed-handle--l { left: 0; border-radius: 10px 0 0 10px; }
.ed-handle--r { right: 0; border-radius: 0 10px 10px 0; }
/* The visible grip is 20px; the finger target is 48px. */
.ed-handle::before { content: ''; position: absolute; top: -8px; bottom: -8px; left: -14px; right: -14px; }
.ed-handle:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.ed-playhead {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  border-radius: 1px;
  background: #fff;
  pointer-events: none;
  transform: translateX(-1px);
}

/* ---- grouped lists (audio, export) ---- */
.ed-label { margin: 0 0 8px 4px; font-size: 13px; font-weight: 600; color: var(--ed-2); text-transform: uppercase; letter-spacing: 0.04em; }
.ed-group { margin: 0; display: grid; border-radius: 12px; background: var(--ed-group); overflow: hidden; }
.ed-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 16px;
  background: transparent; border: 0; color: #fff;
  text-align: left; font-size: 17px; letter-spacing: -0.01em;
  cursor: pointer;
}
.ed-row + .ed-row { border-top: 1px solid var(--ed-sep); }
.ed-row:active { background: rgba(255, 255, 255, 0.06); }
.ed-row-ic { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); color: var(--ed-2); transition: background 0.15s, color 0.15s; }
.ed-row.is-on .ed-row-ic { background: rgba(244, 123, 39, 0.18); color: var(--accent-bright); }
.ed-row-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.ed-row-text b { font-weight: 500; }
.ed-row-text small { font-size: 13px; color: var(--ed-2); }
.ed-row-check { color: var(--accent-bright); opacity: 0; transition: opacity 0.15s; }
.ed-row.is-on .ed-row-check { opacity: 1; }
.ed-group--list .ed-row { cursor: default; }
.ed-group--list dt { color: #fff; }
.ed-group--list dd { margin: 0; color: var(--ed-2); font-variant-numeric: tabular-nums; }

/* ---- voiceover: a row inside the Sound group, under the Voiceover choice ---- */
.ed-vo {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--ed-sep);
  background: rgba(255, 255, 255, 0.03);
}
.ed-vo-rec {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%; border: 3px solid #fff;
  background: transparent; cursor: pointer;
}
.ed-vo-rec i { display: block; width: 32px; height: 32px; border-radius: 50%; background: #ff3b30; transition: width 0.2s, height 0.2s, border-radius 0.2s; }
.ed-vo-rec.is-rec i { width: 18px; height: 18px; border-radius: 5px; }
.ed-vo-rec.is-done { border-color: var(--accent-bright); }
.ed-vo-rec.is-done i { background: var(--accent-bright); width: 18px; height: 18px; }
.ed-vo-rec:disabled { cursor: default; }
.ed-vo-text { display: grid; gap: 1px; min-width: 0; }
.ed-vo-text b { font-size: 15px; font-weight: 500; }
.ed-vo-text small { font-size: 13px; color: var(--ed-2); font-variant-numeric: tabular-nums; }
.ed-meter { display: flex; align-items: flex-end; gap: 2px; width: 52px; height: 26px; opacity: 0.3; transition: opacity 0.2s; }
.ed-meter.is-on { opacity: 1; }
.ed-meter i { flex: 1; height: 12%; border-radius: 2px; background: var(--accent-bright); transition: height 0.08s; }
.ed-vo-redo { padding: 0 4px; }

/* ---- export ---- */
.ed-export { display: grid; gap: 12px; margin-top: 16px; }
.ed-cta {
  height: 52px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer;
}
.ed-cta:active { filter: brightness(0.92); }
.ed-foot { margin: 0; text-align: center; font-size: 13px; color: var(--ed-2); }
.ed-bar { height: 5px; border-radius: 3px; background: var(--ed-group); overflow: hidden; }
.ed-bar i { display: block; height: 100%; width: 0; background: var(--accent-bright); transition: width 0.3s; }

.ed-error {
  position: absolute; left: 16px; right: 16px; top: calc(60px + env(safe-area-inset-top));
  margin: 0; padding: 12px 16px;
  border-radius: 12px;
  background: #2c2c2e;
  font-size: 15px; text-align: center;
  animation: riseIn 0.25s var(--ease-out) both;
  z-index: 2;
}

@media (min-width: 900px) {
  .ed-stage { padding-inline: max(16px, calc(50% - 300px)); }
  .ed-panel { padding-inline: max(16px, calc(50% - 300px)); }
}



.kv-sub { font-size: 12px; color: var(--faint); }
