:root {
  --canvas: #f4f1eb;
  --paper: #fbfaf7;
  --paper-deep: #f0eee8;
  --paper-card: #ffffff;
  --ink: #202721;
  --ink-soft: #526057;
  --muted: #7e877f;
  --line: #deded6;
  --line-strong: #cecec4;
  --olive: #3f6b5a;
  --olive-dark: #2a483c;
  --olive-light: #e8f0eb;
  --gold: #c08a45;
  --gold-light: #fef8ec;
  --error: #a04f48;
  --error-light: #f8e8e4;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  
  --button-primary: #3f6b5a;
  --button-primary-hover: #2f5044;
  --button-soft: #e8f0eb;
  --button-soft-hover: #d7e5dc;
  --button-accent: #c08a45;
  --button-accent-hover: #a87537;
  --button-danger-soft: #f8e8e4;
  --button-danger: #a04f48;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { height: 100%; min-width: 320px; overflow: hidden; background: var(--canvas); }
body { height: 100%; min-width: 320px; min-height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--canvas); }

button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.hidden { display: none !important; }
.app-shell { height: 100%; min-height: 0; overflow: hidden; }

/* SIGN IN VIEW */
.login-view {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 64px);
  background: radial-gradient(circle at 50% 34%, rgba(255, 255, 255, .85), var(--canvas) 60%);
}

.login-panel { width: 100%; max-width: 460px; }
.login-card {
  padding: clamp(32px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 20px 50px rgba(40, 44, 35, .07);
  text-align: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--ink);
  margin-inline: auto;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-mark.small { width: 34px; height: 34px; border-radius: 9px; }

.eyebrow {
  margin: 24px 0 12px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(36px, 5vw, 52px);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: 1;
}

.login-card h1 span { color: var(--muted); font-style: italic; }
.login-copy { max-width: 340px; margin: 18px auto 26px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; }

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--button-primary);
  border-radius: 11px;
  background: var(--button-primary);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
}

.google-button:hover {
  background: var(--button-primary-hover);
  box-shadow: 0 8px 20px rgba(41, 59, 48, .18);
  transform: translateY(-1px);
}

.google-button:disabled { cursor: wait; opacity: .65; transform: none; }
.google-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  color: #3975e7;
  font-size: 14px;
  font-weight: 900;
}
.button-arrow { width: 18px; height: 18px; color: #e5be82; }

.form-error { min-height: 20px; margin: 12px 0 0; color: var(--error); font-size: 12px; }
.login-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 24px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.privacy-mark { color: var(--gold); font-size: 16px; }

/* PIN & OTP VIEW */
.pin-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: clamp(16px, 4vh, 36px) 16px;
  padding-bottom: calc(clamp(20px, 4vh, 40px) + env(safe-area-inset-bottom, 0px));
  background: radial-gradient(circle at 50% 30%, #fff, var(--canvas) 60%);
  overscroll-behavior-y: contain;
}

.pin-card {
  width: min(100%, 460px);
  margin: auto 0;
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(32, 39, 33, .09);
  text-align: center;
  transition: transform .2s ease;
}

.pin-card h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: 1.1;
}

.pin-card h1 em { color: var(--gold); font-style: italic; }
.pin-description { margin: 14px auto 22px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; }

.pin-form label {
  display: block;
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  color: var(--ink);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pin-form input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  letter-spacing: .35em;
  text-align: center;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}

.pin-form input:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(63, 107, 90, .15);
  outline: none;
}

.text-button {
  display: block;
  margin: 16px auto 0;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
  transition: color .2s;
  touch-action: manipulation;
}

.text-button:hover { color: var(--ink); text-decoration: underline; }

.pin-forgot-btn {
  color: var(--olive);
  font-weight: 600;
  font-size: 12.5px;
  margin-top: 14px;
}
.pin-forgot-btn:hover { color: var(--ink); text-decoration: underline; }

