:root {
  color-scheme: dark;
  --base: #080f19;
  --surface: #0d1724;
  --rail: #101c2a;
  --edge: #25384c;
  --ink: #ecf6ff;
  --muted: #9fb2c7;
  --ice: #87e2f3;
  --active: #173248;
  --bubble: #162536;
  --sent: #194359;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--base);
  color: var(--ink);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button, input, textarea, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 3px; }

.app {
  max-width: 1264px;
  margin: 0 auto;
  padding: 0 34px 30px;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 480px;
}
.masthead {
  flex: 0 0 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; line-height: 1; }
.brand img { border-radius: 11px; object-fit: cover; }
.brand strong { display: block; font-size: 19px; font-weight: 720; letter-spacing: -.03em; }
.brand small { font-size: 12px; color: var(--muted); }
.button, .icon-button {
  border: 1px solid var(--edge);
  color: var(--ink);
  background: #142233;
  border-radius: 11px;
}
.button { padding: 10px 15px; min-height: 40px; font-size: 13px; font-weight: 650; }
.button:hover, .icon-button:hover { background: #1e3549; }
.install { display: flex; align-items: center; gap: 9px; }
.install-icon { display: block; width: 13px; height: 12px; border: 1.5px solid var(--ice); border-radius: 3px; position: relative; }
.install-icon::before {
  content: ""; width: 5px; height: 5px; border: solid var(--ice); border-width: 0 1.5px 1.5px 0;
  position: absolute; left: 2.5px; top: 1.5px; transform: rotate(45deg);
}
.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 342px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 19px;
  overflow: hidden;
}
.sidebar, .conversation { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.sidebar { background: var(--rail); border-right: 1px solid var(--edge); }
.list-head { padding: 23px 19px 9px; }
.list-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 21px; }
.list-title h1 { font-size: 29px; line-height: 1; margin: 0; letter-spacing: -.04em; }
.icon-button {
  display: inline-grid; place-items: center; padding: 0; width: 40px; height: 40px;
  flex: 0 0 auto; color: var(--muted); font-size: 25px; line-height: 1;
}
.add-contact { color: var(--ice); }
.search {
  height: 41px; display: flex; align-items: center; gap: 11px;
  padding: 0 12px; border: 1px solid #293d51; border-radius: 10px; background: #0c1724;
}
.search:focus-within { border-color: var(--ice); }
.search input { width: 100%; border: 0; background: none; color: var(--ink); outline: 0; font-size: 14px; }
.search input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.search-icon { position: relative; height: 12px; width: 12px; border: 1.5px solid var(--muted); border-radius: 100%; flex: none; }
.search-icon::after { content: ""; position: absolute; height: 1.5px; width: 6px; background: var(--muted); right: -4px; bottom: -2px; transform: rotate(45deg); }
.tabs { display: flex; gap: 7px; padding-top: 14px; }
.tab {
  background: none; color: var(--muted); border: 1px solid transparent; border-radius: 8px;
  white-space: nowrap; min-height: 35px; padding: 4px 12px; font-size: 13px; font-weight: 650;
}
.tab[aria-pressed="true"] { background: #1d3548; color: var(--ice); border-color: #2d4a60; }
.tab:hover { color: var(--ink); }
.tab-count { margin-inline-start: 6px; color: var(--ice); }
.tab-count:empty { display: none; }
.list { flex: 1; min-height: 0; overflow: auto; padding: 0 11px 12px; scrollbar-width: thin; }
.person {
  width: 100%; text-align: left; display: grid; grid-template-columns: 43px minmax(0, 1fr) auto;
  align-items: center; gap: 11px; padding: 10px 10px; min-height: 68px;
  color: var(--ink); border: 1px solid transparent; border-radius: 10px; background: transparent;
}
.person + .person { margin-top: 3px; }
.person:hover { background: #1a2d40; }
.person[aria-current="true"] { background: var(--active); border-color: #2c5069; }
.person:focus-visible { outline-offset: -2px; }
.avatar {
  width: 43px; height: 43px; display: grid; place-items: center; border-radius: 50%;
  background: #1d4250; color: #b5eef5; font-size: 13px; font-weight: 750; letter-spacing: .015em;
}
.avatar[data-tone="lavender"] { background: #373251; color: #e2d0ff; }
.avatar[data-tone="amber"] { background: #483d32; color: #f2d6a9; }
.avatar[data-tone="blue"] { background: #25415f; color: #c7e1ff; }
.avatar[data-tone="green"] { background: #233f3b; color: #abedcb; }
.person-main { min-width: 0; display: grid; gap: 4px; }
.person-name, .person-detail { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.person-name { font-size: 14px; font-weight: 670; }
.person-detail { color: var(--muted); font-size: 12px; }
.person-time { color: var(--muted); font-size: 11px; align-self: start; margin-top: 4px; }
.section-label { margin: 16px 10px 5px; color: var(--muted); font-size: 12px; font-weight: 640; }
.request-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; padding-right: 4px; }
.request-line .person { grid-template-columns: 43px minmax(0, 1fr); }
.accept { color: var(--ice); padding: 3px 8px; min-height: 34px; }
.empty-list { color: var(--muted); padding: 17px 12px; font-size: 13px; }
.demo {
  padding: 15px 20px; display: flex; gap: 9px; align-items: flex-start; color: var(--muted);
  font-size: 12px; line-height: 1.55; border-top: 1px solid var(--edge);
}
.demo p { margin: 0; }
.demo strong { color: var(--ink); }
.demo-dot { width: 7px; height: 7px; background: var(--ice); border-radius: 50%; flex: none; margin-top: 6px; }
.chat-head {
  min-height: 72px; padding: 12px 24px; display: flex; gap: 12px; align-items: center;
  border-bottom: 1px solid var(--edge); background: #0e1a28;
}
.chat-id { min-width: 0; }
.chat-id h2 { font-size: 16px; margin: 0 0 3px; overflow-wrap: anywhere; }
.chat-id span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.back { display: none; }
.back span { width: 8px; height: 8px; border: solid var(--ice); border-width: 0 0 2px 2px; transform: rotate(45deg); }
.timeline {
  display: flex; flex-direction: column; align-items: stretch; gap: 15px; flex: 1; min-height: 0;
  overflow: auto; padding: 26px clamp(22px, 4vw, 55px) 26px; scrollbar-width: thin;
  background: radial-gradient(ellipse at 77% 0%, #122739 0%, var(--surface) 65%);
}
.timeline-spacer { flex: 1 0 0; }
.date { align-self: center; font-size: 11px; color: var(--muted); background: #142335; border: 1px solid #24374b; border-radius: 20px; padding: 5px 13px; }
.bubble {
  max-width: min(78%, 470px); padding: 10px 13px 8px; align-self: flex-start; background: var(--bubble);
  border: 1px solid #2a4056; border-radius: 13px 13px 13px 4px; position: relative;
  font-size: 14px; line-height: 1.5; overflow-wrap: anywhere;
}
.bubble.mine { align-self: flex-end; background: var(--sent); border-color: #315a70; border-radius: 13px 13px 4px 13px; }
.bubble p { white-space: pre-wrap; margin: 0; }
.bubble time { display: block; text-align: right; font-size: 10px; line-height: 1.45; color: #b2c8da; margin-top: 4px; }
.bubble-photo { display: block; padding: 0; margin: 0 0 5px; width: 100%; border: 0; background: transparent; border-radius: 7px; }
.bubble-photo img { display: block; max-width: 100%; max-height: 200px; border-radius: inherit; }
.empty-chat { text-align: center; align-self: center; color: var(--muted); margin: auto 0; font-size: 14px; }
.composer { margin: 0; padding: 13px 21px 15px; background: #0e1a28; border-top: 1px solid var(--edge); }
.compose-row {
  display: flex; align-items: flex-end; gap: 8px; padding: 5px; background: #0a1420;
  border: 1px solid #2b4055; border-radius: 13px;
}
.compose-row:focus-within { border-color: #43849c; }
.attach { position: relative; overflow: hidden; width: 38px; height: 38px; border: 0; background: transparent; color: var(--ice); cursor: pointer; }
.attach:focus-within { outline: 2px solid var(--ice); }
.attach input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
textarea {
  flex: 1; min-width: 0; min-height: 38px; max-height: 94px; resize: none; line-height: 22px;
  padding: 8px 1px; border: 0; background: transparent; color: var(--ink); outline: 0; font-size: 16px;
}
.send {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; color: #0b2635; background: var(--ice);
}
.send:hover:not(:disabled) { background: #b0f3ff; }
.send:disabled { color: #b2cadb; background: #315369; cursor: default; }
.send-icon { height: 14px; width: 14px; position: relative; }
.send-icon::before { content: ""; position: absolute; left: 6px; top: 2px; width: 2px; height: 12px; border-radius: 2px; background: currentColor; }
.send-icon::after { content: ""; position: absolute; top: 2px; left: 3px; width: 8px; height: 8px; border: solid currentColor; border-width: 2px 0 0 2px; transform: rotate(45deg); }
.attachment-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.attachment-preview img { width: 43px; height: 43px; border-radius: 8px; object-fit: cover; }
.attachment-preview button { margin-left: auto; width: 34px; height: 34px; }
.status {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 2; margin: 0; max-width: calc(100% - 32px); background: #263f54;
  border: 1px solid #4f7390; border-radius: 10px; padding: 11px 15px; font-size: 13px;
}
dialog {
  width: min(440px, calc(100% - 28px)); padding: 20px; border: 1px solid #34536b;
  border-radius: 16px; background: #112031; color: var(--ink); max-height: calc(100dvh - 36px);
}
dialog::backdrop { background: #02060bc4; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 17px; }
.dialog-heading h2 { margin: 0; font-size: 19px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.field input { width: 100%; min-width: 0; height: 42px; padding: 8px 11px; border: 1px solid var(--edge); border-radius: 8px; background: #0c1724; color: var(--ink); font-size: 16px; }
.field-error { margin: 7px 0; color: #ffc9b3; font-size: 12px; }
.field-error:empty { margin: 0; }
.primary { margin-top: 12px; background: #26495e; border-color: #47758e; color: #c7f5ff; }
.instructions { margin: 0; display: grid; gap: 15px; }
.instructions dt { font-size: 14px; font-weight: 700; }
.instructions dd { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.photo-dialog { width: min(800px, calc(100% - 28px)); text-align: center; }
.photo-close { margin: 0 0 10px auto; display: grid; }
.photo-dialog img { max-width: 100%; max-height: calc(100dvh - 130px); object-fit: contain; }

@media (max-width: 760px) {
  .app { padding: 0; min-height: 0; }
  .masthead { flex-basis: 63px; padding: env(safe-area-inset-top) 15px 0; }
  .brand img { width: 34px; height: 34px; border-radius: 9px; }
  .brand strong { font-size: 17px; }
  .install { gap: 7px; padding: 7px 10px; min-height: 35px; font-size: 12px; }
  .workspace { border-width: 1px 0 0; border-radius: 0; grid-template-columns: minmax(0, 1fr); }
  .sidebar { border: 0; padding-bottom: env(safe-area-inset-bottom); }
  .list-head { padding: 15px 13px 8px; }
  .list-title { margin-bottom: 12px; }
  .list-title h1 { font-size: 27px; }
  .list { padding-inline: 7px; }
  .person { padding: 10px 8px; }
  .conversation { display: none; }
  .app[data-mobile-open="true"] .sidebar { display: none; }
  .app[data-mobile-open="true"] .conversation { display: flex; }
  .chat-head { min-height: 59px; padding: 9px 11px; gap: 9px; }
  .chat-head .avatar { width: 36px; height: 36px; }
  .back { display: grid; width: 34px; height: 36px; }
  .timeline { padding: 17px 12px; gap: 12px; }
  .bubble { max-width: 85%; }
  .composer { padding: 8px 9px calc(9px + env(safe-area-inset-bottom)); }
  .demo { padding: 9px 14px; }
}

@media (max-height: 510px) and (min-width: 761px) {
  .app { min-height: 0; padding-bottom: 8px; }
  .masthead { flex-basis: 55px; }
  .chat-head { min-height: 53px; padding-block: 6px; }
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.language-select {
  flex: none;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--edge);
  border-radius: 11px;
  background: #142233;
  color: var(--ice);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.language-select:hover { background: #1e3549; }
.entry {
  display: grid; place-items: center; flex: 1; min-height: 0; overflow: auto;
  padding: 16px; border: 1px solid var(--edge); border-radius: 19px;
  background: radial-gradient(ellipse at 70% -10%, #142b3e, var(--surface) 67%);
}
.entry-card {
  display: grid; width: min(100%, 412px); margin: auto; gap: 15px;
  background: #101d2b; border: 1px solid var(--edge); border-radius: 16px; padding: 26px;
}
.entry-card h1 { font-size: 25px; letter-spacing: -.02em; margin: 0; }
.entry-card p { color: var(--muted); line-height: 1.45; font-size: 14px; margin: 0; }
.entry-card .privacy-note { font-size: 12px; }
.entry-card .primary { margin-top: 3px; }
.muted, .empty-conversation { color: var(--muted); }
.empty-conversation { display: grid; place-items: center; padding: 15px; text-align: center; }
.empty-conversation h2 { color: var(--ink); font-size: 19px; }
.empty-conversation p { font-size: 14px; }
.profile {
  display: flex; justify-content: space-between; gap: 8px; padding: 16px 19px;
  border-top: 1px solid var(--edge); color: var(--muted); font-size: 12px; overflow-wrap: anywhere;
}
#my-name { color: var(--ice); }
.verify-card, .key-warning {
  padding: 15px 19px; border: 1px solid #2d5167; border-radius: 11px;
  background: #132638; margin: 15px 21px 0; overflow-wrap: anywhere;
}
.verify-card h3 { color: var(--ink); font-size: 15px; margin: 0 0 7px; }
.verify-card p, .key-warning { color: var(--muted); font-size: 13px; margin-top: 7px; line-height: 1.45; }
.verify-card code { display: block; max-width: 36ch; color: var(--ice); font-size: 14px; line-height: 1.6; }
.key-warning { border-color: #775746; color: #f3c6ae; }
.compose-row textarea { margin-left: 8px; }
.button:disabled { opacity: .55; cursor: wait; }
.bubble time.pending { color: #fee2ad; }
@media (max-width: 760px) {
  .entry { border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
  .entry-card { padding: 20px; }
  .app[data-mobile-open="true"] .empty-conversation { display: none; }
  .header-actions { gap: 5px; }
  .header-actions .button { font-size: 11px; padding: 6px; min-height: 33px; }
  .header-actions .install-icon { display: none; }
  .language-select { min-height: 33px; padding-inline: 6px; font-size: 11px; }
  .verify-card, .key-warning { margin: 10px 10px 0; padding: 10px 12px; }
  .profile { padding: 13px 14px; }
}

@media (max-width: 480px) {
  .masthead { flex-basis: auto; min-height: 63px; gap: 8px; padding-bottom: 6px; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
}

.discard-pending {
  display: block; margin: 5px 0 0 auto; padding: 3px 0; border: 0; background: transparent;
  color: var(--ice); font-size: 12px; text-decoration: underline;
}


.restore-link { justify-self: center; margin-top: 12px; }
.attach-photo { flex: 0 0 38px; width: 38px; align-self: flex-end; font-size: 23px; }
.bubble-photo { max-height: 176px; overflow: hidden; }
.bubble-photo img { max-height: 176px; width: auto; object-fit: contain; }
.photo-viewport { width: 100%; overflow: auto; max-height: min(65dvh, 660px); }
.photo-viewport.zoomed img { max-width: none; max-height: none; width: 200%; }
#photo-view-caption { overflow-wrap: anywhere; white-space: pre-wrap; }
#photo-zoom { margin-top: 10px; }
#backup-export { flex: none; min-height: 32px; padding: 5px 8px; font-size: 11px; }
.profile #connection { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-options { flex: none; font-size: 17px; }
.chat-options { margin-inline-start: auto; flex: none; font-size: 22px; }
.request-options { flex: none; font-size: 18px; }
.request-line { grid-template-columns: minmax(0, 1fr) auto auto; }
.chat-blocked { margin: 10px 14px 0; color: var(--muted); font-size: 13px; }
.privacy-section + .privacy-section { border-top: 1px solid var(--edge); margin-top: 15px; padding-top: 14px; }
.privacy-section h3, #report-review-panel h3 { margin: 0 0 8px; font-size: 15px; }
.privacy-section p, #report-dialog p, #peer-dialog p { margin: 7px 0; font-size: 13px; line-height: 1.5; }
.privacy-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.privacy-actions .button { min-height: 42px; }
#peer-confirm { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--edge); }
.blocked-contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 7px 0; font-size: 14px; }
.support-link { display: inline-block; margin-top: 10px; color: var(--ice); font-size: 13px; overflow-wrap: anywhere; }
.report-note, .check-line { margin-top: 12px; }
#report-form select, #report-form textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--edge); border-radius: 8px;
  background: #0c1724; color: var(--ink); font: inherit; font-size: 16px;
}
.check-line { display: flex; align-items: start; gap: 8px; color: var(--muted); font-size: 13px; }
.check-line input { flex: none; margin: 2px 0; }
#report-review-panel { border-top: 1px solid var(--edge); margin-top: 15px; padding-top: 13px; }
#report-preview { margin: 0; padding: 10px; background: #0c1724; border-radius: 8px; max-height: 22vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 13px; }
.message-footer { display: flex; justify-content: end; align-items: center; gap: 3px; }
.message-action { padding: 1px 8px; min-height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 17px; }
.message-action:hover, .message-action:focus-visible { color: var(--ice); background: #1a2d40; }

.voice-player, .voice-recording, .pwa-update {
  display: flex;
  align-items: center;
  gap: 8px;
}
.voice-player, .voice-recording { padding: 4px 0; }
#voice-player-row { padding: 6px 12px; border-top: 1px solid var(--edge); }
.voice-player audio { flex: 1; min-width: 0; height: 34px; }
.voice-recording { min-height: 42px; }
#voice-elapsed { flex: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
#voice-stop { color: var(--ice); font-size: 18px; }
.attach-voice { flex: 0 0 38px; width: 38px; align-self: flex-end; }
.mic-icon { width: 9px; height: 14px; border: 1.5px solid currentColor; border-radius: 5px; position: relative; }
.mic-icon::after { content: ""; position: absolute; top: 5px; left: -4px; right: -4px; height: 11px; border: solid currentColor; border-width: 0 1.5px 1.5px; border-radius: 0 0 9px 9px; }
.voice-message { padding: 4px 0; border: 0; color: inherit; background: transparent; text-align: left; }
.voice-message:disabled { opacity: .65; cursor: default; }
.pwa-update { justify-content: space-between; flex: none; padding: 7px 12px; margin-bottom: 5px; font-size: 13px; color: var(--ice); }
.pwa-update .button { min-height: 32px; padding: 5px 8px; }
