/* Premium glass visual system. Behavioral layout remains owned by styles.css. */
:root {
  --pg-depth: 0.65;
  --pg-light-x: 112px;
  --pg-light-y: 72px;
  --pg-light-tilt-x: -0.22;
  --pg-light-tilt-y: -0.3;
  --pg-lens-edge: 1.9px;
  --pg-lens-highlight: 0.41;
  --pg-lens-highlight-soft: 0.18;
  --pg-lens-shadow: 0.26;
  --pg-lens-shadow-soft: 0.15;
  --pg-lens-lift: 26px;
  --pg-lens-scale: 1.0042;
  --pg-glass-low-strength: 38%;
  --pg-glass-mid-strength: 56%;
  --pg-glass-high-strength: 76%;
  --pg-wallpaper-tint: #111722;
  --pg-canvas: color-mix(in srgb, var(--bg) 91%, #0c1320 9%);
  --pg-low: color-mix(in srgb, var(--panel) var(--pg-glass-low-strength), transparent);
  --pg-mid: color-mix(in srgb, var(--panel) var(--pg-glass-mid-strength), transparent);
  --pg-high: color-mix(in srgb, var(--panel) var(--pg-glass-high-strength), transparent);
  --pg-soft: color-mix(in srgb, var(--panel-2) 49%, transparent);
  --pg-stroke: color-mix(in srgb, var(--text) 15%, transparent);
  --pg-stroke-bright: color-mix(in srgb, white 52%, var(--pg-stroke));
  --pg-stroke-accent: color-mix(in srgb, var(--accent) 52%, var(--pg-stroke));
  --pg-specular:
    inset 0 var(--pg-lens-edge) 0 rgb(255 255 255 / var(--pg-lens-highlight)),
    inset var(--pg-lens-edge) 0 0 rgb(255 255 255 / var(--pg-lens-highlight-soft)),
    inset 0 calc(var(--pg-lens-edge) * -1) 0 rgb(2 8 23 / var(--pg-lens-shadow)),
    inset calc(var(--pg-lens-edge) * -1) 0 0 rgb(2 8 23 / var(--pg-lens-shadow-soft));
  --pg-shadow-low: 0 8px 24px rgb(2 8 23 / 0.1), 0 2px 6px rgb(2 8 23 / 0.06);
  --pg-shadow-mid: 0 18px 46px rgb(2 8 23 / 0.17), 0 4px 12px rgb(2 8 23 / 0.09);
  --pg-shadow-high: 0 32px 86px rgb(2 8 23 / 0.26), 0 8px 22px rgb(2 8 23 / 0.12);
  --pg-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pg-radius-xs: 10px;
  --pg-radius-sm: 14px;
  --pg-radius: 20px;
  --pg-radius-lg: 28px;
  --pg-blur: 28px;
  --pg-blur-float: 42px;
}

:root[data-theme="dark"] {
  --pg-canvas: color-mix(in srgb, var(--bg) 88%, #020617 12%);
  --pg-low: color-mix(in srgb, var(--panel) var(--pg-glass-low-strength), transparent);
  --pg-mid: color-mix(in srgb, var(--panel) var(--pg-glass-mid-strength), transparent);
  --pg-high: color-mix(in srgb, var(--panel) var(--pg-glass-high-strength), transparent);
  --pg-soft: color-mix(in srgb, var(--panel-2) 46%, transparent);
  --pg-stroke: rgb(255 255 255 / 0.14);
  --pg-stroke-bright: rgb(255 255 255 / 0.3);
  --pg-specular:
    inset 0 var(--pg-lens-edge) 0 rgb(255 255 255 / var(--pg-lens-highlight)),
    inset var(--pg-lens-edge) 0 0 rgb(255 255 255 / var(--pg-lens-highlight-soft)),
    inset 0 calc(var(--pg-lens-edge) * -1) 0 rgb(0 0 0 / var(--pg-lens-shadow)),
    inset calc(var(--pg-lens-edge) * -1) 0 0 rgb(0 0 0 / var(--pg-lens-shadow-soft));
  --pg-shadow-low: 0 9px 28px rgb(0 0 0 / 0.2), 0 2px 8px rgb(0 0 0 / 0.12);
  --pg-shadow-mid: 0 20px 52px rgb(0 0 0 / 0.3), 0 5px 14px rgb(0 0 0 / 0.17);
  --pg-shadow-high: 0 34px 96px rgb(0 0 0 / 0.44), 0 9px 24px rgb(0 0 0 / 0.22);
}

html { background: var(--pg-canvas); }

body {
  isolation: isolate;
  letter-spacing: 0;
  background:
    linear-gradient(124deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 34%),
    linear-gradient(304deg, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 42%),
    linear-gradient(155deg, color-mix(in srgb, var(--pg-wallpaper-tint) 10%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--pg-canvas) 94%, white 6%), var(--pg-canvas));
}

body::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(108deg, transparent 0 22%, rgb(255 255 255 / 0.075) 22.2% 23%, transparent 23.2% 66%, rgb(255 255 255 / 0.052) 66.2% 67%, transparent 67.2%),
    linear-gradient(180deg, rgb(255 255 255 / 0.08), transparent 25%, transparent 76%, rgb(0 0 0 / 0.065));
}

body::after {
  position: fixed;
  z-index: 100000;
  inset: 0;
  content: "";
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 25%, transparent) transparent;
}

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  min-height: 36px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 24%, transparent);
  background-clip: padding-box;
}

::selection { color: white; background: color-mix(in srgb, var(--accent) 78%, transparent); }

button, input, textarea, select { letter-spacing: 0; }

button {
  position: relative;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 62%, white 12%);
  border-radius: var(--pg-radius-sm);
  color: white;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.25), transparent 46%),
    linear-gradient(140deg, color-mix(in srgb, var(--accent) 90%, #09111f), color-mix(in srgb, var(--accent-2) 26%, var(--accent)));
  box-shadow: var(--pg-specular), 0 10px 24px color-mix(in srgb, var(--accent) 24%, transparent);
  font-weight: 760;
  transition: border-color 160ms ease, box-shadow 220ms ease, color 160ms ease, opacity 160ms ease;
}

button::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: radial-gradient(110px 78px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / 0.24), transparent 68%);
  opacity: 0;
  transform: none;
  transition: opacity 150ms ease;
}

button:hover {
  transform: none;
  border-color: color-mix(in srgb, var(--accent) 76%, white 24%);
  box-shadow: var(--pg-specular), 0 10px 26px color-mix(in srgb, var(--accent) 27%, transparent);
}

button:hover::after { opacity: 1; transform: none; }
button:active { transform: none; transition-duration: 60ms; }
button:disabled { filter: saturate(0.62); transform: none; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 76%, white 24%);
  outline-offset: 2px;
}

button.secondary,
.secondary,
.settings-tab,
.message-tab,
.contact-directory-tab {
  color: var(--text);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.09), transparent 58%), var(--pg-low);
  border-color: var(--pg-stroke);
  box-shadow: var(--pg-specular), 0 5px 16px rgb(2 8 23 / 0.07);
}

button.secondary:hover,
.settings-tab:hover,
.message-tab:hover,
.contact-directory-tab:hover {
  border-color: var(--pg-stroke-bright);
  background: var(--pg-mid);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}

button.danger,
button.danger-button,
.danger-button {
  border-color: color-mix(in srgb, var(--danger) 70%, white 18%);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.14), transparent 52%), color-mix(in srgb, var(--danger) 88%, #31080d 12%);
  box-shadow: var(--pg-specular), 0 9px 24px color-mix(in srgb, var(--danger) 24%, transparent);
}

input,
textarea,
select {
  min-height: 42px;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius-sm);
  color: var(--text);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.09), transparent 54%), color-mix(in srgb, var(--pg-high) 66%, transparent);
  box-shadow: var(--pg-specular), inset 0 2px 5px rgb(2 8 23 / 0.09), 0 5px 16px rgb(2 8 23 / 0.055);
  backdrop-filter: none;
  transition: border-color 160ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

input:hover, textarea:hover, select:hover { border-color: var(--pg-stroke-bright); }
input:focus, textarea:focus, select:focus {
  border-color: var(--pg-stroke-accent);
  box-shadow: var(--pg-specular), 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 78%, transparent); }
input[type="file"] { padding: 5px; }
input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 8px;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius-sm);
  padding: 5px 9px;
  color: var(--text);
  background: var(--pg-mid);
  font: inherit;
  font-weight: 720;
  cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); }
input[type="range"] { min-height: auto; accent-color: var(--accent); box-shadow: none; }

label {
  color: color-mix(in srgb, var(--muted) 88%, var(--text));
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0;
}

.app-shell { grid-template-columns: 82px minmax(252px, 318px) minmax(0, 1fr); background: transparent; }

.rail {
  position: relative;
  z-index: 12;
  gap: 8px;
  padding: 12px 8px;
  border-right: 1px solid var(--pg-stroke);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.08), transparent 28%), color-mix(in srgb, var(--pg-mid) 90%, var(--bg));
  box-shadow: var(--pg-specular), 10px 0 32px rgb(2 8 23 / 0.08);
  backdrop-filter: blur(var(--pg-blur)) saturate(1.18);
}

.rail::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  content: "";
  pointer-events: none;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.3), transparent 28%, transparent 72%, rgb(255 255 255 / 0.1));
}

.rail-button {
  display: grid;
  grid-template-rows: 22px auto;
  place-items: center;
  gap: 3px;
  width: 66px;
  height: 54px;
  min-height: 54px;
  padding: 5px 3px;
  overflow: visible;
  border: 1px solid transparent;
  border-radius: var(--pg-radius);
  color: color-mix(in srgb, var(--text) 72%, var(--muted));
  background: transparent;
  box-shadow: none;
  font-size: 10px;
  font-weight: 720;
}