.form-hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.5;
}

#otp-input {
  font-size: 22px;
  letter-spacing: .35em;
  text-align: center;
}

#forgot-pin-send-section {
  margin-bottom: 16px;
}




/* SKELETON LOADING SYSTEM */
@keyframes sk-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.sk-bone {
  background: linear-gradient(90deg, rgba(230, 226, 218, 0.6) 25%, rgba(248, 246, 242, 0.95) 50%, rgba(230, 226, 218, 0.6) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.8s infinite ease-in-out;
  border-radius: 8px;
}

.skeleton-container {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  background: var(--canvas);
  opacity: 1;
  visibility: visible;
  transition: opacity .35s cubic-bezier(.4, 0, .2, 1), visibility .35s cubic-bezier(.4, 0, .2, 1);
  pointer-events: all;
}

.skeleton-container.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sk-view {
  width: 100%;
  height: 100dvh;
}

/* Auth Skeleton */
.sk-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sk-auth-card {
  width: min(100%, 460px);
  padding: clamp(30px, 6vw, 48px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(32, 39, 33, .07);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.sk-logo { width: 56px; height: 56px; border-radius: 50%; margin-bottom: 20px; }
.sk-eyebrow { width: 140px; height: 12px; margin-bottom: 14px; }
.sk-title { width: 220px; height: 32px; margin-bottom: 12px; }
.sk-desc { width: 280px; height: 16px; margin-bottom: 28px; }
.sk-input { width: 100%; height: 50px; border-radius: 12px; margin-bottom: 16px; }
.sk-btn { width: 100%; height: 50px; border-radius: 12px; }

/* Main Chat Skeleton */
.sk-chat {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  height: 100dvh;
}
.sk-sidebar {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sk-sidebar-top { display: flex; align-items: center; gap: 10px; }
.sk-avatar-sm { width: 34px; height: 34px; border-radius: 50%; }
.sk-brand-name { width: 110px; height: 16px; }
.sk-profile-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--button-soft);
}
.sk-avatar-lg { width: 44px; height: 44px; border-radius: 50%; }
.sk-avatar-md { width: 40px; height: 40px; border-radius: 50%; }
.sk-profile-lines, .sk-conv-lines, .sk-header-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sk-tabs-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sk-tab { height: 36px; border-radius: 10px; }
.sk-conv-list { display: flex; flex-direction: column; gap: 12px; }
.sk-conv-item { display: flex; align-items: center; gap: 12px; padding: 6px 0; }

.sk-main-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sk-chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sk-message-area {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sk-msg { height: 50px; border-radius: 16px; }
.sk-msg-left {
  align-self: flex-start;
  background: linear-gradient(90deg, rgba(230, 226, 218, 0.5) 25%, rgba(248, 246, 242, 0.9) 50%, rgba(230, 226, 218, 0.5) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.8s infinite ease-in-out;
}
.sk-msg-right {
  align-self: flex-end;
  background: linear-gradient(90deg, rgba(63, 107, 90, 0.12) 25%, rgba(63, 107, 90, 0.22) 50%, rgba(63, 107, 90, 0.12) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.8s infinite ease-in-out;
}
.sk-composer-box { padding: 14px 20px; border-top: 1px solid var(--line); }
.sk-composer-input { width: 100%; height: 50px; border-radius: 14px; }

/* Friends & Settings Skeleton */
.sk-friends, .sk-settings {
  padding: 30px clamp(16px, 5vw, 48px);
  overflow-y: auto;
}
.sk-content-header { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.sk-friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.sk-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}
.sk-p20 { padding: 20px; }
.sk-p24 { padding: 24px; }
.sk-full-grid { grid-column: 1 / -1; }
.sk-grid-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

/* Width utilities */
.sk-w20 { width: 20%; height: 12px; }
.sk-w30 { width: 30%; height: 12px; }
.sk-w40 { width: 40%; height: 14px; }
.sk-w50 { width: 50%; height: 14px; }
.sk-w60 { width: 60%; height: 14px; }
.sk-w70 { width: 70%; height: 14px; }
.sk-w80 { width: 80%; height: 14px; }

@media (max-width: 720px) {
  .sk-chat {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .sk-sidebar { display: none; }
  .sk-main-panel { border-radius: 0; border-width: 0; }
  .sk-friends, .sk-settings { padding: 20px 14px; }
}

/* CHAT SHELL & SIDEBAR */
.chat-view {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  max-height: 100dvh;
  overflow: hidden;
  padding: 16px;
  background: var(--canvas);
}

.mobile-toolbar, .mobile-overlay { display: none; }

.sidebar, .chat-panel, .content-panel, .settings-view {
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
}

/* SIDEBAR LAYOUT */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 14px 14px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 16px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-lockup strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-lockup span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--button-soft);
  color: var(--button-primary);
  cursor: pointer;
  transition: all .2s;
}

.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover {
  border-color: #b8cdbd;
  background: var(--button-soft-hover);
  color: var(--button-primary-hover);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: var(--olive);
  color: #fff;
  font-weight: 800;
  user-select: none;
}

.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar.large { width: 44px; height: 44px; }
.avatar.mini { width: 36px; height: 36px; background: var(--paper-deep); color: var(--olive); font-size: 13px; }

.profile-info { min-width: 0; flex: 1; }
.profile-info strong, .profile-info span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-info strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.profile-info span { margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.role-badge {
  padding: 3px 6px;
  border: 1px solid #c7d8cb;
  border-radius: 5px;
  color: var(--olive);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .08em;
}

/* 3 APP TABS */
.app-tabs {
  display: grid;
  gap: 6px;
  margin: 14px 0 6px;
}

.app-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all .2s;
}

.app-tab svg { width: 19px; height: 19px; }
.app-tab b {
  display: grid;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-left: auto;
  place-items: center;
  border-radius: 99px;
  background: var(--error);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
}

.app-tab b:empty { display: none; }
.app-tab:hover { background: var(--paper-deep); color: var(--ink); }
.app-tab.active {
  border-color: #cad9ce;
  background: var(--button-soft);
  color: var(--button-primary-hover);
}

/* SIDEBAR CONVERSATION SECTION */
.sidebar-conversations-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.section-label {
  display: flex;
  justify-content: space-between;
  margin: 14px 6px 8px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-right: -4px;
  padding-right: 4px;
}

.conversation-list::-webkit-scrollbar { width: 4px; }
.conversation-list::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--line-strong); }

.conversation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 4px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f7f9f6;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: all .2s;
}

.conversation-item:hover { background: var(--button-soft); }
.conversation-item.active {
  border-color: #c9dbcd;
  background: #e4eee6;
}

.conversation-copy { min-width: 0; flex: 1; }
.conversation-copy strong, .conversation-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-copy strong { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.conversation-copy small { margin-top: 3px; color: var(--muted); font-size: 10.5px; }

.conversations-empty-hint {
  padding: 16px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  background: #f9f8f4;
  border-radius: 10px;
  border: 1px dashed var(--line);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 6px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--olive);
  vertical-align: 1px;
}

/* TAB 1: CONVERSATIONS PANEL */
.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.contact-avatar {
  width: 44px;
  height: 44px;
  background: var(--ink);
  color: #e5be82;
  font-size: 16px;
}

.chat-overline {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.chat-contact h2 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-contact p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chat-contact p.online { color: var(--olive); font-weight: 600; }

.header-chip {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .05em;
  background: var(--paper-deep);
}

.chat-banner {
  margin: 14px 26px 0;
  padding: 9px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.5;
}

.message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 26px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message-list::-webkit-scrollbar { width: 5px; }
.message-list::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--line-strong); }

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--gold);
  background: #fff;
}

