/* "Log in once" dialog (openLoginDialog in app.js): a live browser on a
   persistent identity, a countdown to the session limit, and one Save
   and close button. Theme tokens only, so Light and Dark both work; on
   phones the dialog fills the screen. */

html.lg-open, html.lg-open body { overflow: hidden; }

.lg-overlay {
  position: fixed; inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: cmdk-fade-in 120ms ease-out;
}
:root[data-theme="light"] .lg-overlay {
  background: rgba(15, 22, 19, 0.34);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.lg-modal {
  display: flex;
  flex-direction: column;
  width: min(1240px, 100%);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  background: var(--vercel-surface);
  color: var(--vercel-text);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--vercel-border-strong), 0 24px 56px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: confirm-pop 140ms cubic-bezier(0.16, 1, 0.3, 1);
}
.lg-modal.lg-compact { width: min(640px, 100%); }
:root[data-theme="light"] .lg-modal {
  background: #FFFFFF;
  box-shadow: 0 0 0 1px var(--vercel-border), 0 1px 2px rgba(15, 22, 19, 0.04), 0 28px 56px -20px rgba(15, 22, 19, 0.35);
}

/* Head: title, countdown, close */
.lg-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--vercel-border);
}
.lg-head-main { min-width: 0; flex: 1 1 auto; }
.lg-title {
  margin: 0;
  font: 600 19px/1.25 var(--font-display);
  letter-spacing: -0.02em;
  color: var(--vercel-text);
}
.lg-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--vercel-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lg-sub code {
  font-size: 12px;
  color: var(--vercel-text);
  background: var(--vercel-elevated);
  padding: 1px 6px;
  border-radius: 5px;
}
.lg-timer {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--vercel-elevated);
  box-shadow: inset 0 0 0 1px var(--vercel-border);
  font: 500 12.5px/1.2 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--vercel-text);
  white-space: nowrap;
}
.lg-timer[hidden] { display: none; }
.lg-timer-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint, rgba(45, 227, 160, 0.12));
}
.lg-timer-warn { color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.lg-timer-warn .lg-timer-dot { background: var(--amber); box-shadow: none; }
.lg-close { flex: 0 0 auto; }

/* Body */
.lg-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.lg-intro { padding: 22px 24px 8px; max-width: 640px; }
.lg-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: lg;
  display: grid;
  gap: 14px;
}
.lg-steps li {
  counter-increment: lg;
  position: relative;
  padding-left: 38px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--vercel-muted);
}
.lg-steps li b { color: var(--vercel-text); font-weight: 600; }
.lg-steps li::before {
  content: counter(lg);
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-faint, rgba(45, 227, 160, 0.1));
  box-shadow: inset 0 0 0 1px var(--border-accent, rgba(45, 227, 160, 0.3));
  color: var(--accent);
  font: 600 12.5px/1 var(--font-mono);
}
.lg-price {
  margin: 18px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--vercel-muted);
}
.lg-ended-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--vercel-text); }

.lg-guide {
  margin: 0;
  padding: 10px 20px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--vercel-muted);
  background: var(--vercel-elevated);
  border-bottom: 1px solid var(--vercel-border);
}
.lg-guide b { color: var(--vercel-text); font-weight: 600; }

/* The live browser. 16:10 at the 1240px width keeps the stage readable;
   the max-height leaves room for head and foot on short screens. */
.lg-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 320px;
  height: min(70vh, 720px);
  height: min(70dvh, 720px);
  background: #0B0F0D;
}
.lg-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
  display: block;
  background: #0B0F0D;
}
.lg-frame:focus { outline: none; }
.lg-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lg-connecting {
  position: absolute; inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  font-size: 13.5px;
  color: #C9D3CE;
  background: #0B0F0D;
  transition: opacity 280ms ease;
  pointer-events: none;
}
.lg-connecting.lg-gone { opacity: 0; }
.lg-nolive { pointer-events: auto; max-width: 520px; margin: 0 auto; line-height: 1.55; }
.lg-nolive a { color: var(--accent); }

/* Inline "Close without saving?" bar. In the dialog, not a second
   modal, so the live view stays visible behind the question. */
.lg-confirm {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--amber);
  background: rgba(247, 185, 85, 0.08);
}
.lg-confirm[hidden] { display: none; }
:root[data-theme="light"] .lg-confirm { background: #FBF3E6; border-top-color: rgba(163, 96, 15, 0.35); }
.lg-confirm-text { flex: 1 1 auto; font-size: 13px; line-height: 1.5; color: var(--vercel-muted); }
.lg-confirm-text strong { color: var(--vercel-text); font-weight: 600; }
.lg-confirm-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.lg-confirm-leave { color: var(--red); }

.lg-err {
  padding: 10px 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--red);
  border-top: 1px solid var(--vercel-border);
}
.lg-err[hidden] { display: none; }

/* Foot: new-tab link on the left, the one Save button on the right. */
.lg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--vercel-border);
}
.lg-foot-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--vercel-muted);
}
.lg-foot-note a { color: var(--vercel-text); text-decoration: none; box-shadow: inset 0 -1px 0 var(--vercel-border-strong); }
.lg-foot-note a:hover { color: var(--accent); }
.lg-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.lg-save {
  min-width: 180px;
  padding: 11px 22px;
  font-size: 14.5px;
}

/* Drawer + row entry points */
.lg-drawer .btn-primary { margin-top: 2px; }
.lg-row-btn { white-space: nowrap; }

/* Phones: full screen, stacked foot, big touch targets. */
@media (max-width: 640px) {
  .lg-overlay { padding: 0; align-items: stretch; }
  .lg-modal {
    width: 100%;
    max-height: none;
    height: 100%;
    border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .lg-head { flex-wrap: wrap; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); gap: 8px 10px; }
  .lg-head-main { flex: 1 1 0; }
  .lg-timer { order: 3; flex: 1 1 100%; justify-content: center; }
  .lg-intro { padding: 18px 16px 8px; }
  .lg-guide { padding: 9px 14px; font-size: 13px; }
  .lg-stage { height: auto; min-height: 260px; }
  .lg-confirm { flex-direction: column; align-items: stretch; padding: 12px 14px; }
  .lg-confirm-actions { flex-direction: column; }
  .lg-confirm-actions .btn-secondary { width: 100%; min-height: 44px; }
  .lg-foot { flex-direction: column-reverse; align-items: stretch; padding: 12px 14px; gap: 10px; }
  .lg-foot-note { justify-content: center; text-align: center; }
  .lg-foot-hint { display: none; }
  .lg-actions { flex-direction: column-reverse; }
  .lg-actions .btn-primary, .lg-actions .btn-secondary { width: 100%; min-height: 46px; }
  .lg-save { min-width: 0; }
  .lg-err { padding: 10px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .lg-overlay, .lg-modal { animation: none; }
  .lg-connecting { transition: none; }
}