.rail-button::after { display: none; }
.rail-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 22px;
  font-size: 19px;
  font-weight: 500;
  line-height: 1;
  transition: color 160ms ease;
}
.rail-label { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; }
.rail-button:hover {
  color: var(--text);
  border-color: var(--pg-stroke);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
.rail-button:hover .rail-icon { transform: none; }
.rail-button.active {
  color: var(--text);
  border-color: var(--pg-stroke-accent);
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 19%, transparent), color-mix(in srgb, var(--accent-2) 8%, var(--pg-mid))), var(--pg-mid);
  box-shadow: var(--pg-specular), 0 10px 24px color-mix(in srgb, var(--accent) 16%, transparent);
}
.rail-button.active::before {
  position: absolute;
  left: -9px;
  width: 3px;
  height: 24px;
  border-radius: 0 999px 999px 0;
  content: "";
  background: color-mix(in srgb, var(--accent) 78%, white 22%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 58%, transparent);
}
.rail-button.message-button {
  height: 72px;
  min-height: 72px;
  margin-bottom: 4px;
  grid-template-rows: 30px auto;
  border-color: color-mix(in srgb, var(--accent) 32%, var(--pg-stroke));
  background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent-2) 10%, var(--pg-low)));
}
.rail-button.message-button .rail-icon { width: 30px; height: 30px; font-size: 23px; }
.rail-button.message-button.active {
  color: white;
  background: linear-gradient(150deg, rgb(255 255 255 / 0.18), transparent 48%), linear-gradient(145deg, color-mix(in srgb, var(--accent) 93%, #0a1630), color-mix(in srgb, var(--accent-2) 45%, var(--accent)));
}

.sidebar, .content { border-left: 0; }
.sidebar {
  position: relative;
  z-index: 8;
  padding: 14px;
  border-right: 1px solid var(--pg-stroke);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.07), transparent 24%), var(--pg-low);
  box-shadow: var(--pg-specular), 12px 0 38px rgb(2 8 23 / 0.07);
  backdrop-filter: blur(var(--pg-blur)) saturate(1.12);
}
.sidebar-view { gap: 13px; padding: 1px 3px 16px 1px; }
.active-sidebar-view { animation: none; }
.brand { gap: 11px; padding: 4px 2px 10px; border-bottom: 1px solid var(--pg-stroke); }
.brand img {
  width: 44px;
  height: 44px;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-specular), 0 10px 24px color-mix(in srgb, var(--accent) 18%, transparent);
}
.brand h1 { font-size: 17px; font-weight: 820; }
.brand p { margin-top: 2px; font-size: 11px; }
.sidebar-view-heading {
  align-items: flex-start;
  padding: 3px 2px 10px;
  border-bottom: 1px solid var(--pg-stroke);
  text-align: left;
}
.sidebar-view-heading h2 { font-size: 18px; font-weight: 820; }
.sidebar-view-heading p { font-size: 11px; }

.identity-card,
.stack,
.design-control-group,
.support-form,
.account-settings-card,
.info-item,
.notice,
.member-picker,
.notifications-toggle {
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: linear-gradient(145deg, rgb(255 255 255 / 0.055), transparent 46%), var(--pg-low);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}

.identity-card, .stack, .design-control-group, .support-form { padding: 12px; }
.menu-presence-toggle, .notifications-toggle { padding: 10px 11px; }
.presence-toggle {
  border-color: var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
.presence-toggle input, .notifications-toggle input { min-height: 0; box-shadow: none; }

.theme-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.theme-preset {
  min-height: 58px;
  border-color: var(--pg-stroke);
  border-radius: var(--pg-radius);
  color: var(--text);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
.theme-preset.selected {
  border-color: var(--pg-stroke-accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--pg-mid));
}
.theme-swatches i, .message-color-presets button {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25), 0 3px 9px rgb(2 8 23 / 0.14);
}
.message-style-preview {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}

.appearance-controls { gap: 12px; }
.appearance-live-preview {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  min-height: 118px;
  overflow: hidden;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: 24px;
  padding: 14px;
  background:
    linear-gradient(140deg, rgb(255 255 255 / 0.18), transparent 34%),
    linear-gradient(320deg, color-mix(in srgb, var(--accent-2) 13%, transparent), transparent 46%),
    color-mix(in srgb, var(--pg-high) 78%, transparent);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
  backdrop-filter: blur(var(--pg-blur)) saturate(1.18);
}
.appearance-preview-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent-2) 56%, transparent);
}
.appearance-preview-panel { display: grid; gap: 5px; align-content: start; min-width: 0; }
.appearance-preview-panel i { display: block; width: 72%; height: 5px; border-radius: 999px; background: color-mix(in srgb, var(--text) 17%, transparent); }
.appearance-preview-panel i:nth-child(2) { width: 48%; }
.appearance-preview-panel strong { margin-top: 1px; color: var(--text); font-size: 11px; }
.appearance-preview-bubble {
  grid-column: 1 / -1;
  justify-self: end;
  max-width: 78%;
  border: 1px solid color-mix(in srgb, var(--accent) 46%, var(--pg-stroke));
  border-radius: 18px 18px 7px 18px;
  padding: 8px 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 25%, var(--pg-mid));
  box-shadow: var(--pg-specular), 0 8px 20px color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: 11px;
  font-weight: 760;
}
.range-setting > span,
.settings-feature-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.range-setting output,
.setting-state { color: color-mix(in srgb, var(--accent-2) 74%, var(--text)); font-size: 11px; font-weight: 820; }
.appearance-select-grid,
.settings-inline-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.appearance-select-grid select,
.settings-inline-grid select { min-height: 39px; padding-inline: 9px; font-size: 11px; }

.settings-feature-card,
.conversation-preferences {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  padding: 12px;
  background: linear-gradient(145deg, rgb(255 255 255 / 0.07), transparent 46%), var(--pg-low);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}
.settings-feature-card h3,
.conversation-preferences h3 { margin: 0; color: var(--text); font-size: 13px; font-weight: 840; }
.conversation-preferences .notifications-toggle { padding: 8px 10px; }
.conversation-preferences .setting-state:empty { display: none; }

.message-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.saved-message-card .message-contact-summary { grid-template-columns: 42px minmax(0, 1fr) auto; }
.saved-message-card .saved-message-open { width: 100%; }
.saved-message-preview { display: block; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.saved-marker {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 54%, var(--pg-stroke));
  border-radius: 999px;
  color: var(--accent-2);
  background: var(--pg-low);
  font-size: 10px;
  font-weight: 900;
}

.contact-directory-tabs,
.message-tabs,
.settings-tabs,
.auth-tabs {
  position: relative;
  padding: 3px;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: color-mix(in srgb, var(--pg-low) 86%, transparent);
  box-shadow: var(--pg-specular), inset 0 1px 3px rgb(2 8 23 / 0.06);
}
.contact-directory-tab,
.message-tab,
.settings-tab,
.auth-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: var(--pg-radius-sm);
  background: transparent;
  box-shadow: none;
}
.contact-directory-tab.active,
.message-tab.active,
.settings-tab.active,
.auth-tabs button.active {
  color: var(--text);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.11), transparent 58%), var(--pg-high);
  box-shadow: var(--pg-specular), 0 4px 12px rgb(2 8 23 / 0.1);
}

.contacts, .quick-add-list { gap: 7px; }
.contact, .quick-add-row, .known-account, .group-member-row {
  border: 1px solid transparent;
  border-radius: var(--pg-radius);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 180ms ease;
}
.contact:hover, .contact.selected, .quick-add-row:hover, .known-account:hover, .group-member-row:hover {
  border-color: var(--pg-stroke);
  background: var(--pg-low);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}
.avatar, .active-chat-avatar, .contact-dialog-avatar, .auth-search-avatar, .call-avatar, .call-bar-avatar, .group-call-avatar {
  border: 1px solid var(--pg-stroke-bright);
  box-shadow: var(--pg-specular), 0 7px 18px rgb(2 8 23 / 0.16);
}
.avatar, .active-chat-avatar, .call-bar-avatar, .group-call-avatar { border-radius: 50%; }

.content {
  position: relative;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.025), transparent 24%), color-mix(in srgb, var(--pg-canvas) 72%, transparent);
}
.content::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 4%, transparent), transparent 42%, color-mix(in srgb, var(--accent-2) 4%, transparent));
}
.view, .chat-screen { position: relative; z-index: 1; }
.active-view, .active-chat-screen, .active-settings-panel { animation: none; }

.panel-heading,
.topbar {
  border-bottom: 1px solid var(--pg-stroke);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.07), transparent 64%), color-mix(in srgb, var(--pg-mid) 90%, transparent);
  box-shadow: var(--pg-specular), 0 10px 30px rgb(2 8 23 / 0.06);
  backdrop-filter: blur(var(--pg-blur)) saturate(1.12);
}
.panel-heading h2, .topbar h2 { color: var(--text); font-size: 19px; font-weight: 820; }
.message-picker-heading { align-items: center; }
.message-picker-tools, .toolbar-row { gap: 6px; }
.message-picker-tools button, .toolbar-row button, .back-button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 11px;
}

.message-tabs { margin: 12px 14px 0; padding: 3px; }
.message-picker-actions { padding: 9px 14px 2px; }
.message-contact-list { gap: 8px; padding: 12px 14px 18px; }
.message-contact {
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: linear-gradient(150deg, rgb(255 255 255 / 0.045), transparent 48%), color-mix(in srgb, var(--pg-low) 88%, transparent);
  box-shadow: var(--pg-specular), 0 6px 20px rgb(2 8 23 / 0.06);
  backdrop-filter: none;
  transition: border-color 170ms ease, background-color 170ms ease, box-shadow 200ms ease;
}
.message-contact:hover, .message-contact.selected {
  border-color: var(--pg-stroke-accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--pg-mid));
  box-shadow: var(--pg-specular), 0 12px 28px color-mix(in srgb, var(--accent) 10%, transparent);
}
.message-contact.has-unread { border-color: color-mix(in srgb, var(--unread) 48%, var(--pg-stroke)); }
.message-contact-action { min-height: 34px; border-radius: var(--pg-radius-sm); }
.contact-options-button, .quick-add-more, .quick-add-plus, .icon-command, .call-options-button, .call-close-button {
  display: grid;
  place-items: center;
  border-radius: var(--pg-radius);
}
.tab-badge, .unread-count, .message-button-unread {
  border: 1px solid rgb(255 255 255 / 0.42);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--unread) 34%, transparent);
}

