/* ============ SnapFlash 闪拍 - 样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --yellow: #FFFC00;
  --dark: #16191c;
  --card: #23272d;
  --text: #f2f4f6;
  --sub: #9aa3ad;
  --line: #31363d;
  --blue: #2f9dff;
  --red: #ff4d5e;
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--dark); color: var(--text);
  overflow: hidden; user-select: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input { font-family: inherit; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--dark); }

/* ============ 登录 ============ */
.auth-screen { align-items: center; justify-content: center; background: linear-gradient(160deg, #fffc00 0%, #ffe95c 45%, #16191c 45.2%); padding: 24px; }
.auth-logo { font-size: 72px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.25)); }
.auth-title { font-size: 30px; margin: 8px 0 2px; color: #1a1c1e; }
.auth-sub { color: #55584f; margin-bottom: 26px; font-size: 14px; }
.auth-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 20px; padding: 20px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.auth-tabs { display: flex; background: #171a1e; border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 10px; border-radius: 9px; color: var(--sub); font-weight: 600; }
.auth-tab.active { background: var(--yellow); color: #1a1c1e; }
.auth-input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: #171a1e; color: var(--text); font-size: 15px; margin-bottom: 12px; outline: none; }
.auth-input:focus { border-color: var(--yellow); }
.auth-error { color: var(--red); font-size: 13px; margin: -4px 0 10px 4px; }
.auth-hint { color: var(--sub); font-size: 12px; margin-top: 12px; text-align: center; line-height: 1.6; }
.btn-primary { width: 100%; padding: 13px; border-radius: 12px; background: var(--yellow); color: #1a1c1e; font-size: 16px; font-weight: 700; }
.btn-primary:active { transform: scale(.98); }
.btn-danger { width: 100%; padding: 13px; border-radius: 12px; background: #2a1518; color: var(--red); font-weight: 600; margin-top: 28px; }
.btn-ghost { padding: 12px 22px; border-radius: 12px; background: #171a1e; color: var(--sub); font-weight: 600; }

/* ============ 通用头部 / 导航 ============ */
.page { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.page-head h2 { font-size: 20px; flex: 1; }
.head-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.head-avatar.small { width: 30px; height: 30px; font-size: 15px; }
.head-spacer { width: 36px; }
.icon-btn { font-size: 22px; padding: 6px; border-radius: 10px; }
.icon-btn:active { background: rgba(255,255,255,.08); }
.icon-btn.big { font-size: 26px; }

.bottom-nav { display: flex; align-items: center; justify-content: space-around; padding: 10px 0 16px; background: var(--dark); border-top: 1px solid var(--line); position: relative; }
.nav-btn { font-size: 26px; position: relative; padding: 6px 18px; border-radius: 14px; }
.nav-btn.active { background: #262a30; }
.nav-cam { background: var(--yellow); font-size: 28px; padding: 8px 22px; border-radius: 18px; }
.nav-badge { position: absolute; top: 0; right: 6px; min-width: 17px; height: 17px; background: var(--red); color: #fff; font-size: 11px; font-style: normal; font-weight: 700; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* ============ 聊天列表 ============ */
.chat-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.chat-item { display: flex; align-items: center; gap: 14px; padding: 13px 18px; cursor: pointer; }
.chat-item:active { background: #1d2126; }
.chat-item .avatar { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.chat-main { flex: 1; min-width: 0; }
.chat-name { font-weight: 700; font-size: 16px; }
.chat-preview { color: var(--sub); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-preview.unread { color: var(--text); font-weight: 700; }
.chat-side { text-align: right; color: var(--sub); font-size: 12px; flex-shrink: 0; }
.snap-dot { width: 14px; height: 14px; border-radius: 3px; background: var(--red); display: inline-block; }
.snap-dot.opened { background: none; border: 2px solid var(--red); }
.empty-tip { text-align: center; color: var(--sub); padding: 60px 30px; line-height: 1.8; font-size: 14px; }

/* ============ 相机页 ============ */
.page-camera { background: #000; }
.cam-wrap { position: absolute; inset: 0; overflow: hidden; }
#camVideo, #camFallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#camOverlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.cam-caption { position: absolute; top: 16%; left: 8%; right: 8%; text-align: center; font-size: 22px; font-weight: 800; padding: 10px 14px; border-radius: 8px; text-shadow: 0 1px 3px rgba(0,0,0,.4); pointer-events: none; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; z-index: 5; }
.cam-title { font-weight: 800; font-size: 17px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.cam-tool { text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.cam-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: #14171a; z-index: 4; padding: 24px; text-align: center; }
.cam-error-icon { font-size: 54px; }
.cam-error p { font-size: 17px; font-weight: 700; }
.cam-error small { color: var(--sub); line-height: 1.7; max-width: 300px; }
.btn-retry { margin-top: 10px; padding: 11px 26px; border-radius: 22px; background: var(--yellow); color: #1a1c1e; font-weight: 700; font-size: 14px; }
.filter-bar { position: absolute; bottom: 110px; left: 0; right: 0; display: flex; gap: 10px; overflow-x: auto; padding: 8px 16px; z-index: 5; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip { flex-shrink: 0; padding: 8px 16px; border-radius: 20px; background: rgba(20,22,25,.65); color: #fff; font-size: 13px; font-weight: 600; backdrop-filter: blur(4px); }
.filter-chip.active { background: var(--yellow); color: #1a1c1e; }
.cam-bottom { position: absolute; bottom: 24px; left: 0; right: 0; display: flex; align-items: center; justify-content: space-around; z-index: 5; }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; }
.shutter span { width: 56px; height: 56px; border-radius: 50%; background: #fff; transition: transform .12s; }
.shutter:active span { transform: scale(.82); }

/* ============ 编辑器 ============ */
#editScreen { background: #000; }
.edit-wrap { position: absolute; inset: 0; overflow: hidden; }
#editImg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#editOverlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.edit-caption { position: absolute; top: 14%; left: 8%; right: 8%; text-align: center; font-size: 22px; font-weight: 800; padding: 10px 14px; border-radius: 8px; text-shadow: 0 1px 3px rgba(0,0,0,.4); pointer-events: none; }
.edit-top { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 10px; padding: 14px; z-index: 6; }
.edit-top input { flex: 1; padding: 11px 16px; border-radius: 22px; border: none; background: rgba(20,22,25,.7); color: #fff; font-size: 15px; outline: none; backdrop-filter: blur(6px); }
.edit-tools { position: absolute; top: 64px; left: 0; right: 0; display: flex; gap: 8px; overflow-x: auto; padding: 6px 14px; z-index: 6; scrollbar-width: none; }
.edit-tools::-webkit-scrollbar { display: none; }
.tool-btn { flex-shrink: 0; padding: 9px 14px; border-radius: 20px; background: rgba(20,22,25,.7); color: #fff; font-size: 13px; font-weight: 600; backdrop-filter: blur(6px); }
.tool-btn.active { background: var(--yellow); color: #1a1c1e; }
.sticker-palette { position: absolute; top: 118px; left: 0; right: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 10px 14px; background: rgba(20,22,25,.85); z-index: 6; border-radius: 0 0 18px 18px; backdrop-filter: blur(6px); }
.sticker-palette span { font-size: 30px; text-align: center; padding: 6px 0; border-radius: 10px; cursor: pointer; }
.sticker-palette span:active { background: rgba(255,255,255,.15); }
.filter-bar.small { position: absolute; bottom: 96px; }
.edit-send { position: absolute; bottom: 24px; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 44px; z-index: 6; }
.send-round { width: 64px; height: 64px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(47,157,255,.45); }
.send-round:active { transform: scale(.94); }

/* ============ 聊天详情 ============ */
.chat-head { background: var(--dark); }
.msg-list { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; }
.msg-row { display: flex; gap: 8px; max-width: 80%; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; align-self: flex-end; }
.bubble { padding: 10px 14px; border-radius: 18px; background: #2a2f36; font-size: 15px; line-height: 1.5; word-break: break-word; }
.mine .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 5px; }
.bubble.snap-bubble { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; font-weight: 700; }
.bubble.snap-bubble .sq { width: 16px; height: 16px; border-radius: 4px; background: var(--red); flex-shrink: 0; }
.bubble.snap-bubble.opened .sq { background: none; border: 2px solid #7a828c; }
.bubble.snap-bubble.opened { color: #7a828c; font-weight: 500; }
.msg-time { font-size: 10px; color: var(--sub); align-self: flex-end; margin: 0 4px 4px; }
.chat-input-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px 18px; border-top: 1px solid var(--line); }
.chat-input-bar input { flex: 1; padding: 12px 18px; border-radius: 22px; border: 1px solid var(--line); background: #171a1e; color: var(--text); font-size: 15px; outline: none; }
.send-btn { color: var(--blue); font-size: 24px; }

/* ============ 查看器（闪拍全屏） ============ */
.viewer { background: #000; z-index: 60; }
.viewer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.viewer-count { position: absolute; top: 20px; left: 20px; z-index: 5; font-size: 30px; font-weight: 800; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.viewer-loc { position: absolute; top: 64px; left: 20px; z-index: 5; font-size: 14px; font-weight: 700; color: #fff; background: rgba(0,0,0,.45); padding: 6px 14px; border-radius: 16px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.viewer-burn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 110px; z-index: 6; animation: burn .9s ease-in forwards; }
@keyframes burn {
  0% { opacity: 0; transform: scale(.4); filter: blur(0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(2.4); filter: blur(6px); }
}

/* ============ 动态 Stories ============ */
.stories-body { flex: 1; overflow-y: auto; padding: 16px; }
.story-section-title { font-size: 14px; color: var(--sub); margin: 20px 0 10px; }
.story-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 4px; }
.story-card { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; flex-shrink: 0; width: 72px; }
.story-ring { width: 66px; height: 66px; border-radius: 50%; padding: 3px; background: linear-gradient(135deg, #ff4d5e, #a44dff, #2f9dff); }
.story-ring.seen { background: #3a3f46; }
.story-ring.plain { background: #3a3f46; }
.story-ring > div { width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; border: 3px solid var(--dark); }
.story-card span { font-size: 12px; color: var(--sub); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-card.add .story-ring { border: 2px dashed #4a515a; background: none; display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--sub); padding: 0; }
.story-head { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 14px; z-index: 5; background: linear-gradient(rgba(0,0,0,.5), transparent); }
.story-time { color: #ddd; font-size: 13px; flex: 1; }
.story-progress { position: absolute; top: 8px; left: 12px; right: 12px; display: flex; gap: 5px; z-index: 6; }
.story-progress i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.story-progress i b { display: block; height: 100%; width: 0; background: #fff; }

/* ============ 个人资料 ============ */
.profile-body { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 34px 24px; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; background: #333a42; display: flex; align-items: center; justify-content: center; font-size: 46px; }
.profile-body h2 { margin-top: 14px; font-size: 24px; }
.profile-username { color: var(--sub); margin-top: 4px; }
.profile-stats { display: flex; gap: 34px; margin-top: 28px; }
.stat { text-align: center; }
.stat b { font-size: 22px; display: block; }
.stat span { font-size: 12px; color: var(--sub); }
.friends-box { width: 100%; max-width: 400px; margin-top: 30px; background: var(--card); border-radius: 16px; padding: 16px; }
.friends-box h3 { font-size: 16px; margin-bottom: 12px; }
.add-friend-row { display: flex; gap: 8px; margin-bottom: 10px; }
.add-friend-row input { flex: 1; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #171a1e; color: var(--text); font-size: 14px; outline: none; }
.add-friend-row button { padding: 10px 18px; border-radius: 12px; background: var(--yellow); color: #1a1c1e; font-weight: 700; font-size: 14px; }
.friend-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.friend-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.friend-item .avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.friend-item .f-info { flex: 1; min-width: 0; }
.friend-item .f-name { font-weight: 700; font-size: 14px; }
.friend-item .f-user { font-size: 12px; color: var(--sub); }
.friend-item .f-act { display: flex; gap: 4px; }
.friend-item .f-btn { font-size: 16px; padding: 6px 8px; border-radius: 8px; }
.friend-item .f-btn:active { background: rgba(255,255,255,.1); }

/* ============ 源码查看 ============ */
.src-tabs { display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.src-tab { padding: 8px 14px; border-radius: 16px; background: #1d2126; color: var(--sub); font-size: 13px; font-weight: 600; }
.src-tab.active { background: var(--yellow); color: #1a1c1e; }
.src-code { flex: 1; overflow: auto; margin: 0; padding: 14px; font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 1.55; color: #cfd6dd; background: #0f1214; white-space: pre; user-select: text; -webkit-user-select: text; }
.src-bar { padding: 12px 14px 18px; border-top: 1px solid var(--line); }

/* ============ 弹窗 / Toast ============ */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 20px; padding: 20px; }
.modal-card h3 { margin-bottom: 14px; }
.pick-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.pick-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; }
.pick-item:active, .pick-item.selected { background: #2c3138; }
.pick-item .avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.pick-check { margin-left: auto; font-size: 18px; color: var(--blue); opacity: 0; }
.pick-item.selected .pick-check { opacity: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn-primary { flex: 1; }
.toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); background: #33393f; color: #fff; padding: 11px 22px; border-radius: 24px; font-size: 14px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: toastIn .25s ease; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }
