* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #070707;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 72px 36px;
  background-position: 0 0, 36px 18px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: #f3f3f3;
}

button, input, textarea { font: inherit; color: inherit; }

.phone-container {
  width: 375px;
  height: 812px;
  max-height: calc(100dvh - 40px);
  background: rgba(18, 18, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -20px 40px rgba(0, 0, 0, 0.35),
    0 30px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.status-bar {
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  color: #eee;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lock-label { color: #cfcfcf; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

#screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  padding: 12px 16px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.back-btn, .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.back-btn svg, .icon-btn svg { width: 20px; height: 20px; stroke: #f5f5f5; stroke-width: 2; fill: none; }

.header-grow { flex: 1; min-width: 0; }
.header-title { color: #f7f7f7; font-size: 20px; font-weight: 700; }
.header-sub { color: #bdbdbd; font-size: 12px; font-weight: 600; }

.modal-back {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  z-index: 5;
}
.modal-sheet {
  width: 100%;
  max-height: 86%;
  overflow: auto;
  min-height: 0;
  padding: 14px 14px 22px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(180deg, rgba(32, 32, 32, 0.72), rgba(8, 8, 8, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(22px);
}

.chat-list, .thread, .panel {
  padding: 0 12px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 4px;
  margin-bottom: 8px;
  border-radius: 10px;
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), inset 0 -10px 16px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.chat-open {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.chat-item.unread {
  border-color: rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.07));
}

.chat-item.unread::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  width: 7px;
  height: 7px;
  background: #f2f2f2;
  border-radius: 2px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  flex-shrink: 0;
  position: relative;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #f5f5f5;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.photo-btn { display: inline-block; text-align: center; cursor: pointer; }

.avatar.online::after {
  content: "";
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  background: #e8e8e8;
  border: 2px solid rgba(0, 0, 0, 0.65);
  border-radius: 2px;
}

.chat-content { flex: 1; margin-left: 12px; min-width: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.username { color: #f7f7f7; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timestamp { color: #9a9a9a; font-size: 12px; flex-shrink: 0; margin-left: 8px; }
.chat-preview { display: flex; align-items: center; gap: 6px; }
.message-text { color: #a3a3a3; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chat-item.unread .message-text { color: #fff; font-weight: 650; }

.badge {
  min-width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.bottom-nav {
  background: rgba(10, 10, 10, 0.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  flex-shrink: 0;
}
.nav-row { display: flex; justify-content: space-around; align-items: center; }

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #8d8d8d;
  background: none;
  border: 0;
  min-width: 72px;
  padding: 6px 0;
  border-radius: 8px;
}

.nav-item.active {
  color: #f5f5f5;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.nav-item svg { width: 24px; height: 24px; fill: currentColor; }
.nav-item span { font-size: 11px; font-weight: 650; }

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

.form { display: flex; flex-direction: column; gap: 12px; padding: 8px 4px 24px; }
.form label { font-size: 13px; font-weight: 650; color: #c8c8c8; }
.form input, .composer input, .search input, textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 14px 16px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}
.form input:focus, .composer input:focus, .search input:focus, textarea:focus {
  border-color: rgba(255, 255, 255, 0.55);
}

.primary, .ghost {
  border-radius: 8px;
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
}
.primary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08));
  color: #f7f7f7;
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.ghost {
  background: transparent;
  color: #eee;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.note, .error { font-size: 14px; line-height: 1.4; }
.note { color: #c4c4c4; }
.error { color: #f2f2f2; min-height: 1.2em; }

.thread { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.35;
  word-wrap: break-word;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(12px);
}
.bubble.mine {
  margin-left: auto;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.08));
  color: #f8f8f8;
}
.bubble.theirs {
  margin-right: auto;
  background: linear-gradient(160deg, rgba(80, 80, 80, 0.35), rgba(0, 0, 0, 0.28));
  color: #eee;
}
.bubble time { display: block; margin-top: 4px; font-size: 11px; opacity: 0.7; }

.book-today {
  margin: 8px 12px 0;
  flex-shrink: 0;
  width: auto;
}
.composer-error { padding: 0 16px; flex-shrink: 0; }
.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}
.composer input { flex: 1; min-width: 0; }
.composer button {
  border-radius: 8px;
  padding: 0 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08));
  color: #f7f7f7;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-weight: 800;
  cursor: pointer;
}

.empty { color: #9a9a9a; padding: 28px 12px; line-height: 1.45; }
.profile-card { padding: 24px 8px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.profile-card .avatar { width: 84px; height: 84px; font-size: 32px; border-radius: 12px; }
.search { padding: 0 0 12px; }
.handle { color: #b0b0b0; font-size: 14px; }
.section-title { font-size: 13px; font-weight: 800; color: #d6d6d6; letter-spacing: 0.08em; }
textarea { min-height: 88px; resize: vertical; }

.quick-menu-actions { display: grid; gap: 10px; }
.quick-menu-action {
  width: 100%;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,.06);
  color: #fff;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.quick-menu-action span { font-weight: 800; }
.quick-menu-action small { color: #999; font-size: 12px; }

@media (max-width: 520px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
  }
  body { padding: 0; background-size: 56px 28px; }
  .phone-container {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}
