/* ============================================================
   PRACO — Sign-in screen, passkey setup sheet, loading screen
   Always light, independent of the app's dark/light toggle.
   ============================================================ */
#loginScreen, .lg-setup, #praco-loading-screen, .lg-pk-modal {
  --lg-praco: #D9560C;
  --lg-praco-press: #BF4A08;
  --lg-on-praco: #FFFFFF;
  --lg-praco-soft: #FDEEE4;
  --lg-ground: #EEF2F7;
  --lg-surface: #FFFFFF;
  --lg-ink: #151A22;
  --lg-muted: #5C6675;
  --lg-line: #E4E8EE;
  --lg-line-strong: #CED5DE;
  --lg-chip: #EEF2F8;
  --lg-good: #1F8A5A;
  --lg-good-soft: #E6F4EC;
  --lg-bad: #B42318;
  --lg-bad-soft: #FDE8E7;
  --lg-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --lg-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

/* ── Screen ── */
#loginScreen {
  position: fixed; inset: 0; z-index: 9000;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  overflow-y: auto;
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(196, 214, 242, 0.45), transparent 70%),
    #F8FAFC;
  color: var(--lg-ink);
  font-family: var(--lg-display);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#loginScreen *, #loginScreen *::before, #loginScreen *::after,
.lg-setup *, .lg-pk-modal * { box-sizing: border-box; }
#loginScreen [hidden], .lg-setup[hidden], .lg-setup [hidden], .lg-pk-modal[hidden], .lg-pk-modal [hidden] { display: none !important; }
#loginScreen button, .lg-setup button, .lg-pk-modal button { font: inherit; color: inherit; cursor: pointer; }
#loginScreen :focus-visible, .lg-setup :focus-visible, .lg-pk-modal :focus-visible { outline: 2px solid var(--lg-praco); outline-offset: 2px; }

.lg-mark, #loginScreen .lg-mark { font-family: var(--lg-display); font-stretch: 125%; font-weight: 800; letter-spacing: .02em; line-height: 1; margin: 0; color: var(--lg-ink); }
.lg-mark .dot { color: var(--lg-praco); }

/* ── Brand panel ── */
.lg-brand {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  min-height: 100%;
  padding: 40px 48px clamp(72px, 15vh, 160px);
  overflow: hidden;
  border-right: 1px solid var(--lg-line);
  background:
    radial-gradient(120% 70% at 0% 0%, #FDDCC4 0%, rgba(253, 220, 196, 0) 62%),
    radial-gradient(110% 80% at 100% 100%, #CFDDF3 0%, rgba(207, 221, 243, 0) 65%),
    #F5F7FB;
}
.lg-brand .lg-mark { font-size: 32px; }
.lg-sub { display: block; margin-top: 8px; font-family: var(--lg-mono); font-size: 12.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--lg-muted); }
.lg-brand h2 {
  margin: 0 0 16px; color: var(--lg-ink);
  font-family: var(--lg-display); font-stretch: 108%; font-weight: 700;
  font-size: clamp(36px, 3.9vw, 56px); line-height: 1.05; letter-spacing: -.015em;
  max-width: none;
}
.lg-brand h2 span { display: block; }
.lg-brand h2 .acc { color: var(--lg-praco); }
.lg-brand p { margin: 0; color: var(--lg-muted); max-width: 36ch; font-size: 18.5px; line-height: 1.5; }
.lg-scene { display: block; width: calc(100% + 16px); margin: 0 -8px; height: clamp(240px, 36vh, 320px); }

/* ── Auth panel ── */
.lg-auth {
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  min-height: 100vh;
  padding: 40px clamp(24px, 6vw, 88px) 28px;
}
.lg-top { display: flex; justify-content: flex-end; align-items: center; min-height: 24px; }
.lg-top .lg-mark { display: none; font-size: 24px; }
.lg-panel { width: 100%; max-width: 440px; margin: 0 auto; display: grid; gap: 18px; }
.lg-panel h1 {
  margin: 0; color: var(--lg-ink);
  font-family: var(--lg-display); font-stretch: 106%; font-weight: 700;
  font-size: 36px; line-height: 1.1; letter-spacing: -.01em;
}
.lg-lede { margin: -10px 0 4px; color: var(--lg-muted); text-wrap: pretty; }

.lg-field { display: grid; gap: 6px; }
.lg-field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.lg-field label { font-size: 15px; font-weight: 600; color: var(--lg-ink); }
.lg-link {
  background: none; border: 0; padding: 0;
  font-size: 15px; color: var(--lg-muted) !important;
  text-decoration: underline; text-decoration-color: var(--lg-line-strong); text-underline-offset: 3px;
}
.lg-link:hover { color: var(--lg-ink) !important; text-decoration-color: currentColor; }
.lg-input { position: relative; }
#loginScreen .lg-input input {
  display: block; width: 100%; height: 54px; padding: 0 16px; margin: 0;
  font: inherit; font-size: 17px; color: var(--lg-ink);
  background: var(--lg-surface);
  border: 1px solid var(--lg-line-strong);
  border-radius: 8px;
  outline: none; box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
#loginScreen .lg-input input::placeholder { color: var(--lg-muted); opacity: .7; }
#loginScreen .lg-input input:focus { border-color: var(--lg-praco); box-shadow: 0 0 0 3px var(--lg-praco-soft); }
#loginScreen .lg-input.pw input { padding-right: 78px; }
.lg-show {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: none;
  font-family: var(--lg-mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--lg-muted) !important;
}
.lg-show:hover { background: var(--lg-chip); color: var(--lg-ink) !important; }

.lg-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 56px; padding: 0 18px; margin: 0;
  border-radius: 8px; border: 1px solid transparent;
  font-family: var(--lg-display); font-weight: 700; font-size: 17px; letter-spacing: .01em;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
}
.lg-btn:active { transform: translateY(1px); }
.lg-btn svg { width: 22px; height: 22px; flex: none; }
.lg-btn[disabled] { opacity: .7; cursor: progress; }
.lg-btn-primary { background: var(--lg-praco); color: var(--lg-on-praco) !important; }
.lg-btn-primary:hover { background: var(--lg-praco-press); }
.lg-btn-quiet { background: var(--lg-surface); color: var(--lg-ink) !important; border-color: var(--lg-line-strong); }
.lg-btn-quiet:hover { border-color: var(--lg-ink); }
.lg-btn-text { background: none; color: var(--lg-muted) !important; height: 42px; }
.lg-btn-text:hover { color: var(--lg-ink) !important; }
.lg-btn.is-loading .lg-btn-label::after { content: "…"; }

