:root {
  color-scheme: light;
  --navy: #191847;
  --navy-soft: #25245d;
  --indigo: #5146e5;
  --cyan: #24b7cb;
  --surface: #ffffff;
  --canvas: #f6f8fc;
  --panel: #fbfcfe;
  --line: #e6eaf1;
  --line-strong: #dbe1eb;
  --ink: #25263d;
  --muted: #788198;
  --quiet: #9ca5b6;
  --green: #16b58a;
  --red: #d85d70;
  --sans: "Inter", "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.22,1,.36,1);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
html { background: var(--canvas); }
body { min-height: 100vh; overflow: hidden; background: var(--canvas); color: var(--ink); font: 14px/1.45 var(--sans); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
::selection { background: rgba(36,183,203,.2); color: var(--navy); }
* { scrollbar-width: thin; scrollbar-color: #cbd2df transparent; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 99px; background: #cbd2df; background-clip: padding-box; }

/* Authentication */
.login-page { display: block; height: 100vh; height: 100svh; overflow: auto; background: var(--canvas); }
.login-eyebrow { color: var(--indigo); font: 600 11px var(--mono); text-transform: uppercase; }
.login-heading h2 { margin: 10px 0 6px; font-size: 27px; font-weight: 800; letter-spacing: -.035em; }
.login-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-tabs { display: flex; gap: 4px; margin: 24px 0 20px; padding: 4px; border-radius: 12px; background: #eef1f8; }
.login-tab { flex: 1; padding: 11px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background .2s,color .2s; }
.login-tab.is-active { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(30,27,75,.12); }
.login-form { display: flex; flex-direction: column; gap: 15px; }
.login-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.login-field > span { color: var(--ink); font-size: 12px; font-weight: 600; }
.login-field small { color: var(--muted); font-size: 11px; }
.login-field input { width: 100%; min-width: 0; height: 46px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; outline: 0; background: #f8fafc; color: var(--ink); font-size: 14px; }
.login-field input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); background: #fff; }
.login-prefix { display: flex; align-items: center; height: 46px; border: 1px solid var(--line-strong); border-radius: 12px; background: #f8fafc; }
.login-prefix > span { padding-left: 14px; color: var(--indigo); font: 14px var(--mono); }
.login-prefix input { height: 44px; border: 0; background: transparent; }
.login-btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; margin-top: 4px; border: 0; border-radius: 14px; background: var(--navy); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .2s,transform .2s; }
.login-btn:hover:not(:disabled) { transform: translateY(-1px); background: var(--indigo); }
.login-btn:disabled { opacity: .65; cursor: wait; }
.login-footnote { margin: 22px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

/* Main shell: contact directory -> compact nav + drawer + conversation */
.app-shell {
  --nav-width: 260px;
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0,1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  transition: grid-template-columns .62s var(--ease);
}
.app-shell.has-chat { --nav-width: 80px; grid-template-columns: 80px 314px minmax(0,1fr); }
.app-shell[data-view="security"], .app-shell[data-view="settings"] { grid-template-columns: 260px minmax(0,1fr); }

/* Main navy sidebar */
.nav-rail {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--navy);
  color: #c5c7e6;
}
.brand-lockup {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 94px;
  min-width: 0;
  padding: 15px 20px;
  overflow: hidden;
}
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; }
.brand-mark img { display: block; width: 31px; height: 31px; object-fit: contain; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; opacity: 1; transform: translateX(0); transition: opacity .2s,transform .35s var(--ease); }
.brand-copy strong { color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .08em; }
.brand-copy small { color: #42c7df; font: 700 8px var(--mono); letter-spacing: .18em; white-space: nowrap; }
.nav-items { position: relative; display: flex; flex-direction: column; gap: 5px; width: 100%; padding: 0 0 0 16px; margin-top: 0; }
.nav-active-pill {
  position: absolute;
  z-index: 0;
  top: 0;
  right: 0;
  left: 16px;
  height: 48px;
  border-radius: 25px 0 0 25px;
  background: #f7f9fd;
  pointer-events: none;
  transform: translateY(0);
  transition: transform .58s var(--ease),height .3s var(--ease),left .45s var(--ease),right .45s var(--ease),border-radius .45s var(--ease);
}
.nav-active-pill::before, .nav-active-pill::after { position: absolute; right: 0; width: 18px; height: 18px; content: ""; background: transparent; }
.nav-active-pill::before { top: -18px; border-bottom-right-radius: 18px; box-shadow: 7px 7px 0 7px #f7f9fd; }
.nav-active-pill::after { bottom: -18px; border-top-right-radius: 18px; box-shadow: 7px -7px 0 7px #f7f9fd; }
.nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 48px;
  flex: 0 0 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 24px 0 0 24px;
  background: transparent;
  color: #9fa3cf;
  text-align: left;
  cursor: pointer;
  transition: color .25s,transform .28s var(--ease),padding .4s var(--ease);
}
.nav-item:hover { color: #fff; }
.nav-item.is-active { color: var(--navy); }
.nav-item svg { display: block; width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { overflow: hidden; font-size: 12px; font-weight: 650; white-space: nowrap; opacity: 1; transition: opacity .18s,transform .35s var(--ease); }
.nav-footer { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding: 14px 16px 18px; }
.logout-button { display: inline-flex; align-items: center; gap: 12px; width: 100%; min-height: 38px; padding: 0 5px; border: 0; border-radius: 11px; background: transparent; color: #a5a8ca; font-size: 11px; cursor: pointer; transition: color .2s,background .2s; }
.logout-button:hover { background: rgba(255,255,255,.08); color: #fff; }
.logout-button svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* In contact mode the main sidebar stays expanded. In chat mode it tucks into an icon rail. */
.app-shell.has-chat .brand-lockup { justify-content: center; padding-inline: 0; }
.app-shell.has-chat .brand-mark { width: 38px; height: 38px; }
.app-shell.has-chat .brand-copy { width: 0; opacity: 0; transform: translateX(-8px); }
.app-shell.has-chat .nav-items { padding: 0 10px; }
.app-shell.has-chat .nav-active-pill { right: 10px; left: 10px; border-radius: 17px; }
.app-shell.has-chat .nav-active-pill::before, .app-shell.has-chat .nav-active-pill::after { display: none; }
.app-shell.has-chat .nav-item { justify-content: center; gap: 0; padding: 0; border-radius: 16px; }
.app-shell.has-chat .nav-label { display: none; }
.app-shell.has-chat .nav-footer { align-items: center; padding-inline: 8px; }
.app-shell.has-chat .logout-button span { display: none; }
.app-shell.has-chat .logout-button { justify-content: center; width: 44px; }

/* Directory stage: one-column people list + welcome preview */
.directory-view {
  grid-column: 2;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #f7f9fd;
}
.directory-inner { display: flex; flex-direction: column; width: min(100%,1120px); min-height: 100%; margin: 0 auto; padding: 34px clamp(22px,3.6vw,58px) 30px; }
.directory-header { display: flex; align-items: center; gap: 9px; width: min(100%,880px); margin: 0 auto; }
.directory-heading-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(36,183,203,.1); }
.directory-header h1 { margin: 0; color: var(--navy); font-size: 20px; font-weight: 850; letter-spacing: -.045em; }
.directory-add-button { margin-left: 12px; }
.directory-count { margin-left: auto; color: #9aa3b5; font: 9px var(--mono); letter-spacing: .08em; }
.directory-content { display: grid; grid-template-columns: minmax(0,500px) minmax(300px,350px); justify-content: center; align-items: start; gap: 27px; width: 100%; margin: 25px auto 0; }
.directory-list-column { display: flex; flex-direction: column; min-width: 0; }
.add-contact-button { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 1px solid #dfe5ef; border-radius: 11px; background: #fff; color: #59627d; font-size: 10px; cursor: pointer; transition: border-color .2s,background .2s,transform .2s; }
.add-contact-button:hover { transform: translateY(-1px); border-color: #bfc5f7; background: #f6f6ff; color: var(--indigo); }
.add-contact-button > span { font-size: 17px; line-height: 1; }
.add-contact-button b { font-weight: 650; }
.search-field { display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 0 14px; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 5px 18px rgba(28,36,77,.025); transition: border-color .2s,box-shadow .2s; }
.search-field:focus-within { border-color: #a9dce4; box-shadow: 0 0 0 4px rgba(36,183,203,.08); }
.search-field svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: #a0a9b8; stroke-width: 1.8; stroke-linecap: round; }
.search-field input { width: 100%; min-width: 0; height: 35px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-field input::placeholder { color: #a2aaba; }
.search-field kbd, .composer-hint kbd { display: inline-grid; place-items: center; min-width: 19px; height: 20px; padding: 0 4px; border: 1px solid var(--line); border-radius: 6px; background: #f7f8fb; color: #929caf; font: 9px var(--mono); }
.contact-list { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; margin-top: 13px; padding: 0 1px 10px; }
.contact-item { position: relative; display: flex; align-items: center; gap: 13px; width: 100%; min-height: 76px; padding: 11px 13px; border: 1px solid #e7ebf2; border-radius: 17px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; box-shadow: 0 3px 10px rgba(27,35,73,.018); transition: transform .32s var(--ease),border-color .25s,background .25s,box-shadow .25s,border-radius .4s var(--ease); }
.contact-item:hover { transform: translateY(-2px); border-color: #d4d9ef; box-shadow: 0 9px 22px rgba(27,35,73,.06); }
.contact-avatar-wrap { position: relative; flex: 0 0 auto; }
.contact-avatar { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 13px; background: hsl(var(--avatar-hue,250) 70% 48%); color: #fff; font-size: 11px; font-weight: 800; }
.status-indicator { position: absolute; right: -2px; bottom: -1px; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: #aab2c2; }
.status-indicator.online { background: var(--green); box-shadow: 0 0 0 3px rgba(22,181,138,.1); }
.contact-detail { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; }
.contact-name-row { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.contact-name-row strong { overflow: hidden; color: #303149; font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.contact-preview { display: -webkit-box; overflow: hidden; color: #778299; font-size: 9px; line-height: 1.4; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.unread-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 7px; background: var(--indigo); color: #fff; font: 700 9px var(--mono); }
.contact-item::after { content: "›"; display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 24px; border-radius: 9px; background: #f2f5f9; color: #78839a; font-size: 19px; transition: background .2s,color .2s,transform .25s; }
.contact-item:hover::after { transform: translateX(2px); background: #e9edff; color: var(--indigo); }
.list-empty { padding: 24px 14px; border: 1px dashed #dce2ec; border-radius: 15px; background: rgba(255,255,255,.65); color: var(--muted); font-size: 11px; line-height: 1.7; text-align: center; }

/* Welcome card: directory's right-side preview */
.directory-welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 325px; padding: 29px 27px; border: 1px solid #e6eaf2; border-radius: 23px; background: #fff; box-shadow: 0 8px 26px rgba(29,38,79,.025); text-align: center; }
.welcome-art { position: relative; display: grid; place-items: center; width: 82px; height: 82px; margin-bottom: 16px; }
.welcome-icon { z-index: 1; display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid #c8f0f3; border-radius: 16px; background: #effdfe; color: #189fb1; box-shadow: 0 7px 18px rgba(36,183,203,.08); }
.welcome-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.welcome-orbit { position: absolute; width: 78px; height: 78px; border: 1px dashed #d7f0f2; border-radius: 50%; }
.welcome-orbit-two { width: 91px; height: 52px; transform: rotate(42deg); border-color: #e6eafb; }
.welcome-node { position: absolute; z-index: 2; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(36,183,203,.09); }
.welcome-node-one { top: 5px; right: 10px; }
.welcome-node-two { bottom: 5px; left: 10px; background: var(--indigo); box-shadow: 0 0 0 4px rgba(81,70,229,.08); }
.directory-welcome h2 { margin: 0; color: var(--navy); font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
.directory-welcome p { max-width: 270px; margin: 8px 0 0; color: #8590a4; font-size: 10px; line-height: 1.7; }
.welcome-divider { width: 100%; height: 1px; margin: 19px 0 15px; background: #edf0f5; }
.welcome-protocol { display: flex; align-items: center; gap: 7px; color: #6d8995; font: 8px var(--mono); letter-spacing: .04em; }
.welcome-protocol i { color: #bec7d1; font-style: normal; }
.welcome-protocol strong { color: #438798; font-size: 8px; font-weight: 700; }
.protocol-ready-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 3px rgba(36,183,203,.1); }
.welcome-caption { margin-top: 19px; color: #b1b8c5; font: 7px var(--mono); letter-spacing: .16em; }

/* Chat stage: the directory becomes a side drawer */
.app-shell.has-chat .directory-view { grid-column: 2; overflow: hidden; border-right: 1px solid #e8ebf2; background: #fafbfe; }
.app-shell.has-chat .directory-inner { width: 100%; min-height: 0; padding: 19px 0 16px 15px; }

.app-shell.has-chat .directory-content { display: flex; flex: 1; flex-direction: column; justify-content: flex-start; gap: 0; min-height: 0; margin: 0; }
.app-shell.has-chat .directory-list-column { flex: 1; min-height: 0; }
.app-shell.has-chat .directory-list-heading { display: flex; padding-right: 13px; }
.app-shell.has-chat .directory-list-heading h2 { font-size: 15px; }
.app-shell.has-chat .add-contact-button { width: 34px; justify-content: center; padding: 0; }
.app-shell.has-chat .add-contact-button b { display: none; }
.app-shell.has-chat .search-field { min-height: 42px; margin-right: 13px; padding-inline: 11px; border-radius: 12px; }
.app-shell.has-chat .search-field input { font-size: 10px; }
.app-shell.has-chat .contact-list { flex: 1; min-height: 0; gap: 6px; margin-top: 11px; padding: 0 0 8px; overflow-y: auto; }
.app-shell.has-chat .contact-item { min-height: 67px; padding: 9px 10px; border-color: transparent; border-right: 0; border-radius: 13px 0 0 13px; background: transparent; box-shadow: none; }
.app-shell.has-chat .contact-item:hover { transform: translateX(2px); border-color: transparent; background: #eef1fa; box-shadow: none; }
.app-shell.has-chat .contact-item.is-active { position: relative; z-index: 1; border-color: #e4e7f5; border-right: 0; border-radius: 16px 0 0 16px; background: #fff; box-shadow: 0 5px 16px rgba(29,38,79,.045); }
.app-shell.has-chat .contact-item.is-active .contact-name-row strong { color: var(--navy); }
.app-shell.has-chat .contact-item::after { content: "›"; }

/* Workspace / chat canvas */
.workspace { display: none; grid-column: 2; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
.app-shell.has-chat .workspace { display: flex; grid-column: 3; }
.app-shell[data-view="security"], .app-shell[data-view="settings"] { grid-template-columns: 260px minmax(0,1fr); }
.app-shell[data-view="security"] .directory-view, .app-shell[data-view="settings"] .directory-view { display: none; }
.app-shell[data-view="security"] .workspace, .app-shell[data-view="settings"] .workspace { display: flex; grid-column: 2; }
.app-shell[data-view="security"] #emptyState, .app-shell[data-view="settings"] #emptyState, .app-shell[data-view="security"] #conversationView, .app-shell[data-view="settings"] #conversationView { display: none !important; }
.empty-state { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.empty-state-icon { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; background: var(--navy); color: #fff; font-size: 26px; font-weight: 800; }
.empty-state h2 { margin: 18px 0 5px; color: var(--navy); font-size: 22px; letter-spacing: -.04em; }
.empty-state p { color: var(--muted); font-size: 11px; }
.conversation { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.conversation-header { display: flex; align-items: center; gap: 13px; min-height: 76px; flex: 0 0 76px; padding: 0 25px; border-bottom: 1px solid var(--line); background: #fff; }
.avatar { display: grid; place-items: center; width: 41px; height: 41px; flex: 0 0 auto; border: 1px solid #dce3ef; border-radius: 13px; background: #e9edff; color: var(--navy); font-weight: 750; }
.chat-avatar { width: 43px; height: 43px; border: 0; border-radius: 14px; background: #e7f5f9; color: #178ca2; font-size: 13px; }
.conversation-person { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.conversation-person strong { overflow: hidden; color: #292a43; font-size: 12px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.conversation-person > span { display: flex; align-items: center; gap: 7px; color: #8b94a6; font-size: 9px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #abb4c3; }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(22,181,138,.1); }
.status-divider { color: #c7cdd7; }
.conversation-caption { color: #9ba4b3; }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.protocol-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 10px; border: 1px solid #e0e9ec; border-radius: 9px; background: #f8fcfd; color: #69828c; font: 8px var(--mono); }
.protocol-chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.protocol-chip b { color: #278e9f; font-size: 8px; }
.conversation-banner { display: flex; align-items: center; gap: 9px; min-height: 42px; flex: 0 0 auto; padding: 0 24px; border-bottom: 1px solid #edf0f4; background: #f9fbfd; color: #8b95a7; font-size: 9px; }
.conversation-banner strong { margin-right: 3px; color: #647185; font-weight: 700; }
.banner-symbol { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 7px; background: #e9f8fa; color: #159db1; font-size: 14px; }
.banner-learn { margin-left: auto; color: #8e9dac; font: 8px var(--mono); white-space: nowrap; }
.messages { display: flex; flex: 1; flex-direction: column; gap: 22px; min-height: 0; overflow: auto; padding: 28px clamp(18px,3vw,42px) 30px; background: #fff; scroll-behavior: smooth; }
.message-row { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 6px; width: fit-content; max-width: min(76%,560px); }
.message-row.mine { align-self: flex-end; align-items: flex-end; }
.message-author { padding: 0 3px; color: #818b9e; font-size: 9px; font-weight: 650; }
.message-bubble { width: fit-content; min-width: 188px; max-width: 100%; padding: 13px 14px 12px; border: 1px solid #e6eaf1; border-radius: 5px 16px 16px 16px; background: #f7f9fc; color: var(--ink); }
.message-row.mine .message-bubble { border-color: #26235b; border-radius: 16px 5px 16px 16px; background: var(--navy); color: #fff; }
.message-lockline { display: flex; align-items: center; gap: 8px; color: #5f6a80; font-size: 10px; font-weight: 650; }
.message-row.mine .message-lockline { color: #e9e9fb; }
.message-lockicon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 7px; background: #e8ecfc; color: var(--indigo); font-size: 12px; }
.message-row.mine .message-lockicon { background: rgba(255,255,255,.13); color: #c7cbff; }
.message-stats { margin-top: 8px; color: #909aac; font: 8px var(--mono); letter-spacing: .04em; }
.message-row.mine .message-stats { color: #bdc0e0; }
.wave-mini-wrap { max-width: 100%; overflow-x: auto; margin-top: 8px; padding: 5px 7px; border: 1px solid #e5eaf2; border-radius: 8px; background: #fff; }
.message-row.mine .wave-mini-wrap { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); }
.wave-mini { display: block; max-width: none; }
.wave-mini-pending { display: grid; min-height: 46px; place-items: center; color: #8490a3; font: 9px var(--mono); }
.message-row.mine .wave-mini-pending { color: #d0d3e8; }
.decode-result { margin-top: 11px; padding: 10px 11px; border: 1px solid #e4e8f0; border-radius: 9px; background: #fff; color: var(--ink); }
.message-row.mine .decode-result { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.1); color: #fff; }
.decode-result-label { margin-bottom: 5px; color: var(--indigo); font: 700 8px var(--mono); letter-spacing: .1em; }
.message-row.mine .decode-result-label { color: #c7cbff; }
.decoded-text { overflow-wrap: anywhere; font-size: 12px; line-height: 1.6; }
.message-actions { display: flex; justify-content: flex-start; margin-top: 10px; }
.inspect-button { min-height: 28px; padding: 0 10px; border: 1px solid #dce3ee; border-radius: 8px; background: #fff; color: #5e6980; font-size: 9px; font-weight: 650; cursor: pointer; transition: border-color .2s,background .2s,color .2s; }
.inspect-button:hover { border-color: #b8c0f0; background: #f1f2ff; color: var(--indigo); }
.message-row.mine .inspect-button { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #f3f3ff; }
.message-row.mine .inspect-button:hover { background: rgba(255,255,255,.18); }
.message-bottom { display: flex; align-items: center; gap: 5px; padding: 0 3px; color: #a0a8b6; font: 8px var(--mono); }
.message-read { color: #5d8aab; }
.empty-messages { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 11px; text-align: center; }
.empty-messages strong { color: var(--navy); font-size: 14px; }
.composer { flex: 0 0 auto; padding: 13px clamp(16px,3vw,38px) 15px; border-top: 1px solid var(--line); background: #fff; }
.composer-inner { display: flex; align-items: center; gap: 10px; min-height: 55px; padding: 6px 7px 6px 14px; border: 1px solid #dfe5ef; border-radius: 15px; background: #fafbfd; transition: border-color .2s,box-shadow .2s,background .2s; }
.composer-inner:focus-within { border-color: #a8dce4; background: #fff; box-shadow: 0 0 0 4px rgba(36,183,203,.07); }
.composer-leading { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto; border-radius: 8px; background: #eaf8fa; color: #159db1; font-size: 17px; }
.composer-inner input { flex: 1; min-width: 0; height: 39px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.composer-inner input::placeholder { color: #a0a8b6; }
.message-counter { color: #9ca5b4; font: 8px var(--mono); white-space: nowrap; }
.send-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-width: 80px; height: 40px; padding: 0 13px; border: 0; border-radius: 11px; background: var(--navy); color: #fff; font-size: 10px; font-weight: 700; cursor: pointer; transition: background .2s,transform .25s var(--ease); }
.send-button:hover:not(:disabled) { transform: translateY(-1px); background: var(--indigo); }
.send-button:disabled { opacity: .55; cursor: wait; }
.send-button b { font-size: 15px; }
.composer-hint { display: flex; justify-content: space-between; gap: 12px; margin: 7px 3px 0; color: #a0a8b6; font: 8px var(--mono); }
.composer-hint i { margin: 0 4px; color: #c3c8d4; font-style: normal; }

/* Account pages */
.page-view { display: none; height: 100%; overflow: auto; padding: 42px clamp(22px,4vw,58px); background: #fff; }
.app-shell[data-view="security"] #securityView, .app-shell[data-view="settings"] #settingsView { display: block; }
.page-inner { width: min(100%,680px); margin: 0 auto; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: #78839a; font: 600 9px var(--mono); letter-spacing: .1em; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px rgba(36,183,203,.09); }
.page-view h1 { margin: 12px 0 7px; color: var(--navy); font-size: 28px; letter-spacing: -.05em; }
.page-lead { margin: 0 0 20px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.page-card { margin-top: 15px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfe; }
.page-card > strong { color: var(--ink); font-size: 12px; }
.page-card > p { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.75; }
.settings-profile { display: flex; align-items: center; gap: 12px; margin: 19px 0; }
.settings-profile > div:last-child { display: flex; flex-direction: column; gap: 4px; }
.settings-profile strong { color: var(--ink); font-size: 12px; }
.settings-profile span { color: var(--muted); font: 10px var(--mono); }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.settings-item > div { display: flex; flex-direction: column; gap: 5px; }
.settings-item strong { color: var(--ink); font-size: 11px; }
.settings-item span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.version-label { white-space: nowrap; font: 10px var(--mono) !important; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 11px; font-size: 11px; font-weight: 700; cursor: pointer; transition: background .2s,border-color .2s,transform .25s var(--ease); }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { border-color: var(--navy); background: var(--navy); color: #fff; }
.button-danger { border-color: #b83c4b; background: #b83c4b; color: #fff; }
.button-danger:hover:not(:disabled) { border-color: #982b39; background: #982b39; }
.danger-zone { border-color: rgba(184,60,75,.28); }
.danger-zone strong { color: #b83c4b; }
.button-primary:hover:not(:disabled) { border-color: var(--indigo); background: var(--indigo); }
.button-secondary { border-color: var(--line-strong); background: #fff; color: var(--navy); }
.button-secondary:hover:not(:disabled) { border-color: #c4c9f5; background: #f4f4ff; }
.button-quiet { border-color: var(--line); background: transparent; color: var(--muted); }
.button-quiet:hover:not(:disabled) { background: #f2f4f8; }

/* Dialogs + transmission inspector */
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid transparent; border-radius: 11px; background: transparent; color: #7d869e; cursor: pointer; }
.icon-button:hover { border-color: var(--line); background: #f4f6fb; color: var(--ink); }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-only { display: none; }
.modal { width: min(92vw,460px); max-height: min(88dvh,780px); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: 20px; background: #fff; color: var(--ink); box-shadow: 0 25px 80px rgba(20,25,60,.22); }
.modal::backdrop { background: rgba(20,24,52,.48); backdrop-filter: blur(4px); }
.modal-card { padding: 25px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-header h2 { margin: 7px 0 0; color: var(--ink); font-size: 21px; letter-spacing: -.04em; }
.dialog-close { margin: -5px -5px 0 0; font-size: 21px; }
.modal-description { margin: 13px 0 18px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; margin-top: 12px; }
.field > span { color: var(--ink); font-size: 11px; font-weight: 650; }
.field input { width: 100%; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; outline: 0; background: #f8f9fc; color: var(--ink); }
.field input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.input-prefix { display: flex; align-items: center; height: 44px; border: 1px solid var(--line-strong); border-radius: 11px; background: #f8f9fc; }
.input-prefix:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.input-prefix > span { padding-left: 12px; color: var(--indigo); font: 13px var(--mono); }
.input-prefix input { height: 42px; border: 0; background: transparent; box-shadow: none !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.unlocked-message { margin-top: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #f7f8fc; }
.unlocked-message .decode-result { margin: 0; }
.modal-wide { width: min(94vw,900px); }
.inspector-card { display: flex; flex-direction: column; max-height: min(88dvh,780px); overflow: hidden; }
.inspector-content { display: flex; flex-direction: column; gap: 15px; min-height: 0; overflow: auto; margin-top: 17px; }
.inspector-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.metric-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8f9fd; }
.metric-card span { display: block; color: var(--muted); font: 9px var(--mono); }
.metric-card strong { display: block; margin-top: 7px; color: var(--navy); font-size: 18px; }
.inspector-section { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fafbfe; }
.inspector-section h3 { margin: 0 0 10px; color: var(--ink); font-size: 11px; }
.inspector-section p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.inspector-frame-format { margin-top: 9px !important; color: var(--indigo) !important; font: 10px var(--mono) !important; }
.inspector-wave-note { margin-top: 8px !important; }
.inspector-binary-payload { color: #525d7e !important; font-family: var(--mono) !important; overflow-wrap: anywhere; }
.inspector-validation { color: var(--green) !important; }
.signal-scroll { max-width: 100%; overflow-x: auto; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #f6f8fd; }
.signal-large { display: block; height: 150px; }
.inspector-table-wrap { max-height: 250px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.inspector-table { width: 100%; border-collapse: collapse; font: 10px var(--mono); }
.inspector-table th, .inspector-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.inspector-table th { position: sticky; top: 0; background: #eef0ff; color: #454c78; font-weight: 650; }
.inspector-table td { color: #53607d; }
.inspector-table tr:last-child td { border-bottom: 0; }
.button-spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(79,70,229,.2); border-top-color: var(--indigo); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Responsive */
@media (max-width: 1100px) {
  .app-shell.has-chat { grid-template-columns: 80px 286px minmax(0,1fr); }
  .directory-inner { padding-inline: 25px; }
  .directory-content { grid-template-columns: minmax(0,1fr); max-width: 520px; gap: 20px; }
  .directory-welcome { display: none; }
}
@media (max-width: 850px) and (min-width: 701px) {
  .app-shell { --nav-width: 220px; }
  .app-shell[data-view="security"], .app-shell[data-view="settings"] { grid-template-columns: 220px minmax(0,1fr); }
  .app-shell.has-chat { grid-template-columns: 72px 250px minmax(0,1fr); }
  .brand-lockup { padding-inline: 15px; }
  .directory-inner { padding: 28px 22px; }
  .directory-content { grid-template-columns: minmax(0,1fr); max-width: 520px; }
  .directory-welcome { display: none; }
  .app-shell.has-chat .directory-inner { padding-left: 10px; }
}
@media (max-width: 700px) {
  body { overflow: hidden; }
  .app-shell, .app-shell.has-chat, .app-shell[data-view="security"], .app-shell[data-view="settings"] {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    transition: none;
  }
  .nav-rail { order: 2; flex: 0 0 66px; flex-direction: row; align-items: center; justify-content: center; width: 100%; min-height: 66px; padding: 6px 14px calc(6px + env(safe-area-inset-bottom,0px)); }
  .brand-lockup { display: none; }
  .nav-items { flex: 1; flex-direction: row; justify-content: center; gap: 7px; width: auto; padding: 0; }
  .nav-active-pill { top: 0; right: auto; left: 0; width: 48px; height: 46px; border-radius: 14px; }
  .nav-active-pill::before, .nav-active-pill::after { display: none; }
  .nav-item { justify-content: center; width: 48px; height: 46px; flex: 0 0 48px; padding: 0; border-radius: 14px; }
  .nav-item .nav-label { display: none; }
  .nav-footer { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 0 0 0 8px; }
  .logout-button span { display: none; }
  .logout-button { justify-content: center; width: 38px; min-height: 40px; padding: 0; }
  .directory-view { order: 1; flex: 1; width: 100%; min-height: 0; border: 0; overflow: auto; }
  .directory-inner { width: 100%; min-height: 100%; padding: 24px 16px; }
  .directory-header { width: 100%; }
  .directory-header h1 { font-size: 17px; }
  .directory-count { font-size: 8px; }
  .directory-content { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
  .search-field { min-height: 48px; border-radius: 13px; }
  .contact-list { overflow: visible; }
  .directory-welcome { min-height: 240px; padding: 20px; border-radius: 18px; }
  .welcome-art { width: 65px; height: 65px; margin-bottom: 9px; }
  .welcome-icon { width: 49px; height: 49px; }
  .welcome-icon svg { width: 25px; height: 25px; }
  .app-shell.has-chat .directory-view { display: none; }
  .workspace, .app-shell.has-chat .workspace, .app-shell[data-view="security"] .workspace, .app-shell[data-view="settings"] .workspace { display: flex; order: 1; flex: 1; width: 100%; min-height: 0; }
  .app-shell.has-chat .nav-rail, .app-shell[data-view="security"] .nav-rail, .app-shell[data-view="settings"] .nav-rail { order: 2; }
  .conversation-header { min-height: 65px; flex-basis: 65px; gap: 9px; padding: 0 12px; }
  .mobile-only { display: inline-grid; }
  .chat-avatar { width: 37px; height: 37px; border-radius: 12px; }
  .conversation-person strong { max-width: min(62vw,280px); font-size: 11px; }
  .header-tools { display: none; }
  .conversation-banner { min-height: 39px; gap: 7px; padding: 0 12px; font-size: 8px; }
  .conversation-banner strong, .banner-learn { display: none; }
  .messages { gap: 16px; padding: 17px 12px 20px; }
  .message-row { max-width: 91%; }
  .composer { padding: 9px 10px calc(11px + env(safe-area-inset-bottom,0px)); }
  .composer-inner { min-height: 50px; gap: 7px; padding-left: 9px; }
  .composer-leading, .message-counter { display: none; }
  .composer-inner input { font-size: 11px; }
  .send-button { min-width: 66px; height: 37px; padding: 0 10px; }
  .composer-hint { font-size: 8px; }
  .composer-hint > span:last-child { display: none; }
  .page-view { padding: 24px 16px; }
  .modal { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .modal-card { padding: 20px; }
  .inspector-card { max-height: calc(100dvh - 20px); }
  .inspector-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 390px) {
  .directory-header h1 { font-size: 15px; }
  .directory-inner { padding-inline: 12px; }
  .contact-item { min-height: 68px; padding: 9px; }
  .message-row { max-width: 96%; }
  .message-bubble { min-width: 0; }
  .composer-hint { font-size: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* ==========================================================================
   Poppins + motion polish
   Refined soft-surface palette and synchronized three-track layout animation.
   ========================================================================== */
:root {
  color-scheme: light;
  --surface: #f5f6fa;
  --canvas: #eaedf4;
  --panel: #f0f2f7;
  --line: #d5dbe6;
  --line-strong: #c3ccda;
  --ink: #25283d;
  --muted: #59667f;
  --quiet: #77839a;
  --directory-bg: #eff1f7;
  --directory-card: #f8f9fc;
  --chat-surface: #f1f3f8;
  --nav-pill-fill: #eff2f8;
  --sans: "Poppins", system-ui, sans-serif;
  --ease: cubic-bezier(.22,1,.36,1);
}

body,
button,
input {
  font-family: var(--sans);
}

body { background: var(--canvas); color: var(--ink); }

/* Keep the same three grid tracks in both modes. Unlike changing from two
   tracks to three, this allows the rail and contact drawer to interpolate. */
.app-shell {
  grid-template-columns: 260px 0px minmax(0,1fr);
  background: var(--canvas);
  transition: grid-template-columns .76s var(--ease);
}
.app-shell.has-chat {
  grid-template-columns: 80px 314px minmax(0,1fr);
}
.app-shell[data-view="security"],
.app-shell[data-view="settings"] {
  grid-template-columns: 260px 0px minmax(0,1fr);
}

.nav-rail {
  overflow: visible;
  z-index: 12;
  transition: background-color .3s ease;
}
.brand-lockup {
  gap: 12px;
  transition: gap .65s var(--ease), padding .65s var(--ease), flex-basis .65s var(--ease);
}
.brand-copy {
  max-width: 150px;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width .62s var(--ease), opacity .24s ease, transform .62s var(--ease);
}
.app-shell.has-chat .brand-lockup {
  gap: 0;
  padding-inline: 0;
}
.app-shell.has-chat .brand-copy {
  max-width: 0;
  opacity: 0;
  transform: translateX(-9px);
}

.nav-items {
  padding: 0 0 0 16px;
  transition: padding .68s var(--ease);
}
.nav-active-pill {
  background: var(--nav-pill-fill);
  will-change: transform, left, right, border-radius;
  transition:
    transform .72s var(--ease),
    height .55s var(--ease),
    left .68s var(--ease),
    right .68s var(--ease),
    border-radius .55s var(--ease),
    background-color .3s ease;
}
.nav-active-pill::before,
.nav-active-pill::after {
  display: block;
  opacity: 1;
  transform: scale(1);
  transform-origin: right center;
  will-change: transform;
  /* Match the pill's horizontal edge transition exactly. */
  transition: transform .68s var(--ease);
}
/* Concave corner pieces are painted with the pill's own fill color via a
   radial gradient, so they always attach to the pill in any theme and stay
   inside the rail (no box-shadow overhang into the directory area).
   Height is 19px so each piece overlaps the pill by 1px and leaves no seam. */
.nav-active-pill::before,
.nav-active-pill::after {
  height: 19px;
  border-radius: 0;
  box-shadow: none;
  background: var(--nav-pill-fill);
  transition: transform .68s var(--ease), background-color .3s ease;
}
.nav-active-pill::before {
  top: -18px;
  -webkit-mask-image: radial-gradient(circle at 0 0, transparent 17.5px, #000 18px);
  mask-image: radial-gradient(circle at 0 0, transparent 17.5px, #000 18px);
}
.nav-active-pill::after {
  bottom: -18px;
  -webkit-mask-image: radial-gradient(circle at 0 100%, transparent 17.5px, #000 18px);
  mask-image: radial-gradient(circle at 0 100%, transparent 17.5px, #000 18px);
}

/* Expanded rail: the active pill takes the exact background of the page it
   opens, so the tab and the page read as one surface. The compact icon rail
   (has-chat) keeps the neutral --nav-pill-fill defined per theme. */
.app-shell:not(.has-chat)[data-view="contacts"] {
  --nav-pill-fill: var(--directory-bg);
}
.app-shell:not(.has-chat)[data-view="security"],
.app-shell:not(.has-chat)[data-view="settings"] {
  --nav-pill-fill: var(--surface);
}
html[data-theme="dark"] .app-shell:not(.has-chat)[data-view="security"],
html[data-theme="dark"] .app-shell:not(.has-chat)[data-view="settings"] {
  --nav-pill-fill: var(--chat-surface);
}
.app-shell.has-chat .nav-items { padding: 0 10px; }
.app-shell.has-chat .nav-active-pill {
  right: 10px;
  left: 10px;
  border-radius: 17px;
}
/* Retract the concave edge pieces into the pill as the rail narrows.
   Keeping opacity fixed avoids a fade: the right edge changes shape instead. */
.app-shell.has-chat .nav-active-pill::before,
.app-shell.has-chat .nav-active-pill::after {
  /* Keep these rendered: display:none would prevent the reverse morph. */
  display: block !important;
  opacity: 1;
  transform: scale(0);
}
.nav-item {
  transition:
    color .25s ease,
    transform .32s var(--ease),
    padding .68s var(--ease),
    border-radius .56s var(--ease),
    gap .56s var(--ease);
}
.nav-label {
  display: block;
  max-width: 128px;
  opacity: 1;
  transform: translateX(0);
  transition: max-width .58s var(--ease), opacity .22s ease, transform .5s var(--ease);
}
.app-shell.has-chat .nav-item {
  justify-content: center;
  gap: 0;
  padding: 0;
  border-radius: 16px;
}
.app-shell.has-chat .nav-label {
  max-width: 0;
  opacity: 0;
  transform: translateX(-7px);
}
.nav-footer {
  transition: padding .65s var(--ease), gap .5s var(--ease);
}
.app-shell.has-chat .nav-footer { align-items: center; padding-inline: 8px; }
.app-shell.has-chat .logout-button span {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  transition: max-width .5s var(--ease), opacity .18s ease;
}
.app-shell.has-chat .logout-button { justify-content: center; width: 44px; }

/* Directory spans the zero-width middle track in stage one. It then becomes
   the drawer when that track grows to 314px in stage two. */
.directory-view {
  grid-column: 2 / 4;
  grid-row: 1;
  z-index: 2;
  overflow: auto;
  background: var(--directory-bg);
}
.directory-inner {
  width: min(100%,1120px);
  transition: opacity .14s ease, padding .72s var(--ease), width .72s var(--ease);
}
.directory-header {
  max-height: none;
  overflow: visible;
  transform: none;
  opacity: 1;
  transition: none;
}
.directory-content {
  grid-template-columns: minmax(0,1fr) minmax(0,350px);
  max-width: 880px;
  transition: grid-template-columns .72s var(--ease), margin .62s var(--ease), gap .62s var(--ease);
}
.directory-list-column {
  width: 100%;
  max-width: 500px;
  justify-self: end;
}
.directory-list-heading {
  display: flex;
  max-height: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height .5s var(--ease), opacity .2s ease, transform .5s var(--ease), padding .5s var(--ease);
}
.directory-welcome {
  width: 350px;
  max-width: 100%;
  background: var(--directory-card);
  border-color: var(--line);
  transition: opacity .25s ease, transform .62s var(--ease), background-color .3s ease;
}
.app-shell.has-chat .directory-view {
  grid-column: 2;
  overflow: visible;
  border-right: 1px solid var(--line);
  background: var(--directory-bg);
}
.app-shell.has-chat .directory-inner {
  width: 100%;
  min-height: 0;
  padding: 19px 0 16px 15px;
  margin: 0;
}
.app-shell.has-chat .directory-header {
  max-height: none;
  width: 100%;
  margin: 0;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.app-shell.has-chat .directory-header { padding-right: 13px; }
.app-shell.has-chat .directory-header .directory-add-button { margin-left: auto; }
.app-shell.has-chat .directory-content {
  display: grid;
  grid-template-columns: minmax(0,1fr) 0px;
  gap: 0;
  max-width: none;
  min-height: 0;
  margin: 10px 0 0;
}
.app-shell.has-chat .directory-list-column {
  max-width: none;
  min-height: 0;
}
.app-shell.has-chat .directory-welcome {
  width: 0;
  min-width: 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  padding: 0;
  border-width: 0;
  opacity: 0;
  transform: translateX(18px) scale(.98);
  pointer-events: none;
}
.app-shell.has-chat .search-field {
  min-height: 42px;
  margin-right: 13px;
  padding-inline: 11px;
  border-radius: 12px;
  background: var(--directory-card);
}
.app-shell.has-chat .contact-list {
  flex: 1;
  min-height: 0;
  gap: 6px;
  margin-top: 11px;
  padding: 0 24px 12px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.app-shell.has-chat .contact-item {
  min-height: 67px;
  margin-right: 0;
  padding: 9px 10px;
  border-color: transparent;
  border-right: 0;
  border-radius: 13px 0 0 13px;
  background: transparent;
  box-shadow: none;
}
.app-shell.has-chat .contact-item:hover {
  transform: translateX(2px);
  border-color: transparent;
  background: #e7ebf3;
  box-shadow: none;
}
.app-shell.has-chat .contact-item.is-active {
  position: relative;
  z-index: 1;
  margin-right: -16px;
  border-color: #d6dce7;
  border-right: 0;
  border-radius: 16px 0 0 16px;
  background: var(--chat-surface);
  box-shadow: 0 5px 16px rgba(29,38,79,.045);
}
.app-shell.has-chat .contact-item.is-active .contact-name-row strong { color: var(--navy); }
.app-shell.has-chat .contact-item::after { content: "›"; }

/* The chat canvas is underneath the directory while stage one is active.
   Keeping it mounted lets opacity + translate animate on selection. */
.workspace {
  display: flex;
  grid-column: 3;
  grid-row: 1;
  z-index: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--chat-surface);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(16px);
  transition:
    opacity .38s ease,
    transform .72s var(--ease),
    visibility 0s linear .72s,
    background-color .3s ease;
}
.app-shell.has-chat .workspace {
  display: flex;
  grid-column: 3;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition:
    opacity .42s ease .13s,
    transform .72s var(--ease),
    visibility 0s linear 0s,
    background-color .3s ease;
}
.app-shell[data-view="security"] .directory-view,
.app-shell[data-view="settings"] .directory-view { display: none; }
.app-shell[data-view="security"] .workspace,
.app-shell[data-view="settings"] .workspace {
  display: flex;
  grid-column: 2 / 4;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity .32s ease, transform .52s var(--ease), visibility 0s;
}
.app-shell[data-view="security"] #emptyState,
.app-shell[data-view="settings"] #emptyState,
.app-shell[data-view="security"] #conversationView,
.app-shell[data-view="settings"] #conversationView { display: none !important; }

/* Softer surfaces with clearer text and separators. */
.login-card { background: var(--surface); border-color: var(--line); }
.login-field input, .login-prefix { background: #eceff5; border-color: var(--line-strong); color: var(--ink); }
.login-heading p, .login-field small { color: var(--muted); }
.directory-header h1, .directory-list-heading h2, .directory-welcome h2 { color: var(--navy); }
.directory-list-heading h2 { font-family: var(--sans); }
.search-field, .contact-item, .directory-welcome, .page-card {
  background-color: var(--directory-card);
  border-color: var(--line);
}
.contact-item { color: var(--ink); }
.contact-name-row strong, .conversation-person strong { color: var(--ink); }
.contact-preview, .directory-welcome p, .conversation-person > span { color: var(--muted); }
.search-field input { color: var(--ink); }
.search-field input::placeholder { color: #7c879c; }
.search-field kbd { background: #e9edf4; border-color: #ccd4e1; color: #5f6b82; }
.contact-item:hover { border-color: #c4cddd; background: #f0f3f8; }
.directory-welcome { border-color: #d6dce7; }
.workspace, .messages { background: var(--chat-surface); }
.conversation-header, .composer { background: #f6f7fb; border-color: var(--line); }
.conversation-banner { background: #eceff5; border-color: #d9dfe9; color: #59677e; }
.message-bubble { background: #e9edf4; border-color: #d1d9e5; }
.message-lockline { color: #47546c; }
.message-stats, .message-bottom { color: #66738b; }
.message-row.mine .message-bubble { background: var(--navy); border-color: #34316c; }
.composer-inner { background: #edf0f6; border-color: #cbd3e0; }
.composer-inner:focus-within { background: #f8f9fc; border-color: #86cdd7; }
.composer-inner input { color: var(--ink); }
.composer-inner input::placeholder { color: #77839a; }
.message-counter, .composer-hint { color: #68758b; }
.protocol-chip, .search-field, .page-card { box-shadow: 0 4px 14px rgba(25,24,71,.035); }
.page-view { background: var(--surface); }
.page-view h1, .metric-card strong { color: var(--navy); }
.page-card > p, .page-lead { color: var(--muted); }
.metric-card, .inspector-section { background: #f0f2f7; border-color: #d2d9e5; }
.inspector-section p { color: #59667f; }
.signal-scroll { background: #eceff5; border-color: #cbd3df; }

/* Intermediate desktop and tablet tracks stay aligned with the same 3-column
   model so they animate instead of snapping. */
@media (max-width: 1100px) and (min-width: 851px) {
  .app-shell { grid-template-columns: 260px 0px minmax(0,1fr); }
  .app-shell.has-chat { grid-template-columns: 80px 286px minmax(0,1fr); }
  .directory-content { grid-template-columns: minmax(0,1fr) 0px; max-width: 520px; }
  .directory-welcome { display: none; }
}
@media (max-width: 850px) and (min-width: 701px) {
  .app-shell { grid-template-columns: 220px 0px minmax(0,1fr); }
  .app-shell.has-chat { grid-template-columns: 72px 250px minmax(0,1fr); }
  .app-shell[data-view="security"], .app-shell[data-view="settings"] { grid-template-columns: 220px 0px minmax(0,1fr); }
  .directory-content { grid-template-columns: minmax(0,1fr) 0px; max-width: 520px; }
  .directory-welcome { display: none; }
}
@media (max-width: 700px) {
  .app-shell, .app-shell.has-chat, .app-shell[data-view="security"], .app-shell[data-view="settings"] {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    transition: none;
  }
  .nav-rail { overflow: hidden; }
  .workspace { display: none; }
  .app-shell.has-chat .workspace,
  .app-shell[data-view="security"] .workspace,
  .app-shell[data-view="settings"] .workspace {
    display: flex;
    grid-column: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: none;
  }
  .app-shell:not(.has-chat):not([data-view="security"]):not([data-view="settings"]) .workspace { display: none; }
  .directory-view { grid-column: auto; }
  .app-shell.has-chat .directory-view { display: none; }
  .directory-inner { transition: none; }
  .app-shell.has-chat .directory-content { display: flex; }
  .app-shell.has-chat .directory-welcome { display: none; }
  .app-shell.has-chat .directory-header { display: none; }
  .app-shell.has-chat .directory-list-heading { max-height: 52px; opacity: 1; }
  .app-shell.has-chat .contact-list { padding-right: 0; }
  .app-shell.has-chat .contact-item.is-active { margin-right: 0; border-radius: 14px; }
}

/* Brand lockup: keep the mark anchored while the wordmark folds away.
   The label reveals through its width instead of fading/sliding independently. */
.brand-lockup {
  justify-content: flex-start;
  gap: 12px;
  transition: gap .76s var(--ease), padding .76s var(--ease), flex-basis .76s var(--ease);
}
.brand-mark {
  transition: width .76s var(--ease), height .76s var(--ease);
}
.brand-copy {
  width: 150px;
  max-width: 150px;
  flex: 0 1 150px;
  min-width: 0;
  overflow: hidden;
  opacity: 1;
  transform: translateX(0);
  transition:
    width .76s var(--ease),
    max-width .76s var(--ease),
    flex-basis .76s var(--ease);
}
.app-shell.has-chat .brand-lockup {
  justify-content: flex-start;
  gap: 0;
  padding-inline: 20px;
}
.app-shell.has-chat .brand-mark {
  width: 38px;
  height: 38px;
}
.app-shell.has-chat .brand-copy {
  width: 0;
  max-width: 0;
  flex-basis: 0;
  opacity: 1;
  transform: translateX(0);
}


/* Fixed icon anchors: the compact state only applies a small offset,
   never a justify-content switch that would snap the icons. */
@media (min-width: 701px) {
  .nav-footer .logout-button {
    padding-left: 14px;
    transition: padding .68s var(--ease), color .2s, background .2s;
  }

  .app-shell.has-chat .nav-item {
    justify-content: flex-start;
    padding: 0 0 0 20px;
  }

  .app-shell.has-chat .nav-footer {
    align-items: flex-start;
    padding-inline: 20px 0;
  }

  .app-shell.has-chat .logout-button {
    justify-content: flex-start;
    width: 44px;
    padding-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell, .nav-active-pill, .nav-item, .nav-label, .directory-inner,
  .directory-header, .directory-content, .directory-welcome, .workspace,
  .brand-copy, .brand-lockup, .nav-items {
    transition-duration: .01ms !important;
  }
}


/* Comfortable message reading: neutral light surfaces and consistent ink
   for both incoming and outgoing bubbles. */
:root {
  --chat-surface: #f1f3f6;
  --message-ink: #29364b;
  --message-muted: #637188;
}
.messages {
  background: var(--chat-surface);
  color: var(--message-ink);
}
.message-author {
  color: #5e6d83;
  font-size: 12px;
}
.message-bubble,
.message-row.mine .message-bubble {
  border: 1px solid #d9e0e9;
  background: #ffffff;
  color: var(--message-ink);
}
.message-row.mine .message-bubble {
  border-color: #d3dce9;
  background: #e9eef6;
}
.message-lockline,
.message-row.mine .message-lockline {
  color: #40516a;
  font-size: 11px;
}
.message-lockicon,
.message-row.mine .message-lockicon {
  background: #e7edf5;
  color: #4d6283;
}
.message-stats,
.message-row.mine .message-stats {
  color: var(--message-muted);
  font-size: 9px;
}
.message-lock-state {
  margin-left: auto;
  padding: 3px 7px;
  border: 1px solid #dbe2eb;
  border-radius: 999px;
  background: #f6f8fb;
  color: #62718a;
  font: 700 8px var(--mono);
  letter-spacing: .05em;
}
.wave-mini-wrap,
.message-row.mine .wave-mini-wrap {
  border-color: #d8e0e9;
  background: #f8fafc;
}
.wave-mini-caption {
  margin: 0 0 5px;
  color: #65738a;
  font: 700 8px var(--mono);
  letter-spacing: .06em;
}
.decode-result,
.message-row.mine .decode-result {
  border-color: #d9e1eb;
  background: #f8fafc;
  color: var(--message-ink);
}
.decode-result-label,
.message-row.mine .decode-result-label {
  color: #52658f;
  font-size: 9px;
}
.decoded-text {
  display: block;
  color: var(--message-ink);
  font-size: 15px;
  line-height: 1.75;
}
.message-actions { flex-wrap: wrap; gap: 7px; }
.inspect-button,
.message-row.mine .inspect-button {
  min-height: 31px;
  border-color: #ccd6e3;
  background: #f9fafc;
  color: #40516a;
  font-size: 12px;
}
.inspect-button:hover,
.message-row.mine .inspect-button:hover {
  border-color: #aebbd0;
  background: #eef2f7;
  color: #273a58;
}
.message-bottom {
  color: #65738a;
  font-size: 11px;
}
.message-read { color: #39775f; }
.workspace, .messages { background: var(--chat-surface); }

/* Higher contrast transmission details without harsh black-on-white glare. */
.inspector-section {
  background: #fbfcfd;
  border-color: #d9e1ea;
}
.inspector-section h3 { color: #34445c; font-size: 12px; }
.inspector-section p { color: #526178; font-size: 11px; }
.metric-card {
  background: #f3f6fa;
  border-color: #d8e0e9;
}
.metric-card span { color: #62718a; font-size: 10px; }
.metric-card strong { color: #2f4059; }
.inspector-table th {
  background: #eaf0f6;
  color: #3a4b63;
}
.inspector-table td { color: #3d4d63; }
.inspector-binary-payload { color: #34445c !important; }
.inspector-validation { color: #34745b !important; }
.signal-scroll {
  background: #f8fafc;
  border-color: #d8e0e9;
}
.inspector-decoded-message {
  padding: 12px 13px;
  border: 1px solid #dce3ec;
  border-radius: 9px;
  background: #f2f5f9;
  color: #29364b;
  font-size: 13px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.inspector-code-block {
  overflow-wrap: anywhere;
  padding: 11px 12px;
  border: 1px solid #dce3ec;
  border-radius: 9px;
  background: #f2f5f9;
  color: #34445c;
  font: 11px/1.8 var(--mono);
}


/* ==========================================================================
   Dark mode · persistent theme + circular portal reveal
   ========================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #e7edf6;
  --navy-soft: #c8d3e3;
  --indigo: #aaa7ff;
  --cyan: #65c9d6;
  --surface: #1a2533;
  --canvas: #111a26;
  --panel: #1d2938;
  --line: #2d3b4d;
  --line-strong: #405168;
  --ink: #e3eaf3;
  --muted: #a3b0c2;
  --quiet: #8292a8;
  --green: #53c49b;
  --red: #ee8797;
  --directory-bg: #172331;
  --directory-card: #202d3d;
  --chat-surface: #131e2b;
  --nav-pill-fill: #304157;
  --message-ink: #e4ebf4;
  --message-muted: #a2b0c3;
}
html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--canvas);
  color: var(--ink);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .app-shell {
  background: var(--canvas);
}
html[data-theme="dark"] ::selection {
  background: rgba(101,201,214,.25);
  color: #f5f8fc;
}
html[data-theme="dark"] * {
  scrollbar-color: #46576c transparent;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #46576c;
  background-clip: padding-box;
}

/* Navigation rail remains deep; labels and icons stay readable. */
html[data-theme="dark"] .nav-rail,
html[data-theme="dark"] .login-side {
  background: #101925;
  color: #d0d9e7;
}
html[data-theme="dark"] .brand-copy strong { color: #f5f7fb; }
html[data-theme="dark"] .brand-copy small { color: #6ccbd8; }
html[data-theme="dark"] .nav-item { color: #a9b7ca; }
html[data-theme="dark"] .nav-item:hover { color: #fff; }
html[data-theme="dark"] .nav-item.is-active { color: #f4f7fb; }
html[data-theme="dark"] .nav-active-pill {
  background: var(--nav-pill-fill);
}
html[data-theme="dark"] .logout-button { color: #a9b7ca; }
html[data-theme="dark"] .logout-button:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

/* Login screen */
html[data-theme="dark"] .login-page,
html[data-theme="dark"] .login-main {
  background: var(--canvas);
}
html[data-theme="dark"] .login-side { background: #101925; }
html[data-theme="dark"] .login-card {
  border-color: var(--line);
  background: #1a2533;
  box-shadow: 0 18px 48px -24px rgba(0,0,0,.55);
}
html[data-theme="dark"] .login-heading h2,
html[data-theme="dark"] .login-field > span { color: var(--ink); }
html[data-theme="dark"] .login-tabs { background: #263447; }
html[data-theme="dark"] .login-tab { color: #a8b6c8; }
html[data-theme="dark"] .login-tab.is-active {
  background: #3a4a60;
  color: #f2f5f9;
  box-shadow: none;
}
html[data-theme="dark"] .login-field input,
html[data-theme="dark"] .login-prefix {
  border-color: var(--line-strong);
  background: #172230;
  color: var(--ink);
}
html[data-theme="dark"] .login-field input:focus,
html[data-theme="dark"] .login-prefix:focus-within {
  border-color: #65bdcb;
  background: #1b2939;
}
html[data-theme="dark"] .login-prefix input { background: transparent; }
html[data-theme="dark"] .login-btn {
  background: #3c4f69;
  color: #f4f7fb;
}
html[data-theme="dark"] .login-btn:hover:not(:disabled) { background: #506887; }

/* Directory and contacts */
html[data-theme="dark"] .directory-view {
  background: var(--directory-bg);
}
html[data-theme="dark"] .directory-count,
html[data-theme="dark"] .directory-overline { color: #91a0b4; }
html[data-theme="dark"] .directory-list-heading h2,
html[data-theme="dark"] .directory-header h1,
html[data-theme="dark"] .directory-welcome h2 { color: #e5edf6; }
html[data-theme="dark"] .add-contact-button {
  border-color: var(--line-strong);
  background: #202d3d;
  color: #c3cfde;
}
html[data-theme="dark"] .add-contact-button:hover {
  border-color: #627a96;
  background: #2a3a4e;
  color: #eef4fa;
}
html[data-theme="dark"] .search-field {
  border-color: var(--line);
  background: #202d3d;
  box-shadow: none;
}
html[data-theme="dark"] .search-field:focus-within {
  border-color: #5798a6;
  box-shadow: 0 0 0 4px rgba(101,201,214,.09);
}
html[data-theme="dark"] .search-field svg { stroke: #8fa0b5; }
html[data-theme="dark"] .search-field input { color: var(--ink); }
html[data-theme="dark"] .search-field input::placeholder { color: #8291a6; }
html[data-theme="dark"] .search-field kbd,
html[data-theme="dark"] .composer-hint kbd {
  border-color: #415168;
  background: #27364a;
  color: #b4c0d0;
}
html[data-theme="dark"] .contact-item {
  border-color: #2b3a4d;
  background: #1c2938;
  color: var(--ink);
  box-shadow: none;
}
html[data-theme="dark"] .contact-item:hover {
  border-color: #40546c;
  background: #253549;
  box-shadow: none;
}
html[data-theme="dark"] .contact-name-row strong { color: #e5edf6; }
html[data-theme="dark"] .contact-preview { color: #9aaac0; }
html[data-theme="dark"] .status-indicator { border-color: #1c2938; }
html[data-theme="dark"] .contact-item::after {
  background: #2a394d;
  color: #bac7d7;
}
html[data-theme="dark"] .contact-item:hover::after {
  background: #354861;
  color: #e7eff8;
}
html[data-theme="dark"] .list-empty {
  border-color: #405168;
  background: rgba(31,44,60,.8);
  color: #a7b4c6;
}
html[data-theme="dark"] .directory-welcome {
  border-color: var(--line);
  background: #1d2a39;
  box-shadow: none;
}
html[data-theme="dark"] .directory-welcome p { color: #a3b1c4; }
html[data-theme="dark"] .welcome-divider { background: #344255; }
html[data-theme="dark"] .welcome-protocol { color: #9bb3bf; }
html[data-theme="dark"] .welcome-caption { color: #7d8da2; }
html[data-theme="dark"] .app-shell.has-chat .directory-view {
  border-right-color: var(--line);
  background: var(--directory-bg);
}
html[data-theme="dark"] .app-shell.has-chat .contact-item.is-active {
  border-color: #3b4b60;
  background: var(--chat-surface);
  box-shadow: 0 5px 16px rgba(0,0,0,.16);
}
html[data-theme="dark"] .app-shell.has-chat .contact-item.is-active .contact-name-row strong {
  color: #eff4fa;
}
html[data-theme="dark"] .app-shell.has-chat .contact-item:hover {
  background: #26364a;
}

/* Conversation surfaces */
html[data-theme="dark"] .workspace,
html[data-theme="dark"] .messages,
html[data-theme="dark"] .page-view {
  background: var(--chat-surface);
  color: var(--ink);
}
html[data-theme="dark"] .conversation-header,
html[data-theme="dark"] .composer {
  border-color: var(--line);
  background: #192635;
}
html[data-theme="dark"] .conversation-person strong { color: #e8eef6; }
html[data-theme="dark"] .conversation-person > span { color: #9eacc0; }
html[data-theme="dark"] .status-dot { background: #65758a; }
html[data-theme="dark"] .status-divider,
html[data-theme="dark"] .conversation-caption { color: #8393a9; }
html[data-theme="dark"] .chat-avatar {
  background: #263d50;
  color: #8ed5df;
}
html[data-theme="dark"] .protocol-chip {
  border-color: #34465a;
  background: #202f40;
  color: #a8bbca;
}
html[data-theme="dark"] .protocol-chip b { color: #76cbd4; }
html[data-theme="dark"] .conversation-banner {
  border-color: var(--line);
  background: #1d2a39;
  color: #a4b1c3;
}
html[data-theme="dark"] .conversation-banner strong { color: #d3dce8; }
html[data-theme="dark"] .banner-symbol {
  background: #29404c;
  color: #7dd1dc;
}
html[data-theme="dark"] .banner-learn { color: #90a2b8; }
html[data-theme="dark"] .message-row.mine .message-bubble {
  border-color: #3a4b60;
  background: #26364a;
  color: #e6edf6;
}
html[data-theme="dark"] .message-bubble {
  border-color: #344358;
  background: #202d3d;
  color: #e3eaf3;
}
html[data-theme="dark"] .message-author { color: #a8b6c8; }
html[data-theme="dark"] .message-lockline,
html[data-theme="dark"] .message-row.mine .message-lockline { color: #c8d4e3; }
html[data-theme="dark"] .message-lockicon,
html[data-theme="dark"] .message-row.mine .message-lockicon {
  background: #34465c;
  color: #a8c8e0;
}
html[data-theme="dark"] .message-lock-state {
  border-color: #45576e;
  background: #2b3b50;
  color: #c1cddd;
}
html[data-theme="dark"] .message-stats,
html[data-theme="dark"] .message-row.mine .message-stats { color: #9eafc4; }
html[data-theme="dark"] .wave-mini-wrap,
html[data-theme="dark"] .message-row.mine .wave-mini-wrap {
  border-color: #405269;
  background: #182635;
}
html[data-theme="dark"] .wave-mini-caption { color: #a4b4c7; }
html[data-theme="dark"] .decode-result,
html[data-theme="dark"] .message-row.mine .decode-result {
  border-color: #405269;
  background: #182635;
  color: #e3eaf3;
}
html[data-theme="dark"] .decode-result-label,
html[data-theme="dark"] .message-row.mine .decode-result-label { color: #aebcff; }
html[data-theme="dark"] .decoded-text { color: #e7edf5; }
html[data-theme="dark"] .inspect-button,
html[data-theme="dark"] .message-row.mine .inspect-button {
  border-color: #465a72;
  background: #2a3b50;
  color: #d5dfeb;
}
html[data-theme="dark"] .inspect-button:hover,
html[data-theme="dark"] .message-row.mine .inspect-button:hover {
  border-color: #6b829e;
  background: #354961;
  color: #fff;
}
html[data-theme="dark"] .message-bottom { color: #96a6bb; }
html[data-theme="dark"] .message-read { color: #71c8a6; }
html[data-theme="dark"] .empty-messages { color: #a5b3c5; }
html[data-theme="dark"] .empty-messages strong { color: #e7edf6; }
html[data-theme="dark"] .composer-inner {
  border-color: #3b4d63;
  background: #202e3f;
}
html[data-theme="dark"] .composer-inner:focus-within {
  border-color: #5a9da9;
  background: #243548;
  box-shadow: 0 0 0 4px rgba(101,201,214,.08);
}
html[data-theme="dark"] .composer-leading {
  background: #2b4651;
  color: #8dd5de;
}
html[data-theme="dark"] .composer-inner input { color: #e7edf5; }
html[data-theme="dark"] .composer-inner input::placeholder { color: #8595aa; }
html[data-theme="dark"] .message-counter,
html[data-theme="dark"] .composer-hint { color: #91a1b5; }
html[data-theme="dark"] .composer-hint i { color: #56677e; }
html[data-theme="dark"] .send-button {
  background: #536d8c;
  color: #fff;
}
html[data-theme="dark"] .send-button:hover:not(:disabled) { background: #6684a7; }

/* Account settings, preferences, forms, and dialogs */
html[data-theme="dark"] .page-card {
  border-color: var(--line);
  background: #1d2a39;
  color: var(--ink);
}
html[data-theme="dark"] .page-view h1,
html[data-theme="dark"] .page-view h2,
html[data-theme="dark"] .settings-profile strong,
html[data-theme="dark"] .settings-item strong { color: #e5edf6; }
html[data-theme="dark"] .settings-profile span,
html[data-theme="dark"] .settings-item span { color: #a2b0c2; }
html[data-theme="dark"] .eyebrow { color: #9dabc0; }
html[data-theme="dark"] .button-primary {
  border-color: #526d8d;
  background: #526d8d;
}
html[data-theme="dark"] .button-primary:hover:not(:disabled) {
  border-color: #6987a9;
  background: #6987a9;
}
html[data-theme="dark"] .button-secondary {
  border-color: #485b72;
  background: #26364a;
  color: #e2eaf3;
}
html[data-theme="dark"] .button-secondary:hover:not(:disabled) { background: #32465e; }
html[data-theme="dark"] .button-quiet {
  border-color: #3b4b60;
  color: #b3c0d1;
}
html[data-theme="dark"] .button-quiet:hover:not(:disabled) { background: #29394d; }
html[data-theme="dark"] .icon-button { color: #aebbd0; }
html[data-theme="dark"] .icon-button:hover {
  border-color: var(--line-strong);
  background: #2a3a4e;
  color: #fff;
}
html[data-theme="dark"] .modal {
  border-color: #3a4a5e;
  background: #1a2635;
  color: #e5ecf5;
  box-shadow: 0 25px 80px rgba(0,0,0,.5);
}
html[data-theme="dark"] .modal::backdrop { background: rgba(3,8,16,.66); }
html[data-theme="dark"] .modal-header h2 { color: #e9eff7; }
html[data-theme="dark"] .modal-description { color: #a4b2c5; }
html[data-theme="dark"] .field > span { color: #dbe4ef; }
html[data-theme="dark"] .field input,
html[data-theme="dark"] .input-prefix {
  border-color: #405168;
  background: #172230;
  color: #e4ebf4;
}
html[data-theme="dark"] .input-prefix input { background: transparent; }
html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .input-prefix:focus-within {
  border-color: #68aab6;
  box-shadow: 0 0 0 3px rgba(101,201,214,.12);
}
html[data-theme="dark"] .inspector-section {
  border-color: #34465b;
  background: #1e2c3c;
}
html[data-theme="dark"] .inspector-section h3 { color: #e1eaf4; }
html[data-theme="dark"] .inspector-section p { color: #afbdcf; }
html[data-theme="dark"] .inspector-frame-format { color: #b1b7ff !important; }
html[data-theme="dark"] .metric-card {
  border-color: #35475c;
  background: #253447;
}
html[data-theme="dark"] .metric-card span { color: #a6b5c8; }
html[data-theme="dark"] .metric-card strong { color: #e5edf6; }
html[data-theme="dark"] .inspector-table-wrap { border-color: #394c62; }
html[data-theme="dark"] .inspector-table th {
  border-color: #394c62;
  background: #2c3d52;
  color: #e0e9f3;
}
html[data-theme="dark"] .inspector-table td {
  border-color: #34465b;
  color: #c6d2e0;
}
html[data-theme="dark"] .inspector-decoded-message,
html[data-theme="dark"] .inspector-code-block {
  border-color: #3a4d63;
  background: #172534;
  color: #dce6f1;
}
html[data-theme="dark"] .inspector-validation { color: #74d2ac !important; }
html[data-theme="dark"] .signal-scroll {
  border-color: #3a4d63;
  background: #172534;
}


/* Theme control */
.settings-item > .theme-setting-control {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 11px;
}
.theme-mode-label {
  min-width: 38px;
  color: var(--muted);
  font: 9px var(--mono);
  text-align: right;
}
.theme-toggle {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  cursor: pointer;
}
.theme-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.theme-switch-track {
  display: flex;
  align-items: center;
  width: 48px;
  height: 28px;
  padding: 3px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #e7ebf1;
  transition: background .28s ease, border-color .28s ease, box-shadow .28s ease;
}
.theme-switch-thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(20,30,45,.2);
  transform: translateX(0);
  transition: transform .32s cubic-bezier(.22,1,.36,1), background .28s ease;
}
.theme-toggle input:checked + .theme-switch-track {
  border-color: #607b9a;
  background: #49627f;
}
.theme-toggle input:checked + .theme-switch-track .theme-switch-thumb {
  background: #eaf1fb;
  transform: translateX(20px);
}
.theme-toggle input:focus-visible + .theme-switch-track {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
html[data-theme="dark"] .theme-switch-track {
  border-color: #4b5d73;
  background: #2b3b50;
}
html[data-theme="dark"] .theme-toggle input:checked + .theme-switch-track {
  border-color: #7292b5;
  background: #526f91;
}

/* Eclipse Slide: the incoming theme expands from one edge and sweeps across. */
@supports (view-transition-name: root) {
  ::view-transition-old(root) {
    animation: theme-eclipse-old .28s ease both;
  }
  ::view-transition-new(root) {
    clip-path: ellipse(0% 145% at 0% 50%);
    animation: theme-eclipse-slide .82s cubic-bezier(.22,1,.36,1) both;
  }
  @keyframes theme-eclipse-slide {
    0% {
      clip-path: ellipse(0% 145% at 0% 50%);
    }
    54% {
      clip-path: ellipse(62% 145% at 42% 50%);
    }
    100% {
      clip-path: ellipse(165% 165% at 100% 50%);
    }
  }
  @keyframes theme-eclipse-old {
    to { opacity: .22; }
  }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none !important; }
}

/* Device details: location, IP and connection times. Cards are styled at the end of this file. */
.device-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 14px;
  margin: 0;
}
.device-facts > div { min-width: 0; }
.device-facts dt {
  color: var(--quiet);
  font: 600 8px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.device-facts dd {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.device-facts dd.mono { font-family: var(--mono); }
@media (max-width: 520px) {
  .device-facts { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Sidebar + directory polish
   Light colours are scoped to html:not([data-theme="dark"]); dark keeps its own.
   ========================================================================== */

/* ---- Sidebar ---- */
.brand-lockup { flex: 0 0 108px; padding: 0 20px 14px; }
.brand-mark { width: 44px; height: 44px; }
.brand-mark img { width: 38px; height: 38px; }
.brand-copy strong { font-size: 19px; letter-spacing: .06em; }
.brand-copy small { font-size: 9px; letter-spacing: .2em; }
.nav-items { gap: 10px; padding-left: 20px; }
.nav-active-pill { left: 20px; height: 56px; border-radius: 28px 0 0 28px; }
.nav-item { height: 56px; flex: 0 0 56px; gap: 16px; padding: 0 20px; border-radius: 28px 0 0 28px; }
.nav-item svg { width: 22px; height: 22px; flex-basis: 22px; }
.nav-label { font-size: 14px; font-weight: 600; }
html:not([data-theme="dark"]) .nav-item:not(.is-active) { color: #a3adf5; }
html:not([data-theme="dark"]) .nav-item:not(.is-active):hover { color: #fff; }

/* Same curve as the reference (30px fillet) using the mask-based corner pieces */
.nav-active-pill::before, .nav-active-pill::after { width: 30px; height: 31px; }
.nav-active-pill::before { top: -30px; -webkit-mask-image: radial-gradient(circle at 0 0, transparent 29.5px, #000 30px); mask-image: radial-gradient(circle at 0 0, transparent 29.5px, #000 30px); }
.nav-active-pill::after { bottom: -30px; -webkit-mask-image: radial-gradient(circle at 0 100%, transparent 29.5px, #000 30px); mask-image: radial-gradient(circle at 0 100%, transparent 29.5px, #000 30px); }
/* Compact (chat) tab merges into the contact panel in light mode */
html:not([data-theme="dark"]) .app-shell.has-chat { --nav-pill-fill: var(--directory-bg); }

.nav-footer { padding: 14px 20px 22px; }
.logout-button { gap: 12px; min-height: 44px; padding: 0; background: transparent; color: #fff; font-size: 12px; font-weight: 700; }
.logout-button svg { box-sizing: content-box; width: 20px; height: 20px; flex: 0 0 20px; padding: 9px; border-radius: 12px; background: rgba(255,255,255,.08); color: #6fd3e6; }
.logout-button:hover { background: transparent; }
.logout-button:hover svg { background: rgba(255,255,255,.16); }

/* Chat mode: logo stays centred (hidden text must not take a gap) */
.app-shell.has-chat .brand-lockup { padding: 0 20px 14px; }
.app-shell.has-chat .brand-mark { width: 40px; height: 40px; }
.app-shell.has-chat .nav-items { padding: 0 0 0 20px; }
.app-shell.has-chat .nav-active-pill { left: 20px; right: 0; border-radius: 28px 0 0 28px; }
.app-shell.has-chat .nav-active-pill::before, .app-shell.has-chat .nav-active-pill::after { transform: scale(1); }
.app-shell.has-chat .nav-item { border-radius: 28px 0 0 28px; }
.nav-footer .logout-button { padding-left: 0; }

/* ---- Directory (before a contact is opened) ---- */
.app-shell:not(.has-chat) .directory-inner { width: 100%; max-width: none; padding: 34px 38px 30px; }
.app-shell:not(.has-chat) .directory-header { width: 100%; margin: 0; }
.app-shell:not(.has-chat) .directory-header h1 { font-size: 24px; letter-spacing: -.03em; }
.app-shell:not(.has-chat) .directory-heading-dot { width: 10px; height: 10px; }

.app-shell:not(.has-chat) .directory-add-button { margin-left: auto; }
.app-shell:not(.has-chat) .directory-content { grid-template-columns: minmax(320px,485px) minmax(0,1fr); justify-content: stretch; max-width: none; gap: 26px; margin: 22px 0 0; }
.app-shell:not(.has-chat) .directory-list-column { max-width: none; justify-self: stretch; }

.app-shell:not(.has-chat) .search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 16px;
}
.app-shell:not(.has-chat) .search-field svg {
  position: static;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  transform: none;
}
.app-shell:not(.has-chat) .search-field input {
  flex: 1;
  width: 100%;
  height: 42px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
}
html:not([data-theme="dark"]) .app-shell:not(.has-chat) .search-field {
  background: #fff;
  border-color: #e6eaf1;
}
html:not([data-theme="dark"]) .app-shell:not(.has-chat) .search-field input {
  background: transparent;
}

.app-shell:not(.has-chat) .contact-list { gap: 11px; margin-top: 12px; }
.app-shell:not(.has-chat) .contact-item { min-height: 88px; padding: 16px 58px 16px 16px; gap: 14px; border-radius: 20px; }
html:not([data-theme="dark"]) .app-shell:not(.has-chat) .contact-item { background: #fff; border-color: #e6eaf1; }
.app-shell:not(.has-chat) .contact-avatar { width: 46px; height: 46px; border-radius: 14px; }
.app-shell:not(.has-chat) .contact-name-row strong { font-size: 15px; }
.contact-status-line { display: block; margin: 2px 0; color: #8a94a7; font-size: 12px; font-weight: 500; }
.contact-status-line.online { color: #0e8f9f; }
.app-shell.has-chat .contact-status-line { display: none; }
.contact-time { position: absolute; top: 17px; right: 18px; color: #8a94a7; font: 500 10px var(--mono); }
.app-shell.has-chat .contact-time { display: none; }
.app-shell:not(.has-chat) .contact-item::after { position: absolute; right: 18px; bottom: 17px; width: 28px; height: 28px; flex: none; border-radius: 9px; }
.app-shell:not(.has-chat) .unread-count { top: auto; bottom: 52px; right: 18px; }

.app-shell:not(.has-chat) .directory-welcome { width: 100%; min-height: calc(100dvh - 148px); padding: 29px 40px; border-radius: 28px; }
html:not([data-theme="dark"]) .app-shell:not(.has-chat) .directory-welcome { background: #fff; border-color: #e6eaf1; }
.app-shell:not(.has-chat) .welcome-orbit, .app-shell:not(.has-chat) .welcome-node, .app-shell:not(.has-chat) .welcome-caption { display: none; }
.app-shell:not(.has-chat) .welcome-art { width: 64px; height: 64px; margin-bottom: 18px; }
.app-shell:not(.has-chat) .welcome-icon { width: 64px; height: 64px; border-radius: 18px; border-color: transparent; box-shadow: none; }
html:not([data-theme="dark"]) .app-shell:not(.has-chat) .welcome-icon { background: #e6fbfd; }
.app-shell:not(.has-chat) .directory-welcome h2 { font-size: 17px; }
.app-shell:not(.has-chat) .directory-welcome p { max-width: 360px; font-size: 12.5px; }
.app-shell:not(.has-chat) .welcome-divider { margin: 24px 0 18px; }
.app-shell:not(.has-chat) .welcome-protocol { font-size: 10px; }
.app-shell:not(.has-chat) .welcome-protocol strong { font-size: 10px; }
@media (max-width: 900px) { .app-shell:not(.has-chat) .directory-content { grid-template-columns: minmax(0,1fr); } .app-shell:not(.has-chat) .directory-welcome { display: none; } }

/* ---- Device alert (Keamanan) ---- */
.nav-item[data-view="security"] { position: relative; }
.nav-dot { position: absolute; top: 14px; left: 38px; z-index: 2; width: 9px; height: 9px; border-radius: 50%; background: #f04438; box-shadow: 0 0 0 2px var(--navy); }
.device-alert { border-left: 4px solid #f04438; }
.device-self-notice { border-left: 4px solid #f5a524; }
.device-alert p, .device-self-notice p { margin: 4px 0 0; }
.device-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.device-section-head strong { color: var(--ink); font-size: 12px; }
.device-section-head span { color: var(--muted); font: 10px var(--mono); }
.device-list { display: grid; gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.device-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--chat-surface); }
.device-card.is-pending { border-color: rgba(240,68,56,.42); background: rgba(240,68,56,.07); }
.device-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.device-card-head > strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.device-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.device-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink); font: 600 9px var(--mono); letter-spacing: .04em; }
.device-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); }
.device-badge.is-current { border-color: rgba(36,183,203,.5); }
.device-badge.is-current::before { background: var(--cyan); }
.device-badge.is-trusted::before { background: var(--green); }
.device-badge.is-pending { border-color: rgba(240,68,56,.5); }
.device-badge.is-pending::before { background: var(--red); }
.device-headline { margin: 0; color: var(--ink); font-size: 12px; font-weight: 600; line-height: 1.5; }
.device-card .device-facts dt { font-size: 9px; }
.device-card .device-facts dd { font-size: 11px; }
.device-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.button-danger { border-color: var(--red); background: transparent; color: var(--red); }
.button-danger:hover:not(:disabled) { background: rgba(216,93,112,.12); }
.button-danger-quiet { border-color: var(--line-strong); background: transparent; color: var(--red); }
.button-danger-quiet:hover:not(:disabled) { background: rgba(216,93,112,.1); }
html:not([data-theme="dark"]) .button-danger, html:not([data-theme="dark"]) .button-danger-quiet { color: #b8384d; }
html:not([data-theme="dark"]) .button-danger { border-color: #d85d70; }
@media (max-width: 520px) { .device-actions .button { flex: 1 1 100%; } }

/* ---- Login: one centred card that fits any screen ---- */
.login-main { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: clamp(16px,4vw,56px); }
.login-card { width: min(100%,440px); padding: clamp(20px,5vw,38px); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 48px -24px rgba(30,27,75,.22); }
@media (max-width: 420px) {
  .login-heading h2 { font-size: 23px; }
  .login-tabs { margin: 18px 0 16px; }
}
@media (max-height: 640px) {
  .login-tabs { margin: 16px 0 14px; }
  .login-form { gap: 11px; }
  .login-field input, .login-prefix { height: 42px; }
  .login-prefix input { height: 40px; }
  .login-footnote { margin-top: 14px; }
}

/* ---- Dark mode: when the rail shrinks for a chat, the active tab keeps the same
   colour as the contact panel next to it (as in light mode) instead of turning lighter. ---- */
html[data-theme="dark"] .app-shell.has-chat { --nav-pill-fill: var(--directory-bg); }


/* SYNTRIX E2EE + Telegram-style permanent message removal */
.message-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  margin-top: 10px;
}
.message-delete-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(216,93,112,.25);
  border-radius: 8px;
  background: transparent;
  color: #bf5368;
  font-size: 9px;
  font-weight: 650;
  cursor: pointer;
  opacity: .78;
  transition: border-color .18s, background .18s, color .18s, transform .18s;
}
.message-delete-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(216,93,112,.58);
  background: rgba(216,93,112,.1);
  color: #a9344d;
}
.message-delete-button:disabled { cursor: wait; opacity: .45; }
.message-row.mine .message-delete-button {
  border-color: rgba(255,190,200,.28);
  color: #ffd0d7;
}
.message-row.mine .message-delete-button:hover:not(:disabled) {
  border-color: rgba(255,190,200,.62);
  background: rgba(255,190,200,.12);
  color: #fff;
}
@media (hover: hover) and (pointer: fine) {
  .message-delete-button { opacity: 0; }
  .message-row:hover .message-delete-button,
  .message-row:focus-within .message-delete-button { opacity: 1; }
}
@media (hover: none), (max-width: 700px) {
  .message-delete-button { opacity: 1; }
}
html[data-theme="dark"] .message-delete-button {
  border-color: rgba(243,133,151,.32);
  color: #ff9eae;
}
html[data-theme="dark"] .message-delete-button:hover:not(:disabled) {
  border-color: rgba(243,133,151,.6);
  background: rgba(243,133,151,.13);
  color: #ffd5dc;
}
html[data-theme="dark"] .message-row.mine .message-delete-button {
  border-color: rgba(255,210,218,.3);
  color: #ffd0d8;
}
html[data-theme="dark"] .message-row.mine .message-delete-button:hover:not(:disabled) {
  background: rgba(255,210,218,.14);
  color: #fff;
}


/* Final message-delete interaction: visible only on hover/focus for pointer
   devices, with a high-contrast destructive state in light and dark themes. */
.message-delete-button {
  min-height: 29px;
  padding: 0 11px;
  border: 1px solid rgba(194,67,86,.34);
  border-radius: 8px;
  background: #fff0f2;
  color: #a92f48;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(3px);
  transition:
    opacity .16s ease,
    transform .16s ease,
    color .16s ease,
    background-color .16s ease,
    border-color .16s ease,
    visibility 0s linear .16s;
}
.message-row:hover .message-delete-button,
.message-row:focus-within .message-delete-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}
.message-delete-button:hover:not(:disabled),
.message-delete-button:focus-visible:not(:disabled) {
  border-color: #c9435b;
  background: #c9435b;
  color: #fff;
}
.message-delete-button:disabled {
  opacity: .5;
  cursor: wait;
}
.message-row.mine .message-delete-button {
  border-color: rgba(255,177,190,.42);
  background: rgba(190,54,76,.2);
  color: #ffd7de;
}
.message-row.mine .message-delete-button:hover:not(:disabled),
.message-row.mine .message-delete-button:focus-visible:not(:disabled) {
  border-color: #ef899b;
  background: #c9435b;
  color: #fff;
}
html[data-theme="dark"] .message-delete-button {
  border-color: rgba(255,141,160,.38);
  background: rgba(185,55,79,.17);
  color: #ffb9c5;
}
html[data-theme="dark"] .message-delete-button:hover:not(:disabled),
html[data-theme="dark"] .message-delete-button:focus-visible:not(:disabled),
html[data-theme="dark"] .message-row.mine .message-delete-button:hover:not(:disabled),
html[data-theme="dark"] .message-row.mine .message-delete-button:focus-visible:not(:disabled) {
  border-color: #ef899b;
  background: #c9435b;
  color: #fff;
}
@media (hover: none), (max-width: 700px) {
  .message-delete-button {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition-delay: 0s;
  }
}


/* Own-message delete controls intentionally match incoming-message controls. */
.message-row.mine .message-delete-button {
  border: 1px solid rgba(194,67,86,.34);
  background: #fff0f2;
  color: #a92f48;
}
.message-row.mine .message-delete-button:hover:not(:disabled),
.message-row.mine .message-delete-button:focus-visible:not(:disabled) {
  border-color: #c9435b;
  background: #c9435b;
  color: #fff;
}
html[data-theme="dark"] .message-row.mine .message-delete-button {
  border: 1px solid rgba(255,141,160,.38);
  background: rgba(185,55,79,.17);
  color: #ffb9c5;
}
html[data-theme="dark"] .message-row.mine .message-delete-button:hover:not(:disabled),
html[data-theme="dark"] .message-row.mine .message-delete-button:focus-visible:not(:disabled) {
  border-color: #ef899b;
  background: #c9435b;
  color: #fff;
}

/* Mobile navigation: use a plain circular selection shape.
   Scoped below 700px so the desktop curved rail remains unchanged. */
@media (max-width: 700px) {
  .nav-items,
  .app-shell.has-chat .nav-items {
    align-items: center;
    padding: 0;
  }

  .nav-active-pill,
  .app-shell.has-chat .nav-active-pill,
  .app-shell:not(.has-chat) .nav-active-pill {
    top: 0;
    right: auto;
    left: 0;
    border-radius: 50%;
  }

  .nav-active-pill::before,
  .nav-active-pill::after,
  .app-shell.has-chat .nav-active-pill::before,
  .app-shell.has-chat .nav-active-pill::after {
    display: none !important;
  }

  .nav-item,
  .app-shell.has-chat .nav-item,
  .app-shell:not(.has-chat) .nav-item {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-radius: 50%;
  }
}

/* Stable directory morph: preserve contact DOM nodes and interpolate only
   their geometry when the shell enters chat mode. */
.search-field {
  transition:
    min-height .62s var(--ease),
    margin .62s var(--ease),
    padding .62s var(--ease),
    border-radius .62s var(--ease),
    border-color .2s,
    box-shadow .2s;
}
.contact-list {
  transition: gap .62s var(--ease), margin .62s var(--ease), padding .62s var(--ease);
}
.contact-item {
  transition:
    min-height .62s var(--ease),
    padding .62s var(--ease),
    gap .62s var(--ease),
    transform .32s var(--ease),
    border-color .25s,
    background .25s,
    box-shadow .25s,
    border-radius .4s var(--ease);
}
.directory-welcome {
  transition:
    width .62s var(--ease),
    max-height .62s var(--ease),
    min-height .62s var(--ease),
    padding .62s var(--ease),
    border-width .62s var(--ease),
    opacity .25s ease,
    transform .62s var(--ease),
    background-color .3s ease;
}

/* A brief, low-contrast fade masks the sharpest part of the desktop
   directory-to-chat layout change. The layout still morphs underneath it. */
@media (min-width: 701px) {
  .app-shell.is-contact-switching .directory-inner {
    opacity: .84;
  }
}

/* The account avatar in Settings shares the same identity hue as contact rows. */
#settingsAvatar.settings-avatar {
  border: 0;
  background: hsl(var(--avatar-hue, 250) 70% 48%);
  color: #fff;
}

/* Contact initials must override the generic .avatar surface styles.
   Keep the identity hue, but use a darker fill for readable white initials. */
.avatar.contact-avatar {
  border: 0;
  background: hsl(var(--avatar-hue, 250) 72% 32%);
  color: #fff;
}


/* A pending device receives only this approval screen, never the workspace. */
.device-gate-view {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  overflow-y: auto;
  background: var(--surface);
}
.device-gate-view[hidden] { display: none !important; }
.device-gate-card {
  width: min(100%, 470px);
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(25, 31, 64, .12);
}
.device-gate-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 28px 0 20px;
  border-radius: 17px;
  background: var(--navy);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
}
.device-gate-card h1 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: clamp(23px, 5vw, 30px);
  letter-spacing: -.045em;
}
.device-gate-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}
.device-gate-note { margin: 20px 0 0; }
.device-gate-recovery {
  margin: 14px 0 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(128, 138, 170, .07);
  font-size: 11px !important;
}
.device-gate-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.device-gate-actions .button { min-height: 42px; }
#deviceGateStatus { display: block; margin-top: 18px; color: var(--muted); font-size: 10px; }


/* SYNTRIX signal disintegration: restrained pixel shards instead of a generic fade. */
.message-disintegrate-layer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  overflow: visible;
  pointer-events: none;
}
.message-disintegrate-fragment {
  position: absolute;
  display: block;
  border-radius: 1px;
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) {
  .message-disintegrate-layer { display: none !important; }
}


/* ==========================================================================
   Unified workspace layout
   - directory: expanded directory over the still-mounted workspace
   - conversation: compact directory drawer + visible conversation workspace
   - page: full workspace for Security / Settings while the drawer retracts
   Keep the DOM mounted so the three states can interpolate without remounting.
   ========================================================================== */
.app-shell {
  --directory-drawer-width: 314px;
  grid-template-columns: 260px 0px minmax(0, 1fr);
  transition: grid-template-columns .76s var(--ease);
}

.app-shell .directory-view {
  grid-column: 2 / 4;
  width: 100%;
  max-width: none;
  min-width: 0;
  justify-self: start;
  overflow: auto;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
  transition:
    width .76s var(--ease),
    opacity .24s ease,
    transform .76s var(--ease),
    visibility 0s linear 0s;
}

.app-shell .workspace {
  position: relative;
  grid-column: 3;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(12px, 0, 0);
  transition:
    opacity .3s ease,
    transform .76s var(--ease),
    visibility 0s linear .76s,
    background-color .3s ease;
}

.app-shell[data-layout="conversation"] {
  grid-template-columns: 80px var(--directory-drawer-width) minmax(0, 1fr);
}

.app-shell[data-layout="conversation"] .directory-view {
  width: var(--directory-drawer-width);
  overflow: hidden;
}

.app-shell[data-layout="conversation"] .workspace,
.app-shell[data-layout="page"] .workspace {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
  transition:
    opacity .36s ease .08s,
    transform .76s var(--ease),
    visibility 0s linear 0s,
    background-color .3s ease;
}

.app-shell[data-layout="page"] {
  grid-template-columns: 260px 0px minmax(0, 1fr);
}

.app-shell[data-layout="page"] .directory-view {
  width: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(-10px, 0, 0);
  transition:
    width .76s var(--ease),
    opacity .2s ease,
    transform .76s var(--ease),
    visibility 0s linear .76s;
}

/* Security and Settings remain mounted above the conversation surface and
   cross-fade when their navigation item changes. */
.app-shell .page-view {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 3;
  transition:
    opacity .24s ease,
    visibility 0s linear .24s;
}

.app-shell[data-view="security"] #securityView,
.app-shell[data-view="settings"] #settingsView {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity .24s ease,
    visibility 0s linear 0s;
}

.app-shell[data-view="security"] .workspace,
.app-shell[data-view="settings"] .workspace {
  grid-column: 3;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}

/* Keep the drawer width synchronized with the existing responsive grid tracks. */
@media (max-width: 1100px) and (min-width: 851px) {
  .app-shell { --directory-drawer-width: 286px; }
}
@media (max-width: 850px) and (min-width: 701px) {
  .app-shell,
  .app-shell[data-layout="directory"],
  .app-shell[data-layout="page"] {
    grid-template-columns: 220px 0px minmax(0, 1fr);
  }
  .app-shell { --directory-drawer-width: 250px; }
  .app-shell[data-layout="conversation"] {
    grid-template-columns: 72px var(--directory-drawer-width) minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .app-shell .directory-view,
  .app-shell[data-layout="conversation"] .directory-view,
  .app-shell[data-layout="page"] .directory-view {
    width: 100%;
    max-width: none;
    transform: none;
    transition: none;
  }
  .app-shell[data-layout="page"] .directory-view {
    display: none;
  }
  .app-shell .page-view {
    position: absolute;
    inset: 0;
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .app-shell .directory-view,
  .app-shell .workspace,
  .app-shell .directory-inner,
  .app-shell .page-view {
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
  }
}

/* Override legacy per-view display/grid rules on desktop: the directory
   stays mounted and changes width instead of being removed from the grid. */
@media (min-width: 701px) {
  .app-shell.has-chat .directory-view,
  .app-shell[data-view="security"] .directory-view,
  .app-shell[data-view="settings"] .directory-view {
    display: flex;
    grid-column: 2 / 4;
  }
}

/* Device approval name: keep the label readable on the dark dialog surface. */
html[data-theme="dark"] .unlocked-message {
  border-color: var(--line-strong);
  background: var(--chat-surface);
  color: var(--ink);
}
html[data-theme="dark"] .unlocked-message > strong {
  color: var(--ink);
}

/* Keep the selected contact pill fully inside the drawer instead of letting
   its right edge merge into, or get clipped by, the directory container. */
@media (min-width: 701px) {
  .app-shell.has-chat .directory-inner {
    padding-right: 14px;
  }

  .app-shell.has-chat .contact-list {
    padding-right: 3px;
  }

  .app-shell.has-chat .contact-item.is-active {
    border-right: 1px solid var(--line-strong);
    border-radius: 15px;
  }
}


/* Language preference */
.language-select {
  min-width: 150px;
  max-width: 48%;
  min-height: 38px;
  padding: 0 32px 0 11px;
  border: 1px solid rgba(120, 135, 155, .38);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.language-select:focus-visible,
select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
.language-select option {
  background: #fff;
  color: #1d2939;
}
html[data-theme="dark"] .language-select {
  border-color: rgba(150, 170, 195, .32);
  background: rgba(19, 29, 44, .72);
  color: #e5edf6;
}
html[data-theme="dark"] .language-select option {
  background: #182231;
  color: #e5edf6;
}
@media (max-width: 420px) {
  .language-select { min-width: 126px; }
}

/* Make the permanent account action clearly destructive on hover/focus. */
.danger-zone #deleteAccountBtn:hover:not(:disabled),
.danger-zone #deleteAccountBtn:focus-visible:not(:disabled) {
  border-color: #b8384d;
  background: #b8384d;
  color: #fff;
}

.danger-zone #deleteAccountBtn:active:not(:disabled) {
  border-color: #982b39;
  background: #982b39;
}

html[data-theme="dark"] .danger-zone #deleteAccountBtn:hover:not(:disabled),
html[data-theme="dark"] .danger-zone #deleteAccountBtn:focus-visible:not(:disabled) {
  border-color: #d94b61;
  background: #d94b61;
  color: #fff;
}

html[data-theme="dark"] .danger-zone #deleteAccountBtn:active:not(:disabled) {
  border-color: #b9364d;
  background: #b9364d;
}
