* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #17102e;
  color: #f1eefc;
}
#app { max-width: 560px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* Auth */
#screen-auth { justify-content: center; padding: 24px; }
.auth-card { background: #241a4a; border: 1px solid #3b2d6e; border-radius: 20px; padding: 28px 22px; text-align: center; }
.logo { width: 96px; height: 96px; border-radius: 22px; margin-bottom: 10px; }
.auth-card h1 { font-size: 30px; margin-bottom: 4px; }
.sub { color: #b9aee0; font-size: 14px; margin-bottom: 18px; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid #3b2d6e; background: transparent; color: #cfc6f2; font-size: 15px; cursor: pointer; }
.tab.active { background: #6d28d9; border-color: #6d28d9; color: #fff; }
input[type="text"], input[type="password"] {
  width: 100%; padding: 12px 14px; margin-bottom: 10px; border-radius: 12px;
  border: 1px solid #3b2d6e; background: #17102e; color: #fff; font-size: 16px; outline: none;
}
input:focus { border-color: #22d3ee; }
.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(90deg, #7c3aed, #06b6d4); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.error { color: #f87171; font-size: 13px; min-height: 18px; margin-top: 8px; }
.hint { color: #8d83b5; font-size: 12px; margin-top: 10px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #241a4a; border-bottom: 1px solid #3b2d6e;
}
.mini-logo { width: 34px; height: 34px; border-radius: 9px; }
.title { font-size: 18px; font-weight: 700; flex: 1; }
.spacer { width: 60px; }
.icon-btn { background: transparent; border: 1px solid #3b2d6e; color: #cfc6f2; border-radius: 9px; padding: 7px 10px; font-size: 14px; cursor: pointer; }

/* Messages */
.messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 16px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; background: #6d28d9; color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: #2a2050; border: 1px solid #3b2d6e; border-bottom-left-radius: 4px; }
.msg.typing { color: #8d83b5; }
.blocked { background: #7f1d1d; color: #fecaca; text-align: center; padding: 10px; font-size: 14px; }

/* Composer */
.composer { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #241a4a; border-top: 1px solid #3b2d6e; }
.composer input[type="text"] { flex: 1; margin: 0; }
.btn-send {
  width: 46px; height: 46px; border: none; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; font-size: 18px; cursor: pointer;
}
.btn-attach { font-size: 22px; align-self: center; cursor: pointer; padding: 0 2px; }
.attach-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #2a2050; border-top: 1px solid #3b2d6e; font-size: 13px; }
.attach-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.once-toggle { display: flex; align-items: center; gap: 5px; color: #b9aee0; cursor: pointer; }
.media-btn { background: #0e7490; color: #fff; border: none; border-radius: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer; }

/* Secret menu */
.search-box { padding: 12px 14px 4px; }
.search-results { margin-top: 6px; }
.search-item { display: flex; justify-content: space-between; align-items: center; background: #2a2050; border: 1px solid #3b2d6e; border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; }
.search-item button { background: #6d28d9; color: #fff; border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.thread-list { flex: 1; overflow-y: auto; padding: 8px 14px 16px; }
.thread-item { background: #241a4a; border: 1px solid #3b2d6e; border-radius: 14px; padding: 13px; margin-bottom: 8px; cursor: pointer; }
.thread-item b { font-size: 16px; }
.thread-last { display: block; color: #8d83b5; font-size: 13px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-badge { background: #22d3ee; color: #082f49; font-size: 12px; font-weight: 700; border-radius: 10px; padding: 2px 8px; margin-left: 6px; }
.empty { color: #8d83b5; text-align: center; margin-top: 30px; font-size: 14px; }

/* Viewer */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; z-index: 50; }
.viewer-close { position: absolute; top: 16px; right: 16px; background: #333; color: #fff; border: none; border-radius: 50%; width: 42px; height: 42px; font-size: 18px; cursor: pointer; z-index: 51; }
.viewer-content { max-width: 94vw; max-height: 88vh; }
.viewer-content img, .viewer-content video { max-width: 94vw; max-height: 88vh; border-radius: 12px; }