.conversation-screen { background: color-mix(in srgb, var(--pg-canvas) 76%, transparent); }
.conversation-screen .topbar { padding: 9px 11px; }
.chat-identity { min-width: 0; }
.chat-heading h2 {
  overflow: hidden;
  font-size: 16px;
  font-weight: 820;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-heading p {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-badge, .group-role-label, .call-eyebrow {
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--pg-stroke));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, var(--pg-low));
  box-shadow: var(--pg-specular);
}
.message-search {
  margin: 9px 11px 0;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: var(--pg-mid);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
  backdrop-filter: blur(18px);
}

.messages { gap: 8px; padding: 16px 14px 18px; scrollbar-gutter: stable; }
.messages.empty-state { place-items: center; color: var(--muted); }
.message {
  max-width: min(66ch, 84%);
  padding: 9px 11px;
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-specular), 0 7px 20px rgb(2 8 23 / 0.09);
  backdrop-filter: none;
}
.message.incoming {
  background: linear-gradient(145deg, rgb(255 255 255 / 0.06), transparent 48%), color-mix(in srgb, var(--bubble-in) 86%, var(--pg-low));
}
.message.outgoing {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--pg-stroke));
  background: linear-gradient(145deg, rgb(255 255 255 / 0.12), transparent 48%), color-mix(in srgb, var(--bubble-out) 92%, var(--accent) 8%);
  box-shadow: var(--pg-specular), 0 8px 22px color-mix(in srgb, var(--accent) 13%, transparent);
}
.message-system {
  justify-self: center;
  border: 1px solid var(--pg-stroke);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
  font-size: 10px;
}
.message-meta { margin-top: 5px; color: color-mix(in srgb, var(--muted) 88%, transparent); font-size: 9px; }
.message-reactions { gap: 4px; margin-top: 6px; }
.message-reaction {
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--text);
  background: var(--pg-mid);
  box-shadow: var(--pg-specular);
}
.message-reaction.mine {
  border-color: var(--pg-stroke-accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--pg-mid));
}
.message-actions-menu, .emoji-picker {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
  backdrop-filter: blur(var(--pg-blur-float)) saturate(1.18);
  animation: pg-floating-controls-in 110ms ease-out both;
}
.message-actions-menu button { min-height: 32px; border-radius: var(--pg-radius-sm); }
.typing-indicator {
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
.new-messages-jump {
  right: 16px;
  bottom: 72px;
  border: 1px solid var(--pg-stroke-accent);
  border-radius: 999px;
  background: var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
  backdrop-filter: blur(18px);
}

.composer {
  gap: 6px;
  padding: 9px 10px 10px;
  border-top: 1px solid var(--pg-stroke);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.06), transparent 62%), color-mix(in srgb, var(--pg-mid) 94%, transparent);
  box-shadow: var(--pg-specular), 0 -10px 30px rgb(2 8 23 / 0.07);
  backdrop-filter: blur(var(--pg-blur)) saturate(1.12);
}
.composer #messageInput {
  min-height: 38px;
  border-radius: var(--pg-radius);
  background: color-mix(in srgb, var(--pg-high) 78%, transparent);
}
#attachButton, .composer-icon-button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border: 1px solid var(--pg-stroke);
  border-radius: 50%;
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
#sendMessageButton { min-height: 38px; padding-inline: 13px; }
.reply-preview, .attachment-preview, .voice-recording-bar, .upload-progress {
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
.chat-background-layer { filter: saturate(0.94) contrast(1.02); }
.chat-background-layer::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--pg-canvas) 10%, transparent), color-mix(in srgb, var(--pg-canvas) 24%, transparent));
}

.settings-shell {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 13px;
  padding: 14px;
  overflow: hidden;
}
.settings-tabs {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  flex-wrap: nowrap;
  gap: 2px;
  background: var(--pg-mid);
  backdrop-filter: blur(18px);
}
.settings-tab { min-width: 0; padding-inline: 6px; font-size: 10px; white-space: nowrap; }
.settings-panel {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.settings-panel-heading { min-height: 38px; padding-bottom: 9px; border-bottom: 1px solid var(--pg-stroke); }
.settings-grid { max-width: 620px; }
.account-settings-card { padding: 13px; }
.account-profile-row img, .profile-preview {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}
.info-grid { gap: 8px; }
.info-item { padding: 11px; }
.log {
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: color-mix(in srgb, var(--pg-canvas) 88%, black 12%);
  box-shadow: inset 0 1px 4px rgb(0 0 0 / 0.18);
}

.auth-overlay, .banned-overlay {
  padding: 14px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 38%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 42%),
    color-mix(in srgb, var(--pg-canvas) 84%, transparent);
  backdrop-filter: blur(var(--pg-blur-float)) saturate(1.12);
}
.auth-card {
  gap: 13px;
  padding: 18px;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: linear-gradient(145deg, rgb(255 255 255 / 0.095), transparent 42%), var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-high);
  animation: pg-auth-enter 380ms var(--pg-ease) both;
}
.auth-brand img {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-specular), 0 14px 32px color-mix(in srgb, var(--accent) 20%, transparent);
}
.auth-brand h1 { font-size: 28px; font-weight: 850; }
.auth-form, .legacy-claim-card { gap: 10px; }
.auth-search-results, .owner-reset-preview, .legacy-claim-card, .recovery-phrase-box {
  border: 1px solid var(--pg-stroke);
  border-radius: var(--pg-radius);
  background: var(--pg-low);
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
}
.auth-search-row { border-radius: var(--pg-radius); background: transparent; box-shadow: none; }
.auth-search-row:hover { background: var(--pg-mid); }

dialog {
  overflow-x: hidden;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: linear-gradient(145deg, rgb(255 255 255 / 0.08), transparent 38%), var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-high);
  backdrop-filter: blur(var(--pg-blur-float)) saturate(1.16);
}
dialog::backdrop {
  background: color-mix(in srgb, var(--pg-canvas) 64%, transparent);
  backdrop-filter: blur(10px) saturate(0.82);
}
dialog[open] .dialog-card { animation: pg-dialog-enter 250ms var(--pg-ease) both; }
.dialog-card { gap: 11px; padding: 16px; }
.contact-dialog-card { min-width: 0; width: 100%; }
.dialog-card h2, .dialog-card h3 { font-weight: 840; }
.contact-profile-hero { border-bottom: 1px solid var(--pg-stroke); padding-bottom: 13px; }
.contact-dialog-avatar { border-radius: 50%; }
.contact-actions, .dialog-actions, .background-image-actions, .call-media-actions, .call-actions { gap: 7px; }
.contact-code {
  border-color: var(--pg-stroke);
  background: var(--pg-low);
  box-shadow: var(--pg-specular);
}
.profile-editor-stage, .image-viewer-card img {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
}
.toast {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-high);
  backdrop-filter: blur(var(--pg-blur-float));
  animation: pg-toast-enter 260ms var(--pg-ease) both;
}

.call-bar {
  min-height: 48px;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.1), transparent 62%), var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
  backdrop-filter: blur(var(--pg-blur-float)) saturate(1.18);
  animation: pg-callbar-enter 280ms var(--pg-ease) both;
}
.call-card { border-radius: var(--pg-radius); }
.call-video-stage {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: color-mix(in srgb, var(--pg-canvas) 84%, black 16%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08), inset 0 -18px 48px rgb(0 0 0 / 0.12);
}
#remoteCallVideo, #localCallVideo, .group-call-tile { border-radius: var(--pg-radius); }
#localCallVideo {
  border: 1px solid var(--pg-stroke-bright);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
}
.call-video-adjustments {
  border: 1px solid var(--pg-stroke-bright);
  border-radius: var(--pg-radius);
  background: color-mix(in srgb, var(--pg-high) 72%, transparent);
  box-shadow: var(--pg-specular), var(--pg-shadow-mid);
  backdrop-filter: blur(18px);
}
.group-call-limit-card { border-radius: var(--pg-radius); }
.startup-failure {
  border-color: color-mix(in srgb, var(--danger) 62%, var(--pg-stroke));
  border-radius: var(--pg-radius);
  background: var(--pg-high);
  box-shadow: var(--pg-specular), var(--pg-shadow-high);
}

/* Rounder liquid-glass finish. Expensive blur stays on structural and floating layers. */
.rail,
.sidebar,
.panel-heading,
.topbar,
.composer,
.settings-tabs,
.auth-card,
dialog,
.call-bar,
.toast,
.message-actions-menu,
.emoji-picker {
  -webkit-backdrop-filter: blur(var(--pg-blur)) saturate(1.42);
  backdrop-filter: blur(var(--pg-blur)) saturate(1.42);
}