.lg-hint { margin: -10px 0 0; font-size: 14px; color: var(--lg-muted); text-align: center; }
.lg-or { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--lg-muted); }
.lg-or::before, .lg-or::after { content: ""; flex: 1; height: 1px; background: var(--lg-line); }

.lg-keep { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px; color: var(--lg-ink); }
.lg-keep small { display: block; color: var(--lg-muted); font-size: 14px; }
.lg-switch {
  position: relative; width: 46px; height: 28px; flex: none; padding: 0;
  border-radius: 14px; border: 0; background: var(--lg-line-strong);
  transition: background .2s;
}
.lg-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .2s;
}
.lg-switch[aria-checked="true"] { background: var(--lg-praco); }
.lg-switch[aria-checked="true"]::after { transform: translateX(18px); }

#loginScreen .login-error {
  display: none; margin: 0;
  font-size: 15px; padding: 11px 13px; border-radius: 8px;
  background: var(--lg-bad-soft); color: var(--lg-bad);
}
#loginScreen .login-error.is-info { background: var(--lg-chip); color: var(--lg-ink); }

/* Returning user */
.lg-who { display: grid; justify-items: center; gap: 8px; text-align: center; }
.lg-scene-small { display: none; width: 100%; height: 118px; margin-bottom: -6px; }
.lg-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--lg-praco-soft); color: var(--lg-praco-press);
  border: 3px solid var(--lg-surface);
  font-family: var(--lg-display); font-stretch: 110%; font-weight: 700; font-size: 23px;
}
.lg-who h1 { font-size: 32px; }
.lg-who p { margin: 0; color: var(--lg-muted); font-size: 16px; }
.lg-bio { display: grid; justify-items: center; gap: 10px; margin: 6px 0 4px; }
.lg-bio-ring {
  width: 80px; height: 80px; border-radius: 22px;
  display: grid; place-items: center;
  color: var(--lg-ink); background: var(--lg-chip); border: 1px solid var(--lg-line);
  transition: background .3s, color .3s;
}
.lg-bio-ring svg { width: 44px; height: 44px; }
.lg-bio-ring.scanning { color: var(--lg-praco); animation: lg-pulse 1s ease-in-out infinite; }
.lg-bio-ring.done { background: var(--lg-good-soft); color: var(--lg-good); border-color: transparent; }
.lg-bio-state { font-size: 15px; color: var(--lg-muted); min-height: 1.5em; text-align: center; }
@keyframes lg-pulse { 50% { transform: scale(.94); } }
.lg-switch-acc { text-align: center; font-size: 15px; color: var(--lg-muted); }

