:root {
  color-scheme: light;
  --bg: #eef1ee;
  --ink: #18211f;
  --muted: #6c7774;
  --line: #dde3df;
  --accent: #128679;
  --accent-soft: #dcece8;
  --surface: #ffffff;
  --surface-soft: #f3f7f4;
  --danger: #a33b3b;
  --bubble-in: #edf1ee;
  --bubble-out: #128679;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(18, 134, 121, 0.08), transparent 30%),
    linear-gradient(130deg, #f8faf7, var(--bg));
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 16px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  min-height: 100vh;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  align-content: center;
}

.screen {
  display: grid;
  gap: 18px;
}

.welcome-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(64px, 13vh, 118px);
}

.brand-symbol {
  display: block;
  width: 112px;
  height: 104px;
  background: var(--accent);
  -webkit-mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
  mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
}

.brand-symbol.small {
  width: 76px;
  height: 70px;
}

.trust-pill {
  border: 1px solid rgba(18, 134, 121, 0.18);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  padding: 9px 12px;
}

.welcome-copy {
  display: grid;
  gap: 20px;
  margin-bottom: clamp(110px, 24vh, 210px);
}

.avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 760;
}

.lead,
.status-line,
.screen-header,
.lock-state,
label,
.conversation-copy small,
.conversation-meta,
.thread-title p,
.setting span,
.placeholder-pane p,
.pulse-card small {
  color: var(--muted);
}

.lead {
  max-width: 28rem;
  font-size: 20px;
  line-height: 1.42;
}

.truth-note,
.field-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.link-button,
.back-button,
.lock-subtle,
.thread-back {
  width: max-content;
  min-height: 32px;
  padding: 0;
  background: transparent;
  color: var(--muted);
}

.primary-action {
  min-height: 68px;
  font-size: 18px;
}

.created-secondary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.secondary-action {
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 12px;
  background: var(--surface);
  color: var(--ink);
}

.signup-block {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.signup-block h2 {
  font-size: 16px;
}

.signup-block ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.qr-panel {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.qr-panel span,
.qr-panel small {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.progress-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress-list li {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
}

.progress-list li.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#progressScreen:not([hidden]) .progress-list li.is-done::after {
  content: "OK";
  float: right;
  color: var(--accent);
  font-weight: 720;
}

.lock-state {
  color: #77837f;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lock-state-icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.74);
}

.lock-state-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.lock-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: clamp(54px, 10vh, 92px) 0 20px;
}

.lock-heading h1 {
  font-size: 36px;
}

.lock-heading .lead {
  font-size: 14px;
  margin-top: 4px;
}

#unlockPin {
  text-align: center;
  font-size: 24px;
  min-height: 74px;
  letter-spacing: 8px;
}

.numeric-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.numeric-pad button {
  min-height: 62px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 22px;
}

.numeric-pad button:nth-child(10),
.numeric-pad button:nth-child(12) {
  color: var(--muted);
  font-size: 15px;
}

.app-main {
  position: fixed;
  inset: 0;
  gap: 0;
  background: var(--surface);
}