.rail {
  background:
    linear-gradient(120deg, rgb(255 255 255 / 0.13), transparent 24%),
    linear-gradient(180deg, color-mix(in srgb, var(--pg-mid) 82%, transparent), color-mix(in srgb, var(--pg-low) 90%, transparent));
  box-shadow: var(--pg-specular), 14px 0 42px rgb(2 8 23 / 0.11);
}
.rail-button {
  border-radius: 20px;
  transition: color 170ms ease, border-color 170ms ease, background-color 180ms ease, box-shadow 220ms ease;
}
.rail-button:hover { transform: none; }
.rail-button.active {
  background:
    linear-gradient(145deg, rgb(255 255 255 / 0.2), transparent 44%),
    linear-gradient(150deg, color-mix(in srgb, var(--accent) 23%, transparent), color-mix(in srgb, var(--accent-2) 12%, var(--pg-mid)));
  box-shadow: var(--pg-specular), inset 0 0 18px rgb(255 255 255 / 0.035), 0 14px 32px color-mix(in srgb, var(--accent) 19%, transparent);
}
.rail-button.message-button { border-radius: 24px; }
.rail-button.message-button.has-unread::after {
  position: absolute;
  z-index: 4;
  top: 3px;
  right: 2px;
  display: grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  border: 2px solid color-mix(in srgb, var(--rail) 72%, black);
  border-radius: 999px;
  content: attr(data-unread-count);
  color: white;
  background: linear-gradient(180deg, #ff7168, var(--unread));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.52), 0 0 0 4px color-mix(in srgb, var(--unread) 18%, transparent), 0 8px 20px color-mix(in srgb, var(--unread) 42%, transparent);
  opacity: 1;
  transform: none;
  animation: pg-unread-pop 280ms var(--pg-ease) both;
  transition: none;
}

.sidebar {
  background:
    linear-gradient(130deg, rgb(255 255 255 / 0.12), transparent 25%),
    linear-gradient(180deg, color-mix(in srgb, var(--pg-mid) 78%, transparent), color-mix(in srgb, var(--pg-low) 90%, transparent));
  box-shadow: var(--pg-specular), inset -1px 0 0 rgb(255 255 255 / 0.06), 16px 0 48px rgb(2 8 23 / 0.09);
}
.brand img,
.profile-preview,
.account-profile-row img { border-radius: 18px; }

.identity-card,
.stack,
.design-control-group,
.support-form,
.account-settings-card,
.info-item,
.notice,
.member-picker,
.notifications-toggle {
  border-color: var(--pg-stroke-bright);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 0.13), transparent 38%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent-2) 5%, transparent), transparent 52%),
    color-mix(in srgb, var(--pg-low) 90%, transparent);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.04), var(--pg-shadow-low);
}
.conversation-screen > .topbar,
.conversation-screen > .composer {
  width: auto;
  min-width: 0;
}

.presence-toggle,
.contact-directory-tabs,
.message-tabs,
.settings-tabs,
.auth-tabs {
  border-color: var(--pg-stroke-bright);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.11), transparent 58%),
    color-mix(in srgb, var(--pg-mid) 80%, transparent);
  box-shadow: var(--pg-specular), inset 0 2px 6px rgb(2 8 23 / 0.1), 0 8px 24px rgb(2 8 23 / 0.07);
}
.contact-directory-tab,
.message-tab,
.settings-tab,
.auth-tabs button { border-radius: 999px; }
.contact-directory-tab.active,
.message-tab.active,
.settings-tab.active,
.auth-tabs button.active {
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.23), transparent 54%),
    color-mix(in srgb, var(--pg-high) 88%, transparent);
  box-shadow: var(--pg-specular), 0 8px 20px rgb(2 8 23 / 0.12);
}

.theme-preset,
.message-style-preview,
.message-search,
.reply-preview,
.attachment-preview,
.voice-recording-bar,
.upload-progress { border-radius: 18px; }

.panel-heading,
.topbar {
  margin: 8px 8px 0;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.16), transparent 34%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent) 5%, transparent), transparent 50%),
    color-mix(in srgb, var(--pg-mid) 82%, transparent);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.04), var(--pg-shadow-low);
}

.message-contact {
  padding: 12px;
  border-color: var(--pg-stroke-bright);
  border-radius: 24px;
  background:
    linear-gradient(140deg, rgb(255 255 255 / 0.14), transparent 38%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent-2) 5%, transparent), transparent 52%),
    color-mix(in srgb, var(--pg-low) 92%, transparent);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.035), 0 12px 30px rgb(2 8 23 / 0.1);
}
.message-contact:hover,
.message-contact.selected {
  background:
    linear-gradient(145deg, rgb(255 255 255 / 0.17), transparent 40%),
    color-mix(in srgb, var(--accent) 11%, var(--pg-mid));
  box-shadow: var(--pg-specular), 0 18px 38px color-mix(in srgb, var(--accent) 13%, transparent);
}
.message-contact-action { border-radius: 999px; }
.contact-call-button {
  border-color: color-mix(in srgb, var(--accent-2) 70%, white 18%);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.23), transparent 48%),
    linear-gradient(145deg, color-mix(in srgb, var(--accent-2) 88%, #06231f), color-mix(in srgb, var(--accent) 28%, var(--accent-2)));
  box-shadow: var(--pg-specular), 0 10px 24px color-mix(in srgb, var(--accent-2) 25%, transparent);
}
.contact-options-button,
.quick-add-more,
.quick-add-plus,
.icon-command,
.call-options-button,
.call-close-button { border-radius: 50%; }

.conversation-screen {
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--accent) 5%, transparent), transparent 40%),
    color-mix(in srgb, var(--pg-canvas) 68%, transparent);
}
.messages { gap: 11px; padding: 18px 14px 20px; }
.message {
  padding: 11px 13px;
  border-color: var(--pg-stroke-bright);
  border-radius: 22px;
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.035), 0 12px 28px rgb(2 8 23 / 0.12);
}
.message.incoming {
  border-bottom-left-radius: 8px;
  background:
    linear-gradient(140deg, rgb(255 255 255 / 0.14), transparent 40%),
    color-mix(in srgb, var(--bubble-in) 78%, var(--pg-low));
}
.message.outgoing {
  border-bottom-right-radius: 8px;
  background:
    linear-gradient(140deg, rgb(255 255 255 / 0.2), transparent 40%),
    color-mix(in srgb, var(--bubble-out) 88%, var(--accent) 12%);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.05), 0 14px 32px color-mix(in srgb, var(--accent) 17%, transparent);
}
.message-system,
.message-reaction,
.new-messages-jump { border-radius: 999px; }
.typing-indicator { border-radius: 20px 20px 20px 8px; }
.message-actions-menu,
.emoji-picker { border-radius: 22px; }

.composer {
  margin: 0 8px 8px;
  border: 1px solid var(--pg-stroke-bright);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.16), transparent 34%),
    color-mix(in srgb, var(--pg-mid) 84%, transparent);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.04), 0 -8px 34px rgb(2 8 23 / 0.12), var(--pg-shadow-low);
}
.composer #messageInput {
  border-radius: 999px;
  background: color-mix(in srgb, var(--pg-high) 58%, transparent);
}
#sendMessageButton { border-radius: 999px; }

.settings-shell { padding-top: 10px; }
.settings-tabs { border-radius: 999px; }

.auth-card {
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.18), transparent 32%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 48%),
    color-mix(in srgb, var(--pg-high) 83%, transparent);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.06), var(--pg-shadow-high);
}

dialog {
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.18), transparent 32%),
    linear-gradient(315deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 50%),
    color-mix(in srgb, var(--pg-high) 84%, transparent);
  box-shadow: var(--pg-specular), inset 1px 0 0 rgb(255 255 255 / 0.05), var(--pg-shadow-high);
}
dialog::backdrop {
  background: color-mix(in srgb, var(--pg-canvas) 54%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(0.9);
  backdrop-filter: blur(18px) saturate(0.9);
}
.profile-editor-stage,
.image-viewer-card img,
.call-video-stage,
#remoteCallVideo,
#localCallVideo,
.group-call-tile { border-radius: 24px; }

.call-bar { border-radius: 999px; }
.call-card,
.group-call-limit-card { border-radius: 28px; }
.call-video-adjustments { border-radius: 22px; }
.toast { border-radius: 999px; }

/* Optical foundation: clear centres, bright lens rims, and a shared moving light. */
.rail {
  background:
    radial-gradient(250px 190px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight-soft)), transparent 64%),
    linear-gradient(180deg, color-mix(in srgb, var(--pg-mid) 74%, transparent), color-mix(in srgb, var(--pg-low) 82%, transparent));
  box-shadow: var(--pg-specular), calc(var(--pg-lens-lift) * 0.42) 0 var(--pg-lens-lift) rgb(2 8 23 / var(--pg-lens-shadow-soft));
}

.sidebar {
  background:
    radial-gradient(280px 220px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight-soft)), transparent 66%),
    linear-gradient(180deg, color-mix(in srgb, var(--pg-mid) 70%, transparent), color-mix(in srgb, var(--pg-low) 82%, transparent));
  box-shadow: var(--pg-specular), calc(var(--pg-lens-lift) * 0.5) 0 calc(var(--pg-lens-lift) * 1.25) rgb(2 8 23 / var(--pg-lens-shadow-soft));
}

.panel-heading,
.topbar,
.composer,
.settings-tabs,
.call-bar {
  border-color: color-mix(in srgb, var(--pg-stroke-bright) 74%, transparent);
  background:
    radial-gradient(240px 180px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight-soft)), transparent 66%),
    linear-gradient(150deg, color-mix(in srgb, var(--pg-high) 62%, transparent), color-mix(in srgb, var(--pg-low) 76%, transparent));
  box-shadow: var(--pg-specular), 0 calc(var(--pg-lens-lift) * 0.34) var(--pg-lens-lift) rgb(2 8 23 / var(--pg-lens-shadow-soft));
}

.auth-card,
dialog,
.toast,
.message-actions-menu,
.emoji-picker {
  border-color: color-mix(in srgb, var(--pg-stroke-bright) 82%, transparent);
  background:
    radial-gradient(290px 220px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight-soft)), transparent 66%),
    linear-gradient(145deg, color-mix(in srgb, var(--pg-high) 70%, transparent), color-mix(in srgb, var(--pg-mid) 70%, transparent));
  box-shadow: var(--pg-specular), 0 calc(var(--pg-lens-lift) * 0.58) calc(var(--pg-lens-lift) * 1.75) rgb(2 8 23 / var(--pg-lens-shadow));
}