.lg-foot {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px;
  font-size: 14px; color: var(--lg-muted);
  border-top: 1px solid var(--lg-line); padding-top: 16px;
  width: 100%; max-width: 560px; margin: 0 auto;
}
.lg-foot .mono { font-family: var(--lg-mono); font-size: 13px; }

#loginScreen.is-leaving { opacity: 0; transition: opacity .35s ease; }

/* ── Phone / narrow ── */
@media (max-width: 860px) {
  #loginScreen {
    grid-template-columns: 1fr;
    background:
      radial-gradient(110% 340px at 0% 0%, #FDD9BF 0%, rgba(253, 217, 191, 0) 70%),
      radial-gradient(110% 380px at 100% 0%, #CCDCF4 0%, rgba(204, 220, 244, 0) 72%),
      #FFFFFF;
  }
  .lg-brand { display: none; }
  .lg-auth { min-height: 100vh; min-height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); gap: 20px; }
  .lg-top { justify-content: space-between; }
  .lg-top .lg-mark { display: block; }
  .lg-panel { gap: 14px; }
  .lg-panel h1 { font-size: 30px; }
  .lg-scene-small { display: block; }
  .lg-avatar { margin-top: -30px; }
  .lg-foot { justify-content: center; text-align: center; border-top: 0; padding-top: 0; }
  .lg-foot .mono { display: none; }
}

/* ── Passkey setup sheet (shown over the app after sign-in) ── */
.lg-setup {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(21, 26, 34, 0.32);
  font-family: var(--lg-display); color: var(--lg-ink);
  -webkit-font-smoothing: antialiased;
}
.lg-sheet {
  width: 100%; max-width: 440px;
  background: var(--lg-surface);
  border-radius: 24px 24px 0 0;
  padding: 12px 24px max(26px, env(safe-area-inset-bottom));
  display: grid; gap: 14px;
  box-shadow: 0 -8px 30px rgba(21, 26, 34, .14);
  animation: lg-sheet-in .28s ease-out;
}
@media (min-width: 600px) {
  .lg-setup { align-items: center; }
  .lg-sheet { border-radius: 18px; padding-bottom: 24px; }
  .lg-grab { display: none; }
}
@keyframes lg-sheet-in { from { transform: translateY(24px); opacity: 0; } }
.lg-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--lg-line-strong); justify-self: center; }
.lg-sheet .lg-bio-ring { width: 60px; height: 60px; border-radius: 18px; background: var(--lg-praco-soft); color: var(--lg-praco); border: 0; }
.lg-sheet .lg-bio-ring svg { width: 34px; height: 34px; }
.lg-sheet .lg-bio-ring.done { background: var(--lg-good-soft); color: var(--lg-good); }
.lg-sheet h3 { margin: 0; font-family: var(--lg-display); font-stretch: 106%; font-size: 25px; font-weight: 700; letter-spacing: -.01em; color: var(--lg-ink); }
.lg-sheet ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.lg-sheet li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; font-size: 16px; color: var(--lg-muted); }
.lg-sheet li svg { width: 18px; height: 18px; color: var(--lg-good); margin-top: 1px; }
.lg-sheet .lg-msg { font-size: 13.5px; padding: 10px 12px; border-radius: 8px; background: var(--lg-bad-soft); color: var(--lg-bad); }
.lg-sheet-btns { display: grid; gap: 6px; margin-top: 4px; }

