/* === CSS Variables === */
:root {
  --primary: #07C160;
  --primary-dark: #06AD56;
  --bg: #EDEDED;
  --white: #FFFFFF;
  --text: #333333;
  --text-sm: #999999;
  --danger: #E64340;
  --warn: #FF9500;
  --border: #E5E5E5;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 8px;
}

/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
.page { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; padding-bottom: 70px; }
a { text-decoration: none; color: inherit; }

/* === Top Bar === */
.top-bar {
  display: flex; align-items: center; justify-content: center;
  height: 48px; background: var(--primary); color: #fff; padding: 0 12px;
  position: sticky; top: 0; z-index: 100;
}
.top-bar-title { font-size: 18px; font-weight: 600; }
.btn-back { position: absolute; left: 12px; font-size: 15px; cursor: pointer; }

/* === Buttons === */
.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: var(--radius); font-size: 15px; cursor: pointer; text-align: center; }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-close { background: var(--bg); color: var(--text-sm); margin-top: 8px; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 15px; margin: 8px 0; outline: none; }
.input:focus { border-color: var(--primary); }
.input-sm { width: 100px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }

/* === Login Page === */
.login-page { text-align: center; padding-top: 60px; }
.login-header { margin-bottom: 30px; }
.login-logo { font-size: 64px; }
.login-header h1 { font-size: 24px; margin: 10px 0 5px; }
.login-header p { color: var(--text-sm); font-size: 14px; }
.login-presets { display: flex; justify-content: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.preset-card { display: flex; flex-direction: column; align-items: center; cursor: pointer; padding: 10px; border-radius: var(--radius); transition: background .2s; }
.preset-card:hover { background: rgba(0,0,0,0.05); }
.preset-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.preset-card span { font-size: 13px; margin-top: 4px; }
.login-form { max-width: 300px; margin: 0 auto; padding: 0 20px; }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--text-sm); }