.identity-card,
.stack,
.design-control-group,
.account-settings-card,
.settings-feature-card,
.message-contact,
.contact-dialog-card,
.appearance-live-preview {
  border-color: color-mix(in srgb, var(--pg-stroke-bright) 66%, transparent);
  background:
    radial-gradient(230px 170px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight-soft)), transparent 68%),
    linear-gradient(150deg, color-mix(in srgb, var(--pg-mid) 60%, transparent), color-mix(in srgb, var(--pg-low) 72%, transparent));
  box-shadow: var(--pg-specular), 0 calc(var(--pg-lens-lift) * 0.32) var(--pg-lens-lift) rgb(2 8 23 / var(--pg-lens-shadow-soft));
}

.appearance-live-preview::before {
  position: absolute;
  z-index: 0;
  inset: 11px;
  border: var(--pg-lens-edge) solid rgb(255 255 255 / var(--pg-lens-highlight-soft));
  border-radius: 28px 34px 25px 31px;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(220px 160px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight)), transparent 62%),
    color-mix(in srgb, var(--pg-low) 42%, transparent);
  box-shadow:
    var(--pg-specular),
    inset 10px 10px 26px rgb(255 255 255 / var(--pg-lens-highlight-soft)),
    inset -12px -14px 30px rgb(2 8 23 / var(--pg-lens-shadow-soft)),
    0 calc(var(--pg-lens-lift) * 0.38) var(--pg-lens-lift) rgb(2 8 23 / var(--pg-lens-shadow-soft));
  transform: scale(var(--pg-lens-scale));
  transition: border-radius 320ms var(--pg-ease), box-shadow 180ms ease, transform 180ms ease;
}

.appearance-live-preview > .glass-refraction-canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.appearance-live-preview.refraction-ready {
  background: color-mix(in srgb, var(--pg-canvas) 88%, black);
}

.appearance-live-preview.refraction-ready::before {
  opacity: 0;
}

.appearance-live-preview.refraction-ready .glass-refraction-canvas {
  opacity: 1;
}

.appearance-live-preview > * {
  position: relative;
  z-index: 1;
}

:root[data-motion="full"] .appearance-live-preview:hover::before {
  border-radius: 34px 25px 33px 24px;
  transform: scale(calc(var(--pg-lens-scale) + 0.003));
}