/* ── Sign-in & passkeys (key button by your name) ── */
.lg-pk-modal {
  position: fixed; inset: 0; z-index: 9400;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(21, 26, 34, 0.32);
  font-family: var(--lg-display); color: var(--lg-ink);
  -webkit-font-smoothing: antialiased;
}
.lg-pk-card {
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--lg-surface); border-radius: 18px;
  padding: 20px 22px 22px; display: grid; gap: 14px;
  box-shadow: 0 20px 50px -20px rgba(21,26,34,.35);
}
.lg-pk-card .lg-grab { display: none; }
.lg-pk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lg-pk-head h3 { margin: 0; font-size: 22px; font-stretch: 106%; font-weight: 700; letter-spacing: -.01em; color: var(--lg-ink); }
.lg-pk-x { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--lg-chip); color: var(--lg-muted) !important; }
.lg-pk-x:hover { color: var(--lg-ink) !important; }
.lg-pk-sub { margin: -8px 0 2px; font-size: 15px; color: var(--lg-muted); }
.lg-pk-list { display: grid; border: 1px solid var(--lg-line); border-radius: 14px; overflow: hidden; }
.lg-pk-item { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; padding: 14px 16px; }
.lg-pk-item + .lg-pk-item { border-top: 1px solid var(--lg-line); }
.lg-pk-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--lg-chip); color: var(--lg-ink); }
.lg-pk-ico svg { width: 22px; height: 22px; }
.lg-pk-item.is-here .lg-pk-ico { background: var(--lg-praco-soft); color: var(--lg-praco); }
.lg-pk-main { min-width: 0; display: grid; gap: 2px; }
.lg-pk-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 16.5px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.lg-pk-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--lg-good-soft); color: var(--lg-good); white-space: nowrap; }
.lg-pk-meta { font-size: 14px; color: var(--lg-muted); }
.lg-pk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 6px; }
.lg-pk-act { background: none; border: 0; padding: 4px 0; font-size: 14.5px; font-weight: 600; color: var(--lg-ink) !important; }
.lg-pk-act:hover { text-decoration: underline; text-underline-offset: 3px; }
.lg-pk-act.danger { color: var(--lg-bad) !important; }
.lg-pk-confirm { font-size: 14px; color: var(--lg-ink); width: 100%; }
.lg-pk-rename { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; width: 100%; }
#lgPkModal .lg-pk-rename input {
  flex: 1 1 100%; min-width: 0; height: 44px; padding: 0 12px; margin: 0;
  font: inherit; font-size: 16px; color: var(--lg-ink);
  background: var(--lg-surface); border: 1px solid var(--lg-line-strong); border-radius: 8px; outline: none;
}
#lgPkModal .lg-pk-rename input:focus { border-color: var(--lg-praco); box-shadow: 0 0 0 3px var(--lg-praco-soft); }
.lg-pk-rename .lg-btn { width: auto; height: 42px; font-size: 15px; padding: 0 14px; }
.lg-pk-empty { font-size: 15px; color: var(--lg-muted); padding: 16px; }
.lg-pk-modal .lg-msg { font-size: 14.5px; padding: 10px 12px; border-radius: 8px; background: var(--lg-bad-soft); color: var(--lg-bad); }
@media (max-width: 600px) {
  .lg-pk-modal { align-items: flex-end; padding: 0; }
  .lg-pk-card {
    max-width: none; max-height: 88vh; border-radius: 22px 22px 0 0;
    padding: 10px 18px max(20px, env(safe-area-inset-bottom));
    animation: lg-sheet-in .28s ease-out;
  }
  .lg-pk-card .lg-grab { display: block; }
}
.pk-settings-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px; padding: 4px; }
.pk-settings-btn:hover { color: var(--accent); }

/* ── Loading screen (after sign-in) ── */
#praco-loading-screen {
  position: fixed; inset: 0; z-index: 10000;
  background:
    radial-gradient(900px 520px at 0% 0%, rgba(253, 214, 186, 0.5), transparent 70%),
    radial-gradient(900px 600px at 100% 10%, rgba(196, 214, 242, 0.5), transparent 70%),
    #F8FAFC;
  opacity: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 400ms ease;
  font-family: var(--lg-display);
}
#praco-loading-screen[data-active="true"] { opacity: 1; pointer-events: auto; }
#praco-loading-screen[data-leaving="true"] { opacity: 0; transition: opacity 400ms ease; }
.praco-loading-content { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 24px; }
.praco-loading-mark { font-family: var(--lg-display); font-stretch: 125%; font-weight: 800; font-size: clamp(2.2rem, 5vw, 3.2rem); letter-spacing: .02em; line-height: 1; margin: 0; color: var(--lg-ink); }
.praco-loading-mark .dot { color: var(--lg-praco); }
.praco-loader-ring { position: relative; width: 44px; height: 44px; }
.praco-loader-ring .ring-outer { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--lg-line); border-top-color: var(--lg-praco); animation: lg-spin .8s linear infinite; }
.praco-loader-ring .ring-inner, .praco-loader-ring .ring-dot { display: none; }
@keyframes lg-spin { to { transform: rotate(360deg); } }
.praco-loading-status-block { text-align: center; min-height: 44px; }
.praco-loading-status { font-family: var(--lg-mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--lg-muted); transition: opacity 320ms ease; }
.praco-loading-percent { margin-top: 8px; display: flex; justify-content: center; gap: 2px; font-family: var(--lg-mono); font-size: 11px; color: var(--lg-muted); }
.praco-progress-track { width: 220px; height: 3px; background: var(--lg-line); border-radius: 3px; overflow: hidden; }
.praco-progress-bar { height: 100%; width: 0%; background: var(--lg-praco); transition: width 200ms linear; }

@media (prefers-reduced-motion: reduce) {
  #loginScreen *, .lg-setup *, #praco-loading-screen * { animation: none !important; transition: none !important; }
}