.empty-icon svg { width: 28px; height: 28px; }
.empty-state h3 { margin: 16px 0 6px; color: var(--ink); font-size: 17px; font-weight: 700; }
.empty-state p { margin: 0; font-size: 12px; max-width: 320px; line-height: 1.5; }

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 300px);
  margin: 8px auto 20px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
}

.date-divider::before, .date-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.message-row { display: flex; margin: 8px 0; }
.message-row.mine { justify-content: flex-end; }

.message-bubble {
  max-width: min(72%, 540px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(40, 44, 35, .03);
}

.mine .message-bubble {
  border-color: var(--olive-dark);
  border-radius: 14px 4px 14px 14px;
  background: var(--olive-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(42, 72, 60, .15);
}

.message-bubble p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; }
.message-bubble time { display: block; margin-top: 5px; color: var(--muted); font-size: 9.5px; }
.mine .message-bubble time { color: #b2cfbe; }

.typing-status { min-height: 14px; color: var(--gold) !important; font-size: 11px !important; font-style: italic; }
.typing-status:empty { display: none; }
.composer-typing { margin: 0 30px 4px; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 26px 12px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  transition: all .2s;
}

.composer:focus-within {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(63, 107, 90, .12);
}

.composer textarea {
  flex: 1;
  max-height: 130px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
  padding: 6px 0;
}

.composer textarea::placeholder { color: #a4aaa2; }
.composer-actions { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9.5px; }

.send-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--button-primary);
  color: #fff;
  cursor: pointer;
  transition: all .2s;
}

.send-button svg { width: 18px; height: 18px; }
.send-button:hover { background: var(--button-primary-hover); transform: translateY(-1px); }
.send-button:disabled, .composer textarea:disabled { cursor: not-allowed; opacity: .45; }
.chat-error { min-height: 16px; margin: 0 30px 6px; color: var(--error); font-size: 11px; }
.chat-error:empty { display: none; }

/* TAB 2: FRIENDS PANEL (HUB) */
.content-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(24px, 4vw, 40px);
}