@keyframes pg-panel-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pg-pop {
  from { opacity: 0; transform: scale(0.95) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pg-floating-controls-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pg-dialog-enter {
  from { opacity: 0; transform: scale(0.965) translateY(14px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pg-auth-enter {
  from { opacity: 0; transform: scale(0.97) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pg-toast-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pg-callbar-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pg-unread-pop {
  from { opacity: 0; transform: scale(0.58); }
  to { opacity: 1; transform: scale(1); }
}

:root[data-message-density="compact"] .messages { gap: 6px; padding-block: 12px 14px; }
:root[data-message-density="compact"] .message { padding: 7px 9px; }
:root[data-message-density="compact"] .group-message-row { gap: 6px; }
:root[data-message-density="roomy"] .messages { gap: 16px; padding-block: 22px 25px; }
:root[data-message-density="roomy"] .message { padding: 13px 15px; }
:root[data-message-density="roomy"] .group-message-row { gap: 10px; }

:root[data-bubble-shape="round"] .message,
.appearance-live-preview[data-shape="round"] .appearance-preview-bubble { border-radius: 28px; }
:root[data-bubble-shape="crisp"] .message,
.appearance-live-preview[data-shape="crisp"] .appearance-preview-bubble { border-radius: 13px; }
:root[data-bubble-shape="round"] .message.incoming,
:root[data-bubble-shape="round"] .message.outgoing { border-bottom-left-radius: 28px; border-bottom-right-radius: 28px; }
:root[data-bubble-shape="crisp"] .message.incoming { border-bottom-left-radius: 5px; }
:root[data-bubble-shape="crisp"] .message.outgoing { border-bottom-right-radius: 5px; }

:root[data-motion="subtle"] .view.active-view,
:root[data-motion="subtle"] .sidebar-view.active-sidebar-view,
:root[data-motion="subtle"] dialog[open] .dialog-card { animation-duration: 120ms; }
:root[data-motion="subtle"] button::after { display: none; }
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  scroll-behavior: auto !important;
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
}

@media (max-width: 760px) {
  .app-shell,
  .app-shell.sidebar-mode,
  .app-shell.messages-mode,
  .app-shell.settings-mode {
    grid-template-columns: 76px minmax(0, 1fr);
  }
  .rail { padding-inline: 6px; }
  .rail-button { width: 62px; }
  .sidebar { padding: 12px; }
  .app-shell.messages-mode .content,
  .app-shell.settings-mode .content { grid-column: 2; }
  .conversation-screen .topbar { grid-template-columns: auto minmax(0, 1fr); gap: 7px; }
  .conversation-screen .toolbar { grid-column: 1 / -1; }
  .conversation-screen .toolbar-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .message-contact-summary { grid-template-columns: 42px minmax(0, 1fr) 34px; }
  .message-contact-summary .unread-count { display: none; }
  .contact-options-button {
    grid-column: 3;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    font-size: 19px;
  }
  .settings-tabs { overflow-x: auto; scrollbar-width: none; }
}

@media (max-width: 430px) {
  .app-shell,
  .app-shell.sidebar-mode,
  .app-shell.messages-mode,
  .app-shell.settings-mode {
    grid-template-columns: 68px minmax(0, 1fr);
  }
  .rail { padding: 9px 4px; }
  .rail-button { width: 58px; height: 50px; min-height: 50px; font-size: 9px; }
  .rail-button.message-button { height: 66px; min-height: 66px; }
  .rail-button.active::before { left: -5px; }
  .message-picker-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 9px;
    padding: 11px;
  }
  .message-picker-tools { grid-template-columns: minmax(0, 1fr) 36px minmax(54px, auto); }
  .message-tab { padding-inline: 4px; font-size: 10px; }
  .message-tabs { margin-inline: 9px; }
  .appearance-select-grid, .settings-inline-grid { grid-template-columns: minmax(0, 1fr); }
  .message-picker-actions, .message-contact-list { padding-inline: 9px; }
  .conversation-screen .topbar { padding: 8px; }
  .conversation-screen .toolbar-row button { padding-inline: 6px; font-size: 10px; }
  .chat-heading h2 { font-size: 14px; }
  .active-chat-avatar { width: 34px; height: 34px; flex-basis: 34px; }
  .messages { padding: 12px 9px 15px; }
  .message { max-width: 88%; }
  .composer { grid-template-columns: 36px 36px minmax(0, 1fr) auto; padding-inline: 8px; }
  #sendMessageButton { padding-inline: 10px; }
  .settings-shell { padding: 10px; }
  .settings-tab { min-width: 70px; }
  .auth-overlay { padding: 8px; }
  .auth-card, .dialog-card { padding: 13px; }
  .auth-brand h1 { font-size: 24px; }
  dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .contact-dialog-card { gap: 9px; padding: 11px 13px 14px; }
  .contact-profile-hero { gap: 4px; padding-block: 4px 9px; }
  .contact-dialog-avatar { width: 96px; height: 96px; font-size: 32px; }
}

@media (max-width: 340px) {
  .app-shell,
  .app-shell.sidebar-mode,
  .app-shell.messages-mode,
  .app-shell.settings-mode {
    grid-template-columns: 62px minmax(0, 1fr);
  }
  .rail-button { width: 52px; font-size: 8px; }
  .rail-label { max-width: 48px; }
  .rail-icon { font-size: 17px; }
  .composer { grid-template-columns: 34px 34px minmax(0, 1fr) auto; gap: 4px; padding: 7px 6px; }
  #attachButton, .composer-icon-button { width: 34px; height: 34px; min-width: 34px; }
  #sendMessageButton { min-height: 34px; padding-inline: 8px; font-size: 11px; }
}

@media (max-height: 620px) {
  .rail { gap: 5px; }
  .rail-button { height: 45px; min-height: 45px; }
  .rail-button.message-button { height: 56px; min-height: 56px; }
  .rail-icon { height: 18px; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* Crisp spring motion: all effects stay on compositor-friendly properties. */
:root {
  --motion-press: 90ms cubic-bezier(.2, .8, .2, 1);
  --motion-crisp: 180ms cubic-bezier(.2, .9, .2, 1);
  --motion-spring: 340ms cubic-bezier(.16, 1.18, .3, 1);
  --motion-panel: 190ms cubic-bezier(.2, .8, .2, 1);
}

.rail-website-button .rail-icon {
  font-size: 17px;
}

.website-dialog-card {
  width: min(430px, 100%);
  gap: 14px;
}

.website-dialog-heading {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
}

.website-dialog-heading h3,
.website-dialog-heading p {
  margin: 0;
}

.website-dialog-heading > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.website-dialog-heading > div > p:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.website-dialog-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid color-mix(in srgb, var(--accent) 58%, var(--pg-stroke-bright));
  border-radius: 19px;
  color: white;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent-2));
  box-shadow: var(--pg-specular), 0 15px 32px color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 26px;
}

.website-url {
  overflow: hidden;
  padding: 11px 13px;
  border: 1px solid var(--pg-stroke);
  border-radius: 15px;
  color: var(--muted);
  background: var(--pg-low);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .08);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.website-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 7px;
}

.website-actions button {
  min-width: 0;
}

.motion-view-enter {
  animation: motion-view-enter var(--motion-panel) both;
  transform-origin: 50% 22%;
}

.motion-stack-item {
  animation-delay: var(--stack-delay, 0ms);
  animation-duration: 540ms;
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(.2, .78, .24, 1);
  will-change: transform;
}

.motion-stack-from-top {
  animation-name: motion-stack-from-top;
  transform-origin: 50% 0;
}

.motion-stack-from-bottom {
  animation-name: motion-stack-from-bottom;
  transform-origin: 50% 100%;
}

.motion-panel-unfold {
  animation: motion-panel-unfold var(--motion-panel) both;
  transform-origin: 50% 0;
}

.motion-chat-enter {
  animation: motion-chat-enter 380ms cubic-bezier(.16, 1, .3, 1) both;
}

.motion-composer-rise {
  animation: motion-composer-rise 440ms cubic-bezier(.16, 1.12, .3, 1) both;
}

.motion-nav-bounce {
  animation: motion-nav-bounce 360ms cubic-bezier(.18, 1.35, .3, 1) both;
}

.motion-status-change {
  animation: motion-status-change 260ms var(--pg-ease) both;
}

.motion-badge-pop {
  animation: motion-badge-pop 380ms cubic-bezier(.18, 1.45, .3, 1) both;
}

.motion-toast-pop {
  animation: motion-toast-pop 420ms cubic-bezier(.18, 1.3, .3, 1) both;
}

.motion-success-pop {
  animation: motion-success-pop 420ms cubic-bezier(.18, 1.45, .3, 1) both;
}

.motion-error-shake {
  animation: motion-error-shake 340ms ease-out both;
}

.motion-list-settle > * {
  animation: motion-list-item 360ms var(--pg-ease) both;
}

.motion-list-settle > :nth-child(2) { animation-delay: 28ms; }
.motion-list-settle > :nth-child(3) { animation-delay: 48ms; }
.motion-list-settle > :nth-child(4) { animation-delay: 66ms; }
.motion-list-settle > :nth-child(n + 5) { animation-delay: 82ms; }

dialog[open]::backdrop {
  animation: motion-backdrop-in 220ms ease-out both;
}

dialog[open] > .dialog-card,
dialog[open] > form.dialog-card {
  animation: motion-dialog-in 380ms cubic-bezier(.16, 1.15, .3, 1) both;
  transform-origin: 50% 35%;
}

.auth-overlay:not(.hidden) .auth-card,
.banned-overlay:not(.hidden) .auth-card {
  animation: motion-auth-card 520ms cubic-bezier(.16, 1.08, .3, 1) both;
}

.auth-overlay:not(.hidden) .auth-form > *,
.banned-overlay:not(.hidden) .auth-card > * {
  animation: motion-list-item 360ms var(--pg-ease) both;
}

.auth-overlay:not(.hidden) .auth-form > :nth-child(2) { animation-delay: 35ms; }
.auth-overlay:not(.hidden) .auth-form > :nth-child(3) { animation-delay: 60ms; }
.auth-overlay:not(.hidden) .auth-form > :nth-child(n + 4) { animation-delay: 80ms; }

.call-bar:not(.hidden) {
  animation: motion-call-bar 440ms cubic-bezier(.16, 1.2, .3, 1) both;
}

.incoming-call-card,
.call-dialog[open] .call-stage,
.group-call-stage {
  animation: motion-call-stage 520ms cubic-bezier(.16, 1.08, .3, 1) both;
}

.call-participant,
.call-video-tile,
.group-call-participant {
  transition: transform var(--motion-spring), opacity var(--motion-crisp), box-shadow var(--motion-crisp);
}

.typing-indicator:not(.hidden),
.typing-dots:not(.hidden) {
  animation: motion-soft-rise 240ms var(--pg-ease) both;
}

.typing-indicator i,
.typing-dots i,
.typing-dots span {
  animation: motion-typing-dot 1.05s ease-in-out infinite;
}

.typing-indicator i:nth-child(2),
.typing-dots i:nth-child(2),
.typing-dots span:nth-child(2) { animation-delay: 110ms; }

.typing-indicator i:nth-child(3),
.typing-dots i:nth-child(3),
.typing-dots span:nth-child(3) { animation-delay: 220ms; }

.unread-dot,
.unread-count,
.tab-badge,
.story-add-mark,
.saved-marker {
  transform-origin: 50% 55%;
}

.rail-button.has-unread::after,
.rail-button.has-story-update::after,
.new-messages-jump:not(.hidden) {
  animation: motion-attention 1.8s ease-in-out 2;
}

.story-chip,
.discover-story-card,
.discover-story-tile,
.content-story-card,
.reel-card,
.content-reel-card,
.message-contact,
.contact-card,
.quick-add-card,
.account-card,
.theme-preset,
.info-grid > *,
.stack,
.identity-card {
  will-change: transform;
  transition: transform var(--motion-spring), border-color var(--motion-crisp), box-shadow var(--motion-crisp), filter var(--motion-crisp), opacity var(--motion-crisp);
}

.story-viewer-dialog[open] .story-frame,
.story-viewer-dialog[open] .story-viewer-card {
  animation: motion-story-open 440ms cubic-bezier(.16, 1.08, .3, 1) both;
}

.story-progress-fill,
.story-progress-segment > span {
  transform-origin: left center;
}

.story-feedback-panel:not(.hidden),
.story-comments:not(.hidden),
.reel-comments-dialog[open] .reel-comments-card {
  animation: motion-sheet-up 360ms cubic-bezier(.16, 1.12, .3, 1) both;
}

.reel-card {
  scroll-snap-stop: normal;
}

.reel-card.is-active,
.reel-card.active {
  animation: motion-reel-settle 380ms cubic-bezier(.16, 1.06, .3, 1) both;
}

.reel-action-button:active,
.story-action-button:active,
.like-story-button:active,
.dislike-story-button:active {
  animation: motion-reaction-burst 360ms cubic-bezier(.18, 1.45, .3, 1) both;
}

.message-actions-menu,
.emoji-picker,
.mention-suggestions,
.auth-search-results {
  animation: motion-floating-menu 220ms ease-out both;
}

.emoji-picker-library:not(.hidden) {
  animation: motion-panel-unfold 300ms cubic-bezier(.16, 1.12, .3, 1) both;
}

.emoji-choice:active,
.message-reaction:active {
  animation: motion-reaction-burst 340ms cubic-bezier(.18, 1.45, .3, 1) both;
}

.upload-progress:not(.hidden),
.attachment-preview:not(.hidden),
.reply-preview:not(.hidden),
.voice-recording-bar:not(.hidden),
.message-search-bar:not(.hidden) {
  animation: motion-soft-rise 300ms cubic-bezier(.16, 1.1, .3, 1) both;
}

progress::-webkit-progress-value {
  transition: width 260ms var(--pg-ease);
}

.presence-toggle input,
.notifications-toggle input,
input[type="checkbox"],
input[type="radio"] {
  transition: transform var(--motion-spring), background-color var(--motion-crisp), border-color var(--motion-crisp), box-shadow var(--motion-crisp);
}

.presence-toggle input:checked,
.notifications-toggle input:checked,
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  animation: motion-toggle-settle 330ms cubic-bezier(.18, 1.35, .3, 1) both;
}

.profile-editor-dialog[open] canvas,
.profile-editor-dialog[open] .profile-editor-stage,
.contact-profile-hero,
.group-profile-hero {
  animation: motion-profile-focus 440ms cubic-bezier(.16, 1.08, .3, 1) both;
}

.contact-dialog-avatar,
.group-dialog-avatar,
.profile-preview,
.avatar,
.story-chip-avatar {
  transition: transform var(--motion-spring), box-shadow var(--motion-crisp), filter var(--motion-crisp);
}

.send-button,
#sendMessageButton {
  overflow: hidden;
  isolation: isolate;
}

.send-button::after,
#sendMessageButton::after {
  position: absolute;
  inset: -50%;
  z-index: -1;
  content: "";
  background: radial-gradient(circle, rgb(255 255 255 / .45), transparent 56%);
  opacity: 0;
  transform: scale(.25);
  transition: opacity var(--motion-crisp), transform 420ms var(--pg-ease);
}

.send-button:active::after,
#sendMessageButton:active::after {
  opacity: .6;
  transform: scale(1);
}

.toast:not(.hidden) {
  box-shadow: var(--pg-specular), 0 18px 44px color-mix(in srgb, var(--accent) 20%, transparent);
}

@media (hover: hover) {
  button:not(:disabled):hover,
  .rail-button:hover,
  .message-tab:hover,
  .settings-tab:hover,
  .destination-tab:hover,
  .contact-directory-tab:hover {
    filter: brightness(1.08) saturate(1.04);
  }

  .rail-button:hover .rail-icon {
    filter: brightness(1.14) drop-shadow(0 0 7px color-mix(in srgb, var(--accent) 35%, transparent));
  }

  .message-contact:hover,
  .contact-card:hover,
  .quick-add-card:hover,
  .story-chip:hover,
  .discover-story-card:hover,
  .discover-story-tile:hover,
  .content-story-card:hover,
  .content-reel-card:hover,
  .theme-preset:hover,
  .account-card:hover {
    border-color: var(--pg-stroke-bright);
    box-shadow: var(--pg-specular), var(--pg-shadow-mid);
  }

  .avatar:hover,
  .story-chip-avatar:hover,
  .contact-dialog-avatar:hover,
  .group-dialog-avatar:hover {
    transform: scale(1.055);
    filter: brightness(1.06) saturate(1.05);
  }
}

button:not(:disabled):active,
.rail-button:active,
.message-tab:active,
.settings-tab:active,
.destination-tab:active,
.contact-directory-tab:active {
  transform: translateY(1px) scale(.955);
  transition-duration: 70ms;
}

@keyframes motion-view-enter {
  0% { transform: translateY(3px) scale(.998); }
  100% { transform: none; }
}

