/* ============================================================================
 * App chrome shared by every mode: sign-in gate, header account menu and the
 * Settings page (AI connections, About). Built on the tokens in base.css;
 * reuses the .mv-* building blocks from music-video.css.
 * ========================================================================== */

/* Sign-in gate — covers everything until the user is signed in. ---------- */
#authGate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  /* margin:auto on the card centres it when it fits and lets it scroll
     (instead of being cut off top and bottom) on a landscape phone. */
  align-items: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--space-5) + env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right))
           calc(var(--space-5) + env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 60, 120, 0.16), transparent 55%),
    #060607;
  color: var(--ink);
  font-family: var(--font-body);
}
#authGate[hidden] { display: none; }
html.auth-locked #vizzyHeader,
html.auth-locked #stage,
html.auth-locked #controls { visibility: hidden; }

.ag-card { width: 100%; max-width: 380px; margin: auto; }
.ag-brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.32em; color: var(--ink-2);
  margin-bottom: var(--space-6);
}
.ag-title { font-family: var(--font-display); font-size: 28px; font-weight: 700; }
.ag-sub { font-size: 14px; color: var(--ink-3); margin-top: var(--space-2); line-height: 1.45; }
.ag-form { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-6); }
.ag-input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--hairline-2); border-radius: var(--radius-4);
  font-size: 16px; font-family: inherit;
}
.ag-input:focus { outline: none; border-color: var(--accent); }
.ag-code { text-align: center; font-family: var(--font-mono); font-size: 24px; letter-spacing: 0.3em; }
.ag-btn {
  min-height: 48px; border-radius: var(--radius-pill); border: 1px solid var(--hairline-2);
  background: var(--surface-4); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.ag-btn.primary { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 18px var(--accent-glow); }
.ag-btn:disabled { opacity: 0.6; }
.ag-links { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-4); flex-wrap: wrap; }
.ag-link { background: none; border: none; color: var(--ink-3); font-size: 13px; cursor: pointer; padding: 10px 0; min-height: 44px; font-family: inherit; }
.ag-link:hover { color: var(--ink); }
.ag-error { color: var(--err); font-size: 13px; margin-top: var(--space-3); }
.ag-google {
  width: 100%; margin-top: var(--space-6); display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; border-color: #fff;
}
.ag-google:hover { background: #f2f2f2; }
.ag-or { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-5); color: var(--ink-4); font-size: 12px; }
.ag-or::before, .ag-or::after { content: ''; flex: 1; height: 1px; background: var(--hairline-2); }
.ag-or + .ag-form { margin-top: var(--space-4); }

/* Header account menu ------------------------------------------------------ */
.vh-account { position: relative; }
.vh-account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 50;
  background: rgba(16, 16, 18, 0.97); border: 1px solid var(--hairline-2); border-radius: var(--radius-5);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); padding: var(--space-1); backdrop-filter: blur(20px);
}
.vh-account-menu[hidden] { display: none; }
.am-email { font-size: 11px; color: var(--ink-4); padding: 10px 12px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-item {
  display: block; width: 100%; text-align: left; background: none; border: none; color: var(--ink-2);
  font-size: 14px; padding: 12px; border-radius: var(--radius-3); cursor: pointer; font-family: inherit; min-height: 44px;
}
.am-item:hover { background: var(--surface-4); color: var(--ink); }
.am-item[hidden] { display: none; }

/* Settings page ---------------------------------------------------------- */
#settingsPage {
  position: fixed; top: var(--vizzy-header-height, 52px); left: 0; right: 0; bottom: 0; z-index: 35;
  background: #0a0a0a; color: var(--ink); font-family: var(--font-body);
  overflow-y: auto; overscroll-behavior: contain;
  opacity: 0; transform: translateY(8px); transition: opacity 220ms ease, transform 220ms ease; pointer-events: none;
}
#settingsPage.is-open { opacity: 1; transform: none; pointer-events: auto; }
#settingsPage[hidden] { display: none !important; }
.sp-wrap { max-width: 760px; margin: 0 auto; padding: var(--space-7) var(--space-5) calc(var(--space-8) * 2 + env(safe-area-inset-bottom)); }
.sp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.sp-tabs { display: flex; gap: var(--space-1); margin-top: var(--space-5); border-bottom: 1px solid var(--hairline); }
.sp-tab {
  background: none; border: none; color: var(--ink-3); padding: 12px 14px; min-height: 44px; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sp-tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.sp-conns { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-3) 0; }