.messenger-root {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.chat-sidebar {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  height: 100vh;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #fbfdfb;
}

.sidebar-header,
.thread-header,
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header {
  grid-row: 1;
  justify-content: space-between;
  padding: 22px 24px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-dot {
  display: block;
  width: 58px;
  height: 54px;
  background: var(--accent);
  -webkit-mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
  mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
}

.sidebar-brand strong {
  display: block;
  font-size: 22px;
}

.sidebar-brand p {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 13px;
}

.sidebar-version {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.sidebar-actions,
.thread-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-action {
  position: relative;
}

.contact-action.has-pending::after {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border: 2px solid #fbfdfb;
  border-radius: 50%;
  background: #d92d20;
  content: "";
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--ink);
}

.icon-button svg,
.nav-icon svg,
.contact-choice svg {
  content: "";
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pulse-rail {
  grid-row: 2;
  display: flex;
  gap: 12px;
  min-width: 0;
  padding: 2px 20px 16px;
  overflow-x: auto;
}

.notification-card {
  grid-row: 3;
  display: grid;
  gap: 10px;
  margin: 0 20px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.notification-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.notification-card button {
  justify-self: start;
  min-height: 32px;
  padding: 0 12px;
}

.pulse-avatar {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 58px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.pulse-avatar span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-soft);
  border: 2px solid var(--line);
  font-size: 13px;
  font-weight: 760;
}

.pulse-avatar.is-new span {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pulse-avatar small {
  max-width: 58px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-list {
  grid-row: 4;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 10px;
}

.conversation-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 70px;
  padding: 10px;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.conversation-item.is-active,
.conversation-item:hover {
  background: var(--surface-soft);
}

.avatar {
  width: 44px;
  height: 44px;
  font-size: 13px;
}

.avatar.big {
  width: 86px;
  height: 86px;
  margin: 0 auto;
  font-size: 22px;
}

.conversation-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.conversation-copy strong,
.conversation-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  display: grid;
  justify-items: end;
  gap: 7px;
  font-size: 12px;
}

.conversation-meta b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}

.empty-conversations {
  display: grid;
  gap: 7px;
  margin: 12px 6px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
}

.empty-conversations strong {
  color: var(--ink);
}

.empty-conversations span {
  font-size: 13px;
  line-height: 1.4;
}

.sidebar-footer {
  grid-row: 5;
  min-height: 68px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.nav-icon span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.nav-icon.is-active {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--accent);
}

.lock-subtle {
  font-size: 13px;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(18, 134, 121, 0.04), transparent 180px),
    var(--surface);
}

.thread-header {
  min-height: 74px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.thread-back {
  display: none;
}

.thread-title {
  min-width: 0;
}

.thread-title h2 {
  font-size: 18px;
}

.thread-title p {
  margin-top: 3px;
  font-size: 13px;
}

.thread-actions {
  margin-left: auto;
}

.message-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 22px clamp(22px, 5vw, 70px);
}

.message {
  display: grid;
  gap: 4px;
  max-width: 62%;
}

.message p {
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.42;
}

.message time {
  color: var(--muted);
  font-size: 11px;
}

.message.in {
  align-self: flex-start;
}

.message.in p {
  background: var(--bubble-in);
}

.message.out {
  align-self: flex-end;
  justify-items: end;
}

.message.out p {
  background: var(--bubble-out);
  color: #fff;
}

.media-message {
  min-width: min(280px, 72%);
}

.attachment-preview,
.attachment-file {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--bubble-in);
  color: var(--ink);
  text-decoration: none;
}

.message.out .attachment-preview,
.message.out .attachment-file {
  background: var(--bubble-out);
  color: #fff;
}

.attachment-preview img,
.attachment-preview video {
  display: block;
  width: 100%;
  max-height: 280px;
  border-radius: 6px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.08);
}

.attachment-preview audio {
  width: 100%;
}

.attachment-file span,
.attachment-preview a {
  color: inherit;
  font-size: 12px;
  opacity: 0.78;
}

.composer {
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.composer button {
  min-height: 38px;
}

.media-picker {
  position: relative;
  overflow: hidden;
}

.media-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.composer .send {
  background: var(--accent);
  color: #fff;
}

.composer input {
  border: 0;
  background: var(--surface-soft);
}

.empty-thread {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-thread h2 {
  color: var(--ink);
  font-size: 20px;
}

.empty-thread p {
  max-width: 320px;
  line-height: 1.45;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  background: #101816;
}

.call-remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #101816;
}

.call-overlay.is-audio .call-remote {
  display: none;
}

.call-overlay.is-audio::before {
  content: "";
  place-self: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--accent);
  -webkit-mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
  mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
}

.call-local {
  position: absolute;
  right: 18px;
  bottom: 92px;
  width: min(34vw, 180px);
  aspect-ratio: 3 / 4;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  object-fit: cover;
  background: #18211f;
}

.call-overlay.is-audio .call-local {
  display: none;
}

.call-controls {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 22px;
}

.incoming-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(16, 24, 22, 0.58);
  backdrop-filter: blur(8px);
}

.incoming-call-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(340px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(16, 24, 22, 0.24);
}

.incoming-call-card .avatar {
  width: 72px;
  height: 72px;
  font-size: 24px;
}

