/* ==========================================================================
   Installed-app layer (PWA). Loaded after ceria.css.
   html.app-mode   = running as an installed app (display-mode: standalone / iOS home screen),
                     or simulated with ?app=1 (the local preview page uses this).
   The normal browser website is unchanged: everything below needs .app-mode, .is-offline,
   or one of the notice elements that only appear when needed.
   ========================================================================== */

/* ---------- phones in app mode: bottom tab bar replaces the scrolling menu row ---------- */
.apptabs { display: none; }
@media (max-width: 760px) {
  html.app-mode .apptabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface, #fff); border-top: 1px solid var(--line, #E3DDF7);
    box-shadow: 0 -10px 30px -22px rgba(42, 31, 114, .55);
  }
  html.app-mode .apptab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; border-radius: 14px; text-decoration: none;
    color: var(--muted, #6B6896); font: 700 .78rem/1.1 var(--font, sans-serif);
  }
  html.app-mode .apptab .ic { width: 24px; height: 24px; }
  html.app-mode .apptab.on { color: var(--purple, #6C4DF4); background: var(--purple-soft, #EEE9FF); }
  html.app-mode[data-theme="dark"] .apptab.on { color: #fff; background: var(--surface-3, #2A2468); }
  html.app-mode .apptab:focus-visible { outline: 3px solid var(--ring, #6C4DF4); outline-offset: -3px; }
  /* the tab bar does the job of the menu-pill row */
  html.app-mode .hbar .htabs { display: none !important; } /* beats the Ceria header rule */
  html.app-mode[data-design="ceria"] .hbar { padding-bottom: 10px; }
  html.app-mode body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  html.app-mode .app-update { bottom: calc(80px + env(safe-area-inset-bottom)); }
  html.app-mode .app-offline { bottom: calc(76px + env(safe-area-inset-bottom)); }
  html.app-sim body::before { bottom: calc(74px + env(safe-area-inset-bottom)); }
}

/* ---------- installed app: respect the notch / status bar, feel less like a web page ---------- */
html.app-mode .topbar { padding-top: env(safe-area-inset-top); }
html.app-mode body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
html.app-mode .site-footer { padding-bottom: env(safe-area-inset-bottom); }
/* a simulated app (preview) shows a small marker so it is never mistaken for the real install */
html.app-sim body::before {
  content: "App preview"; position: fixed; bottom: 8px; left: 8px; z-index: 60;
  padding: 2px 10px; border-radius: 999px; background: #2A1F72; color: #fff; font: 700 11px/1.6 var(--font, sans-serif); opacity: .75; pointer-events: none;
}

/* ---------- install button in the header (only rendered when installing is possible) ---------- */
.hinstall .ic { color: var(--purple, #6C4DF4); }

/* ---------- notices ---------- */
.app-offline {
  position: fixed; left: 50%; bottom: 16px; z-index: 45; transform: translateX(-50%);
  display: none; align-items: center; gap: 8px; max-width: calc(100vw - 24px);
  padding: 8px 14px; border-radius: 999px; background: #2A1F72; color: #fff; font: 700 .9rem/1.3 var(--font, sans-serif);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .5);
}
.app-offline .ic { width: 18px; height: 18px; flex: none; }
html.is-offline .app-offline { display: inline-flex; }
.app-update {
  position: fixed; left: 50%; bottom: 16px; z-index: 46; transform: translateX(-50%);
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px; width: max-content; max-width: calc(100vw - 24px);
  padding: 10px 12px 10px 16px; border-radius: 18px; background: var(--surface, #fff); color: var(--text, #24205A);
  box-shadow: 0 0 0 1px var(--line, #E3DDF7), 0 16px 40px -14px rgba(42, 31, 114, .6); font-weight: 700;
}
.install-help {
  width: min(480px, 100%); padding: 22px; border-radius: 24px; background: var(--surface, #fff); color: var(--text, #24205A);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.install-help h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.install-help h2 .ic { width: 28px; height: 28px; color: var(--purple, #6C4DF4); }
.install-help ol { margin: 0 0 16px; padding-left: 22px; line-height: 1.5; }
.install-help li + li { margin-top: 6px; }
.app-panel .setting-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.app-panel .setting-row > b { min-width: 7em; }

@media print { .apptabs, .app-offline, .app-update, .install-help { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .app-update, .app-offline { transition: none; } }

/* ---------- parent account pages (js/views/account.js) ---------- */
.acc { display: grid; place-items: start center; padding: 10px 0 30px; }
.acc-card { width: min(560px, 100%); padding: 24px; border-radius: 24px; background: var(--surface, #fff); color: var(--text, #24205A); box-shadow: var(--shadow-card, 0 14px 30px -18px rgba(42, 31, 114, .35)); border: 1px solid var(--line, #E3DDF7); }
.acc-card h1 { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; font-size: 1.6rem; line-height: 1.15; }
.acc-card h1 small { display: block; font-size: .9rem; font-weight: 600; color: var(--muted, #6B6896); margin-top: 2px; word-break: break-all; }
.acc-card h2 { font-size: 1.1rem; margin: 22px 0 8px; }
.acc-form { display: grid; gap: 12px; margin: 10px 0; }
.acc-form.acc-inline { grid-template-columns: 1fr 1fr auto; align-items: end; }
@media (max-width: 560px) { .acc-form.acc-inline { grid-template-columns: 1fr; } .acc-card { padding: 18px; } }
.acc-field { display: grid; gap: 4px; font-weight: 700; }
.acc-field small { font-weight: 500; }
.acc-input { width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line, #E3DDF7); background: var(--surface-2, #F6F3FF); color: var(--text, #24205A); font: inherit; }
.acc-input:focus { outline: 3px solid var(--ring, #6C4DF4); outline-offset: 1px; }
.acc-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; line-height: 1.4; }
.acc-check input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.acc-msg { margin: 8px 0; padding: 10px 12px; border-radius: 12px; font-weight: 700; background: var(--surface-2, #F6F3FF); }
.acc-msg.error { background: #FFE9E6; color: #9B1C0F; }
.acc-msg.ok { background: #E3F7EC; color: #125C36; }
html[data-theme="dark"] .acc-msg.error { background: #4A1C1C; color: #FFD3CC; }
html[data-theme="dark"] .acc-msg.ok { background: #143A27; color: #C9F2DA; }
.acc-google { width: 100%; justify-content: center; min-height: 48px; background: #fff; color: #1f1f1f; border: 1.5px solid #dadce0; border-radius: 999px; font-weight: 700; }
.acc-g { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #4285F4; color: #fff; font: 800 14px/1 Arial, sans-serif; }
.acc-or { text-align: center; color: var(--muted, #6B6896); margin: 10px 0 0; }
.acc-link { font-weight: 700; }
.acc-done { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border-radius: 14px; background: #E3F7EC; color: #125C36; font-weight: 700; }
html[data-theme="dark"] .acc-done { background: #143A27; color: #C9F2DA; }
.acc-dev { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 12px; border-radius: 12px; background: #FFF4D6; color: #6A4A00; font-weight: 700; font-size: .9rem; }
html[data-theme="dark"] .acc-dev { background: #3D3110; color: #FFE6A6; }
.acc-member { display: grid; gap: 4px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2, #F6F3FF); }
.acc-member[data-status="active"] { background: #E3F7EC; }
html[data-theme="dark"] .acc-member[data-status="active"] { background: #143A27; }
.acc-small { font-size: .85rem; }
.acc-doc section + section { margin-top: 4px; }
.acc-doc ul { padding-left: 20px; }
.acc-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; padding: 12px 14px; border-radius: 16px; background: var(--surface-2, #F6F3FF); border: 1px solid var(--line, #E3DDF7); }
.acc-banner .ic { color: var(--purple, #6C4DF4); }
.acc-banner span { flex: 1 1 240px; }
.btn.busy { opacity: .6; cursor: progress; }
/* password Show / Hide */
.pw-wrap { position: relative; display: block; }
.pw-wrap .acc-input { padding-right: 84px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 34px; padding: 4px 12px; border: 0; border-radius: 999px;
  background: var(--surface, #fff); color: var(--purple, #6C4DF4); font: inherit; font-weight: 800; font-size: .9rem; cursor: pointer; }
.pw-toggle:focus-visible { outline: 3px solid var(--ring, #6C4DF4); }
/* pay-first lock: hide the menus that lead into the (locked) app; sign-in / payment stays */
body.paywall-locked .htab, body.paywall-locked .hsearch, body.paywall-locked .hfind-toggle, body.paywall-locked .hfind,
body.paywall-locked .apptabs, body.paywall-locked .site-footer { display: none !important; }
/* e-mail code + Lifetime Premium checkout */
.acc-code { font: 800 1.6rem/1.2 ui-monospace, Consolas, monospace; letter-spacing: .35em; text-align: center; }
.acc-member .btn { justify-self: start; margin-top: 6px; }
.acc-price { font-size: 1.05rem; }
.acc-price b { font-size: 1.6rem; color: var(--purple, #6C4DF4); }
.acc-order { font-weight: 600; }
.acc-status { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2, #F6F3FF); font-weight: 700; font-size: .9rem; }
.acc-status.s-submitted { background: #FFF4D6; color: #6A4A00; }
.acc-status.s-approved { background: #E3F7EC; color: #125C36; }
.acc-status.s-rejected { background: #FFE9E6; color: #9B1C0F; }
.acc-qr { margin: 12px auto; width: min(280px, 100%); text-align: center; }
.acc-qr img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 16px; padding: 10px; border: 1px solid var(--line, #E3DDF7); }
.acc-qr figcaption { margin-top: 6px; font-weight: 800; }
.acc-qr .btn { margin-top: 8px; }
.acc-qr small { display: block; margin-top: 6px; }
.acc-steps { padding-left: 22px; display: grid; gap: 6px; }
.acc-code-inline { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2, #F6F3FF); padding: 1px 6px; border-radius: 6px; user-select: all; }
.acc .row-btns { margin: 8px 0; }
