/* LeaderLab accounts UI: topbar slot, History link, account menu, sign-in dialog.
   Linked by index.html, play.html and history.html. Uses the site tokens with fallbacks,
   so it looks right whichever page stylesheet is loaded. */

/* ---------- Topbar additions ---------- */
.ll-topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.ll-history-link {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border, #232c45); background: var(--surface, #121829);
  color: var(--text, #e9ecf5); text-decoration: none; white-space: nowrap;
  font: 600 13px/1 var(--display, "Oswald", "Arial Narrow", sans-serif); letter-spacing: 0.12em; text-transform: uppercase;
}
.ll-history-link:hover { border-color: var(--muted, #8a93ad); color: var(--gold, #f2b53a); }
.ll-history-link svg { flex: none; }
.ll-history-link[aria-current="page"] { color: var(--gold, #f2b53a); border-color: rgba(242, 181, 58, 0.5); }

.auth-slot { display: flex; align-items: center; }
.auth-slot[hidden] { display: none; }

.ll-auth-btn {
  display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(242, 181, 58, 0.55); background: rgba(242, 181, 58, 0.1); color: var(--gold, #f2b53a);
  font: 600 13px/1 var(--display, "Oswald", "Arial Narrow", sans-serif); letter-spacing: 0.12em; text-transform: uppercase;
  white-space: nowrap;
}
.ll-auth-btn:hover { background: rgba(242, 181, 58, 0.18); }

.ll-auth-account { position: relative; }
.ll-auth-chip {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 1px solid rgba(242, 181, 58, 0.6); color: #1d1405;
  background: linear-gradient(180deg, #ffd06a, var(--gold, #f2b53a) 60%, #d99a1e);
  font: 700 18px/1 var(--display, "Oswald", "Arial Narrow", sans-serif);
}
.ll-auth-chip[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(242, 181, 58, 0.25); }

.ll-auth-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 70; min-width: 200px; max-width: min(280px, calc(100vw - 24px));
  background: var(--surface, #121829); border: 1px solid var(--border, #232c45); border-radius: 12px; padding: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); text-align: left;
}
.ll-auth-menu[hidden] { display: none; }
.ll-auth-menu__name { padding: 8px 10px 0; font-weight: 700; font-size: 14px; color: var(--text, #e9ecf5); overflow-wrap: anywhere; }
.ll-auth-menu__email { padding: 2px 10px 8px; font-size: 12px; color: var(--muted, #8a93ad); overflow-wrap: anywhere; border-bottom: 1px solid var(--border, #232c45); margin-bottom: 4px; }
.ll-auth-menu__item {
  display: block; width: 100%; text-align: left; padding: 10px; border-radius: 8px; border: 0; background: none; cursor: pointer;
  color: var(--text, #e9ecf5); text-decoration: none; font: 500 14px/1.2 var(--body, "Inter", system-ui, sans-serif);
}
.ll-auth-menu__item:hover { background: var(--bg, #0a0e1a); color: var(--gold, #f2b53a); }

/* Narrow screens: History becomes an icon button, the BETA tag gives way. */
@media (max-width: 600px) {
  .ll-topbar-right { gap: 8px; }
  .ll-history-link { width: 40px; padding: 0; justify-content: center; }
  .ll-history-link__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ll-auth-btn { padding: 0 10px; font-size: 12px; letter-spacing: 0.08em; }
}
@media (max-width: 440px) {
  .topbar .brand .chip--tag { display: none; }
  .topbar .chip--mode { display: none; }
}

/* ---------- Sign-in dialog ---------- */
html.ll-auth-lock, html.ll-auth-lock body { overflow: hidden; }

.ll-auth-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-start; justify-content: center;
  padding: max(16px, 6vh) 12px 16px; overflow-y: auto;
  background: rgba(5, 8, 16, 0.78); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ll-auth-overlay[hidden] { display: none; }

.ll-auth-dialog {
  position: relative; width: 100%; max-width: 400px; padding: 26px 22px 18px; border-radius: 16px;
  background: var(--surface, #121829); border: 1px solid var(--border, #232c45);
  box-shadow: 0 0 0 1px rgba(242, 181, 58, 0.08), 0 24px 70px rgba(0, 0, 0, 0.6);
  color: var(--text, #e9ecf5); font: 400 15px/1.5 var(--body, "Inter", system-ui, sans-serif);
}
.ll-auth-dialog:focus { outline: none; }
.ll-auth-dialog[aria-busy="true"] { cursor: progress; }

.ll-auth-close {
  position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid var(--border, #232c45); background: var(--bg, #0a0e1a); color: var(--muted, #8a93ad); cursor: pointer;
}
.ll-auth-close:hover { color: var(--text, #e9ecf5); border-color: var(--muted, #8a93ad); }

.ll-auth-title {
  margin: 0 44px 4px 0; font: 700 24px/1.1 var(--display, "Oswald", "Arial Narrow", sans-serif);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.ll-auth-desc { margin: 0 0 16px; color: var(--muted, #8a93ad); font-size: 14px; }
.ll-auth-desc[hidden] { display: none; }

.ll-auth-msg {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: rgba(226, 67, 59, 0.12); border: 1px solid rgba(226, 67, 59, 0.45); color: #ffb3ae;
}
.ll-auth-msg--ok { background: rgba(62, 207, 122, 0.12); border-color: rgba(62, 207, 122, 0.45); color: #9ff0c2; }
.ll-auth-msg[hidden] { display: none; }
.ll-auth-msg--info { background: rgba(143, 179, 255, 0.12); border-color: rgba(143, 179, 255, 0.45); color: #c9d8ff; }
.ll-auth-msg-actions { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -8px 0 12px; }
.ll-auth-msg-actions[hidden] { display: none; }

.ll-auth-view[hidden] { display: none; }
.ll-auth-providers { display: grid; gap: 10px; }
.ll-auth-provider {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 46px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border, #232c45); background: var(--bg, #0a0e1a); color: var(--text, #e9ecf5);
  cursor: pointer; font: 600 15px/1 var(--body, "Inter", system-ui, sans-serif);
}
.ll-auth-provider:hover:not(:disabled) { border-color: var(--muted, #8a93ad); }
.ll-auth-provider svg { flex: none; }

.ll-auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted, #8a93ad); font-size: 12px; text-transform: uppercase; letter-spacing: 0.14em; }
.ll-auth-divider::before, .ll-auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border, #232c45); }

.ll-auth-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 999px; background: var(--bg, #0a0e1a); border: 1px solid var(--border, #232c45); }
.ll-auth-tab {
  flex: 1; min-height: 36px; border: 0; border-radius: 999px; background: none; cursor: pointer; color: var(--muted, #8a93ad);
  font: 600 13px/1 var(--display, "Oswald", "Arial Narrow", sans-serif); letter-spacing: 0.12em; text-transform: uppercase;
}
.ll-auth-tab[aria-selected="true"] { background: var(--surface, #121829); color: var(--gold, #f2b53a); box-shadow: inset 0 0 0 1px rgba(242, 181, 58, 0.45); }

.ll-auth-form { display: grid; gap: 12px; }
.ll-auth-field { display: grid; gap: 6px; }
.ll-auth-field label { font-size: 13px; font-weight: 600; color: var(--text, #e9ecf5); }
.ll-auth-input {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border, #232c45);
  background: var(--bg, #0a0e1a); color: var(--text, #e9ecf5); font: 400 16px/1 var(--body, "Inter", system-ui, sans-serif);
}
.ll-auth-input:focus { border-color: var(--gold, #f2b53a); outline: none; box-shadow: 0 0 0 3px rgba(242, 181, 58, 0.2); }

.ll-auth-submit {
  min-height: 46px; width: 100%; border-radius: 10px; border: 0; cursor: pointer; color: #1d1405;
  background: linear-gradient(180deg, #ffd06a, var(--gold, #f2b53a) 55%, #d99a1e);
  font: 600 16px/1 var(--display, "Oswald", "Arial Narrow", sans-serif); letter-spacing: 0.14em; text-transform: uppercase;
}
.ll-auth-submit:disabled, .ll-auth-provider:disabled { opacity: 0.5; cursor: progress; }

.ll-auth-row { display: flex; justify-content: flex-end; }
.ll-auth-row:empty { display: none; }
.ll-auth-link {
  border: 0; background: none; padding: 6px 2px; cursor: pointer; color: #8fb3ff;
  font: 500 14px/1.3 var(--body, "Inter", system-ui, sans-serif); text-decoration: underline; text-underline-offset: 3px;
}
.ll-auth-link[hidden] { display: none; }
.ll-auth-link:hover { color: var(--text, #e9ecf5); }
.ll-auth-link--block { display: block; margin: 10px auto 0; }

.ll-auth-check { text-align: center; display: grid; gap: 14px; justify-items: center; }
.ll-auth-check[hidden] { display: none; }
.ll-auth-check__icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; font-size: 26px;
  background: rgba(242, 181, 58, 0.12); border: 1px solid rgba(242, 181, 58, 0.45); color: var(--gold, #f2b53a);
}
.ll-auth-check__text { margin: 0; color: var(--text, #e9ecf5); overflow-wrap: anywhere; }

.ll-auth-foot { margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--border, #232c45); font-size: 12px; color: var(--muted, #8a93ad); text-align: center; }
.ll-auth-foot a { color: #8fb3ff; }

@media (max-width: 440px) {
  .ll-auth-dialog { padding: 22px 16px 14px; }
  .ll-auth-title { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .ll-auth-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
