/* App shell (v9): login gate, tabs, views, admin, confirm pop-up, toast. Uses the tokens from style.css. */
body.booting > *:not(.gate) { visibility: hidden; }
body.gated > *:not(.gate):not(.toast) { display: none !important; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 6px max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.tabs a, .me-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
}
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tabs a.on { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.tabs-spacer { flex: 1; }
/* "You've been assigned" count on the Planning tab (shell.js planningBadge) */
.tabs a { position: relative; }
.tab-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
@media (max-width: 600px) { .tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); } }
.offline-pill { font-size: 12px; font-weight: 700; color: var(--queued-text); background: var(--queued-soft); padding: 4px 10px; border-radius: 999px; }
.offline-pill[hidden] { display: none; }
.admin-only { display: none !important; }
body.is-admin .admin-only { display: inline-flex !important; }
body.locked .tabs { pointer-events: none; opacity: .4; }

/* Live-only parts of the top bar. On other tabs it stays as a mini-transport: play/stop, bar, current song. */
body:not(.tab-live) .foot,
body:not(.tab-live) #lockBtn,
body:not(.tab-live) .lock-banner,
body:not(.tab-live) .transport .field { display: none !important; }

.view[hidden] { display: none !important; }
.view:not(.grid) { padding: 16px max(20px, env(safe-area-inset-left)) 24px; max-width: 1280px; margin: 0 auto; }
.view-title { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.card.soon h2 { font-size: 20px; color: var(--text); text-transform: none; letter-spacing: 0; }
.card.soon p { margin: 0; }

/* ---------- Gate (login, invite, password) ---------- */
.gate { position: fixed; inset: 0; z-index: 60; overflow-y: auto; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; }
.gate[hidden] { display: none; }
.gate-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 20px; }
.gate-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; justify-content: center; }
.gate-form { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; }
.gate-form h1 { margin: 0; font-size: 20px; }
.gate-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.gate-field input, .inline-form input, .inline-form select, .admin-body select {
  background-color: var(--surface-2); border: 1px solid var(--faint); border-radius: 9px; padding: 10px 12px;
  font-size: 16px; color: var(--text); width: 100%; min-height: 44px;
}
.gate-note { margin: 0; color: var(--muted); }
.gate-error { margin: 0; color: var(--danger-text); font-size: 14px; font-weight: 500; }
.gate-error[hidden] { display: none; }
.gate-submit { min-height: 48px; font-size: 15px; font-weight: 600; }
.gate-hint { margin: 0; font-size: 13px; color: var(--faint); text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--bottom-bar, 0px)); z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: var(--danger-ink); }

/* ---------- Confirm pop-up and account sheet ---------- */
.confirm-msg { margin: 0; font-size: 15px; line-height: 1.5; }
.btn.danger-solid { background: var(--danger); color: var(--danger-ink); font-weight: 700; }
#meDialog .btn { width: 100%; }
#meDialog h3 { margin-bottom: -8px; }

/* ---------- Admin ---------- */
/* Long member lists must scroll on laptops: undo the Live tab's single-screen body lock (style.css). */
@media (min-width: 1000px) and (min-height: 600px) and (min-aspect-ratio: 5/4) {
  body.tab-admin { height: auto; overflow: visible; display: block; }
  body.tab-admin .topbar { position: sticky; }
}
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-nav { flex-wrap: wrap; max-width: 100%; }
.sys-warn { background: var(--queued-soft); color: var(--queued-text); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.sys-warn p { margin: 0; }
.admin-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-tools select { width: auto; }
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member {
  display: grid; grid-template-columns: minmax(0, 1fr) 190px auto; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.member:not(:has(.member-role)) { grid-template-columns: minmax(0, 1fr) auto; }
.member-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member-sub { font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }
.member-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip.danger { color: var(--danger-text); border-color: var(--danger-soft); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.master { background: var(--accent-soft); color: var(--accent); }
.badge.off { background: var(--danger-soft); color: var(--danger-text); }
.inline-form { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.inline-form h3, .custom-roles h3, .danger-zone h3 { margin: 0; font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.form-actions select { width: auto; flex: 1 1 200px; }
.secret { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--play-soft); border: 1px solid var(--play); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.secret-title { width: 100%; font-weight: 700; }
.secret code { font-size: 15px; background: var(--surface); padding: 8px 10px; border-radius: 8px; overflow-wrap: anywhere; flex: 1 1 200px; user-select: all; }
.secret .hint { width: 100%; }
.matrix-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 12px 0; }
.matrix { border-collapse: collapse; width: 100%; font-size: 13px; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.matrix tbody th { text-align: left; font-weight: 500; }
.matrix thead th { font-size: 12px; color: var(--muted); white-space: nowrap; }
.matrix small { color: var(--faint); }
.matrix input { width: 22px; height: 22px; accent-color: var(--accent); }
.custom-roles, .danger-zone { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.danger-zone { border: 1px solid var(--danger-soft); border-radius: 14px; padding: 16px; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.activity li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.activity .when { font-size: 12px; color: var(--faint); min-width: 110px; font-variant-numeric: tabular-nums; }
.activity .what { flex: 1; }

/* ---------- Phone: bottom tab bar (Admin lives in the account menu) ---------- */
@media (max-width: 600px) {
  :root { --bottom-bar: 64px; }
  body { padding-bottom: calc(var(--bottom-bar) + env(safe-area-inset-bottom)); }
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    padding: 4px 4px max(4px, env(safe-area-inset-bottom)); gap: 0;
    border-top: 1px solid var(--line); border-bottom: 0; background: var(--topbar-bg); backdrop-filter: blur(14px);
  }
  .tabs a, .me-btn { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 11px; min-height: 52px; justify-content: center; }
  .tabs a.on { background: none; box-shadow: none; color: var(--accent); }
  .tabs a.admin-only, .tabs-spacer { display: none !important; }
  .offline-pill { position: fixed; top: 8px; right: 8px; z-index: 31; }
  .lock-banner { bottom: calc(var(--bottom-bar) + 14px); }
  .audio-resume { bottom: calc(var(--bottom-bar) + 62px); }
  .member { grid-template-columns: minmax(0, 1fr); }
  .member-actions { justify-content: flex-start; }
  .sheet.confirm { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; }
  .sheet.confirm .sheet-actions { flex-direction: column; align-items: stretch; }
  .sheet.confirm .sheet-actions .spacer { display: none; }
  .sheet.confirm .sheet-actions button { min-height: 52px; font-size: 16px; }
  .view:not(.grid) { padding: 12px 16px 24px; }
}
