* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #0b141a; color: #e9edef; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; font-size: 16px; }
.app {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: 100dvh;
  background: #111b21; display: flex; flex-direction: column; overflow: hidden;
}
[hidden] { display: none !important; }

#main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pane.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.header { height: 52px; background: #202c33; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; flex-shrink: 0; }
.logo { font-weight: 700; letter-spacing: .2px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.status { font-size: 12px; background: #2a3942; padding: 4px 10px; border-radius: 999px; }
.btn-small { background: transparent; color: #c7c7c7; border: 1px solid #445; padding: 4px 10px; border-radius: 8px; cursor: pointer; }

.tabs { display: flex; background: #202c33; border-bottom: 1px solid #2f3b43; flex-shrink: 0; }
.tab { flex: 1; background: none; border: none; color: #8aa; padding: 10px 4px; cursor: pointer; border-bottom: 2px solid transparent; font-size: 14px; }
.tab.active { color: #fff; border-bottom-color: #00a884; }
.badge { display: inline-block; min-width: 16px; padding: 0 5px; background: #e53935; color: #fff; border-radius: 99px; font-size: 11px; margin-left: 4px; }

.search-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 28px 20px; text-align: center; }
.big-icon { font-size: 42px; color: #00a884; margin-bottom: 8px; }
.muted { color: #8b9aa3; font-size: 13px; margin: 8px 0 16px; }
.lbl { display: block; text-align: left; font-size: 13px; color: #9bb; margin-bottom: 6px; }
.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg button { flex: 1; background: #2a3942; color: #ddd; border: 1px solid transparent; border-radius: 10px; padding: 10px; cursor: pointer; }
.seg button.on { background: #005c4b; border-color: #00a884; color: #fff; }
.btn-primary { background: #00a884; color: #fff; border: none; border-radius: 10px; padding: 12px 16px; width: 100%; cursor: pointer; font-weight: 600; }
.btn-ghost { margin-top: 10px; background: transparent; color: #aaa; border: 1px solid #445; border-radius: 10px; padding: 10px; width: 100%; cursor: pointer; }

.chat-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.partner-bar { flex-shrink: 0; background: #202c33; padding: 8px 12px; font-size: 14px; border-bottom: 1px solid #2a3942; }
.partner-bar b { font-size: 15px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.banner { flex-shrink: 0; background: #1b3a32; color: #d7fff3; padding: 8px 12px; display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: 13px; }
.banner button { background: #00a884; color: #fff; border: none; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.banner .no { background: #445; }

.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.message { max-width: 78%; margin: 4px 0; padding: 8px 12px; border-radius: 8px; overflow-wrap: anywhere; line-height: 1.35; }
.message.me { background: #005c4b; margin-left: auto; }
.message.partner { background: #202c33; }
.message.system { max-width: 100%; text-align: center; color: #8b9aa3; background: transparent; font-size: 13px; margin-left: 0; }
.media-bubble { padding: 4px; background: transparent; }
.media-bubble.me { margin-left: auto; }
.media-bubble img, .media-bubble video { display: block; max-width: min(220px, 70vw); max-height: 280px; border-radius: 8px; }
.locked { position: relative; cursor: pointer; display: inline-block; }
.locked img { filter: blur(16px); }
.locked .cap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; text-align: center; padding: 8px; }

.voice-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 0; color: #ff8a80; font-size: 13px; }
.typing { flex-shrink: 0; color: #8b9aa3; font-size: 12px; padding: 0 12px 4px; }
.voice-bar button { margin-left: auto; background: #1a242b; color: #fff; border: 1px solid #345; border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 12px; }
.voice-bar #voiceStop { margin-left: 0; background: #00a884; border-color: #00a884; }
.media-bubble audio, .voice { width: min(240px, 72vw); display: block; }
.composer { flex-shrink: 0; background: #202c33; border-top: 1px solid #2a3942; padding-bottom: env(safe-area-inset-bottom); }
.composer-actions { display: flex; gap: 8px; padding: 8px 8px 0; }
.composer-actions button { flex: 1; background: #1a242b; color: #cfd8dc; border: 1px solid #345; border-radius: 8px; padding: 8px 6px; cursor: pointer; font-size: 12px; line-height: 1.25; }
.input-row { display: flex; gap: 6px; align-items: center; padding: 8px; }
#msgInput { flex: 1; min-width: 0; background: #2a3942; border: none; border-radius: 20px; padding: 10px 12px; color: #fff; outline: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: #2a3942; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative; }
.once-toggle { font-size: 12px; color: #bbb; display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.btn-send { background: #00a884; color: #fff; border: none; border-radius: 20px; padding: 10px 12px; cursor: pointer; flex-shrink: 0; }

.list { flex: 1; min-height: 0; overflow-y: auto; }
.friend-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid #223; cursor: pointer; }
.friend-item:hover { background: #1c272e; }
.friend-item .actions { display: flex; gap: 6px; }
.friend-item .actions button { border: none; border-radius: 8px; padding: 6px 8px; cursor: pointer; color: #fff; font-size: 12px; }
.ok { background: #00a884; }
.no { background: #445; }
.pill { font-size: 11px; background: #e53935; color: #fff; border-radius: 99px; padding: 2px 7px; }

.form { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.form input, .form select, .form textarea { background: #2a3942; border: none; border-radius: 8px; padding: 10px; color: #fff; margin-bottom: 8px; }

#authScreen { align-items: center; justify-content: center; overflow-y: auto; }
.auth-box { background: #202c33; padding: 22px; border-radius: 16px; width: 92%; max-width: 360px; margin: 16px auto; }
.logo-big { text-align: center; font-size: 26px; font-weight: 800; color: #00a884; }
.tag { text-align: center; color: #8b9aa3; margin: 4px 0 14px; font-size: 13px; }
.auth-box h2 { font-size: 16px; margin-bottom: 10px; }
.auth-box input, .auth-box select, .auth-box textarea { width: 100%; margin-bottom: 8px; padding: 11px; background: #2a3942; border: none; border-radius: 8px; color: #fff; }
.switch { text-align: center; font-size: 13px; color: #8b9aa3; }
.switch a { color: #00a884; }
.error { color: #ff8a80; text-align: center; margin-top: 8px; min-height: 18px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 50; display: flex; align-items: center; justify-content: center; }
.overlay img, .overlay video { max-width: 100%; max-height: 86%; }
.overlay .hint { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #ccc; font-size: 13px; }
.overlay .x { position: absolute; top: 12px; right: 12px; background: #222; color: #fff; border: none; border-radius: 8px; padding: 8px 12px; cursor: pointer; z-index: 3; }

.shot-wrap { position: relative; display: inline-block; }
.media-bubble .shot { cursor: zoom-in; }
.once-mini { position: absolute; left: 8px; bottom: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #fff; color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); pointer-events: none; }
.once-card { width: 168px; height: 120px; border: none; border-radius: 12px; background: #1a242b; color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 0; }
.once-card .once-ico { width: 42px; height: 42px; border-radius: 50%; border: 2px solid #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.once-card .once-label { font-size: 13px; font-weight: 600; }
.once-card.opened { cursor: default; opacity: .75; }
.once-card.opened .once-ico { border-color: #8b9aa3; color: #8b9aa3; }
.locked { border: none; background: transparent; color: #fff; padding: 0; }
.locked.seen { cursor: default; }
.locked .cap { text-shadow: 0 1px 4px #000; }

button.icon-btn { border: none; color: #e9edef; padding: 0; }
.icon-btn svg { display: block; pointer-events: none; }
.file-hide { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.file-off { position: absolute; width: 1px; height: 1px; opacity: 0; }

.send-preview { flex-direction: column; }
.send-preview .stage { flex: 1; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 56px 16px 128px; }
.send-preview .stage img, .send-preview .stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.72)); }
.preview-hint { text-align: center; color: #ddd; font-size: 13px; margin: 0 0 10px; }
.preview-bar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.once-clock { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid #fff; background: transparent; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.once-clock .num { display: none; font-weight: 700; font-size: 18px; line-height: 1; }
.once-clock.on { background: #fff; color: #111; }
.once-clock.on .clk { display: none; }
.once-clock.on .num { display: block; }

.cam-modal { background: #000; }
.cam-modal video { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; background: #000; }
.cam-bar { position: absolute; left: 0; right: 0; bottom: 28px; display: flex; align-items: center; justify-content: center; gap: 28px; z-index: 2; }
.cam-shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff; background: transparent; cursor: pointer; padding: 0; }
.cam-shutter::after { content: ''; display: block; width: 52px; height: 52px; margin: 4px auto; border-radius: 50%; background: #fff; }
.cam-side { width: 64px; background: transparent; color: #fff; border: none; cursor: pointer; font-size: 14px; }
.cam-side.on { color: #ff5252; font-weight: 700; }