.content-panel-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.content-panel-header .eyebrow { margin-top: 0; }
.content-panel-header h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 400;
  letter-spacing: -.04em;
  line-height: 1;
}

.content-panel-header p { margin: 10px 0 0; color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; }

.friends-hub {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.friends-hub-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .02);
}

.friends-hub-card.full-width { grid-column: 1 / -1; }

.card-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.card-header p {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.contact-search-row {
  display: flex;
  gap: 8px;
}

.contact-search-row input {
  min-width: 0;
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: all .2s;
}

.contact-search-row input:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(63, 107, 90, .1);
}

.contact-search-row button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--button-primary);
  border-radius: 10px;
  background: var(--button-primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}

.contact-search-row button svg { width: 16px; height: 16px; }
.contact-search-row button:hover { background: var(--button-primary-hover); }

.contact-search-results, .friend-requests {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 12px;
}

.contact-result-item, .friend-request-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: #f9f8f4;
  margin-bottom: 6px;
  transition: background .2s;
}

.contact-result-item:hover, .friend-request-item:hover { background: #f0eee8; }

.contact-result-copy, .friend-request-copy { min-width: 0; flex: 1; }
.contact-result-copy strong, .contact-result-copy small,
.friend-request-copy strong, .friend-request-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-result-copy strong, .friend-request-copy strong { font-size: 12.5px; font-weight: 700; }
.contact-result-copy small, .friend-request-copy small { margin-top: 2px; color: var(--muted); font-size: 10.5px; }

.contact-result-action {
  padding: 6px 12px;
  border: 1px solid var(--button-accent);
  border-radius: 8px;
  background: var(--button-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}

.contact-result-action:hover:not(:disabled) { background: var(--button-accent-hover); border-color: var(--button-accent-hover); }
.contact-result-action:disabled { opacity: .55; cursor: default; background: #e0ded6; border-color: var(--line); color: var(--muted); }

.friend-request-actions { display: flex; gap: 6px; }
.btn-accept {
  padding: 6px 10px;
  border: 1px solid #c2dac9;
  border-radius: 8px;
  background: var(--button-soft);
  color: var(--button-primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-accept:hover { background: var(--button-soft-hover); }

.btn-reject {
  padding: 6px 10px;
  border: 1px solid #efcfc8;
  border-radius: 8px;
  background: var(--button-danger-soft);
  color: var(--button-danger);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-reject:hover { background: #f3d4cd; }

.contacts-empty { color: var(--muted); font-size: 11.5px; margin: 8px 0; }
.contacts-mini-heading { font-size: 9.5px; font-weight: 800; color: var(--muted); letter-spacing: .1em; margin: 0 0 8px; text-transform: uppercase; }
.contacts-pending-note { margin: 8px 0 0; color: var(--muted); font-size: 11px; }

/* FRIENDS FULL LIST */
.friends-full-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.friend-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaf7;
  transition: all .2s;
}

.friend-profile-card:hover {
  border-color: #c9dbcd;
  background: #f4f8f5;
  box-shadow: 0 4px 12px rgba(63, 107, 90, .06);
}

.friend-card-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.friend-card-copy { min-width: 0; flex: 1; }
.friend-card-copy strong, .friend-card-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-card-copy strong { font-size: 13px; font-weight: 700; color: var(--ink); }
.friend-card-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.friend-card-actions { display: flex; align-items: center; gap: 6px; }

.btn-chat-now {
  padding: 7px 12px;
  border: 1px solid var(--button-primary);
  border-radius: 8px;
  background: var(--button-primary);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}

.btn-chat-now:hover {
  background: var(--button-primary-hover);
  transform: translateY(-1px);
}

.btn-unfriend {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}

.btn-unfriend:hover {
  border-color: #efcfc8;
  background: var(--button-danger-soft);
  color: var(--button-danger);
}

.friends-list-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #faf9f5;
}

/* TAB 3: SETTINGS PANEL */
.settings-view {
  min-height: 0;
  overflow-y: auto;
}

.settings-shell { min-height: 100%; }

.settings-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 30px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.settings-content {
  width: min(100%, 640px);
  margin: 0 auto;
  padding: clamp(32px, 5vw, 60px) 24px 60px;
}

.settings-content .eyebrow { margin-top: 0; }
.settings-content h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 50px);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: 1;
}

.settings-content h1 em { color: var(--gold); font-style: italic; }
.settings-intro { max-width: 460px; margin: 16px 0 28px; color: var(--ink-soft); font-size: 13.5px; line-height: 1.65; }

.settings-card {
  padding: clamp(22px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .02);
}

.settings-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.settings-identity strong, .settings-identity span { display: block; }
.settings-identity strong { color: var(--ink); font-size: 14px; font-weight: 700; }
.settings-identity span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.settings-identity-copy { min-width: 0; flex: 1; }
.settings-identity-copy small { display: block; margin-top: 6px; color: var(--muted); font-size: 10.5px; }

.avatar-settings-actions { display: flex; align-items: center; flex: 0 0 auto; }
.avatar-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }

.avatar-change-button {
  padding: 8px 14px;
  border: 1px solid #d3a765;
  border-radius: 8px;
  background: #fdf5e8;
  color: #8c5d23;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all .2s;
}

.avatar-change-button:hover {
  border-color: var(--button-accent);
  background: #f9ead0;
}

.settings-status { min-height: 16px; margin: 10px 0 0; color: var(--success); font-size: 11px; font-weight: 600; }
.settings-status:empty { display: none; }

.displayname-form { margin-top: 22px; }
.displayname-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.displayname-form input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: all .2s;
}

.displayname-form input:focus {
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(63, 107, 90, .1);
}

.field-meta { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 9.5px; }

.settings-save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  border: 1px solid var(--button-primary);
  border-radius: 10px;
  background: var(--button-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}

.settings-save svg { width: 18px; height: 18px; color: #e5be82; }
.settings-save:hover { background: var(--button-primary-hover); transform: translateY(-1px); }
.settings-save:disabled { cursor: wait; opacity: .65; transform: none; }

.security-card { margin-top: 22px; }
.security-card .eyebrow { margin: 0 0 8px; }
.security-card h2 { margin: 0; font-size: 18px; font-weight: 700; }
.security-card > p:not(.eyebrow) { margin: 6px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.security-card .displayname-form label:not(:first-child) { margin-top: 14px; }
.settings-note { display: flex; align-items: center; gap: 8px; margin: 20px 0 0; color: var(--muted); font-size: 11px; }

/* FIRST-TIME ONBOARDING MODAL */
.onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 39, 33, .45);
  backdrop-filter: blur(8px);
}

.onboarding-card {
  width: min(100%, 460px);
  padding: clamp(28px, 5vw, 44px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .18);
  text-align: center;
}

.onboarding-card h2 {
  margin: 0;
  font-size: clamp(30px, 6vw, 40px);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: 1;
}

.onboarding-card h2 em { color: var(--gold); font-style: italic; }
.onboarding-copy { margin: 14px auto 22px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }

/* RESPONSIVENESS */
@media (max-width: 900px) {
  .chat-view { grid-template-columns: 280px minmax(0, 1fr); }
  .friends-hub { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .chat-view {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding: 0;
  }

  .mobile-toolbar {
    display: flex;
    position: relative;
    z-index: 10;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
  }

  .mobile-toolbar-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--button-soft);
    color: var(--button-primary);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-toolbar-button svg { width: 17px; height: 17px; }
  .mobile-toolbar-title { min-width: 0; text-align: center; }
  .mobile-toolbar-title span { display: block; color: var(--gold); font-size: 8px; font-weight: 800; letter-spacing: .14em; }
  .mobile-toolbar-title strong { display: block; max-width: 170px; margin-top: 2px; color: var(--ink); font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .mobile-overlay {
    position: absolute;
    inset: 56px 0 0;
    z-index: 25;
    width: 100%;
    border: 0;
    background: rgba(32, 39, 33, .3);
    cursor: pointer;
  }

  .chat-view.mobile-sidebar-open .mobile-overlay { display: block; }

  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(85vw, 320px);
    height: 100%;
    border-width: 0 1px 0 0;
    border-radius: 0 18px 18px 0;
    box-shadow: 18px 0 40px rgba(32, 39, 33, .15);
    transform: translateX(-105%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  }

  .chat-view.mobile-sidebar-open .sidebar { transform: translateX(0); }

  .chat-panel, .content-panel, .settings-view {
    flex: 1 1 auto;
    border-radius: 0;
    border-width: 0;
  }

  .chat-header { padding: 14px 16px; }
  .header-chip { display: none; }
  .chat-banner { margin: 10px 16px 0; }
  .message-list { padding: 16px; }
  .composer { margin: 0 14px 8px; }
  .content-panel { padding: 20px 16px; }
  .settings-content { padding: 28px 16px; }
}

@media (max-width: 520px) {
  .login-view, .pin-view {
    padding: 16px 12px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .login-card, .pin-card, .onboarding-card {
    padding: 24px 18px;
    border-radius: 20px;
  }

  .pin-card h1, .login-card h1, .onboarding-card h2 {
    font-size: 26px;
  }

  .pin-description, .onboarding-copy {
    margin: 12px auto 18px;
    font-size: 13px;
  }

  .pin-form input {
    height: 48px;
    font-size: 20px;
    letter-spacing: .3em;
  }

  #otp-input {
    font-size: 20px;
    letter-spacing: .3em;
  }

  .google-button, .settings-save {
    height: 48px;
    font-size: 13.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