.sp-conn {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  background: var(--surface-3); border: 1px solid var(--hairline); border-radius: var(--radius-4); padding: var(--space-3);
}
.sp-conn-main { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.sp-conn-main b { font-size: 14px; }
.sp-conn-main small { font-size: 12px; color: var(--ink-4); }
.sp-conn .mv-btn { min-height: 40px; }
.sp-ok { color: var(--ok) !important; }
.sp-bad { color: var(--err) !important; }
.sp-default {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent-soft); border-radius: var(--radius-pill); padding: 6px 10px;
}
.sp-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-2); margin-top: var(--space-2); }
.sp-pick-btn {
  text-align: left; background: var(--surface-3); border: 1px solid var(--hairline); border-radius: var(--radius-4);
  color: var(--ink); padding: var(--space-3); cursor: pointer; font-family: inherit; min-height: 64px;
}
.sp-pick-btn:hover { border-color: var(--accent); }
.sp-pick-btn b { display: block; font-size: 14px; }
.sp-pick-btn small { display: block; font-size: 12px; color: var(--ink-4); margin-top: 4px; line-height: 1.35; }
.sp-form { background: var(--surface-3); border: 1px solid var(--hairline-2); border-radius: var(--radius-5); padding: var(--space-4); margin-top: var(--space-2); }
.sp-form-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.sp-form-head a { color: var(--accent); font-size: 13px; text-decoration: none; white-space: nowrap; flex-shrink: 0; padding: 12px 0; }
.sp-field { display: block; margin-top: var(--space-3); }
.sp-field span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.sp-field textarea { min-height: 120px; }
.sp-form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
.sp-invite { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-top: var(--space-3); }
.sp-invite .mv-input { flex: 1 1 240px; }
.sp-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); cursor: pointer; }
.sp-role {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  border-radius: var(--radius-pill); padding: 5px 9px; border: 1px solid var(--hairline-2); color: var(--ink-3);
}
.sp-role.owner, .sp-role.admin { color: var(--accent); border-color: var(--accent-soft); }
.sp-notice {
  background: var(--surface-3); border: 1px solid var(--accent-soft); border-radius: var(--radius-4);
  padding: var(--space-3); margin-top: var(--space-3); font-size: 13px; line-height: 1.5;
}
.sp-notice .sp-link-row { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.sp-notice input { flex: 1 1 240px; font-family: var(--font-mono); font-size: 12px; }
.sp-notice .sp-link-row small { align-self: center; color: var(--ink-3); }
/* Beta requests (Settings → People) */
.sp-req-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.sp-req { align-items: flex-start; flex-wrap: wrap; }
.sp-req-role {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 500;
  color: var(--accent); margin-left: 6px;
}
.sp-req-links { word-break: break-word; }
.sp-req-links a { color: var(--ink-2); }
.sp-req-note { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink-2); white-space: pre-wrap; }
.sp-warn { color: #ffc46b; }
.ag-request { display: block; text-align: center; margin-top: var(--space-4); font-size: 13px; color: var(--ink-3); }
.ag-request a { color: var(--accent); text-decoration: none; font-weight: 600; }
.sp-about { text-align: center; padding: var(--space-8) 0; }
.sp-logo .vh-mark { width: 28px; height: 28px; box-shadow: 0 0 40px var(--accent-glow); }
.sp-name { font-family: var(--font-display); font-size: 34px; font-weight: 700; margin-top: var(--space-4); }
.sp-rev { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); margin-top: var(--space-2); }
.sp-copy { font-size: 13px; color: var(--ink-3); margin-top: var(--space-1); }
.sp-about .mv-hint { max-width: 420px; margin: var(--space-6) auto 0; }

@media (max-width: 767px) {
  .sp-wrap {
    padding: var(--space-5) max(var(--space-4), env(safe-area-inset-right)) calc(var(--space-8) + env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
  }
  .sp-conn .mv-btn { flex: 1; }
}

/* Shared-key siblings (Qwen Cloud: video + chat + images from one key) */
.sp-also {
  border: 1px solid var(--hairline); border-radius: var(--radius-4); padding: var(--space-3);
  margin: 0; display: grid; gap: var(--space-2);
}
.sp-also legend { font-size: 12px; color: var(--ink-2, var(--ink)); padding: 0 var(--space-1); }
.sp-check { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; cursor: pointer; }
.sp-check input { width: 20px; height: 20px; accent-color: var(--accent, #ff3d6e); flex: none; }
.sp-check small { display: block; opacity: 0.7; font-size: 12px; }

/* Basic-mode playback auto-hides the header (body.chrome-hidden). With the
   Settings page open that left an empty band above it and no way to switch
   modes — keep the header shown while Settings is open. */
body.chrome-hidden:has(#settingsPage.is-open) #vizzyHeader {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

/* Settings → Downloads */
.sp-dl-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-2, 8px); }
.sp-dl-list { display: grid; gap: var(--space-2, 8px); margin-top: var(--space-2, 8px); }
.sp-dl-card {
  display: flex; align-items: center; gap: var(--space-3, 12px); padding: var(--space-3, 12px);
  background: var(--surface-3); border: 1px solid var(--hairline); border-radius: var(--radius-3, 10px);
}
.sp-dl-card.rec { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sp-dl-text { flex: 1; min-width: 0; }
.sp-dl-text b { display: block; font-size: 14px; }
.sp-dl-text small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.sp-dl-card .mv-btn { flex: 0 0 auto; white-space: nowrap; text-decoration: none; }
.sp-dl-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-left: 6px; }