@keyframes motion-stack-from-top {
  0% { transform: translateY(-16px) scale(.975); }
  64% { transform: translateY(1.5px) scale(1.005); }
  84% { transform: translateY(-.5px) scale(.999); }
  100% { transform: none; }
}

@keyframes motion-stack-from-bottom {
  0% { transform: translateY(19px) scale(.975); }
  64% { transform: translateY(-1.5px) scale(1.005); }
  84% { transform: translateY(.5px) scale(.999); }
  100% { transform: none; }
}

@keyframes motion-panel-unfold {
  0% { transform: translateY(-5px) scaleY(.985); }
  68% { transform: translateY(1px) scaleY(1.003); }
  100% { transform: none; }
}

@keyframes motion-chat-enter {
  0% { transform: translateX(8px) scale(.996); }
  68% { transform: translateX(-1px) scale(1.001); }
  100% { transform: none; }
}

@keyframes motion-composer-rise {
  0% { opacity: 0; transform: translateY(15px) scale(.985); }
  65% { opacity: 1; transform: translateY(-2px) scale(1.002); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-nav-bounce {
  0% { transform: scale(.9); }
  58% { transform: scale(1.065); }
  82% { transform: scale(.985); }
  100% { transform: scale(1); }
}

@keyframes motion-status-change {
  0% { opacity: .25; transform: translateY(4px); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-badge-pop {
  0% { opacity: 0; transform: scale(.35); }
  58% { opacity: 1; transform: scale(1.24); }
  80% { transform: scale(.92); }
  100% { transform: scale(1); }
}

@keyframes motion-toast-pop {
  0% { opacity: 0; transform: translateY(16px) scale(.88); }
  62% { opacity: 1; transform: translateY(-2px) scale(1.025); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-success-pop {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.09); filter: brightness(1.14); }
  72% { transform: scale(.98); }
}

@keyframes motion-error-shake {
  0%, 100% { transform: translateX(0); }
  24% { transform: translateX(-5px); }
  48% { transform: translateX(4px); }
  72% { transform: translateX(-2px); }
}

@keyframes motion-list-item {
  0% { opacity: 0; transform: translateY(8px) scale(.99); }
  70% { opacity: 1; transform: translateY(-1px) scale(1.002); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-dialog-in {
  0% { opacity: 0; transform: translateY(14px) scale(.92); filter: blur(4px); }
  64% { opacity: 1; transform: translateY(-2px) scale(1.012); filter: blur(0); }
  84% { transform: translateY(0) scale(.996); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-backdrop-in {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(9px); }
}

@keyframes motion-auth-card {
  0% { opacity: 0; transform: translateY(18px) scale(.94); filter: blur(6px); }
  68% { opacity: 1; transform: translateY(-2px) scale(1.008); filter: blur(0); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-call-bar {
  0% { opacity: 0; transform: translateY(-14px) scale(.97); }
  65% { opacity: 1; transform: translateY(2px) scale(1.006); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-call-stage {
  0% { opacity: 0; transform: scale(.94); }
  58% { opacity: 1; transform: scale(1.015); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes motion-soft-rise {
  0% { opacity: 0; transform: translateY(7px) scale(.985); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-typing-dot {
  0%, 60%, 100% { transform: translateY(0) scale(.85); opacity: .45; }
  30% { transform: translateY(-4px) scale(1.08); opacity: 1; }
}

@keyframes motion-attention {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.08); }
  28% { transform: scale(.98); }
  42% { transform: scale(1.035); }
}

@keyframes motion-story-open {
  0% { opacity: 0; transform: scale(.9) translateY(10px); filter: blur(5px); }
  65% { opacity: 1; transform: scale(1.008) translateY(-1px); filter: blur(0); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-sheet-up {
  0% { opacity: 0; transform: translateY(24px) scale(.985); }
  68% { opacity: 1; transform: translateY(-2px) scale(1.002); }
  100% { opacity: 1; transform: none; }
}

@keyframes motion-reel-settle {
  0% { transform: scale(.985); filter: brightness(.92); }
  65% { transform: scale(1.004); filter: brightness(1.03); }
  100% { transform: scale(1); filter: none; }
}

@keyframes motion-reaction-burst {
  0%, 100% { transform: scale(1); }
  42% { transform: scale(1.24) rotate(-5deg); }
  68% { transform: scale(.93) rotate(2deg); }
}

@keyframes motion-floating-menu {
  0% { opacity: 0; filter: blur(3px) brightness(.9); }
  100% { opacity: 1; filter: none; }
}

@keyframes motion-toggle-settle {
  0% { transform: scale(.9); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes motion-profile-focus {
  0% { opacity: 0; transform: scale(.93); }
  68% { opacity: 1; transform: scale(1.015); }
  100% { opacity: 1; transform: scale(1); }
}

@media (max-width: 360px) {
  .website-actions {
    grid-template-columns: 1fr 1fr;
  }

  .website-actions #openWebsite {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* A one-shot liquid-glass reveal while the side panel initializes. */
.startup-glass {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  background: color-mix(in srgb, var(--pg-canvas) 82%, transparent);
  backdrop-filter: blur(22px) saturate(1.25);
  animation: pg-startup-curtain 1050ms cubic-bezier(.2, .8, .2, 1) forwards;
}

.startup-glass-lens {
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / .48);
  border-radius: 42px;
  background:
    radial-gradient(circle at 30% 18%, rgb(255 255 255 / .42), transparent 34%),
    linear-gradient(145deg, rgb(255 255 255 / .2), color-mix(in srgb, var(--accent) 12%, transparent));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .72),
    inset 0 -18px 34px rgb(255 255 255 / .06),
    0 22px 70px color-mix(in srgb, var(--accent) 30%, transparent);
  backdrop-filter: blur(34px) saturate(1.65);
  animation: pg-startup-lens 1050ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.startup-glass-lens img {
  position: relative;
  z-index: 2;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  filter: drop-shadow(0 10px 18px rgb(0 0 0 / .26));
  animation: pg-startup-mark 820ms cubic-bezier(.2, 1.25, .35, 1) both;
}

.startup-glass-shine {
  position: absolute;
  z-index: 1;
  inset: -45%;
  background: linear-gradient(112deg, transparent 38%, rgb(255 255 255 / .72) 49%, transparent 60%);
  transform: translateX(-65%) rotate(8deg);
  animation: pg-startup-shine 720ms 120ms ease-out both;
}

@keyframes pg-startup-curtain {
  0%, 62% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; backdrop-filter: blur(0) saturate(1); }
}

@keyframes pg-startup-lens {
  0% { opacity: 0; transform: scale(.5); border-radius: 50%; filter: blur(6px); }
  38% { opacity: 1; transform: scale(1); border-radius: 42px; filter: none; }
  68% { opacity: 1; transform: scale(1.08); border-radius: 34px; }
  100% { opacity: 0; transform: scale(5.2); border-radius: 26px; filter: blur(2px); }
}

@keyframes pg-startup-mark {
  0% { opacity: 0; transform: scale(.65) rotate(-5deg); }
  58% { opacity: 1; transform: scale(1.08) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes pg-startup-shine {
  from { transform: translateX(-65%) rotate(8deg); }
  to { transform: translateX(65%) rotate(8deg); }
}

@media (prefers-reduced-motion: reduce) {
  .startup-glass { display: none; }
}

@supports not (backdrop-filter: blur(1px)) {
  .rail,
  .sidebar,
  .panel-heading,
  .topbar,
  .composer,
  dialog,
  .auth-overlay,
  .call-bar,
  .toast {
    background: color-mix(in srgb, var(--panel) 96%, var(--bg));
  }
}

.saved-empty {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 180px;
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 22px;
  background: color-mix(in srgb, var(--pg-low) 76%, transparent);
}

.saved-empty p { margin: 0; max-width: 32ch; }
.saved-message-card { gap: 10px; }

.saved-message-preview {
  margin: 0;
  padding: 0 4px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.saved-marker,
.message-saved-label {
  color: color-mix(in srgb, var(--accent-2) 72%, #fff);
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent-2) 44%, transparent);
}

/* Selective refraction: one morphing navigation lens and one floating optical plane. */
.rail {
  position: relative;
  isolation: isolate;
}

.rail-button {
  z-index: 2;
}

.rail-liquid-indicator {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  overflow: hidden;
  border: var(--pg-lens-edge) solid color-mix(in srgb, white 54%, var(--pg-stroke));
  border-radius: 20px;
  pointer-events: none;
  background: color-mix(in srgb, var(--accent) 12%, var(--pg-mid));
  box-shadow:
    var(--pg-specular),
    0 calc(var(--pg-lens-lift) * 0.45) calc(var(--pg-lens-lift) * 1.15) color-mix(in srgb, var(--accent) 22%, transparent);
  transform-origin: center;
  transition:
    width 420ms var(--pg-ease),
    height 420ms var(--pg-ease),
    transform 420ms var(--pg-ease),
    border-radius 420ms var(--pg-ease),
    box-shadow 220ms ease;
  will-change: width, height, transform;
}

.rail-liquid-indicator[data-shape="tall"] { border-radius: 25px; }
.rail-liquid-indicator.liquid-morphing { animation: pg-liquid-settle 460ms var(--pg-ease); }
.rail-liquid-indicator.hidden { opacity: 0; }

.rail.liquid-nav-ready .rail-button.active {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  text-shadow: 0 1px 9px rgb(2 8 23 / 0.34);
}

.rail.liquid-nav-ready .rail-button.active:hover {
  transform: none;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.liquid-surface-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.rail-liquid-indicator > .liquid-surface-canvas { opacity: 0.78; }

.liquid-surface-host {
  position: relative;
  isolation: isolate;
}

.message-actions-menu.liquid-surface-host,
.emoji-picker.liquid-surface-host {
  position: fixed;
}

.liquid-surface-host > :not(.liquid-floating-canvas) {
  position: relative;
  z-index: 1;
}

.liquid-floating-canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  border-radius: inherit;
  opacity: 0.3;
  filter: saturate(1.08) contrast(1.04);
}

.liquid-surface-host.liquid-over-light {
  border-color: rgb(19 31 49 / 0.32);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.72), 0 18px 48px rgb(23 42 68 / 0.18);
}

.liquid-surface-host.liquid-over-dark {
  border-color: rgb(255 255 255 / 0.36);
  box-shadow: var(--pg-specular), 0 20px 54px rgb(0 0 0 / 0.34);
}

.liquid-surface-host.liquid-materializing {
  animation: pg-liquid-materialize 440ms var(--pg-ease) both;
}

.message-actions-menu.liquid-materializing,
.emoji-picker.liquid-materializing {
  animation: pg-floating-controls-in 110ms ease-out both;
  transform: none;
  filter: none;
}

:root[data-glass-performance="balanced"] .liquid-floating-canvas { opacity: 0.22; }
:root[data-glass-performance="css"] .liquid-surface-canvas { display: none; }
:root[data-glass-performance="css"] .rail-liquid-indicator {
  background:
    radial-gradient(150px 110px at var(--pg-surface-light-x, var(--pg-light-x)) var(--pg-surface-light-y, var(--pg-light-y)), rgb(255 255 255 / var(--pg-lens-highlight)), transparent 62%),
    linear-gradient(145deg, color-mix(in srgb, var(--accent) 20%, var(--pg-mid)), color-mix(in srgb, var(--accent-2) 12%, var(--pg-low)));
}

@keyframes pg-liquid-settle {
  0% { filter: brightness(1) saturate(1); }
  48% { filter: brightness(1.12) saturate(1.18); }
  100% { filter: brightness(1) saturate(1); }
}

@keyframes pg-liquid-materialize {
  from { opacity: 0; transform: translateY(12px) scale(0.94); filter: blur(8px) saturate(1.3); }
  58% { opacity: 1; transform: translateY(-1px) scale(1.008); filter: blur(0) saturate(1.08); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: none; }
}

.message-saved-label {
  display: block;
  width: fit-content;
  margin-top: 5px;
  font-size: 0.67rem;
  font-weight: 750;
}

.message.saved {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 30%, transparent), 0 12px 30px rgb(0 0 0 / 0.16);
}

.message.saved-focus { animation: saved-focus-pulse 1.8s ease both; }

@keyframes saved-focus-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 30%, transparent), 0 12px 30px rgb(0 0 0 / 0.16); }
  40% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent-2) 82%, #fff), 0 0 26px color-mix(in srgb, var(--accent-2) 46%, transparent); }
}

.message-tab {
  min-width: 0;
  padding-inline: 5px;
  gap: 4px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}

.message-tab .tab-badge { flex: 0 0 auto; }

.multi-send-short { display: none; }

/* Give the conversation directory priority in narrow side panels. */
@media (max-width: 430px) {
  .app-shell,
  .app-shell.sidebar-mode,
  .app-shell.messages-mode,
  .app-shell.settings-mode {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .rail {
    padding: 7px 3px;
  }

  .rail-button {
    width: 52px;
    height: 44px;
    min-height: 44px;
  }

  .rail-button.message-button {
    height: 58px;
    min-height: 58px;
  }

  .message-picker-heading {
    grid-template-columns: minmax(70px, 1fr) auto;
    gap: 6px;
    align-items: center;
    padding: 8px 9px;
  }

  .message-picker-heading h2 {
    font-size: 17px;
  }

  .message-picker-heading p {
    display: none;
  }

  .message-picker-tools {
    display: grid;
    grid-template-columns: 68px 30px 34px 34px;
    gap: 4px;
  }

  .message-picker-tools .presence-toggle {
    min-width: 0;
    min-height: 34px;
    padding: 5px 8px;
    gap: 5px;
    font-size: 10px;
  }

  .message-picker-tools .presence-toggle input {
    width: 28px;
    height: 16px;
  }

  .message-picker-tools .presence-toggle input::after {
    width: 10px;
    height: 10px;
  }

  .message-picker-tools .presence-toggle input:checked::after {
    transform: translateX(12px);
  }

  .message-picker-tools button {
    min-width: 0;
    min-height: 34px;
    padding: 5px;
    font-size: 9px;
  }

  .multi-send-full { display: none; }
  .multi-send-short { display: inline; }

  .stories-panel {
    gap: 5px;
    padding: 7px 10px 0;
  }

  .stories-heading span {
    display: none;
  }

  .stories-heading button {
    min-height: 28px;
    padding: 4px 9px;
    font-size: 10px;
  }

  .stories-strip {
    gap: 7px;
    padding-bottom: 4px;
  }

  .story-chip {
    flex-basis: 48px;
    width: 48px;
    gap: 3px;
  }

  .story-chip-avatar {
    width: 42px;
    height: 42px;
    padding: 2px;
  }

  .story-chip-label {
    font-size: 8px;
  }

  .story-add-mark {
    width: 16px;
    height: 16px;
    font-size: 11px;
  }

  .message-tabs {
    min-height: 40px;
    margin: 7px 9px 0;
    gap: 3px;
    padding: 3px;
  }

  .message-tab {
    min-height: 32px;
    padding: 4px 3px;
    font-size: 9px;
  }

  .message-contact-list {
    gap: 7px;
    padding: 8px 9px 14px;
  }
}

@media (max-width: 340px) {
  .message-picker-heading {
    grid-template-columns: minmax(0, 1fr);
  }

  .message-picker-heading > div:first-child {
    display: block;
  }
}

/* Final geometry rules live last so glass styling cannot compress the UI. */
@media (max-width: 760px) {
  .settings-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
    border-radius: 20px;
  }

  .settings-tab {
    min-width: 0;
    min-height: 36px;
    padding: 7px 8px;
    border-radius: 15px;
    font-size: 11px;
  }

  .conversation-screen .toolbar-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }
}

@media (max-width: 430px) {
  .members-dialog-card {
    width: 100%;
    max-width: 100%;
  }

  .group-member-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .group-member-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .group-member-actions button {
    width: 100%;
  }

  .discover-stories {
    gap: 8px;
  }

  .discover-story-card,
  .story-stack-layer {
    border-radius: 18px;
  }
}

@media (max-width: 340px) {
  .settings-panel-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 7px;
    margin-bottom: 6px;
  }

  .settings-panel-heading button {
    width: 100%;
  }

  .discover-story-tile {
    aspect-ratio: 4 / 5;
  }

  .discover-story-owner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 2px;
    padding-right: 0;
  }

  .discover-story-owner strong {
    width: 100%;
    font-size: 9px;
  }

  .discover-story-meta strong {
    -webkit-line-clamp: 1;
  }
}

/* Motion overhaul: short, composited feedback without reflowing chat content. */
:root {
  --motion-snap: 150ms cubic-bezier(.2, .8, .2, 1);
  --motion-settle: 280ms cubic-bezier(.16, 1, .3, 1);
}

button,
.message-tab,
.destination-tab,
.settings-tab,
.contact-directory-tab,
.story-chip,
.message-reaction,
.rail-button {
  transition:
    color var(--motion-snap),
    background-color var(--motion-snap),
    border-color var(--motion-snap),
    box-shadow var(--motion-snap),
    filter var(--motion-snap),
    opacity var(--motion-snap),
    transform var(--motion-snap);
}

button:active,
.story-chip:active,
.message-reaction:active {
  transform: scale(.965);
  transition-duration: 70ms;
}

.message-tab.active,
.destination-tab.active,
.settings-tab.active,
.contact-directory-tab.active {
  animation: pg-selection-settle var(--motion-settle) both;
}

.presence-toggle input::after,
.notifications-toggle input::after {
  transition: transform 220ms cubic-bezier(.2, 1.4, .35, 1), background-color var(--motion-snap), box-shadow var(--motion-snap);
}

.message-reaction.active {
  animation: pg-reaction-pop 260ms cubic-bezier(.2, 1.35, .35, 1) both;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--pg-stroke-bright));
  box-shadow: var(--pg-specular), 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent), var(--pg-shadow-low);
}

.group-create-action {
  animation: pg-card-arrive var(--motion-settle) both;
}

.group-create-action > button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--pg-stroke));
  border-radius: 20px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 14%, var(--pg-mid)), var(--pg-low));
  box-shadow: var(--pg-specular), var(--pg-shadow-low);
  text-align: left;
}

.group-create-action > button > span:first-child {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  color: white;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 82%, white), var(--accent));
  font-size: 24px;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), 0 9px 22px color-mix(in srgb, var(--accent) 28%, transparent);
}

