/* ============================================================
   VIVE LA MESA · SALAS v2.0 — Estilos Completos
   Modern Rustic · Santander, Colombia
   ============================================================ */

:root {
  --green-deep:   #3d4922;
  --green-mid:    #74864B;
  --green-light:  #b0bb98;
  --green-pale:   #e8ebe0;
  --gold:         #C6A355;
  --gold-light:   #f0dba8;

  --bg:           #f4f2ee;
  --bg-card:      #fdfcf9;
  --bg-white:     #ffffff;
  --border:       #e5e2da;
  --border-light: #ede9e0;

  --text:         #2a2e1a;
  --text-mid:     #4a4e38;
  --text-muted:   #7a7d6a;
  --text-faint:   #b0ad9e;

  --red:          #C0392B; --red-bg:    #fdf3f2; --red-tint:    #f8e0de; --red-dark:    #922b21;
  --amber:        #D97706; --amber-bg:  #fef9f0; --amber-tint:  #fdecc8; --amber-dark:  #a05400;
  --teal:         #2e7d4e; --teal-bg:   #f0f7f3; --teal-tint:   #c8e8d7; --teal-dark:   #1e5235;
  --blue:         #1a5f8a; --blue-bg:   #f0f6fb; --blue-tint:   #c5dff0; --blue-dark:   #0f3d5c;
  --brown:        #7c4a1e; --brown-bg:  #faf5f0; --brown-tint:  #e8d0b8; --brown-dark:  #5a3314;
  --purple:       #6b3fa0; --purple-bg: #f5f0fa; --purple-tint: #ddd0f0; --purple-dark: #4a2b70;
  --orange:       #c2520a; --orange-bg: #fef4ee; --orange-tint: #fdd9c0; --orange-dark: #8a3507;

  --radius-sm: 10px; --radius: 16px; --radius-lg: 22px; --radius-xl: 28px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --spring:     0.35s cubic-bezier(0.34,1.56,0.64,1);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent; }
html { font-size:16px; -webkit-text-size-adjust:100%; }
body {
  font-family:'DM Sans',system-ui,sans-serif;
  background:var(--bg); color:var(--text); line-height:1.5;
  min-height:100vh; min-height:100dvh;
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
}
::-webkit-scrollbar { display:none; }
* { scrollbar-width:none; }

#app {
  width:100vw; height:100vh; height:100dvh;
  display:flex; flex-direction:column;
  overflow:hidden; position:relative;
}

/* ── VIEWS ── */
.view { position:absolute; inset:0; display:none; flex-direction:column; background:var(--bg); }
.view.active { display:flex; }

/* ── SPLASH ── */
#splash {
  position:fixed; inset:0;
  background:linear-gradient(160deg,#3d4922 0%,#2a3418 100%);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  z-index:9999; transition:opacity 0.5s ease;
}
#splash.fade-out { opacity:0; pointer-events:none; }
.splash-logo {
  width:90px; height:90px; background:rgba(255,255,255,0.1); border-radius:26px;
  display:flex; align-items:center; justify-content:center; font-size:48px;
  margin-bottom:18px; border:1.5px solid rgba(255,255,255,0.15);
  animation:logo-in 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes logo-in { from{transform:scale(0.5);opacity:0} to{transform:scale(1);opacity:1} }
.splash-title {
  font-family:'Lora',serif; font-size:26px; font-weight:700; color:white;
  animation:fade-up 0.5s 0.2s both;
}
.splash-sub { font-size:13px; color:rgba(255,255,255,0.5); margin-top:4px; animation:fade-up 0.5s 0.3s both; }
.splash-dot { width:8px;height:8px;background:rgba(255,255,255,0.3);border-radius:50%;margin-top:32px;animation:pulse-dot 1.2s ease-in-out infinite; }

@keyframes fade-up { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
@keyframes pulse-dot { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.3;transform:scale(0.7)} }
@keyframes slide-up { from{opacity:0;transform:translateY(18px)} to{opacity:1;transform:translateY(0)} }
@keyframes msg-in { from{opacity:0;transform:translateY(10px) scale(0.98)} to{opacity:1;transform:translateY(0) scale(1)} }
@keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }
@keyframes spin { to{transform:rotate(360deg)} }
@keyframes bounce-in { 0%{transform:scale(0.3);opacity:0} 60%{transform:scale(1.1)} 100%{transform:scale(1);opacity:1} }
@keyframes progress-stripe { 0%{background-position:0 0} 100%{background-position:40px 0} }

/* ── TYPOGRAPHY ── */
.font-serif { font-family:'Lora',Georgia,serif; }

