:root {
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #f5f5f7;
  --primary: #007aff; --primary-dark: #0062cc;
  --text: #1d1d1f; --text-secondary: #6e6e73;
  --border: rgba(0,0,0,0.1);
  --bubble-own: #007aff; --bubble-other: #e9e9eb;
  --tab-bar-height: 82px; --nav-bar-height: 56px;
  --danger: #ff3b30; --green: #30d158;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); height: 100dvh; overflow: hidden; -webkit-font-smoothing: antialiased; }
.view { display: none; height: 100dvh; flex-direction: column; }
.view.active { display: flex; }
.login-container { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; gap: 36px; }
.login-logo { text-align: center; }
.logo-icon { font-size: 60px; line-height: 1; margin-bottom: 10px; }
.login-title { font-size: 36px; font-weight: 700; letter-spacing: -0.8px; }
.login-subtitle { font-size: 17px; color: var(--text-secondary); margin-top: 4px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 24px; box-shadow: 0 4px 24px rgba(0,0,0,0.07); display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px; }
input[type='text'], input[type='password'] { width: 100%; padding: 13px 14px; border: 1.5px solid var(--border); border-radius: 11px; font-size: 17px; font-family: inherit; color: var(--text); background: var(--surface-2); outline: none; transition: border-color 0.15s; -webkit-appearance: none; }
input:focus { border-color: var(--primary); background: #fff; }
.error-msg { color: var(--danger); font-size: 14px; min-height: 18px; text-align: center; }
.btn-primary { width: 100%; padding: 14px; background: var(--primary); color: #fff; border: none; border-radius: 12px; font-size: 17px; font-weight: 600; font-family: inherit; cursor: pointer; transition: background 0.15s, transform 0.1s, opacity 0.15s; }
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }
.btn-primary.loading { opacity: 0.6; pointer-events: none; }
.btn-danger { width: 100%; padding: 14px; background: transparent; color: var(--danger); border: 1.5px solid var(--danger); border-radius: 12px; font-size: 17px; font-weight: 500; font-family: inherit; cursor: pointer; }
.btn-danger:active { background: rgba(255,59,48,0.06); }
#app-view { background: var(--bg); }
.tab-content { flex: 1; overflow: hidden; position: relative; }
.tab-pane { display: none; flex-direction: column; position: absolute; inset: 0; background: var(--bg); }
.tab-pane.active { display: flex; }
.nav-bar { height: var(--nav-bar-height); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; background: rgba(255,255,255,0.82); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-bottom: 0.5px solid var(--border); flex-shrink: 0; z-index: 1; }
.nav-bar h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.badge { font-size: 13px; color: var(--text-secondary); background: var(--surface-2); padding: 4px 10px; border-radius: 20px; font-weight: 500; }
.nav-action { font-size: 15px; color: var(--primary); background: none; border: none; font-family: inherit; cursor: pointer; padding: 4px 0; }
.messages-list { flex: 1; overflow-y: auto; padding: 12px 16px 4px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.message-row { display: flex; flex-direction: column; max-width: 74%; }
.message-row.own { align-self: flex-end; align-items: flex-end; }
.message-row.other { align-self: flex-start; align-items: flex-start; }
.message-sender { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; padding: 0 4px; font-weight: 500; }
.message-bubble { padding: 10px 14px; border-radius: 18px; font-size: 16px; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.own .message-bubble { background: var(--bubble-own); color: #fff; border-bottom-right-radius: 5px; }
.other .message-bubble { background: var(--bubble-other); color: var(--text); border-bottom-left-radius: 5px; }
.message-time { font-size: 11px; color: var(--text-secondary); margin-top: 2px; padding: 0 4px; }
.system-message { align-self: center; font-size: 12px; color: var(--text-secondary); background: rgba(0,0,0,0.055); padding: 4px 12px; border-radius: 10px; margin: 8px 0; font-weight: 500; }
.typing-indicator { height: 26px; padding: 0 20px; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; font-style: italic; flex-shrink: 0; }
.input-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px 12px; background: rgba(255,255,255,0.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 0.5px solid var(--border); flex-shrink: 0; }
.input-bar input { flex: 1; padding: 10px 15px; border: 1.5px solid var(--border); border-radius: 22px; font-size: 16px; font-family: inherit; background: var(--surface-2); outline: none; transition: border-color 0.15s; user-select: text; -webkit-user-select: text; }
.input-bar input:focus { border-color: var(--primary); background: #fff; }
.send-btn { width: 38px; height: 38px; background: var(--primary); color: #fff; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: transform 0.1s; }
.send-btn:active { transform: scale(0.88); background: var(--primary-dark); }
.tab-bar { display: flex; align-items: flex-start; justify-content: space-around; height: var(--tab-bar-height); padding-top: 10px; padding-bottom: env(safe-area-inset-bottom, 10px); background: rgba(255,255,255,0.9); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border-top: 0.5px solid var(--border); flex-shrink: 0; }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 0; transition: color 0.15s; }
.tab-btn span { font-size: 10px; font-weight: 500; }
.tab-btn.active { color: var(--primary); }
.members-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.member-row { display: flex; align-items: center; gap: 14px; padding: 11px 14px; background: var(--surface); border-radius: 13px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 17px; flex-shrink: 0; }
.avatar-lg { width: 76px; height: 76px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 30px; }
.member-name { font-size: 16px; font-weight: 500; }
.online-dot { width: 9px; height: 9px; background: var(--green); border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.activity-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.activity-row { display: flex; align-items: center; gap: 13px; padding: 11px 14px; background: var(--surface); border-radius: 13px; }
.activity-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.activity-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.activity-text p { font-size: 15px; font-weight: 500; }
.activity-text span { font-size: 12px; color: var(--text-secondary); }
.empty-state { text-align: center; color: var(--text-secondary); font-size: 15px; margin-top: 48px; }
.profile-content { flex: 1; overflow-y: auto; padding: 28px 20px 32px; display: flex; flex-direction: column; gap: 28px; }
.profile-avatar-section { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.profile-avatar-section h3 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.profile-status { font-size: 14px; color: var(--green); font-weight: 500; }
.settings-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.settings-card { background: var(--surface); border-radius: 13px; overflow: hidden; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 0.5px solid var(--border); font-size: 16px; }
.settings-row:last-child { border-bottom: none; }
.toggle { position: relative; width: 51px; height: 31px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #e5e5ea; border-radius: 31px; transition: background 0.2s; }
.toggle-slider::before { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform 0.22s; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
::-webkit-scrollbar { width: 0; height: 0; }
@media (min-width: 600px) { #app-view { max-width: 480px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,0.1); } }