/* === Personal Page === */
.personal-page { padding-bottom: 20px; }
.user-card { text-align: center; padding: 20px 0; background: var(--white); margin-bottom: 12px; }
.user-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: 18px; font-weight: 600; margin-top: 8px; }
.user-id { font-size: 13px; color: var(--text-sm); }
.menu-list { background: var(--white); margin: 0 0 12px; }
.menu-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 15px; }
.menu-item:last-child { border-bottom: none; }
.menu-val { color: var(--primary); font-weight: 600; }
.menu-hint { color: var(--text-sm); font-size: 12px; margin-left: 8px; }
.menu-arrow { color: #ccc; }

/* === Chat Page === */
.chat-page { display: flex; flex-direction: column; height: 100vh; padding-bottom: 0; }
.chat-top-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; background: var(--primary); color: #fff; padding: 0 10px;
  position: sticky; top: 0; z-index: 100; flex-shrink: 0;
}
.btn-personal { background: #06AD56; padding: 4px 8px; border-radius: 4px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chat-group-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: center; margin: 0 8px; }
.chat-top-actions { display: flex; gap: 12px; align-items: center; }
.btn-sound, .btn-settings { cursor: pointer; font-size: 20px; }

.announce-banner { background: #FFF3CD; color: #856404; padding: 8px 12px; font-size: 13px; text-align: center; border-bottom: 1px solid #FFEEBA; }

.message-list { flex: 1; overflow-y: auto; padding: 10px 12px; background: #EDEDED; -webkit-overflow-scrolling: touch; }
.loading-msg { text-align: center; color: var(--text-sm); font-size: 13px; padding: 10px; }

.msg-row { margin-bottom: 12px; display: flex; align-items: flex-start; }
.msg-system { justify-content: center; }
.msg-self { justify-content: flex-end; }
.msg-other { justify-content: flex-start; }

.msg-avatar { display: flex; flex-direction: column; align-items: center; margin-right: 8px; min-width: 40px; }
.msg-avatar-self { margin-right: 0; margin-left: 8px; order: 2; }
.msg-avatar img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.msg-nick { font-size: 10px; color: var(--text-sm); margin-top: 2px; max-width: 50px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msg-bubble { max-width: 75%; padding: 10px 14px; border-radius: 8px; font-size: 15px; word-break: break-all; position: relative; }
.msg-bubble a { color: #0066cc; text-decoration: underline; word-break: break-all; }
.msg-self .msg-bubble { background: #95EC69; margin-right: 0; }
.msg-other .msg-bubble { background: var(--white); }
.msg-system .msg-bubble { background: transparent; }
.system-text { color: var(--text-sm); font-size: 12px; text-align: center; }

.voice-bubble { display: flex; align-items: center; gap: 6px; cursor: pointer; min-width: 60px; }

.typing-indicator { font-size: 12px; color: var(--text-sm); padding: 4px 12px; font-style: italic; }

.input-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--white); border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input { flex: 1; border: 1px solid var(--border); border-radius: 20px; padding: 8px 14px; font-size: 15px; outline: none; resize: none; max-height: 80px; }
.btn-voice { width: 40px; height: 40px; border: none; border-radius: 50%; font-size: 20px; cursor: pointer; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.btn-send { padding: 8px 16px; border: none; border-radius: 20px; background: var(--primary); color: #fff; font-size: 14px; cursor: pointer; }
.btn-send:disabled { opacity: 0.5; }

/* === Settings Page === */
.settings-page { padding-bottom: 20px; }
.member-avatars { display: flex; overflow-x: auto; padding: 12px; background: var(--white); gap: 10px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.member-avatar-item { display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.avatar-wrap { position: relative; }
.avatar-wrap img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.owner-badge { position: absolute; top: -4px; right: -8px; background: var(--warn); color: #fff; font-size: 10px; padding: 1px 4px; border-radius: 6px; white-space: nowrap; }
.member-name { font-size: 11px; color: var(--text-sm); margin-top: 2px; max-width: 52px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }

.danger-zone { margin: 12px 0; padding: 0 12px; }
.danger-zone .btn { margin-top: 10px; }

/* === Modals === */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--white); border-radius: 12px; padding: 20px; width: 100%; max-width: 360px; max-height: 80vh; overflow-y: auto; }
.modal-lg { max-width: 400px; }
.modal-title { font-size: 17px; font-weight: 600; text-align: center; margin-bottom: 12px; }
.modal-balance { text-align: center; font-size: 14px; color: var(--primary); margin-bottom: 8px; }

.tab-bar { display: flex; margin-bottom: 12px; }
.tab { flex: 1; text-align: center; padding: 8px; font-size: 14px; border-bottom: 2px solid transparent; cursor: pointer; color: var(--text-sm); }
.tab.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }

.section-title { font-size: 14px; font-weight: 600; padding: 8px 0 4px; color: var(--text-sm); }
.group-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.group-status { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.group-status.active { background: #E8F8E8; color: var(--primary); }
.group-status.expired { background: #FFE5E5; color: var(--danger); }

.empty-tip { text-align: center; padding: 20px; color: var(--text-sm); font-size: 14px; }

.search-result { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; margin: 8px 0; }
.search-result img { width: 36px; height: 36px; border-radius: 50%; }
.selected-user { padding: 8px; font-size: 14px; color: var(--primary); }

.card-type-list { margin: 8px 0; }
.card-type-item { display: flex; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; cursor: pointer; }
.card-type-item.selected { border-color: var(--primary); background: #E8F8E8; }
.card-price { color: var(--primary); font-weight: 600; }

.record-list { max-height: 300px; overflow-y: auto; }
.record-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.record-desc { margin-bottom: 4px; }
.record-info { display: flex; justify-content: space-between; align-items: center; }
.record-amount { font-weight: 600; color: var(--primary); }
.record-time { font-size: 11px; color: var(--text-sm); }

.member-row { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.member-row img { width: 36px; height: 36px; border-radius: 50%; }

.request-row { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.request-row img { width: 32px; height: 32px; border-radius: 50%; }

.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 24px; transition: .3s; }
.slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

.transfer-section { margin: 8px 0; }
.transfer-section select { margin-top: 4px; }

.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: rgba(0,0,0,0.75); color: #fff; padding: 10px 24px; border-radius: 20px; font-size: 14px; z-index: 9999; pointer-events: none; animation: toast-in .3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%,-50%) scale(0.8); } to { opacity: 1; transform: translate(-50%,-50%) scale(1); } }

/* === Invite Landing === */
.invite-landing { text-align: center; padding: 20px; }
.invite-info-card { background: var(--white); border-radius: var(--radius); padding: 20px; margin: 15px 0; box-shadow: var(--shadow); }
.invite-info-card p { margin: 8px 0; font-size: 15px; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }
