/* Sifir: self-contained application theme. No remote assets or fonts. */
:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  --canvas: #edf1f2;
  --surface: #ffffff;
  --soft: #f6f8f8;
  --sidebar: #f8faf9;
  --ink: #192e31;
  --muted: #607478;
  --line: #e2e9e8;
  --accent: #147969;
  --accent-hover: #096457;
  --accent-soft: #e5f2ec;
  --outgoing: #e4f1eb;
  --rail: #132e30;
  --rail-ink: #b6cdce;
  --notice: #fff6e4;
  --notice-ink: #75551e;
  --danger: #a33535;
  --shadow: 0 12px 45px #16373d09;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
}
button,
input,
textarea,
output {
  font: inherit;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 42px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.35;
  cursor: pointer;
  transition:
    background 130ms ease,
    border-color 130ms ease,
    color 130ms ease;
}
button:hover:not(:disabled) {
  background: var(--soft);
  border-color: var(--accent);
}
button:active:not(:disabled) {
  background: var(--accent-soft);
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
button[type="submit"],
button[data-action="accept-message-request"],
button[data-action="send-image"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button[type="submit"]:hover:not(:disabled),
button[data-action="accept-message-request"]:hover:not(:disabled),
button[data-action="send-image"]:hover:not(:disabled) {
  background: var(--accent-hover);
}
:focus-visible {
  outline: 3px solid #41a88d;
  outline-offset: 3px;
}
input,
textarea {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 0.45rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
  color: var(--ink);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
input:focus,
textarea:focus {
  border-color: var(--accent);
}
input:disabled,
textarea:disabled {
  opacity: 0.6;
}
input[readonly],
output {
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 0.82rem;
}
input[type="checkbox"] {
  accent-color: var(--accent);
}
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
form {
  display: grid;
  gap: 1.1rem;
  min-width: 0;
}
output {
  display: block;
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  overflow-wrap: anywhere;
}
h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
h1 {
  font-size: 1.45rem;
}
h2 {
  font-size: 1.2rem;
}
p {
  margin: 0;
  overflow-wrap: anywhere;
}
a {
  color: var(--accent);
  text-underline-offset: 3px;
}
img {
  max-width: 100%;
  height: auto;
}
.ui-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}
.eyebrow {
  font-size: 0.63rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.brand-bar,
#app,
.site-footer {
  width: min(1480px, calc(100% - 40px));
  margin-inline: auto;
}
.brand-bar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 36px;
  border-radius: 11px 11px 11px 3px;
  background: var(--rail);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 650;
  line-height: 1;
}
.brand-name {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.07em;
  line-height: 1;
}
.brand-caption {
  display: block;
  color: var(--muted);
  font-size: 0.61rem;
  margin-top: 0.25rem;
  font-weight: 450;
  letter-spacing: 0.025em;
}
.connection-indicator {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
}
.connection-indicator-light {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    0 0 0 4px color-mix(in srgb, currentColor 12%, transparent),
    0 0 12px color-mix(in srgb, currentColor 45%, transparent);
}
.connection-indicator[data-state="connected"] {
  color: #24ad72;
}
.connection-indicator[data-state="updating"] {
  color: #d4a52c;
}
.connection-indicator[data-state="offline"] {
  color: #d96b67;
}
.connection-indicator-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.connection-indicator:is(:hover, :focus)::after {
  content: attr(aria-label);
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 10;
  width: max-content;
  max-width: min(260px, calc(100vw - 32px));
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.73rem;
}
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 36px;
  font-size: 0.66rem;
  color: var(--muted);
}
#app {
  min-width: 0;
}
main {
  display: grid;
  align-content: start;
  gap: 1.25rem;
  min-width: 0;
  width: min(100%, 480px);
  margin: 2.5rem auto;
  padding: 2.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}
main > p {
  color: var(--muted);
  font-size: 0.88rem;
}
main > header {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  margin-bottom: 0.4rem;
}
main > header button {
  flex: 0 0 auto;
}
main > header button .ui-icon {
  width: 16px;
  height: 16px;
}
main > [role="status"],
main > [role="alert"] {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
}
[role="alert"] {
  color: var(--danger);
}
.account-entry {
  box-shadow: var(--shadow);
  gap: 1.4rem;
  padding: 2.7rem;
}