/* ── HEADER ── */
.app-header { background:var(--bg-card); border-bottom:1px solid var(--border-light); flex-shrink:0; z-index:10; }
.status-pad { padding-top:max(var(--safe-top),12px); }
.header-inner { padding:12px 20px 10px; }
.header-row { display:flex; align-items:center; gap:12px; }

.brand-wrap { display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.brand-logo {
  width:40px; height:40px; border-radius:12px;
  background:linear-gradient(135deg,var(--green-deep),var(--green-mid));
  display:flex; align-items:center; justify-content:center; font-size:20px;
  flex-shrink:0; box-shadow:0 3px 10px rgba(61,73,34,0.25);
}
.brand-text { min-width:0; }
.brand-title { font-family:'Lora',serif; font-size:17px; font-weight:700; color:var(--green-deep); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.brand-subtitle { font-size:11px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.header-avatar {
  width:38px; height:38px; border-radius:50%;
  background:linear-gradient(135deg,var(--gold),#e8b96a);
  display:flex; align-items:center; justify-content:center;
  font-size:14px; font-weight:700; color:white; flex-shrink:0; cursor:pointer;
  position:relative; box-shadow:0 2px 8px rgba(198,163,85,0.35);
}
.avatar-badge {
  position:absolute; top:-2px; right:-2px; width:16px; height:16px;
  background:var(--red); border:2px solid var(--bg-card); border-radius:50%;
  font-size:8px; display:flex; align-items:center; justify-content:center;
  color:white; font-weight:700;
}
.header-back {
  width:36px; height:36px; border-radius:var(--radius-sm); background:var(--bg);
  border:1px solid var(--border); display:flex; align-items:center; justify-content:center;
  cursor:pointer; color:var(--text-mid); transition:background var(--transition); flex-shrink:0;
}
.header-back:active { background:var(--border); }
.header-back svg { width:18px; height:18px; stroke-width:2.5; }

/* ── SEARCH ── */
.search-wrap { padding:0 20px 12px; background:var(--bg-card); }
.search-bar {
  display:flex; align-items:center; gap:9px; background:var(--bg);
  border:1.5px solid var(--border); border-radius:14px; padding:10px 14px;
  transition:border-color var(--transition);
}
.search-bar:focus-within { border-color:var(--green-mid); background:var(--bg-white); }
.search-bar svg { width:16px; height:16px; color:var(--text-muted); flex-shrink:0; stroke-width:2; }
.search-bar input { flex:1; border:none; background:transparent; font-size:14px; color:var(--text); font-family:inherit; outline:none; }
.search-bar input::placeholder { color:var(--text-faint); }

/* ── TABS ── */
.tabs-wrap { display:flex; gap:6px; padding:0 20px 12px; background:var(--bg-card); border-bottom:1px solid var(--border-light); overflow-x:auto; }
.tab-btn { padding:6px 16px; border-radius:20px; font-size:13px; font-weight:500; cursor:pointer; white-space:nowrap; border:1.5px solid transparent; flex-shrink:0; user-select:none; transition:all var(--transition); }
.tab-btn.active { background:var(--green-deep); color:white; }
.tab-btn:not(.active) { background:var(--bg); color:var(--text-muted); border-color:var(--border); }

/* ── OFFLINE BANNER ── */
.offline-banner {
  background:#1a1a1a; color:white; font-size:12.5px; font-weight:500;
  padding:8px 16px; text-align:center; display:none; align-items:center;
  justify-content:center; gap:6px; flex-shrink:0; z-index:20;
}
.offline-banner.show { display:flex; }

/* ── ANNOUNCE ── */
.announce-banner {
  margin:12px 16px 0; background:linear-gradient(105deg,var(--green-deep) 0%,var(--green-mid) 100%);
  border-radius:var(--radius); padding:12px 14px; display:flex; align-items:center; gap:10px;
}
.announce-icon { font-size:22px; flex-shrink:0; }
.announce-text { flex:1; min-width:0; }
.announce-title { font-size:13px; font-weight:600; color:white; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.announce-sub { font-size:11px; color:rgba(255,255,255,0.65); margin-top:1px; }
.announce-close { font-size:20px; color:rgba(255,255,255,0.45); cursor:pointer; flex-shrink:0; }

/* ── CARDS ── */
.cards-scroll { flex:1; overflow-y:auto; padding:10px 16px 100px; display:flex; flex-direction:column; gap:10px; }
.section-label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.1em; color:var(--text-muted); padding:4px 4px 0; }

.cat-card {
  border-radius:var(--radius); padding:15px 16px; display:flex; align-items:center; gap:13px;
  cursor:pointer; border:1.5px solid transparent; position:relative; overflow:hidden;
  transition:transform var(--spring), box-shadow var(--transition); user-select:none;
}
.cat-card:active { transform:scale(0.97); box-shadow:0 2px 8px rgba(0,0,0,0.1); }
.cat-card::before { content:''; position:absolute; left:0;top:0;bottom:0; width:4px; border-radius:0 4px 4px 0; }

.cat-red    { background:var(--red-bg);    border-color:var(--red-tint);    } .cat-red::before    { background:var(--red); }
.cat-amber  { background:var(--amber-bg);  border-color:var(--amber-tint);  } .cat-amber::before  { background:var(--amber); }
.cat-teal   { background:var(--teal-bg);   border-color:var(--teal-tint);   } .cat-teal::before   { background:var(--teal); }
.cat-blue   { background:var(--blue-bg);   border-color:var(--blue-tint);   } .cat-blue::before   { background:var(--blue); }
.cat-brown  { background:var(--brown-bg);  border-color:var(--brown-tint);  } .cat-brown::before  { background:var(--brown); }
.cat-purple { background:var(--purple-bg); border-color:var(--purple-tint); } .cat-purple::before { background:var(--purple); }
.cat-orange { background:var(--orange-bg); border-color:var(--orange-tint); } .cat-orange::before { background:var(--orange); }

.cat-icon-wrap { width:52px;height:52px;border-radius:14px;display:flex;align-items:center;justify-content:center;font-size:26px;flex-shrink:0; }
.cat-red .cat-icon-wrap{background:var(--red-tint)} .cat-amber .cat-icon-wrap{background:var(--amber-tint)}
.cat-teal .cat-icon-wrap{background:var(--teal-tint)} .cat-blue .cat-icon-wrap{background:var(--blue-tint)}
.cat-brown .cat-icon-wrap{background:var(--brown-tint)} .cat-purple .cat-icon-wrap{background:var(--purple-tint)}
.cat-orange .cat-icon-wrap{background:var(--orange-tint)}

.cat-info { flex:1; min-width:0; }
.cat-name { font-size:14.5px; font-weight:700; letter-spacing:-0.1px; line-height:1.2; margin-bottom:3px; }
.cat-red .cat-name{color:var(--red-dark)} .cat-amber .cat-name{color:var(--amber-dark)}
.cat-teal .cat-name{color:var(--teal-dark)} .cat-blue .cat-name{color:var(--blue-dark)}
.cat-brown .cat-name{color:var(--brown-dark)} .cat-purple .cat-name{color:var(--purple-dark)}
.cat-orange .cat-name{color:var(--orange-dark)}
.cat-sub-tag { display:inline-block;background:rgba(0,0,0,0.04);border-radius:6px;padding:1px 6px;margin-right:3px;font-size:10.5px;color:var(--text-muted); }

.cat-meta { display:flex; flex-direction:column; align-items:flex-end; gap:5px; flex-shrink:0; }
.cat-badge { font-size:10px;font-weight:700;padding:3px 8px;border-radius:10px;color:white;min-width:32px;text-align:center; }
.cat-red .cat-badge{background:var(--red)} .cat-amber .cat-badge{background:var(--amber)}
.cat-teal .cat-badge{background:var(--teal)} .cat-blue .cat-badge{background:var(--blue)}
.cat-brown .cat-badge{background:var(--brown)} .cat-purple .cat-badge{background:var(--purple)}
.cat-orange .cat-badge{background:var(--orange)}
.cat-badge.zero { background:var(--border)!important; color:var(--text-muted); }

.cat-online { font-size:10px;color:var(--text-muted);display:flex;align-items:center;gap:3px; }
.online-dot { width:6px;height:6px;border-radius:50%;background:#22c55e;flex-shrink:0; }

/* ── PULL TO REFRESH ── */
.ptr-indicator {
  text-align:center; font-size:12px; color:var(--text-muted); padding:10px;
  display:none; flex-shrink:0;
}
.ptr-indicator.show { display:block; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position:fixed; bottom:0; left:0; right:0;
  background:rgba(253,252,249,0.95); border-top:1px solid var(--border-light);
  padding:10px 10px max(var(--safe-bottom),14px);
  display:flex; justify-content:space-around; align-items:center;
  z-index:50; backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);
}
.nav-item { display:flex;flex-direction:column;align-items:center;gap:3px;cursor:pointer;padding:4px 12px;border-radius:12px;transition:background var(--transition);user-select:none; }
.nav-item:active { background:var(--bg); }
.nav-icon { font-size:22px; line-height:1; }
.nav-label { font-size:10px;font-weight:500;color:var(--text-muted); }
.nav-item.active .nav-label { color:var(--green-deep);font-weight:700; }

/* ── CHAT HEADER ── */
.chat-header { background:var(--bg-card); border-bottom:1px solid var(--border-light); flex-shrink:0; }
.chat-header-top { display:flex;align-items:center;gap:10px;padding:10px 16px 8px; }
.chat-room-info { flex:1; min-width:0; }
.chat-room-name { font-family:'Lora',serif;font-size:16px;font-weight:700;color:var(--text);letter-spacing:-0.3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:6px; }
.room-status-pill { font-family:'DM Sans',sans-serif;font-size:10px;font-weight:700;padding:2px 7px;border-radius:8px;letter-spacing:0.04em;flex-shrink:0; }
.chat-members { font-size:11px;color:var(--text-muted);display:flex;align-items:center;gap:4px;margin-top:2px; }
.members-stack { display:flex; }
.mem-dot { width:18px;height:18px;border-radius:50%;border:2px solid var(--bg-card);margin-right:-6px;font-size:8px;display:flex;align-items:center;justify-content:center;color:white;font-weight:700; }
.chat-actions { display:flex;gap:6px;flex-shrink:0; }
.icon-btn { width:34px;height:34px;border-radius:var(--radius-sm);background:var(--bg);border:1px solid var(--border);display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:16px;transition:background var(--transition);position:relative; }
.icon-btn:active { background:var(--border); }
.icon-btn .notif-dot { position:absolute;top:4px;right:4px;width:7px;height:7px;background:var(--red);border-radius:50%;border:1.5px solid var(--bg-card); }

.chat-alert-pill { display:flex;align-items:center;gap:8px;padding:7px 16px;border-top:1px solid var(--border-light);cursor:pointer; }
.alert-pill-dot { width:8px;height:8px;border-radius:50%;flex-shrink:0;animation:pulse-dot 1.8s ease-in-out infinite; }
.alert-pill-text { font-size:12px;font-weight:600;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }

.subrooms-wrap { display:flex;gap:6px;padding:8px 16px;overflow-x:auto;border-top:1px solid var(--border-light); }
.subroom-chip { display:flex;align-items:center;gap:5px;padding:5px 12px;border-radius:14px;font-size:12px;font-weight:500;cursor:pointer;white-space:nowrap;flex-shrink:0;border:1.5px solid var(--border);background:var(--bg);color:var(--text-mid);transition:all var(--transition); }

/* ── NEW MESSAGES INDICATOR ── */
.new-msgs-indicator {
  position:absolute; bottom:130px; left:50%; transform:translateX(-50%);
  background:var(--green-deep); color:white; font-size:12px; font-weight:600;
  padding:7px 16px; border-radius:20px; cursor:pointer; z-index:30;
  box-shadow:0 4px 16px rgba(61,73,34,0.4); white-space:nowrap;
  animation:bounce-in 0.3s both;
  display:none;
}
.new-msgs-indicator.show { display:block; }

/* ── MESSAGES ── */
.messages-area { flex:1;overflow-y:auto;padding:12px 14px 8px;display:flex;flex-direction:column;gap:10px;position:relative;overscroll-behavior:contain; }
.load-earlier-btn { align-self:center;background:var(--bg-card);border:1.5px solid var(--border);border-radius:20px;padding:7px 16px;font-size:12.5px;font-weight:600;color:var(--text-muted);cursor:pointer;flex-shrink:0;transition:all var(--transition); }
.load-earlier-btn:active { background:var(--border); }
.date-divider { display:flex;align-items:center;gap:10px;margin:4px 0;flex-shrink:0; }
.date-divider::before,.date-divider::after { content:'';flex:1;height:1px;background:var(--border); }
.date-divider span { font-size:11px;color:var(--text-muted);font-weight:500;white-space:nowrap; }

.msg-row { display:flex;gap:8px;align-items:flex-end;flex-shrink:0;animation:msg-in 0.25s ease-out both; }
.msg-row.other { align-self:flex-start;max-width:86%; }
.msg-row.mine  { align-self:flex-end;max-width:86%;flex-direction:row-reverse; }
.msg-row.sys   { align-self:center; }

.msg-av { width:28px;height:28px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;color:white;margin-bottom:2px; }
.msg-content { display:flex;flex-direction:column;gap:2px; }
.msg-row.mine .msg-content { align-items:flex-end; }
.msg-name { font-size:10.5px;font-weight:600;color:var(--text-muted);padding-left:2px;display:flex;align-items:center;gap:5px; }

.msg-bubble { padding:9px 13px;border-radius:18px;font-size:14px;line-height:1.45;color:var(--text);word-wrap:break-word;white-space:pre-wrap; }
.msg-row.other .msg-bubble { background:var(--bg-card);border-bottom-left-radius:5px;box-shadow:0 1px 3px rgba(0,0,0,0.06); }
.msg-row.mine  .msg-bubble { background:var(--green-deep);color:white;border-bottom-right-radius:5px; }
.msg-time { font-size:10px;color:var(--text-faint);padding:0 3px; }

/* Long press highlight */
.msg-bubble.pressed { opacity:0.75; }

.sys-msg { background:rgba(255,255,255,0.75);backdrop-filter:blur(8px);border:1px solid var(--border);border-radius:10px;padding:5px 12px;font-size:11.5px;color:var(--text-muted);align-self:center;text-align:center; }

/* ── ALERT CARD ── */
.alert-card { background:var(--bg-card);border-radius:16px;border:1.5px solid;padding:12px 13px;max-width:290px; }
.alert-card-header { display:flex;align-items:center;gap:6px;margin-bottom:6px; }
.alert-card-label { font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:0.07em; }
.alert-card p { font-size:13.5px;line-height:1.4;color:var(--text); }
.alert-card-actions { display:flex;gap:6px;margin-top:9px; }
.alert-action { padding:6px 11px;border-radius:9px;font-size:11.5px;font-weight:600;cursor:pointer;border:none;font-family:inherit;transition:opacity var(--transition); }
.alert-action:active { opacity:0.75; }

/* ── FILE MESSAGE ── */
.file-msg {
  background:var(--bg-card); border:1.5px solid var(--border); border-radius:14px;
  padding:10px 13px; max-width:260px; cursor:pointer;
  transition:border-color var(--transition);
}
.file-msg:active { border-color:var(--green-mid); }
.file-msg-inner { display:flex;align-items:center;gap:10px; }
.file-icon { width:42px;height:42px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:22px;flex-shrink:0; }
.file-info { flex:1;min-width:0; }
.file-name { font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.file-meta { font-size:11px;color:var(--text-muted);margin-top:2px; }
.file-expiry { font-size:10.5px;color:var(--text-faint);margin-top:6px;display:flex;align-items:center;gap:4px; }
.file-expiry.warning { color:#D97706; font-weight:600; }
.file-expiry.danger  { color:var(--red); font-weight:700; }

/* ── IMAGE MESSAGE ── */
.img-msg { border-radius:14px;overflow:hidden;max-width:240px;cursor:pointer;position:relative; }
.img-msg img { width:100%;height:auto;display:block;max-height:300px;object-fit:cover; }
.img-msg-overlay {
  position:absolute;bottom:0;left:0;right:0;
  background:linear-gradient(transparent,rgba(0,0,0,0.5));
  padding:8px 10px 6px;
}
.img-expiry { font-size:10px;color:rgba(255,255,255,0.8);display:flex;align-items:center;gap:3px; }

/* ── REACTIONS ── */
.reactions-row { display:flex;gap:4px;flex-wrap:wrap;margin-top:-2px; }
.reaction-chip { background:var(--bg-card);border:1.5px solid var(--border);border-radius:10px;padding:3px 8px;font-size:12px;display:flex;align-items:center;gap:3px;cursor:pointer;transition:border-color var(--transition);user-select:none; }
.reaction-chip.mine { border-color:var(--green-mid);background:var(--green-pale); }
.reaction-chip:active { border-color:var(--green-mid); }
.rc-count { font-size:10px;color:var(--text-muted);font-weight:600; }

/* ── TYPING ── */
.typing-row { display:flex;align-items:center;gap:8px;align-self:flex-start;flex-shrink:0;padding-left:36px;padding-bottom:4px; }
.typing-bubble { background:var(--bg-card);border-radius:18px;border-bottom-left-radius:5px;padding:10px 14px;display:flex;gap:4px;align-items:center;box-shadow:0 1px 3px rgba(0,0,0,0.06); }
.t-dot { width:7px;height:7px;border-radius:50%;background:var(--green-light);animation:t-bounce 1.3s ease-in-out infinite; }
.t-dot:nth-child(2){animation-delay:0.18s} .t-dot:nth-child(3){animation-delay:0.36s}
@keyframes t-bounce { 0%,60%,100%{transform:translateY(0);opacity:0.5} 30%{transform:translateY(-6px);opacity:1} }
.typing-label { font-size:10.5px;color:var(--text-muted); }

/* ── QUICK CHIPS ── */
.quick-chips { display:flex;gap:6px;padding:8px 14px 4px;overflow-x:auto;background:var(--bg-card);border-top:1px solid var(--border-light);flex-shrink:0; }
.quick-chip { display:flex;align-items:center;gap:5px;background:var(--bg);border:1.5px solid var(--border);border-radius:14px;padding:6px 12px;font-size:12px;font-weight:500;white-space:nowrap;cursor:pointer;flex-shrink:0;transition:all var(--transition);color:var(--text-mid); }
.quick-chip:active { border-color:var(--green-mid);background:var(--green-pale); }

/* ── INPUT AREA ── */
.input-area { background:var(--bg-card);border-top:1px solid var(--border-light);padding:8px 14px max(var(--safe-bottom),12px);display:flex;align-items:flex-end;gap:9px;flex-shrink:0; }
.input-attach { width:38px;height:38px;border-radius:12px;background:var(--bg);border:1.5px solid var(--border);display:flex;align-items:center;justify-content:center;font-size:20px;cursor:pointer;flex-shrink:0;transition:background var(--transition); }
.input-attach:active { background:var(--border); }
.input-field-wrap { flex:1;display:flex;align-items:flex-end;background:var(--bg);border:1.5px solid var(--border);border-radius:20px;padding:9px 12px;gap:8px;transition:border-color var(--transition); }
.input-field-wrap:focus-within { border-color:var(--green-mid); }
.msg-input { flex:1;border:none;background:transparent;font-size:14.5px;font-family:inherit;color:var(--text);outline:none;resize:none;max-height:100px;line-height:1.4; }
.msg-input::placeholder { color:var(--text-faint); }
.input-emoji-btn { font-size:20px;cursor:pointer;flex-shrink:0;line-height:1;align-self:flex-end;margin-bottom:1px; }
.send-btn { width:40px;height:40px;background:var(--green-deep);border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;box-shadow:0 3px 10px rgba(61,73,34,0.35);transition:transform var(--spring);align-self:flex-end; }
.send-btn:active { transform:scale(0.88); }
.send-btn svg { width:17px;height:17px;color:white;stroke-width:2.5; }
.send-btn.disabled { opacity:0.4;pointer-events:none; }

/* ── FILE UPLOAD PREVIEW ── */
.file-preview-bar {
  background:var(--bg-card); border-top:1px solid var(--border-light);
  padding:10px 14px; display:none; align-items:center; gap:10px; flex-shrink:0;
}
.file-preview-bar.show { display:flex; }
.file-preview-thumb { width:48px;height:48px;border-radius:10px;object-fit:cover;flex-shrink:0;border:1.5px solid var(--border); }
.file-preview-icon { width:48px;height:48px;border-radius:10px;background:var(--blue-bg);border:1.5px solid var(--blue-tint);display:flex;align-items:center;justify-content:center;font-size:24px;flex-shrink:0; }
.file-preview-info { flex:1;min-width:0; }
.file-preview-name { font-size:13px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.file-preview-size { font-size:11px;color:var(--text-muted);margin-top:2px; }
.file-preview-remove { font-size:20px;color:var(--text-muted);cursor:pointer;flex-shrink:0;line-height:1; }

/* ── UPLOAD PROGRESS ── */
.upload-progress {
  background:var(--bg-card); border-top:1px solid var(--border-light);
  padding:8px 14px; display:none; align-items:center; gap:10px; flex-shrink:0;
}
.upload-progress.show { display:flex; }
.progress-bar-wrap { flex:1;background:var(--border);border-radius:4px;height:4px;overflow:hidden; }
.progress-bar { height:100%;background:var(--green-mid);border-radius:4px;transition:width 0.3s ease;width:0%; }
.progress-label { font-size:11px;color:var(--text-muted);white-space:nowrap;flex-shrink:0; }

/* ── ATTACH MENU (bottom sheet) ── */
.attach-grid { display:grid;grid-template-columns:repeat(4,1fr);gap:12px;padding:8px 0 16px; }
.attach-item { display:flex;flex-direction:column;align-items:center;gap:8px;cursor:pointer; }
.attach-icon-wrap { width:56px;height:56px;border-radius:16px;display:flex;align-items:center;justify-content:center;font-size:26px;transition:transform var(--spring); }
.attach-item:active .attach-icon-wrap { transform:scale(0.9); }
.attach-label { font-size:11.5px;font-weight:500;color:var(--text-mid);text-align:center; }

/* ── LIGHTBOX ── */
.lightbox {
  position:fixed;inset:0;background:rgba(0,0,0,0.92);z-index:500;
  display:none;flex-direction:column;align-items:center;justify-content:center;
}
.lightbox.show { display:flex; }
.lightbox img { max-width:100%;max-height:80vh;object-fit:contain;border-radius:8px; }
.lightbox-close { position:absolute;top:max(var(--safe-top),20px);right:20px;font-size:28px;color:white;cursor:pointer;line-height:1;background:rgba(255,255,255,0.15);border-radius:50%;width:40px;height:40px;display:flex;align-items:center;justify-content:center; }
.lightbox-meta { margin-top:14px;font-size:12px;color:rgba(255,255,255,0.55);text-align:center; }

/* ── EXPIRY NOTIFICATION BANNER ── */
.expiry-notif {
  background:linear-gradient(90deg,#fef9f0,#fdecc8);
  border:1.5px solid var(--amber-tint);
  border-radius:var(--radius); margin:10px 16px 0;
  padding:10px 14px; display:none; align-items:center; gap:10px; flex-shrink:0;
}
.expiry-notif.show { display:flex; }
.expiry-notif-text { flex:1;font-size:12px;color:var(--amber-dark);line-height:1.4; }
.expiry-notif-close { font-size:18px;color:var(--amber);cursor:pointer;flex-shrink:0; }

/* ── CONTEXT MENU (long press) ── */
.context-menu {
  position:fixed;background:var(--bg-card);border-radius:var(--radius);
  box-shadow:0 8px 30px rgba(0,0,0,0.2);z-index:400;min-width:180px;
  overflow:hidden;animation:bounce-in 0.2s both;
  display:none;
}
.context-menu.show { display:block; }
.context-item { padding:12px 16px;font-size:14px;cursor:pointer;display:flex;align-items:center;gap:10px;transition:background var(--transition); }
.context-item:active { background:var(--bg); }
.context-item.danger { color:var(--red); }

/* ── EMOJI PICKER ── */
.emoji-picker {
  background:var(--bg-card);border:1.5px solid var(--border);
  border-radius:var(--radius-lg);padding:12px;
  display:none;position:absolute;bottom:100%;right:0;margin-bottom:8px;
  width:280px;z-index:100;box-shadow:0 8px 30px rgba(0,0,0,0.12);
}
.emoji-picker.show { display:block; }
.emoji-grid { display:grid;grid-template-columns:repeat(8,1fr);gap:4px; }
.emoji-btn { font-size:22px;text-align:center;cursor:pointer;padding:4px;border-radius:8px;transition:background var(--transition); }
.emoji-btn:active { background:var(--bg); }

/* ── LOGIN ── */
.login-view { background:linear-gradient(160deg,#3d4922 0%,#2a3418 100%); display:flex; flex-direction:column; align-items:center; justify-content:center; padding:40px 28px; overflow-y:auto; }
.login-logo { width:80px;height:80px;background:rgba(255,255,255,0.1);border-radius:24px;display:flex;align-items:center;justify-content:center;font-size:42px;margin-bottom:20px;border:1.5px solid rgba(255,255,255,0.15);box-shadow:0 8px 30px rgba(0,0,0,0.3); }
.login-title { font-family:'Lora',serif;font-size:28px;font-weight:700;color:white;text-align:center;margin-bottom:6px; }
.login-sub { font-size:14px;color:rgba(255,255,255,0.55);text-align:center;margin-bottom:36px;line-height:1.5; }
.auth-tabs { display:flex;background:rgba(255,255,255,0.1);border-radius:14px;padding:4px;gap:4px;margin-bottom:20px;width:100%;max-width:360px; }
.auth-tab { flex:1;padding:9px;border:none;border-radius:11px;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;transition:all 0.2s; }
.auth-tab.active { background:white;color:var(--green-deep); }
.auth-tab:not(.active) { background:transparent;color:rgba(255,255,255,0.6); }
.login-card { background:var(--bg-card);border-radius:var(--radius-xl);padding:24px 22px;width:100%;max-width:360px;box-shadow:0 20px 60px rgba(0,0,0,0.3); }
.login-card h2 { font-family:'Lora',serif;font-size:20px;color:var(--text);margin-bottom:18px; }
.form-group { margin-bottom:14px; }
.form-label { font-size:12px;font-weight:600;color:var(--text-mid);margin-bottom:5px;display:block;letter-spacing:0.03em; }
.form-input { width:100%;padding:11px 14px;border:1.5px solid var(--border);border-radius:12px;font-size:14.5px;font-family:inherit;color:var(--text);background:var(--bg);outline:none;transition:border-color var(--transition); }
.form-input:focus { border-color:var(--green-mid); }
.form-input::placeholder { color:var(--text-faint); }
.form-helper { font-size:11px;color:var(--text-muted);margin-top:4px; }
.form-error { background:#fdf3f2;border:1px solid var(--red-tint);border-radius:10px;padding:10px 12px;font-size:13px;color:var(--red);margin-top:4px;display:none; }
.btn-primary { width:100%;padding:13px;background:var(--green-deep);color:white;border:none;border-radius:14px;font-size:15px;font-weight:600;font-family:inherit;cursor:pointer;margin-top:6px;transition:transform var(--spring);box-shadow:0 4px 14px rgba(61,73,34,0.35); }
.btn-primary:active { transform:scale(0.97); }
.btn-primary:disabled { opacity:0.6;cursor:wait; }
.login-footer { margin-top:16px;font-size:12px;color:var(--text-muted);text-align:center;line-height:1.6; }
.login-footer a { color:var(--green-mid);font-weight:600;text-decoration:none; }

/* ── SKELETON ── */
.skeleton { background:linear-gradient(90deg,var(--border) 25%,var(--border-light) 50%,var(--border) 75%);background-size:200% 100%;border-radius:8px;animation:shimmer 1.5s infinite; }

/* ── TOAST ── */
.toast { position:fixed;bottom:90px;left:50%;transform:translateX(-50%) translateY(20px);background:var(--text);color:white;padding:10px 18px;border-radius:12px;font-size:13px;font-weight:500;opacity:0;pointer-events:none;transition:all 0.3s ease;z-index:999;white-space:nowrap;box-shadow:0 4px 20px rgba(0,0,0,0.25); }
.toast.show { opacity:1;transform:translateX(-50%) translateY(0); }

/* ── SHEET ── */
.sheet-overlay { position:fixed;inset:0;background:rgba(0,0,0,0.4);backdrop-filter:blur(4px);z-index:100;opacity:0;pointer-events:none;transition:opacity var(--transition); }
.sheet-overlay.visible { opacity:1;pointer-events:all; }
.bottom-sheet { position:fixed;bottom:0;left:0;right:0;background:var(--bg-card);border-radius:var(--radius-xl) var(--radius-xl) 0 0;padding:16px 20px max(var(--safe-bottom),24px);z-index:101;transform:translateY(100%);transition:transform var(--spring); }
.bottom-sheet.visible { transform:translateY(0); }
.sheet-handle { width:36px;height:4px;background:var(--border);border-radius:2px;margin:0 auto 16px; }
.sheet-title { font-family:'Lora',serif;font-size:18px;font-weight:700;color:var(--text);margin-bottom:14px; }

/* ── INSTALL PROMPT ── */
.install-prompt { position:fixed;bottom:80px;left:16px;right:16px;background:var(--bg-card);border:1.5px solid var(--border);border-radius:var(--radius-lg);padding:14px 16px;display:flex;align-items:center;gap:12px;z-index:200;box-shadow:0 8px 30px rgba(0,0,0,0.15);transform:translateY(150px);transition:transform var(--spring); }
.install-prompt.visible { transform:translateY(0); }
.install-icon { font-size:32px;flex-shrink:0; }
.install-text { flex:1; }
.install-text strong { font-size:13.5px;color:var(--text); }
.install-text p { font-size:11.5px;color:var(--text-muted);margin-top:1px; }
.install-btn { background:var(--green-deep);color:white;border:none;border-radius:10px;padding:8px 14px;font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;flex-shrink:0; }
.install-dismiss { font-size:20px;color:var(--text-muted);cursor:pointer;flex-shrink:0;line-height:1; }

/* ── NOTIFICATION PERMISSION BANNER ── */
.notif-banner { background:linear-gradient(90deg,var(--blue-bg),#e8f4ff);border:1.5px solid var(--blue-tint);border-radius:var(--radius);margin:10px 16px 0;padding:10px 14px;display:none;align-items:center;gap:10px;flex-shrink:0; }
.notif-banner.show { display:flex; }
.notif-banner-text { flex:1;font-size:12px;color:var(--blue-dark);line-height:1.4; }
.notif-banner-btn { background:var(--blue);color:white;border:none;border-radius:9px;padding:6px 12px;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;flex-shrink:0; }
.notif-banner-close { font-size:18px;color:var(--blue);cursor:pointer;flex-shrink:0; }

/* ── STAGGER IN ── */
.stagger-in > * { animation:slide-up 0.45s both ease-out; }
.stagger-in > *:nth-child(1){animation-delay:.00s} .stagger-in > *:nth-child(2){animation-delay:.06s}
.stagger-in > *:nth-child(3){animation-delay:.12s} .stagger-in > *:nth-child(4){animation-delay:.18s}
.stagger-in > *:nth-child(5){animation-delay:.24s} .stagger-in > *:nth-child(6){animation-delay:.30s}
.stagger-in > *:nth-child(7){animation-delay:.36s} .stagger-in > *:nth-child(8){animation-delay:.42s}

/* ── DESKTOP PREVIEW ── */
@media(min-width:480px){
  #app { max-width:390px;margin:0 auto;border-left:1px solid var(--border);border-right:1px solid var(--border);box-shadow:0 0 60px rgba(0,0,0,0.1); }
  body { background:#e8e5dd; }
  .bottom-nav { max-width:390px;left:50%;transform:translateX(-50%); }
  .install-prompt { max-width:358px;left:50%;transform:translateX(-50%) translateY(150px); }
  .install-prompt.visible { transform:translateX(-50%) translateY(0); }
  .new-msgs-indicator { bottom:90px; }
}
