.account-page {
  background: var(--vv-page);
  color: var(--vv-text);
}
.account-page *, .account-page *::before, .account-page *::after { box-sizing: border-box; }
.account-bar {
  min-height: 64px;
  padding: 8px max(var(--vv-gutter), calc((100% - 63rem) / 2));
  border-bottom: 1px solid var(--vv-border);
  background: var(--vv-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.account-brand {
  color: var(--vv-text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 1.05rem;
  font-weight: 700;
}
.account-brand img { width: 30px; height: 30px; object-fit: contain; }
.account-bar-actions { display: flex; gap: 6px; }
.account-main { width: min(100%, 63rem); margin: 0 auto; padding: clamp(20px, 4vw, 48px) var(--vv-gutter) 48px; }
.account-main h1 {
  margin: 0 0 20px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 730;
  letter-spacing: -.045em;
}
.account-main h2, .account-dialog h2 { margin: 0; font-size: 1.18rem; letter-spacing: -.015em; }
.account-grid { display: grid; align-items: stretch; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.account-card {
  border: 1px solid var(--vv-border);
  border-radius: 20px;
  background: var(--vv-surface);
  padding: 18px clamp(16px, 3vw, 24px);
  min-width: 0;
}
section.account-card { display: grid; align-content: start; gap: 13px; }
.account-page :is(input, select, button) {
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  font: inherit;
  color: var(--vv-text);
  background: var(--vv-control-fill);
  border: 1px solid var(--vv-border);
  border-radius: 12px;
  padding: 8px 12px;
}
.account-page :is(input, select):not([type="file"], [type="range"]) { width: 100%; }
.account-page #account-locale { width: auto; }
.account-page #account-theme { flex: 0 0 auto; }
.account-page input[type="range"] { width: 100%; padding-inline: 0; accent-color: var(--vv-action); }
.account-page label { color: var(--vv-muted); font-size: .87rem; font-weight: 570; min-width: 0; }
.account-page label :is(select,input) { font-size: .95rem; font-weight: 450; }
.account-page button:disabled { opacity: .55; }
.account-page button.account-primary {
  background: var(--vv-action);
  border-color: transparent;
  color: var(--vv-action-ink);
  font-weight: 650;
}
.account-page button.account-danger { color: var(--alert-bad-text, var(--vv-danger)); }
.account-page a.account-primary--link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 20px;
  border-radius: 12px; background: var(--vv-action); color: var(--vv-action-ink); font-weight: 650; text-decoration: none;
}
.account-page a.account-primary--link[hidden] { display: none; }
.account-who__form { margin: 0; justify-self: start; }
.account-preview, .account-row-actions, .account-save {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.account-avatar {
  display: grid;
  place-items: center;
  width: 66px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: var(--vv-control-hover);
  color: var(--vv-text);
  font-size: 1.3rem;
  font-weight: 650;
}
.account-avatar > * { grid-area: 1 / 1; }
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-avatar--small { width: 38px; font-size: .88rem; }
.account-avatar span:empty::before {
  content: "";
  display: block;
  width: 1.2em;
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 28%, currentColor 20%, transparent 22%),
    radial-gradient(ellipse at 50% 95%, currentColor 43%, transparent 46%);
}
.account-preview { background: var(--vv-control-fill); border-radius: 14px; padding: 10px; flex-wrap: nowrap; }
.account-preview small, .account-preview strong { display: block; overflow-wrap: anywhere; }
.account-preview small { color: var(--vv-muted); margin-bottom: 3px; }
.account-page :is(a,button).account-link {
  display: inline-flex;
  align-items: center;
  color: var(--vv-focus);
  background: transparent;
  border-color: transparent;
  font-weight: 600;
  min-height: 44px;
}
.account-prefs, .account-save, .account-sections h2 { grid-column: 1 / -1; }
.account-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 142px), 1fr)); gap: 10px; }
.account-fields[data-stacked] { grid-template-columns: minmax(0, 1fr); }
.account-save { justify-content: flex-end; }
.account-save [hidden] { display: none !important; }
/* The line under the cards says how the last save went, with its shape first (dot, spinner, tick, "!"). */
#save-status:not(:empty) { display: flex; align-items: center; gap: 7px; line-height: 18px; }
#save-status[data-kind]::before {
  content: ""; flex: none; display: grid; place-items: center; box-sizing: border-box;
  width: 18px; height: 18px; border-radius: 50%; font-size: .72rem; font-weight: 750; line-height: 1;
}
#save-status[data-kind=unsaved]::before { width: 10px; height: 10px; margin: 4px; background: var(--vv-focus); }
#save-status[data-kind=saving]::before, #save-status[data-kind=waiting]::before {
  width: 14px; height: 14px; margin: 2px; border: 2px solid var(--vv-muted); border-right-color: transparent;
  animation: vf-spin .9s linear infinite;
}
#save-status[data-kind=saved]::before {
  content: "\2713"; color: var(--vv-indicator-live, #1f8a4c);
  background: color-mix(in srgb, var(--vv-indicator-live, #1f8a4c) 16%, transparent);
}
#save-status[data-kind=error]::before {
  content: "!"; color: var(--alert-bad-text, var(--vv-danger));
  background: color-mix(in srgb, var(--alert-bad-text, var(--vv-danger)) 16%, transparent);
}
@media (prefers-reduced-motion: reduce) { #save-status[data-kind]::before { animation: none; } }
/* Something to save: one bar with the state, Discard and Save, kept in view at the bottom of the screen. */
.account-save[data-unsaved], .account-save[data-answer] {
  position: sticky; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 5;
  justify-content: flex-end; flex-wrap: nowrap; gap: 6px;
  padding: 8px 8px 8px 16px; border-radius: 18px;
  background: var(--vv-surface); border: 1px solid var(--vv-border);
  box-shadow: 0 10px 28px rgb(0 0 0 / .22), 0 2px 6px rgb(0 0 0 / .12);
}
.account-save[data-unsaved] #save-status, .account-save[data-answer] #save-status { margin-right: auto; color: var(--vv-text); font-weight: 600; min-width: 0; }
.account-page .account-save .account-link { padding-inline: 12px; }
.account-page .account-save button.account-primary { padding-inline: 20px; white-space: nowrap; }
/* Phones: the state on its own line, then Discard and a wide Save (the frequent action, the bigger target). */
@media (max-width: 560px) {
  .account-save[data-unsaved] { flex-wrap: wrap; row-gap: 4px; padding: 10px 10px 10px 14px; }
  .account-save[data-unsaved] #save-status { flex: 1 0 100%; padding-left: 2px; }
  .account-page .account-save[data-unsaved] .account-link { flex: 0 0 auto; }
  .account-page .account-save[data-unsaved] button.account-primary { flex: 1 1 0; padding-inline: 12px; }
}

/* Text size: five "A" tiles that grow, the chosen one ringed and ticked, and its word beside the title. */
.account-size-field { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; min-width: 0; }
.account-size-field legend {
  display: flex; align-items: baseline; gap: 8px; padding: 0; margin-bottom: 6px;
  color: var(--vv-muted); font-size: .87rem; font-weight: 570;
}
.account-size-field legend b { color: var(--vv-text); font-weight: 650; }
.account-size-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 440px; }
.account-page label.account-size {
  position: relative; display: grid; place-items: center; height: 60px; border-radius: 14px; cursor: pointer;
  background: var(--vv-control-fill); border: 1px solid var(--vv-border); color: var(--vv-text);
}
.account-page label.account-size:hover { background: var(--vv-control-hover); }
.account-page .account-size input {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0;
  opacity: 0; cursor: pointer;
}
.account-size__a { font-weight: 700; line-height: 1; pointer-events: none; }
.account-size:nth-child(1) .account-size__a { font-size: 15px; }
.account-size:nth-child(2) .account-size__a { font-size: 19px; }
.account-size:nth-child(3) .account-size__a { font-size: 24px; }
.account-size:nth-child(4) .account-size__a { font-size: 29px; }
.account-size:nth-child(5) .account-size__a { font-size: 35px; }
.account-page label.account-size:has(input:checked) {
  border-color: var(--vv-action); box-shadow: 0 0 0 2px var(--vv-action);
  background: color-mix(in srgb, var(--vv-action) 12%, var(--vv-control-fill));
}
.account-page label.account-size:has(input:focus-visible) { outline: 2px solid var(--vv-focus); outline-offset: 3px; }
.account-size__tick {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%;
  display: none; place-items: center; background: var(--vv-action); border: 2px solid var(--vv-surface);
  pointer-events: none;
}
.account-size:has(input:checked) .account-size__tick { display: grid; }
.account-size__tick svg { width: 12px; height: 12px; fill: none; stroke: var(--vv-action-ink); stroke-width: 3.2;
  stroke-linecap: round; stroke-linejoin: round; }

/* The theme button: an icon of the theme on screen, as tall as the language menu. */
.account-page button.account-theme { display: grid; place-items: center; width: 44px; padding: 0; }
.account-theme svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.account-theme[data-theme-now=dark] .account-theme__sun,
.account-theme:not([data-theme-now=dark]) .account-theme__moon { display: none; }
.account-theme__moon { fill: currentColor; fill-opacity: .18; }
.account-bar-actions { align-items: stretch; }
.account-status { margin: 0; color: var(--vv-muted); font-size: .86rem; }
.account-status:empty { display: none; }
.account-status[data-error] { color: var(--alert-bad-text, var(--vv-danger)); }
/* The privacy card's own line: its state reads by shape first (spinner, tick, exclamation). */
#privacy-status:not(:empty) { display: flex; align-items: flex-start; gap: 7px; line-height: 18px; }
#privacy-status[data-kind]::before {
  content: ""; flex: none; display: grid; place-items: center; box-sizing: border-box;
  width: 18px; height: 18px; border-radius: 50%; font-size: .72rem; font-weight: 750; line-height: 1;
}
#privacy-status[data-kind=saving]::before {
  width: 14px; height: 14px; margin: 2px; border: 2px solid var(--vv-muted); border-right-color: transparent;
  animation: vf-spin .9s linear infinite;
}
#privacy-status[data-kind=saved]::before {
  content: "\2713"; color: var(--vv-indicator-live, #1f8a4c);
  background: color-mix(in srgb, var(--vv-indicator-live, #1f8a4c) 16%, transparent);
}
#privacy-status[data-kind=error]::before {
  content: "!"; color: var(--alert-bad-text, var(--vv-danger));
  background: color-mix(in srgb, var(--alert-bad-text, var(--vv-danger)) 16%, transparent);
}
@media (prefers-reduced-motion: reduce) { #privacy-status[data-kind=saving]::before { animation: none; } }
/* Another device restricted what hosts see: one calm line with a devices icon,
   next to the choice it changed. #save-status carries the same words for screen readers. */
.account-notice {
  display: flex; align-items: center; gap: 9px; margin: 0;
  padding: 9px 11px; border-radius: 12px;
  background: color-mix(in srgb, var(--vv-focus) 12%, transparent);
  color: var(--vv-text, inherit); font-size: .9rem; font-weight: 550; line-height: 1.3;
}
.account-notice[hidden] { display: none; }
.account-notice svg {
  flex: none; width: 22px; height: 22px; fill: none; stroke: var(--vv-focus);
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
/* The Save line keeps the words for screen readers; eyes get the line beside the choice. */
.account-status[data-notice] {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
/* Offline, the controls that change what hosts see are disabled and this note says why.
   It takes the place of the "Last confirmed for hosts" preview: both always occupy the same
   cell, so going offline or back online never moves anything on the page. */
.account-preview-slot { display: grid; }
.account-preview-slot > * { grid-area: 1 / 1; }
.account-preview-slot[data-offline] .account-preview,
.account-preview-slot:not([data-offline]) .account-offline { visibility: hidden; }
.account-offline {
  display: flex; align-items: center; gap: 10px; margin: 0;
  padding: 10px 12px; border-radius: 14px;
  background: var(--vv-control-fill); color: var(--vv-text, inherit);
  font-size: .9rem; font-weight: 550; line-height: 1.3;
}
.account-offline:focus { outline: none; }
.account-offline:focus-visible { outline: 2px solid var(--vv-focus); outline-offset: 2px; }
.account-offline svg {
  flex: none; width: 22px; height: 22px; fill: none; stroke: var(--vv-muted);
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.account-page :is(input, select):disabled { opacity: .55; cursor: not-allowed; }
.account-page button:disabled { cursor: not-allowed; }
.account-sections { margin-top: 23px; }
.account-sections details { align-self: start; padding-block: 0; }
.account-sections summary {
  display: list-item;
  min-height: 50px;
  padding-block: 15px;
  font-weight: 630;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.account-sections details[open] { padding-bottom: 12px; }
.account-sections p { margin: 7px 0; color: var(--vv-muted); font-size: .9rem; }
.account-room { border-top: 1px solid var(--vv-border); padding: 12px 0 4px; overflow-wrap: anywhere; }
.account-room .account-link { padding-inline: 2px; margin-right: 12px; }
.account-room .account-room-link { display: inline-block; max-width: 100%; }
.account-room [data-qr-room].account-link { padding-inline: 8px; }
.account-room [data-qr-room]:focus-visible { outline-offset: -3px; }
.account-dialog {
  width: min(calc(100% - 24px), 420px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  border: 1px solid var(--vv-border);
  background: var(--vv-surface);
  color: var(--vv-text);
  border-radius: 22px;
  padding: 20px;
}
.account-dialog > * + *, #crop-controls > * + * { margin-top: 12px; }
.account-dialog::backdrop { background: #11182780; }
.account-dialog canvas { display: block; max-width: 100%; height: auto; background: white; margin-inline: auto; }
#crop-canvas { width: min(100%, 182px); border-radius: 50%; }
#room-qr { width: min(100%, 220px); }
.account-dialog .account-row-actions { justify-content: flex-end; }
@media (max-width: 620px) {
  .account-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .account-card { border-radius: 17px; padding-top: 14px; padding-bottom: 14px; }
}

.account-loading, #sign-in-form { display: grid; justify-items: start; gap: 12px; }
#sign-in-form { width: min(100%, 28rem); }
#sign-in-form label { width: 100%; }
/* Pilot rule (VV_PILOT_ANONYMOUS): one line with the person icon stands in for the sharing choice,
   its preview and its save state. The offline note keeps its place for the name and photo. */
.account-pilot {
  display: flex; align-items: center; gap: 12px; margin: 0;
  padding: 10px 12px; border-radius: 14px;
  background: var(--vv-control-fill); color: var(--vv-text, inherit);
  font-size: .95rem; font-weight: 600; line-height: 1.3;
}
.account-pilot[hidden] { display: none; }
.account-pilot__icon {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: color-mix(in srgb, var(--vv-muted) 18%, transparent);
}
.account-pilot__icon svg {
  width: 24px; height: 24px; fill: none; stroke: var(--vv-muted);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.account-card[data-pilot] :is(#privacy-status, #privacy-notice, .account-preview),
.account-card[data-pilot] .account-preview-slot:not([data-offline]) { display: none; }

/* The person at a glance: their own picture (photo or initials; tapping it opens the photo dialog), the name as typed
   in bold, the address below (hosted), the photo buttons, church and role as short chips, and Sign out. The tick on the
   picture says "signed in" (hosted only). The privacy card says who else sees any of it. */
.account-who { margin-bottom: 14px; }
.account-who[hidden] { display: none; }
.account-who__row { display: flex; align-items: flex-start; gap: 16px; min-width: 0; }
.account-who__me { position: relative; flex: none; }
.account-avatar--me { width: 76px; font-size: 1.5rem; cursor: pointer; }
.account-avatar--me:not([data-offline]):hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--vv-focus) 45%, transparent); }
.account-avatar--me[data-offline] { cursor: default; }
.account-who__tick {
  position: absolute; right: -1px; bottom: -1px; width: 24px; height: 24px; border-radius: 50%; display: grid;
  place-items: center; background: var(--vv-action); border: 2px solid var(--vv-surface); pointer-events: none;
}
.account-who__tick[hidden] { display: none; }
.account-who__tick svg { width: 13px; height: 13px; fill: none; stroke: var(--vv-action-ink); stroke-width: 3;
  stroke-linecap: round; stroke-linejoin: round; }
.account-who__text { display: grid; justify-items: start; align-content: start; min-width: 0; padding-top: 6px; }
.account-who__text strong { font-size: 1.2rem; font-weight: 700; line-height: 1.25; letter-spacing: -.01em;
  overflow-wrap: anywhere; }
.account-who__text strong:not([data-name]) { color: var(--vv-muted); font-weight: 600; }
.account-who__text small { color: var(--vv-muted); font-size: .9rem; font-weight: 500; margin-top: 2px; overflow-wrap: anywhere; }
.account-who__text small[hidden] { display: none; }
.account-photo-actions { display: flex; flex-wrap: wrap; gap: 0 4px; margin: 4px 0 0 -10px; }
.account-page .account-photo-actions .account-link { gap: 7px; padding-inline: 10px; }
.account-page .account-photo-actions .account-link[hidden] { display: none; }
.account-photo-actions svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.account-page .account-photo-actions .account-link--quiet { color: var(--vv-muted); font-weight: 550; }
.account-who__roles { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.account-who__roles:empty { display: none; }
.account-who__roles li {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border-radius: 999px;
  background: var(--vv-control-fill); border: 1px solid var(--vv-border); font-size: .9rem; font-weight: 600;
}
.account-who__roles li b { font-weight: 700; color: var(--vv-focus); }
.account-who__roles li[data-paused] { border-style: dashed; }
.account-who__out {
  justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border-radius: 12px; border: 1px solid var(--vv-border); background: var(--vv-control-fill); color: var(--vv-text);
  font-weight: 650; text-decoration: none;
}
.account-who__out:hover { background: var(--vv-control-hover); }
.account-who__out svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; }
/* Wide screens: the person on the left; church, role and Sign out on the right, so the card is not a long empty strip. */
@media (min-width: 760px) {
  .account-who { grid-template-columns: minmax(0, 1fr) auto; column-gap: 20px; align-items: start; }
  .account-who__row { grid-row: 1 / span 2; }
  .account-who__roles { grid-column: 2; justify-content: flex-end; padding-top: 6px; }
  .account-who__form { grid-column: 2; justify-self: end; }
}
/* The privacy card holds one line during the pilot: it keeps its own height instead of the Profile card's. */
.account-privacy { align-self: start; }

/* Remove photo asks first and shows the outcome: the photo, an arrow, the initials that will show instead. */
.account-swap { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 6px 0 2px; }
.account-avatar--swap { width: 72px; font-size: 1.45rem; }
.account-avatar--swap[hidden], .account-swap__arrow[hidden] { display: none; }
.account-avatar--swap img:not([src]) { visibility: hidden; }
.account-swap__arrow { width: 26px; height: 26px; fill: none; stroke: var(--vv-muted); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
#remove-photo-dialog h2 { text-align: center; margin-top: 16px; }
#remove-photo-body { margin-block: 8px 0; color: var(--vv-muted); text-align: center; line-height: 1.4; }
#remove-photo-dialog .account-row-actions { margin-top: 18px; }
#remove-photo-dialog .account-row-actions button { flex: 1 1 0; }
html.dark-theme #confirm-remove-photo { border-color: color-mix(in srgb, var(--vv-danger) 55%, transparent); }

/* The Publisher page menu (hosted only): Sign out reads as a menu item. Loaded on that page by app.py with the Account item. */
#menu-sign-out { margin: 0; display: block; border-top: 1px solid var(--panel-border, var(--vv-border)); }
#menu-sign-out button {
  width: 100%; border: 0; border-radius: 0 0 16px 16px; background: transparent; box-shadow: none;
  text-align: start; font: inherit; font-weight: 700; color: var(--text-primary, var(--vv-text)); cursor: pointer;
}
#menu-sign-out button:hover, #menu-sign-out button:focus-visible { background: var(--panel-bg-light, var(--vv-control-hover)); color: var(--brand-accent-strong, var(--vv-action)); }