.account-reset-dialog {
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(18px, 4vw, 32px);
  background: var(--surface);
  color: var(--ink);
}
.account-reset-dialog::backdrop {
  background: rgb(0 0 0 / 65%);
}
.account-reset-dialog h1 {
  font-size: 1.6rem;
}
.account-reset-dialog p {
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.account-reset-dialog form {
  display: grid;
  gap: 14px;
}
.account-reset-dialog label {
  display: grid;
  gap: 8px;
}
.account-reset-dialog input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.account-reset-dialog .account-reset-consent {
  display: flex;
  align-items: start;
  gap: 10px;
}
.account-reset-dialog input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 3px;
}
.account-reset-dialog button {
  white-space: normal;
}
.account-reset-dialog .account-reset-confirm {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--surface);
}
.account-entry h1 {
  font-size: 1.85rem;
  letter-spacing: -0.04em;
}
.account-entry .eyebrow {
  margin-bottom: -0.65rem;
  font-size: 0.67rem;
  color: var(--accent);
}
.account-entry > button,
.account-entry form button {
  width: 100%;
}
.account-emblem {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.account-emblem .ui-icon {
  width: 25px;
  height: 25px;
}

/* Rail / directory / detail. The controller remains the only navigation owner. */
.secure-client-shell {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100dvh - 108px);
  min-height: 580px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.secure-client-shell.has-directory {
  grid-template-columns: 76px 290px minmax(0, 1fr);
}
.secure-client-shell > nav {
  grid-column: 1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 20px 8px 14px;
  background: var(--rail);
}
.secure-client-shell > nav button {
  flex-direction: column;
  gap: 0.4rem;
  width: 58px;
  min-height: 60px;
  padding: 0.55rem 0.15rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--rail-ink);
  font-size: 0.62rem;
  font-weight: 500;
}
.secure-client-shell > nav button .ui-icon {
  width: 21px;
  height: 21px;
}
.secure-client-shell > nav button:hover:not(:disabled) {
  color: #fff;
  background: #ffffff12;
  border-color: #ffffff14;
}
.secure-client-shell > nav button[aria-current] {
  color: #fff;
  background: #ffffff15;
  border-color: #ffffff16;
}
.secure-client-shell > nav button[data-action="lock-account"] {
  margin-top: auto;
}
.secure-client-shell > main {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 30px clamp(20px, 4vw, 52px);
  border: 0;
  border-radius: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.secure-client-shell.has-directory > main {
  grid-column: 3;
}
.secure-client-shell > .conversation-privacy {
  grid-column: 2;
  grid-row: 3;
  padding: 9px 24px;
  border-top: 1px solid var(--line);
  font-size: 0.63rem;
  line-height: 1.45;
  color: var(--muted);
  background: var(--surface);
}
.secure-client-shell.has-directory > .conversation-privacy {
  grid-column: 3;
}
.connection-notice {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 12px 24px;
  background: var(--notice);
  color: var(--notice-ink);
  border-bottom: 1px solid
    color-mix(in srgb, var(--notice-ink) 15%, transparent);
  font-size: 0.76rem;
  line-height: 1.5;
}
.has-directory > .connection-notice {
  grid-column: 3;
}
.connection-notice .ui-icon {
  width: 17px;
  height: 17px;
}
.connection-notice button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0.45rem 0.7rem;
  font-size: 0.73rem;
}
.conversation-privacy {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}
.conversation-sidebar,
.secure-client-shell.has-directory > .conversation-directory {
  grid-column: 2;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 0;
  padding: 25px 0 16px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  overflow: hidden;
}
.conversation-sidebar > h2,
.conversation-directory > h1 {
  font-size: 1.25rem;
  padding-inline: 22px;
}
.conversation-sidebar > .conversation-privacy,
.conversation-directory > .conversation-privacy {
  padding: 8px 22px 22px;
  font-size: 0.72rem;
}
.conversation-directory > p:not(.conversation-privacy) {
  margin: 12px 22px;
}
.conversation-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 3px;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0 10px;
  scrollbar-width: thin;
}
.conversation-list > li {
  min-width: 0;
}
.conversation-list button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 78px;
  padding: 14px 12px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
}
.conversation-list button:hover:not(:disabled) {
  background: var(--soft);
  border-color: var(--line);
}
.conversation-list button[aria-current] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 9%, transparent);
}
.contact-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 650;
}
li:nth-child(3n + 2) .contact-avatar {
  background: #e9edf5;
  color: #627393;
}
li:nth-child(3n) .contact-avatar {
  background: #f5eee3;
  color: #947347;
}
.contact-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1;
}
.contact-label {
  font-size: 0.83rem;
  line-height: 1.45;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.contact-caption {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
}
.conversation-sidebar > button,
.conversation-directory > button {
  margin: 16px 20px 0;
  flex: 0 0 auto;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.8rem;
}
.workspace-welcome {
  grid-column: 3;
  grid-row: 1 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
  padding: 40px;
  min-width: 0;
  background: var(--surface);
}
.directory-view:has(.connection-notice) > .workspace-welcome {
  grid-row: 2;
}
.welcome-mark {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 26px 26px 26px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 12px;
}
.welcome-mark .ui-icon {
  width: 36px;
  height: 36px;
  stroke-width: 1.25;
}
.workspace-welcome h2 {
  white-space: pre-line;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1.2;
  font-weight: 550;
  letter-spacing: -0.055em;
}
.workspace-welcome > p:not(.eyebrow) {
  max-width: 26rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.workspace-welcome .welcome-security {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2rem;
  font-size: 0.7rem !important;
}
.welcome-security .ui-icon {
  width: 17px;
  height: 17px;
}

/* The message log alone scrolls; the composer's controls remain in reach. */
.secure-client-shell > .conversation-screen {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.conversation-screen > header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 80px;
  padding: 17px 24px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.conversation-title {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
}
.conversation-title .eyebrow {
  font-size: 0.56rem;
  letter-spacing: 0.12em;
}
.conversation-title h1 {
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.conversation-screen > header > button {
  padding: 0.5rem;
  min-width: 36px;
  min-height: 36px;
  border-color: transparent;
}
.conversation-screen > header > button .button-label {
  display: none;
}
.chat-options {
  position: relative;
  flex: 0 0 44px;
}
.chat-options > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  min-height: 44px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
}
.chat-options > summary::-webkit-details-marker {
  display: none;
}
.chat-options > summary:focus-visible {
  outline: 2px solid var(--accent);
}
.chat-options-panel {
  position: absolute;
  z-index: 10;
  right: 0;
  top: calc(100% + 6px);
  width: 210px;
  max-width: calc(100vw - 32px);
  padding: 6px;
  background: var(--panel, #17272b);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px #0005;
}
.chat-options-panel > button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  text-align: left;
  border-color: transparent;
}
.chat-options-panel > button:hover {
  color: var(--danger, #f39a9a);
}
.conversation-screen > .conversation-privacy {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 12px 24px 5px;
  font-size: 0.67rem;
  background: var(--soft);
}
.conversation-screen > .conversation-privacy .ui-icon {
  width: 12px;
  height: 12px;
}
.message-log {
  display: grid;
  flex: 1 1 auto;
  min-height: 140px;
  align-content: start;
  gap: 14px;
  padding: 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--soft);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.message {
  display: grid;
  width: fit-content;
  min-width: 110px;
  max-width: min(85%, 480px);
  gap: 7px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 13px 13px 13px 3px;
  background: var(--surface);
}
.message-outgoing {
  justify-self: end;
  background: var(--outgoing);
  border-color: color-mix(in srgb, var(--accent) 12%, var(--outgoing));
  border-radius: 13px 13px 3px 13px;
}
.message-incoming {
  justify-self: start;
}
.message p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 0.88rem;
}
.message footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 0.64rem;
}
.message button {
  width: auto;
  font-size: 0.72rem;
  min-height: 34px;
  padding: 0.45rem 0.65rem;
}
.message .local-removal {
  font-size: 0.64rem;
  color: var(--muted);
}
.local-removal summary {
  cursor: pointer;
  padding-block: 3px;
}
.local-removal[open] {
  display: grid;
  gap: 0.6rem;
}
.local-removal[open] p {
  font-size: 0.76rem;
}
.local-removal button[data-action="confirm-delete-message-locally"] {
  color: var(--danger);
}
.empty-messages {
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 3rem;
}
.conversation-screen form[data-action="send-message"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  flex: 0 0 auto;
  padding: 14px 24px 10px;
  border-top: 1px solid var(--line);
}
.conversation-screen form[data-action="send-message"] label {
  font-size: 0.68rem;
  color: var(--muted);
}
.conversation-screen textarea {
  resize: vertical;
  min-height: 48px;
  height: 48px;
  max-height: 140px;
  margin-top: 4px;
  padding: 0.8rem 0.9rem;
  font-size: 0.9rem;
}
.conversation-screen form[data-action="send-message"] button {
  height: 48px;
  min-width: 82px;
}
.conversation-screen > [role="status"] {
  flex: 0 0 auto;
  margin: 4px 24px;
  font-size: 0.76rem;
}
.image-composer {
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 6px 24px 14px;
  background: var(--surface);
}
.image-composer > label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.75rem;
}
.image-composer input[type="file"] {
  flex: 1;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 0.73rem;
}
input[type="file"]::file-selector-button {
  font: inherit;
  padding: 7px 10px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
}
.image-composer .conversation-privacy {
  font-size: 0.62rem;
}
.image-composer .message-image {
  max-height: 130px;
  width: auto;
}
.image-composer:has(.message-image) {
  max-height: 250px;
  overflow-y: auto;
}
.image-composer > button {
  justify-self: start;
  min-height: 36px;
  font-size: 0.75rem;
}
.message-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 7px;
}