.group-create-action > button > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.group-create-action strong,
.group-create-action small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-create-action small {
  color: var(--muted);
  font-size: 10px;
}

.create-group-card {
  width: min(440px, 100%);
}

.create-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--pg-stroke);
}

.create-group-heading h3 {
  margin-top: 2px;
  font-size: 22px;
}

@media (hover: hover) {
  button:hover,
  .story-chip:hover,
  .message-reaction:hover {
    filter: brightness(1.08) saturate(1.04);
  }

  .group-create-action > button:hover {
    border-color: color-mix(in srgb, var(--accent) 68%, var(--pg-stroke-bright));
    box-shadow: var(--pg-specular), 0 14px 34px color-mix(in srgb, var(--accent) 14%, transparent);
  }
}

@keyframes pg-selection-settle {
  0% { filter: brightness(.94); box-shadow: inset 0 1px 0 rgb(255 255 255 / .08); }
  58% { filter: brightness(1.1); }
  100% { filter: none; }
}

@keyframes pg-reaction-pop {
  0% { transform: scale(.82); opacity: .55; }
  62% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes pg-card-arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .message-tab,
  .destination-tab,
  .settings-tab,
  .contact-directory-tab,
  .story-chip,
  .message-reaction,
  .rail-button,
  .group-create-action {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}
