/* Shared by the blocking document stylesheet and React. The same composition
   persists through startup stages, independent of the workspace wallpaper. */
.river-page-loader__phone { display: none; }

:root.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"],
:root:not(.river-phone-ready) .river-page-loader.river-page-loader--phone {
  --river-phone-art: url('/login/onboardingbg.webp');
  --river-phone-art-position: 50% 50%;
  --river-phone-ground: #426885;
  --river-phone-ink: #fff;
  --river-phone-shade: radial-gradient(ellipse at 50% 44%, rgba(7, 23, 35, .23), transparent 55%),
    linear-gradient(rgba(7, 23, 35, .06), rgba(7, 23, 35, .16));
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background-color: var(--river-phone-ground);
  background-image: var(--river-phone-shade), var(--river-phone-art), var(--river-loading-login-preview, none);
  background-size: cover;
  background-position: var(--river-phone-art-position);
  background-repeat: no-repeat;
  color: var(--river-phone-ink);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"]::before,
:root:not(.river-phone-ready) .river-page-loader.river-page-loader--phone::before {
  display: none;
}
/* A low-opacity light ripple stays over the water; no image displacement or
   full-screen movement. Only transform and opacity animate. */
:root.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"]::after,
:root:not(.river-phone-ready) .river-page-loader.river-page-loader--phone::after {
  content: '';
  display: block;
  position: absolute;
  inset: 58% 22% -3%;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(174deg, transparent 0 18px, rgba(220, 241, 255, .16) 19px, transparent 21px 36px);
  -webkit-mask-image: radial-gradient(ellipse at center, #000, transparent 70%);
  mask-image: radial-gradient(ellipse at center, #000, transparent 70%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: riverPhoneWater 4s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
:root.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"] .river-page-loader__content,
:root:not(.river-phone-ready) .river-page-loader--phone .river-page-loader__content { display: none; }

:root.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"] .river-page-loader__phone,
:root:not(.river-phone-ready) .river-page-loader--phone .river-page-loader__phone {
  position: absolute;
  top: calc(50% - 35px);
  left: 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Safe-area insets arrive after first paint; they must not move the brand. */
  transform: translate(-50%, -50%);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.river-phone-brand { display: flex; align-items: center; gap: 12px; }
.river-phone-brand > span { font-size: 38px; line-height: 1.15; font-weight: 650; letter-spacing: -.8px; }
.river-phone-brand__mark { width: 46px; height: 46px; flex: none; }
.river-phone-brand__mark svg { display: block; width: 100%; height: 100%; }
/* Absolute positioning keeps the brand fixed when the activity indicator appears. */
.river-phone-wave {
  position: absolute;
  top: calc(100% + 24px);
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 20px;
  overflow: hidden;
  color: #fff;
}
.river-phone-wave svg {
  display: block;
  width: 200%;
  height: 100%;
  animation: riverLoadingWave 1.8s linear infinite;
}
@keyframes riverLoadingWave {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.river-phone-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:root.theme-scheme-dark.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"],
:root.theme-scheme-dark:not(.river-phone-ready) .river-page-loader.river-page-loader--phone {
  --river-phone-art: url('/login/onboardingbg-dark.webp');
  --river-phone-art-position: 50% 50%;
  --river-phone-ground: #0d1e35;
  --river-phone-shade: linear-gradient(rgba(7, 23, 35, .02), rgba(7, 23, 35, .05));
}
@keyframes riverPhoneWater {
  from { transform: translateY(0); opacity: .18; }
  to { transform: translateY(8px); opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
  .river-phone-wave { display: none; }
  .river-phone-wave svg { animation: none; }
  :root.river-phone-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"]::after,
  :root:not(.river-phone-ready) .river-page-loader.river-page-loader--phone::after { animation: none; display: none; will-change: auto; }
  /* Static, readable status is retained when animation cannot convey activity. */
  .river-phone-status { position: absolute; top: calc(100% + 30px); width: max-content; max-width: 100vw; height: auto; margin: 0; overflow: visible; clip-path: none; font-size: 17px; }
}

/* The native launch storyboard remains underneath transparent WebKit. Do not
   replace it with independently cropped artwork or a second rendered wordmark.
   Restore the page canvas as soon as real content replaces the loader. */
:root.river-native-startup:not(.river-phone-ready):not(:has(#root)),
:root.river-native-startup:not(.river-phone-ready):has(#root:empty),
:root.river-native-startup:not(.river-phone-ready):has(.river-page-loader[aria-busy="true"]),
:root.river-native-startup:not(.river-phone-ready):has(#root:empty) body,
:root.river-native-startup:not(.river-phone-ready):has(.river-page-loader[aria-busy="true"]) body {
  background: transparent !important;
}
:root.river-native-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"] {
  background: transparent;
}
/* The workspace layout mounts before chat. Its opaque canvas must not cover
   the native surface while it still contains the full-screen loader. */
:root.river-native-startup:not(.river-phone-ready) .gui-layout--mobile:has(.river-page-loader[aria-busy="true"]) {
  background: transparent !important;
}
:root.river-native-startup:not(.river-phone-ready) .gui-layout--mobile:has(.river-page-loader[aria-busy="true"])::after {
  display: none;
}
:root.river-native-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"]::after {
  display: none;
  animation: none;
}
:root.river-native-startup:not(.river-phone-ready) .river-page-loader[aria-busy="true"] .river-phone-brand {
  visibility: hidden;
}

/* New native builds animate one persistent layer from the launch storyboard.
   Older apps and browsers still draw the web wave above. */
:root.river-native-wave .river-phone-wave { visibility: hidden; }
:root.river-native-wave .river-phone-wave svg { animation: none; }

/* Skeleton geometry is shared by the first HTML frame and React. It contains
   no account data or interactive controls while the destination is authorized. */
.river-chat-skeleton, .river-settings-skeleton { display: none; }
/* Only a loader that knows its destination draws its shape: the chat (and an account switch, which lands
   on the new account's chat) or Settings. Any other wait keeps River's own loader (PageLoader.scss). */
:root.river-phone-ready .river-page-loader--chat[aria-busy="true"],
:root.river-phone-ready .river-page-loader--settings[aria-busy="true"],
:root.river-phone-ready[data-river-navigation="account"] .river-page-loader[aria-busy="true"] {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  display: block;
  /* The phone chat's own surface (--c-bg), so the skeleton hands over to the chat without a colour change. */
  background: var(--c-bg, #f6f6f7);
  color: var(--theme-text-secondary, #6e6e73);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root.river-phone-ready.theme-scheme-dark .river-page-loader--chat[aria-busy="true"],
:root.river-phone-ready.theme-scheme-dark[data-river-navigation="account"] .river-page-loader[aria-busy="true"] {
  background: var(--c-bg, #252527);
  color: var(--theme-text-secondary, #a1a1a6);
}
:root.river-phone-ready .river-page-loader__phone { display: none; }
:root.river-phone-ready :is(.river-page-loader--chat, .river-page-loader--settings)[aria-busy="true"]::before,
:root.river-phone-ready :is(.river-page-loader--chat, .river-page-loader--settings)[aria-busy="true"]::after,
:root.river-phone-ready[data-river-navigation="account"] .river-page-loader[aria-busy="true"]::before,
:root.river-phone-ready[data-river-navigation="account"] .river-page-loader[aria-busy="true"]::after,
:root.river-phone-ready :is(.river-page-loader--chat, .river-page-loader--settings) :is(.river-page-loader__mark, .river-page-loader__wave),
:root.river-phone-ready[data-river-navigation="account"] .river-page-loader :is(.river-page-loader__mark, .river-page-loader__wave) { display: none; }
:root.river-phone-ready :is(.river-page-loader--chat, .river-page-loader--settings)[aria-busy="true"] .river-page-loader__content,
:root.river-phone-ready[data-river-navigation="account"] .river-page-loader[aria-busy="true"] .river-page-loader__content {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
:root.river-phone-ready .river-page-loader--chat .river-chat-skeleton,
:root.river-phone-ready[data-river-navigation="account"] .river-chat-skeleton {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  pointer-events: none;
  --skeleton-fill: rgba(120, 120, 128, .14);
}
:root.theme-scheme-dark .river-chat-skeleton { --skeleton-fill: rgba(235, 235, 245, .12); }
.river-chat-skeleton span, .river-chat-skeleton i {
  display: block;
  flex: none;
  background: var(--skeleton-fill);
  border-radius: 6px;
}
.river-chat-skeleton span { height: 12px; }
.river-chat-skeleton i { width: 28px; height: 28px; border-radius: 50%; }
/* As the phone chat header: menu, a centered title, the buttons at the end. */
.river-chat-skeleton__header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 56px;
}
.river-chat-skeleton__header span { width: 112px; height: 16px; }
.river-chat-skeleton__header i:last-child { justify-self: end; }
.river-chat-skeleton__messages {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding-top: 32px;
  box-sizing: border-box;
}
.river-chat-skeleton__question {
  margin-left: auto;
  width: 58%;
  padding: 16px;
  border-radius: 20px;
  background: var(--skeleton-fill);
}
.river-chat-skeleton__question span + span { width: 65%; margin-top: 10px; }
.river-chat-skeleton__answer { margin-top: 32px; }
.river-chat-skeleton__answer i { margin-bottom: 16px; }
.river-chat-skeleton__answer span { margin-top: 12px; width: 92%; }
.river-chat-skeleton__answer span:last-child { width: 58%; }
.river-chat-skeleton__composer {
  box-sizing: border-box;
  flex: none;
  width: 100%;
  max-width: 680px;
  margin: 16px auto 0;
  padding: 18px 16px 12px;
  border: 1px solid var(--skeleton-fill);
  border-radius: 24px;
}
.river-chat-skeleton__composer > span { width: 38%; }
.river-chat-skeleton__composer > div { display: flex; justify-content: space-between; margin-top: 22px; }
/* A stationary placeholder avoids a new flash on fast switches, and works
   unchanged with Reduce Motion. No minimum display time delays the destination. */

/* Settings' shape while its panel loads over the chat. */
:root.river-phone-ready .river-page-loader--settings[aria-busy="true"] {
  background: var(--theme-bg-primary, #fff);
  color: var(--theme-text-primary, #161618);
  /* Match the Settings overlay while its chunk loads above the workspace. */
  z-index: var(--z-dropdown, 1000);
}
:root.river-phone-ready.theme-scheme-dark .river-page-loader--settings[aria-busy="true"] {
  background: var(--theme-bg-primary, #1e1e1e);
  color: var(--theme-text-primary, #f5f5f7);
}
:root.river-phone-ready .river-page-loader--settings .river-chat-skeleton { display: none; }
:root.river-phone-ready .river-page-loader--settings .river-settings-skeleton {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  pointer-events: none;
  text-align: left;
  --skeleton-fill: rgba(120, 120, 128, .14);
  --skeleton-card: var(--theme-bg-secondary, #f6f6f7);
}
:root.river-phone-ready.theme-scheme-dark .river-page-loader--settings .river-settings-skeleton {
  --skeleton-fill: rgba(235, 235, 245, .12);
  --skeleton-card: var(--theme-bg-secondary, #252527);
}
.river-settings-skeleton span, .river-settings-skeleton i {
  display: block;
  flex: none;
  background: var(--skeleton-fill);
  border-radius: 6px;
}
.river-settings-skeleton span { height: 12px; }
.river-settings-skeleton i { width: 24px; height: 24px; }
.river-settings-skeleton__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 52px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--skeleton-fill);
}
.river-settings-skeleton__header strong { font-size: 18px; font-weight: 600; }
.river-settings-skeleton__header i { width: 44px; height: 44px; border-radius: 50%; background: var(--skeleton-card); }
.river-settings-skeleton__body { padding: 16px; overflow: hidden; }
.river-settings-skeleton__account, .river-settings-skeleton__team {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--skeleton-card);
}
.river-settings-skeleton__account { min-height: 61px; margin-bottom: 32px; }
.river-settings-skeleton__account > i { width: 32px; height: 32px; border-radius: 50%; }
.river-settings-skeleton__account > div, .river-settings-skeleton__team > div { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.river-settings-skeleton__account span { width: 65%; }
.river-settings-skeleton__account span:nth-child(2) { width: 90%; }
.river-settings-skeleton__section { margin-top: 24px; }
.river-settings-skeleton__section > span { width: 96px; margin: 0 12px 12px; }
.river-settings-skeleton__group { padding: 0 12px; border-radius: 16px; background: var(--skeleton-card); }
.river-settings-skeleton__group > div { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.river-settings-skeleton__group > div + div { border-top: 1px solid var(--skeleton-fill); }
.river-settings-skeleton__group span { width: 55%; }
.river-settings-skeleton__team { margin-bottom: 16px; min-height: 41px; }
.river-settings-skeleton__team > i { width: 32px; height: 32px; }
.river-settings-skeleton__team span { width: 55%; }
.river-settings-skeleton__team span + span { width: 35%; }