/* Profile, requests, recovery and device management share the same form language. */
.message-request-list,
.device-management-list {
  display: grid;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.message-request-list > li,
.device-management-list > li {
  display: grid;
  gap: 0.65rem;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow-wrap: anywhere;
  background: var(--surface);
}
.message-request-list > li > span,
.device-management-list > li > span {
  font-size: 0.75rem;
  color: var(--muted);
}
.message-request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.message-request-actions button {
  min-height: 36px;
  font-size: 0.76rem;
}
.account-contact,
.contact-preview {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}
.account-contact p,
.contact-preview p {
  font-size: 0.78rem;
  color: var(--muted);
}
.account-contact > button {
  justify-self: start;
}
.contact-qr summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.82rem;
  padding-block: 0.4rem;
}
.contact-qr svg {
  display: block;
  width: min(100%, 256px);
  height: auto;
  margin: 1rem auto;
  shape-rendering: crispEdges;
}
[data-screen="ACCOUNT_SETTINGS"] > form,
[data-screen="PUBLIC_PROFILE"] > form {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
[data-screen="PUBLIC_PROFILE"] form p {
  font-size: 0.78rem;
  color: var(--muted);
}
[data-screen="ACCOUNT_SETTINGS"] > button {
  justify-self: start;
}
.profile-discovery-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.5;
}