.incoming-call-card p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.incoming-call-card h2 {
  font-size: 22px;
  text-align: center;
}

.incoming-call-actions {
  display: flex;
  gap: 16px;
  margin-top: 6px;
}

.empty-symbol {
  display: block;
  width: 150px;
  height: 140px;
  background: var(--accent);
  -webkit-mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
  mask: url("/brand-assets/logos/blink-monochrome.svg") center / contain no-repeat;
}

.contact-modal {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 33, 31, 0.34);
  backdrop-filter: blur(6px);
}

.contact-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(24, 33, 31, 0.18);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: var(--surface-soft);
  color: var(--ink);
}

.contact-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  background: var(--surface-soft);
  color: var(--ink);
}

.contact-notice {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(18, 134, 121, 0.18);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.contact-notice.is-error {
  border-color: rgba(163, 59, 59, 0.18);
  background: rgba(163, 59, 59, 0.08);
  color: var(--danger);
}

.handle-entry {
  font-size: 13px;
}

.contact-requests {
  display: grid;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.contact-requests p {
  color: var(--muted);
  font-size: 13px;
}

.contact-request {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.contact-request span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.contact-request small {
  color: var(--muted);
  font-size: 12px;
}

.contact-request-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-request-actions button {
  min-height: 34px;
  padding: 0 12px;
}

.settings-pane,
.placeholder-pane {
  align-self: center;
  justify-self: center;
  width: min(520px, calc(100% - 44px));
  display: grid;
  gap: 18px;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.setting {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.settings-actions {
  display: flex;
  gap: 10px;
}

.danger-button {
  background: var(--danger);
}

.placeholder-pane {
  text-align: center;
}

.pulse-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(24, 33, 31, 0.42);
  backdrop-filter: blur(8px);
}

.pulse-viewer {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(260px, 420px) auto;
  gap: 16px;
  align-items: center;
  width: min(760px, calc(100vw - 32px));
}

.pulse-progress {
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.pulse-progress span {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
}

.pulse-progress .is-filled {
  background: #fff;
}

.pulse-close {
  position: absolute;
  top: -70px;
  right: 0;
  background: rgba(255, 255, 255, 0.16);
}

.pulse-nav {
  background: rgba(255, 255, 255, 0.18);
}

.pulse-card {
  display: grid;
  gap: 14px;
  min-height: 460px;
  place-content: center;
  padding: 28px;
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.status-line {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  min-height: 20px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    padding: 24px;
    align-content: stretch;
  }

  #welcomeScreen {
    align-content: stretch;
  }

  #welcomeScreen button {
    margin-top: auto;
    min-height: 62px;
  }

  #lockScreen {
    align-content: start;
    padding-top: 42px;
  }

  .messenger-root {
    grid-template-columns: 1fr;
  }

  .chat-sidebar,
  .conversation-panel {
    grid-column: 1;
    grid-row: 1;
  }

  .conversation-panel {
    transform: translateX(100%);
    transition: transform 180ms ease;
  }

  .messenger-root.is-thread-open .conversation-panel {
    transform: translateX(0);
  }

  .messenger-root.is-thread-open .chat-sidebar {
    pointer-events: none;
  }

  .messenger-root.is-thread-open .sidebar-footer {
    display: none;
  }

  .thread-back {
    display: block;
  }

  .sidebar-header {
    padding-top: 18px;
  }

  .conversation-list {
    padding-bottom: 78px;
  }

  .sidebar-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    justify-content: space-around;
    background: var(--surface);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .nav-icon {
    width: auto;
    min-width: 74px;
    gap: 3px;
  }

  .nav-icon span {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
    font-size: 11px;
  }

  .lock-subtle {
    margin-left: 0;
    font-size: 0;
  }

  .lock-subtle::after {
    content: "Lock";
    font-size: 12px;
  }

  .message {
    max-width: 82%;
  }

  .message-stream {
    padding: 16px;
  }

  .composer {
    padding: 12px;
  }

  .pulse-viewer {
    grid-template-columns: 1fr;
  }

  .pulse-nav {
    min-height: 38px;
  }

  .pulse-card {
    min-height: 420px;
  }
}
