/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --g: #1a7a4a; --gm: #22a05a; --gl: #e8f7ef; --gd: #0f4d2e;
  --g2: #d4eddf; --g3: #a8dbbe;
  --txt: #1a1a1a; --txt2: #666; --txt3: #999;
  --bg: #f5f8f6; --white: #ffffff; --border: #dde9e2; --border2: #c5dbd0;
  --danger: #e24b4a; --warn: #ba7517; --info: #185fa5;
  --r: 14px; --r2: 10px; --r3: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08); --shadow2: 0 4px 24px rgba(0,0,0,0.12);
  --transition: .18s ease;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
}
html { height: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--txt);
  height: 100%; overflow: hidden; -webkit-tap-highlight-color: transparent;
}
#app { height: 100vh; overflow: hidden; position: relative; max-width: 480px; margin: 0 auto; }
button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
input, textarea { font-family: var(--font); outline: none; border: none; }
a { color: var(--g); text-decoration: none; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--g3); border-radius: 2px; }

/* ===== AUTH ===== */
.screen-full { position: absolute; inset: 0; z-index: 100; display: none; flex-direction: column; }
.screen-full.active { display: flex; }
.auth-bg { position: absolute; inset: 0; background: linear-gradient(160deg, #0f4d2e 0%, #1a7a4a 50%, #22a05a 100%); overflow: hidden; }
.auth-blob { position: absolute; border-radius: 50%; opacity: .15; }
.blob1 { width: 300px; height: 300px; background: #fff; top: -80px; right: -80px; }
.blob2 { width: 200px; height: 200px; background: #fff; bottom: 100px; left: -60px; }
.blob3 { width: 150px; height: 150px; background: #fff; bottom: -40px; right: 60px; }
.auth-content { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; padding: 3rem 2rem 2.5rem; }
.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 2.5rem; }
.logo-mark { width: 56px; height: 56px; border-radius: 16px; background: rgba(255,255,255,0.2); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; }
.logo-mark svg { width: 36px; height: 36px; }
.auth-title { font-family: var(--font-display); font-size: 36px; font-weight: 800; color: #fff; }
.auth-tagline { font-size: 20px; font-weight: 300; color: rgba(255,255,255,0.9); line-height: 1.5; margin-bottom: 2.5rem; }
.auth-stats { display: flex; flex-direction: column; gap: .75rem; margin-bottom: auto; padding: 1.25rem; background: rgba(255,255,255,0.12); border-radius: var(--r); backdrop-filter: blur(10px); }
.auth-stat { width: 100%; }
.stat-n { display: block; font-size: 22px; font-weight: 700; color: #fff; }
.stat-l { display: block; font-size: 11px; color: rgba(255,255,255,0.75); margin-top: 2px; line-height: 1.3; }
.auth-actions { margin-top: 2.5rem; display: flex; flex-direction: column; gap: 12px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #333; font-size: 15px; font-weight: 600; padding: 14px; border-radius: 50px; transition: transform var(--transition), box-shadow var(--transition); }
.btn-google:active { transform: scale(0.98); }
.btn-guest { background: rgba(255,255,255,0.15); color: #fff; font-size: 14px; font-weight: 500; padding: 13px; border-radius: 50px; border: 1px solid rgba(255,255,255,0.3); transition: background var(--transition); }
.btn-guest:hover { background: rgba(255,255,255,0.25); }
.auth-note { font-size: 11px; color: rgba(255,255,255,0.6); text-align: center; line-height: 1.6; }

/* ===== MAIN APP ===== */
#main-app { height: 100vh; display: flex; flex-direction: column; }
.top-nav { height: 56px; background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; flex-shrink: 0; position: sticky; top: 0; z-index: 20; }
.nav-left { display: flex; align-items: center; gap: 8px; }
.nav-logo-sm { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.nav-logo-sm svg { width: 22px; height: 22px; }
.nav-brand { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--g); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-pts { font-size: 12px; font-weight: 600; color: var(--g); background: var(--gl); padding: 4px 10px; border-radius: 20px; }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--g); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; cursor: pointer; }
.page-content { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

/* ===== BOTTOM NAV ===== */
.bottom-nav { height: 64px; background: var(--white); border-top: 1px solid var(--border); display: flex; align-items: center; flex-shrink: 0; position: sticky; bottom: 0; z-index: 20; padding: 0 4px; }
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--txt3); font-size: 10px; font-weight: 500; cursor: pointer; padding: 6px 0; transition: color var(--transition); user-select: none; }
.bn-item svg { width: 20px; height: 20px; transition: stroke var(--transition); }
.bn-item.active { color: var(--g); }
.bn-item.active svg { stroke: var(--g); }
.bn-scan { position: relative; }
.scan-bubble { width: 52px; height: 52px; background: var(--g); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-top: -16px; box-shadow: 0 4px 16px rgba(26,122,74,0.45); transition: transform var(--transition); }
.scan-bubble svg { width: 24px; height: 24px; }
.bn-item.bn-scan:active .scan-bubble { transform: scale(0.93); }
.bn-item.bn-scan { color: var(--g); }

/* ===== HOME PAGE ===== */
.hero { background: linear-gradient(145deg, var(--gd) 0%, var(--g) 55%, #2db36e 100%); padding: 1.75rem 1.5rem 2.25rem; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; top: -60px; right: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,0.07); }
.hero::after { content: ''; position: absolute; bottom: -40px; left: 20px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,0.05); }
.hero-greet { color: rgba(255,255,255,0.75); font-size: 13px; }
.hero-name { color: #fff; font-size: 22px; font-weight: 600; margin: 3px 0 1.25rem; }
.hero-cta { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; position: relative; }
.hero-btn { background: #fff; color: var(--g); font-size: 14px; font-weight: 700; padding: 11px 22px; border-radius: 50px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); transition: transform var(--transition); }
.hero-btn:active { transform: scale(0.97); }
.hero-streak { background: rgba(255,255,255,0.18); color: #fff; font-size: 12px; font-weight: 600; padding: 8px 12px; border-radius: 50px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; position: relative; }
.h-stat { background: rgba(255,255,255,0.13); border-radius: var(--r2); padding: 12px 10px; text-align: center; cursor: pointer; transition: background var(--transition); }
.h-stat:active { background: rgba(255,255,255,0.2); }
.h-stat-n { color: #fff; font-size: 20px; font-weight: 700; line-height: 1; }
.h-stat-l { color: rgba(255,255,255,0.7); font-size: 10px; margin-top: 4px; line-height: 1.3; }
.section { padding: 1.5rem; }
.section + .section { padding-top: 0; }
.sec-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.sec-title { font-size: 15px; font-weight: 600; color: var(--txt); }
.sec-link { font-size: 12px; font-weight: 600; color: var(--g); cursor: pointer; }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1.1rem 1rem; cursor: pointer; transition: border-color var(--transition), transform var(--transition); }
.qa-card:active { transform: scale(0.98); border-color: var(--gm); }
.qa-ic { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 10px; }
.qa-label { font-size: 13px; font-weight: 600; color: var(--txt); margin-bottom: 3px; }
.qa-sub { font-size: 11px; color: var(--txt2); line-height: 1.4; }
.challenge-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem 1.1rem; display: flex; gap: 12px; margin-bottom: 10px; transition: border-color var(--transition); cursor: pointer; }
.challenge-card:hover { border-color: var(--gm); }
.ch-em { font-size: 28px; width: 40px; text-align: center; flex-shrink: 0; padding-top: 2px; }
.ch-info .ch-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.ch-info .ch-sub { font-size: 12px; color: var(--txt2); margin-bottom: 8px; }
.progress-bar { height: 5px; background: var(--gl); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--g); border-radius: 3px; transition: width .6s ease; }
.ch-meta { font-size: 11px; color: var(--txt2); margin-top: 5px; }
.tip-card { background: var(--gl); border-left: 3px solid var(--g); border-radius: 0 var(--r2) var(--r2) 0; padding: 12px 14px; font-size: 13px; color: var(--gd); line-height: 1.55; margin-bottom: 1rem; }
.tip-card.warn { background: #faeeda; border-color: var(--warn); color: #5a3206; }
.tip-card.danger { background: #fcebeb; border-color: var(--danger); color: #5a1010; }

/* ===== SCAN PAGE ===== */
.scan-page { padding: 1.5rem; }
.page-header { margin-bottom: 1.5rem; }
.page-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--g); }
.page-sub { font-size: 13px; color: var(--txt2); margin-top: 3px; }
.scan-box { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1.5rem; text-align: center; margin-bottom: 1.25rem; }
.scan-target { width: 200px; height: 200px; border-radius: 18px; background: var(--gl); border: 2px dashed var(--gm); display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 1.25rem; cursor: pointer; gap: 10px; transition: background var(--transition), border-color var(--transition); position: relative; overflow: hidden; }
.scan-target:active { background: var(--g2); }
.scan-target .scan-anim { position: absolute; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--g), transparent); top: 0; animation: scanline 2s linear infinite; display: none; }
.scan-target.scanning .scan-anim { display: block; }
@keyframes scanline { 0% { top: 0; } 100% { top: 100%; } }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.scan-target .scan-ic, .scan-target .scan-txt { position: relative; z-index: 2; background: rgba(255,255,255,0.76); padding: 4px 8px; border-radius: 8px; backdrop-filter: blur(4px); }
.scan-ic { font-size: 44px; }
.scan-txt { font-size: 13px; color: var(--txt2); font-weight: 500; }
.camera-controls { display: flex; gap: 8px; margin-bottom: 8px; justify-content: center; flex-wrap: wrap; }
.cam-btn { background: var(--white); color: var(--g); border: 1px solid var(--gm); border-radius: 999px; padding: 8px 14px; font-size: 12px; font-weight: 700; }
.cam-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.cam-btn-primary { background: var(--g); color: #fff; border-color: var(--g); }
.camera-status { font-size: 12px; color: var(--txt2); margin-bottom: 8px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--txt3); font-size: 12px; margin: 1rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.input-row { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 50px; padding: 10px 16px; }
.input-row input { flex: 1; background: transparent; font-size: 14px; color: var(--txt); }
.input-row input::placeholder { color: var(--txt3); }
.input-row .go-btn { background: var(--g); color: #fff; font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 50px; }
.recent-scans { margin-top: 0.5rem; }
.scan-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.scan-item:last-child { border-bottom: none; }
.scan-em { width: 40px; height: 40px; border-radius: var(--r3); background: var(--gl); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.scan-info { flex: 1; }
.scan-name { font-size: 13px; font-weight: 600; }
.scan-meta { font-size: 11px; color: var(--txt2); margin-top: 2px; }
.scan-arrow { color: var(--txt3); font-size: 16px; }
/* Result card */
.result-card { background: var(--white); border: 2px solid var(--gm); border-radius: var(--r); padding: 1.25rem; animation: slideUp .3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.result-hdr { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 1rem; }
.result-em { font-size: 40px; }
.result-nm { font-size: 18px; font-weight: 700; color: var(--g); }
.result-type { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table tr:last-child { border-bottom: none; }
.info-table td { padding: 9px 0; font-size: 13px; }
.info-table td:first-child { color: var(--txt2); }
.info-table td:last-child { text-align: right; font-weight: 600; }
.td-good { color: var(--g) !important; }
.td-bad { color: var(--danger) !important; }
.alt-section { margin-top: 1rem; }
.alt-title { font-size: 13px; font-weight: 700; color: var(--txt); margin-bottom: 10px; }
.alt-row { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--gl); border-radius: var(--r2); margin-bottom: 8px; }
.alt-em { font-size: 24px; width: 36px; text-align: center; }
.alt-nm { font-size: 13px; font-weight: 600; }
.alt-ds { font-size: 11px; color: var(--txt2); margin-top: 2px; }
.points-earned { background: var(--g); color: #fff; border-radius: var(--r2); padding: 10px 14px; font-size: 13px; font-weight: 600; margin-top: 10px; text-align: center; }

/* ===== LEARN PAGE ===== */
.learn-page { padding: 1.5rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.25rem; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem; text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.stat-lbl { font-size: 11px; color: var(--txt2); line-height: 1.4; }
.plastic-type { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem 1.1rem; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; transition: border-color var(--transition); }
.plastic-type:hover { border-color: var(--gm); }
.pt-badge { width: 42px; height: 42px; border-radius: var(--r2); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.pt-info { flex: 1; }
.pt-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.pt-uses { font-size: 12px; color: var(--txt2); margin-bottom: 6px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.tag-g { background: var(--gl); color: var(--gd); }
.tag-a { background: #faeeda; color: #5a3206; }
.tag-r { background: #fcebeb; color: #5a1010; }
.ai-chat { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.ai-chat-hdr { background: var(--g); color: #fff; padding: 12px 1rem; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ai-dot { width: 8px; height: 8px; background: #4afa8c; border-radius: 50%; }
.ai-messages { padding: 1rem; max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 85%; }
.ai-msg.bot { align-self: flex-start; }
.ai-msg.user { align-self: flex-end; }
.ai-bubble { padding: 10px 12px; border-radius: 14px; font-size: 13px; line-height: 1.5; }
.ai-msg.bot .ai-bubble { background: var(--gl); color: var(--gd); border-radius: 4px 14px 14px 14px; }
.ai-msg.user .ai-bubble { background: var(--g); color: #fff; border-radius: 14px 4px 14px 14px; }
.ai-input-row { display: flex; border-top: 1px solid var(--border); }
.ai-input { flex: 1; padding: 12px 14px; font-size: 13px; background: transparent; }
.ai-send { background: var(--g); color: #fff; padding: 10px 16px; font-size: 13px; font-weight: 600; }
.ai-thinking { display: flex; gap: 4px; align-items: center; padding: 10px 12px; background: var(--gl); border-radius: 4px 14px 14px 14px; width: fit-content; }
.ai-thinking span { width: 6px; height: 6px; background: var(--g); border-radius: 50%; animation: bounce .8s ease infinite; }
.ai-thinking span:nth-child(2) { animation-delay: .15s; }
.ai-thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* ===== COMMUNITY PAGE ===== */
.community-page { padding: 1.5rem; }
.community-layout { width: 100%; }
.community-hdr-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notif-btn { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--white); font-size: 16px; }
.notif-badge { position: absolute; top: -4px; right: -3px; min-width: 18px; height: 18px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.loc-banner { background: var(--gl); border-radius: var(--r2); padding: 12px 14px; display: flex; align-items: center; gap: 10px; margin-bottom: 1.25rem; }
.loc-pin { font-size: 20px; }
.loc-name { font-size: 13px; font-weight: 600; }
.loc-sub { font-size: 11px; color: var(--txt2); margin-top: 2px; }
.community-map-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem; margin-bottom: 1rem; }
.community-map-hdr { margin-bottom: 0.65rem; }
.community-map-sub { font-size: 11px; color: var(--txt2); margin-top: 2px; }
.map-actions { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 0.6rem; }
.map-cta { background: var(--gl); color: var(--g); border: 1px solid var(--gm); border-radius: 999px; padding: 6px 11px; font-size: 11px; font-weight: 700; }
.community-map-live { position: relative; height: 240px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; background: #eef4ef; }
.community-map-live .leaflet-container { z-index: 1; }
.map-fallback { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--txt2); padding: 1rem; text-align: center; }
.community-map-live .leaflet-control-attribution { font-size: 9px; }
.map-list { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 0.65rem; }
.map-list-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--txt); font-size: 12px; font-weight: 600; text-align: left; }
.event-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem; margin-bottom: 10px; display: flex; gap: 12px; }
.ev-date { background: var(--gl); border-radius: var(--r2); padding: 8px 10px; text-align: center; flex-shrink: 0; min-width: 48px; }
.ev-day { font-size: 20px; font-weight: 800; color: var(--g); line-height: 1; }
.ev-mon { font-size: 10px; font-weight: 700; color: var(--gd); text-transform: uppercase; letter-spacing: .5px; }
.ev-info { flex: 1; }
.ev-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.ev-loc { font-size: 12px; color: var(--txt2); }
.ev-dist { font-size: 11px; color: var(--info); margin-top: 2px; }
.ev-cnt { font-size: 11px; color: var(--txt2); margin-top: 3px; }
.ev-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.ev-link { font-size: 11px; font-weight: 700; color: var(--info); background: #eaf2fb; border: 1px solid #d7e8fa; border-radius: 999px; padding: 5px 9px; }
.ev-btn { font-size: 12px; font-weight: 700; color: var(--g); margin-top: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.ev-btn.joined { color: var(--txt2); cursor: default; }
.story-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem; margin-bottom: 10px; }
.story-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.story-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.story-name { font-size: 13px; font-weight: 600; }
.story-loc { font-size: 11px; color: var(--txt2); }
.story-followers { font-size: 10px; color: var(--txt3); margin-top: 1px; }
.story-owner-badge { font-size: 10px; color: var(--g); background: var(--gl); border-radius: 999px; padding: 2px 6px; margin-left: 5px; vertical-align: middle; }
.story-menu-btn { margin-left: auto; background: transparent; border: 1px solid var(--border); color: var(--txt2); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.story-head-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.story-follow-btn { margin-left: auto; background: var(--gl); color: var(--g); border: 1px solid var(--gm); border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 700; }
.story-follow-btn.active { background: var(--g); color: #fff; border-color: var(--g); }
.story-flag-btn { background: #fff7f7; border: 1px solid #f3c9c9; color: #9b2a2a; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 700; }
.story-tag { display: inline-flex; background: var(--gl); color: var(--gd); border-radius: 999px; padding: 4px 9px; font-size: 10px; font-weight: 700; margin-bottom: 8px; }
.story-text { font-size: 13px; color: var(--txt); line-height: 1.55; margin-bottom: 10px; }
.story-stats { display: flex; gap: 14px; font-size: 11px; color: var(--txt2); margin-bottom: 9px; }
.story-actions { display: flex; gap: 14px; }
.story-act { font-size: 12px; color: var(--txt2); cursor: pointer; display: flex; align-items: center; gap: 4px; }
.story-act.liked { color: var(--danger); }
.story-act.shared { color: var(--info); font-weight: 700; }
.story-act.saved { color: #855f00; font-weight: 700; }
.comment-wrap { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.comment-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; max-height: 160px; overflow-y: auto; }
.comment-item { display: flex; gap: 8px; }
.comment-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--gl); color: var(--g); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comment-body { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 7px 10px; flex: 1; }
.comment-line { font-size: 12px; color: var(--txt); line-height: 1.4; }
.comment-time { font-size: 10px; color: var(--txt3); margin-top: 2px; }
.comment-actions-row { margin-top: 3px; }
.comment-reply-btn { background: transparent; color: var(--info); font-size: 10px; font-weight: 700; padding: 0; }
.reply-list { margin-top: 7px; display: flex; flex-direction: column; gap: 6px; }
.reply-item { display: flex; gap: 8px; }
.comment-empty { font-size: 11px; color: var(--txt3); padding: 4px 0; }
.comment-input-row { display: flex; gap: 8px; }
.comment-input-row input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 9px 12px; font-size: 12px; background: var(--bg); color: var(--txt); }
.comment-input-row button { background: var(--g); color: #fff; border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 700; }
.reply-input-row { display: flex; gap: 7px; margin-top: 7px; }
.reply-input-row input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 8px 11px; font-size: 11px; background: #fff; color: var(--txt); }
.reply-input-row button { background: var(--g); color: #fff; border-radius: 999px; padding: 7px 10px; font-size: 11px; font-weight: 700; }
.notif-list { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.notif-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; cursor: pointer; background: var(--white); }
.notif-item.unread { border-color: #b8d7c5; background: #f4fbf7; }
.notif-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--gl); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; }
.notif-body { flex: 1; }
.notif-text { font-size: 12px; color: var(--txt); line-height: 1.35; }
.notif-time { font-size: 10px; color: var(--txt3); margin-top: 2px; }
.feed-filter-row { display: flex; gap: 8px; margin: 0 0 10px; }
.feed-filter-btn { background: var(--white); border: 1px solid var(--border); color: var(--txt2); border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 700; }
.feed-filter-btn.active { background: var(--gl); border-color: var(--g2); color: var(--g); }
.story-manage-actions { display: flex; flex-direction: column; gap: 8px; }
.story-manage-btn { width: 100%; border: 1px solid var(--border); background: var(--white); color: var(--txt); border-radius: 10px; padding: 10px 12px; text-align: left; font-size: 13px; font-weight: 600; }
.story-manage-btn.danger { color: var(--danger); border-color: #f3c9c9; background: #fff5f5; }
.add-story { background: var(--white); border: 1px dashed var(--border2); border-radius: var(--r); padding: 1.25rem; text-align: center; cursor: pointer; margin-top: 4px; }
.add-story-txt { font-size: 14px; font-weight: 600; color: var(--g); margin-bottom: 4px; }
.add-story-sub { font-size: 12px; color: var(--txt2); }

/* ===== RANK PAGE ===== */
.rank-page { padding: 1.5rem; }
.rank-hero { background: linear-gradient(135deg, var(--gd), var(--g)); border-radius: var(--r); padding: 1.25rem; margin-bottom: 1.25rem; display: flex; align-items: center; gap: 14px; }
.rank-medal { font-size: 40px; }
.rank-info .rank-pos { font-size: 26px; font-weight: 800; color: #fff; line-height: 1; }
.rank-info .rank-sub { font-size: 12px; color: rgba(255,255,255,0.75); margin-top: 3px; }
.rank-info .rank-pts { font-size: 13px; color: rgba(255,255,255,0.9); font-weight: 600; margin-top: 6px; }
.tab-row { display: flex; gap: 6px; margin-bottom: 1rem; }
.tab-btn { flex: 1; padding: 8px 0; border-radius: var(--r2); font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--white); color: var(--txt2); cursor: pointer; transition: all var(--transition); text-align: center; }
.tab-btn.active { background: var(--gl); color: var(--g); border-color: var(--g2); }
.lb-table { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 1rem; border-bottom: 1px solid var(--border); }
.lb-row:last-child { border-bottom: none; }
.lb-row.me { background: #f0faf5; }
.lb-rank { width: 24px; font-size: 13px; font-weight: 700; color: var(--txt2); text-align: center; flex-shrink: 0; }
.lb-rank.top3 { color: var(--g); }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.lb-name { flex: 1; font-size: 14px; font-weight: 500; }
.lb-pts { font-size: 13px; font-weight: 700; color: var(--g); }
.earn-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--r); padding: 1rem 1.1rem; display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.earn-em { font-size: 26px; width: 40px; text-align: center; }
.earn-info { flex: 1; }
.earn-title { font-size: 13px; font-weight: 600; }
.earn-pts { font-size: 11px; color: var(--g); font-weight: 700; margin-top: 2px; }
.earn-arrow { font-size: 16px; color: var(--txt3); }

/* ===== PROFILE MODAL ===== */
.profile-modal { padding: 1.5rem; }
.profile-hdr { text-align: center; margin-bottom: 1.5rem; }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--g); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.profile-name { font-size: 18px; font-weight: 700; }
.profile-email { font-size: 13px; color: var(--txt2); margin-top: 3px; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.p-stat { background: var(--gl); border-radius: var(--r2); padding: 10px 8px; text-align: center; }
.p-stat-n { font-size: 18px; font-weight: 700; color: var(--g); }
.p-stat-l { font-size: 10px; color: var(--gd); margin-top: 2px; }
.profile-menu { display: flex; flex-direction: column; gap: 2px; }
.pm-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; font-weight: 500; color: var(--txt); }
.pm-item:last-child { border-bottom: none; }
.pm-em { font-size: 18px; width: 28px; }
.pm-item.danger { color: var(--danger); }
.sign-out-btn { width: 100%; background: var(--danger); color: #fff; font-size: 14px; font-weight: 600; padding: 13px; border-radius: 50px; margin-top: 1rem; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: rgba(15,77,46,0.95); color: #fff; font-size: 13px; font-weight: 500; padding: 10px 20px; border-radius: 50px; z-index: 1000; backdrop-filter: blur(10px); max-width: 320px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.toast.show { animation: toastAnim .3s ease; }
@keyframes toastAnim { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ===== LOADING ===== */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.85); display: flex; align-items: center; justify-content: center; z-index: 500; backdrop-filter: blur(4px); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--gl); border-top-color: var(--g); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 5000; display: flex; align-items: flex-end; }
.modal { background: var(--white); border-radius: var(--r) var(--r) 0 0; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; z-index: 5001; }
.modal-drag { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 0; }

/* ===== UTILITIES ===== */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.bold { font-weight: 600; }
.green { color: var(--g); }
.muted { color: var(--txt2); font-size: 12px; }

/* ===== DESKTOP LAYOUT ===== */
@media (min-width: 992px) {
  #app { max-width: none; width: 100%; margin: 0; }

  #main-app {
    height: 100vh;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
  }

  .top-nav {
    grid-column: 1 / -1;
    grid-row: 1;
    height: 64px;
    padding: 0 1.25rem;
    position: relative;
    z-index: 30;
  }

  .bottom-nav {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    bottom: auto;
    height: auto;
    border-top: none;
    border-right: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 12px;
    gap: 6px;
  }

  .bn-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .bn-item svg { width: 18px; height: 18px; }
  .bn-item.active { background: var(--gl); }

  .bn-item.bn-scan { color: var(--txt3); }
  .bn-item.bn-scan.active { color: var(--g); }
  .bn-item.bn-scan .scan-bubble {
    width: 26px;
    height: 26px;
    margin-top: 0;
    box-shadow: none;
    border-radius: 8px;
  }
  .bn-item.bn-scan .scan-bubble svg { width: 16px; height: 16px; }

  .page-content {
    grid-column: 2;
    grid-row: 2;
    background: #f7faf8;
    padding: 1.25rem 2rem 2rem;
  }

  .hero,
  .section,
  .scan-page,
  .learn-page,
  .rank-page {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
  }

  .community-layout {
    max-width: 1260px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 16px;
    align-items: start;
  }
  .community-page {
    max-width: none;
    margin: 0;
  }
  .community-right-rail {
    position: sticky;
    top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .rail-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 12px;
  }
  .rail-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--txt); }
  .rail-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--txt2); padding: 6px 0; border-bottom: 1px solid var(--border); }
  .rail-row:last-child { border-bottom: none; }
  .rail-row strong { color: var(--txt); }
  .rail-chip { font-size: 11px; font-weight: 600; color: var(--g); background: var(--gl); border: 1px solid var(--g2); border-radius: 999px; padding: 5px 9px; display: inline-flex; margin: 0 6px 6px 0; }
  .rail-btn { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--txt); border-radius: 10px; padding: 9px 10px; font-size: 12px; font-weight: 700; text-align: left; margin-top: 7px; }

  .hero {
    border-radius: 18px;
    margin-bottom: 1rem;
  }

  .qa-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .modal-overlay {
    align-items: center;
    justify-content: center;
  }
  .modal {
    max-width: 640px;
    border-radius: var(--r);
  }
  .modal-drag { display: none; }

  .auth-content { max-width: 560px; margin: 0 auto; }
}

@media (max-width: 991.98px) {
  .community-right-rail { display: none; }
}