.alias-input-field {
  display: flex;
  align-items: center;
  position: relative;
  min-width: 0;
  margin-top: 0.45rem;
}
.alias-input-prefix {
  position: absolute;
  left: 16px;
  user-select: none;
  pointer-events: none;
  color: var(--muted);
}
.alias-input-field input {
  margin-top: 0;
  width: 100%;
  min-width: 0;
  padding-left: 38px;
}
.profile-discovery-choice input {
  margin: 0;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.profile-release {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.profile-release button {
  color: var(--danger);
}
.locked-shell {
  display: block;
  width: min(100%, 480px);
  height: auto;
  min-height: 0;
  margin: clamp(2rem, 8vh, 6rem) auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.locked-shell > main {
  margin: 0;
  padding: 2.7rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: visible;
}

/* System preference only: no new account setting or persistence. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-color-scheme])) {
    color-scheme: dark;
    --canvas: #101a1e;
    --surface: #172428;
    --soft: #132024;
    --sidebar: #19272b;
    --ink: #e6eeef;
    --muted: #9cafb2;
    --line: #2b3d41;
    --accent: #207e6b;
    --accent-hover: #258e79;
    --accent-soft: #213e38;
    --outgoing: #25463c;
    --rail: #0b191e;
    --rail-ink: #98b1b6;
    --notice: #352e22;
    --notice-ink: #e0c487;
    --danger: #f2a5a5;
    --shadow: none;
  }
  :where(:root:not([data-color-scheme])) .contact-avatar,
  :where(:root:not([data-color-scheme])) .account-emblem,
  :where(:root:not([data-color-scheme])) .welcome-mark,
  :where(:root:not([data-color-scheme])) .eyebrow,
  :where(:root:not([data-color-scheme])) .account-entry .eyebrow {
    color: #87c7b2;
  }
  :where(:root:not([data-color-scheme])) li:nth-child(3n + 2) .contact-avatar {
    background: #2a3448;
    color: #b4c2e3;
  }
  :where(:root:not([data-color-scheme])) li:nth-child(3n) .contact-avatar {
    background: #40372c;
    color: #d9c093;
  }
  :where(:root:not([data-color-scheme])) .conversation-sidebar > button,
  :where(:root:not([data-color-scheme])) .conversation-directory > button,
  :where(:root:not([data-color-scheme])) .contact-qr summary,
  :where(:root:not([data-color-scheme])) a {
    color: #87c7b2;
  }
}
/* Explicit mode also applies when the OS prefers the opposite scheme. */
:root:where([data-color-scheme="dark"]) {
    color-scheme: dark;
    --canvas: #101a1e;
    --surface: #172428;
    --soft: #132024;
    --sidebar: #19272b;
    --ink: #e6eeef;
    --muted: #9cafb2;
    --line: #2b3d41;
    --accent: #207e6b;
    --accent-hover: #258e79;
    --accent-soft: #213e38;
    --outgoing: #25463c;
    --rail: #0b191e;
    --rail-ink: #98b1b6;
    --notice: #352e22;
    --notice-ink: #e0c487;
    --danger: #f2a5a5;
    --shadow: none;
  }
  :where(:root[data-color-scheme="dark"]) .contact-avatar,
  :where(:root[data-color-scheme="dark"]) .account-emblem,
  :where(:root[data-color-scheme="dark"]) .welcome-mark,
  :where(:root[data-color-scheme="dark"]) .eyebrow,
  :where(:root[data-color-scheme="dark"]) .account-entry .eyebrow {
    color: #87c7b2;
  }
  :where(:root[data-color-scheme="dark"]) li:nth-child(3n + 2) .contact-avatar {
    background: #2a3448;
    color: #b4c2e3;
  }
  :where(:root[data-color-scheme="dark"]) li:nth-child(3n) .contact-avatar {
    background: #40372c;
    color: #d9c093;
  }
  :where(:root[data-color-scheme="dark"]) .conversation-sidebar > button,
  :where(:root[data-color-scheme="dark"]) .conversation-directory > button,
  :where(:root[data-color-scheme="dark"]) .contact-qr summary,
  :where(:root[data-color-scheme="dark"]) a {
    color: #87c7b2;
  }

@media (min-width: 1600px) {
  .secure-client-shell.has-directory {
    grid-template-columns: 80px 330px minmax(0, 1fr);
  }
}
@media (max-width: 1050px) and (min-width: 761px) {
  .brand-bar,
  #app,
  .site-footer {
    width: calc(100% - 24px);
  }
  .secure-client-shell.has-directory {
    grid-template-columns: 66px 235px minmax(0, 1fr);
  }
  .secure-client-shell > nav {
    padding-inline: 4px;
  }
  .conversation-screen > header {
    padding-inline: 16px;
  }
  .message-log {
    padding: 18px;
  }
  .conversation-list button {
    padding: 12px 8px;
    gap: 9px;
  }
  .contact-avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }
  .contact-caption {
    font-size: 0.62rem;
  }
  .conversation-screen form[data-action="send-message"],
  .image-composer {
    padding-inline: 16px;
  }
}
@media (max-width: 760px) {
  input:not([type="file"]),
  textarea,
  .conversation-screen textarea {
    /* Keep iOS from zooming the viewport when a field receives focus. */
    font-size: 16px;
  }
  .brand-bar,
  #app {
    width: 100%;
  }
  .brand-bar {
    height: 62px;
    padding: 0 16px;
  }
  .brand-mark {
    width: 29px;
    height: 31px;
    font-size: 1.5rem;
    border-radius: 9px 9px 9px 3px;
  }
  .brand-name {
    font-size: 1.4rem;
  }
  .brand-caption {
    font-size: 0.55rem;
  }
  .site-footer {
    display: none;
  }
  .secure-client-shell,
  .secure-client-shell.has-directory {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    height: calc(100dvh - 62px);
    min-height: 600px;
    border-radius: 0;
    border-inline: 0;
    box-shadow: none;
  }
  .secure-client-shell > nav {
    grid-column: 1;
    grid-row: 1;
    flex-direction: row;
    justify-content: space-around;
    gap: 4px;
    padding: 5px 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .secure-client-shell > nav button {
    flex-direction: row;
    min-width: 44px;
    min-height: 44px;
    width: auto;
    padding: 8px;
    border-radius: 9px;
    color: var(--muted);
  }
  .secure-client-shell > nav button .button-label {
    display: none;
  }
  .secure-client-shell > nav button[aria-current],
  .secure-client-shell > nav button:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--ink);
    border-color: transparent;
  }
  .secure-client-shell > nav button[data-action="lock-account"] {
    margin: 0;
  }
  .secure-client-shell > main,
  .secure-client-shell.has-directory > main {
    grid-column: 1;
    grid-row: 3;
    padding: 22px 18px;
  }
  .secure-client-shell.has-directory > .conversation-directory {
    /* Match the desktop selector: otherwise it creates an implicit column. */
    grid-column: 1;
    grid-row: 3;
    padding: 24px 0 20px;
    border-right: 0;
    background: var(--surface);
  }
  .secure-client-shell > .conversation-screen {
    padding: 0 !important;
  }
  .conversation-sidebar,
  .workspace-welcome {
    display: none;
  }
  .secure-client-shell > .conversation-privacy,
  .secure-client-shell.has-directory > .conversation-privacy {
    grid-column: 1;
    grid-row: 4;
    padding: 8px 16px max(8px, env(safe-area-inset-bottom));
    font-size: 0.58rem;
  }
  .connection-notice,
  .has-directory > .connection-notice {
    grid-column: 1;
    grid-row: 2;
    padding: 10px 14px;
    font-size: 0.7rem;
  }
  .connection-notice > .ui-icon {
    display: none;
  }
  .connection-notice button {
    font-size: 0.68rem;
    padding: 0.4rem 0.5rem;
  }
  .conversation-screen > header {
    min-height: 66px;
    padding: 12px 16px;
    gap: 10px;
  }
  .conversation-title h1 {
    font-size: 0.93rem;
  }
  .conversation-screen > header .contact-avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }
  .conversation-screen > .conversation-privacy {
    padding: 10px 12px 5px;
    font-size: 0.59rem;
  }
  .message-log {
    padding: 16px;
    gap: 12px;
    min-height: 120px;
  }
  .message {
    max-width: 91%;
    padding: 10px 13px;
  }
  .message p {
    font-size: 0.85rem;
  }
  .message footer,
  .message .local-removal {
    font-size: 0.6rem;
  }
  .conversation-screen form[data-action="send-message"] {
    padding: 10px 14px 8px;
  }
  .conversation-screen form[data-action="send-message"] button {
    min-width: 48px;
    padding: 12px;
  }
  .conversation-screen form[data-action="send-message"] button .button-label {
    display: none;
  }
  .image-composer {
    padding: 4px 14px 10px;
    gap: 5px;
  }
  .image-composer > label {
    gap: 5px;
  }
  .image-composer > label .ui-icon {
    width: 17px;
    height: 17px;
  }
  .image-composer .conversation-privacy {
    font-size: 0.58rem;
  }
  .account-contact,
  .contact-preview,
  [data-screen="ACCOUNT_SETTINGS"] > form,
  [data-screen="PUBLIC_PROFILE"] > form {
    padding: 16px;
  }
  main.account-entry {
    width: calc(100% - 32px);
    padding: 24px;
    margin: 24px auto;
  }
  .secure-client-shell.locked-shell {
    display: block;
    width: calc(100% - 32px);
    height: auto;
    min-height: 0;
    margin: 24px auto;
    border: 0;
  }
  .locked-shell > main.account-entry {
    width: 100%;
    margin: 0;
    padding: 26px;
    border: 1px solid var(--line);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
