/* =========================================================
   SevenChat — minimal black canvas, white cards, red accent
   Palette: black / white / red
   ========================================================= */

:root {
  --bg: #050506;
  --bg-elev: #101014;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-3: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f6;
  --text-dim: #b7b7c0;
  --muted: #85858f;
  --accent: #ff2d3f;
  --accent-soft: rgba(255, 45, 63, 0.16);
  --accent-2: #ff6b76;
  --green: #3ddc97;
  --amber: #ffb454;
  --danger: #ff2d3f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --blur: saturate(150%) blur(18px);
  --sidebar-w: 268px;
  --topbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(900px 600px at 82% -10%, rgba(255, 45, 63, 0.16), transparent 60%),
    radial-gradient(700px 500px at -10% 100%, rgba(255, 45, 63, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

a { color: var(--accent-2); text-decoration: none; }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.hidden { display: none !important; }

.muted { color: var(--muted); }

/* ---------------------------------------------------------
   Buttons / shared controls
   --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.94rem;
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #d91f30);
  color: #fff;
  box-shadow: 0 10px 26px rgba(255, 45, 63, 0.32);
}
.btn.primary:hover { filter: brightness(1.06); }

.btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
}
.btn.ghost:hover { background: var(--surface); }

.btn.danger {
  background: var(--accent-soft);
  color: #ff8a92;
  border-color: rgba(255, 45, 63, 0.4);
}
.btn.danger:hover { background: rgba(255, 45, 63, 0.24); }

.btn.sm { padding: 8px 14px; font-size: 0.84rem; }
.btn.full { width: 100%; }

.btn svg { width: 18px; height: 18px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  transition: background 0.18s, color 0.18s, transform 0.12s;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.accent { color: var(--accent-2); }
.icon-btn.send {
  background: linear-gradient(135deg, var(--accent), #d91f30);
  color: #fff;
}
.icon-btn.send:hover { filter: brightness(1.08); }

.link-btn {
  border: none;
  background: none;
  color: var(--accent-2);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 8px;
}
.link-btn:hover { background: var(--accent-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.pill svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------
   Avatars
   --------------------------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--surface-3);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  flex: none;
  overflow: hidden;
}
.avatar.sm { width: 38px; height: 38px; font-size: 0.8rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; border-width: 2px; }
.avatar.xxl { width: 132px; height: 132px; font-size: 2.8rem; border-width: 2px; }

/* ---------------------------------------------------------
   Landing
   --------------------------------------------------------- */
.landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(18px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
  max-width: 1180px;
  margin: 0 auto;
  animation: fadeUp 0.5s ease both;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #a8121f);
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: 0 8px 22px rgba(255, 45, 63, 0.35);
}
.brand-text small {
  display: block;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1px;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 0 32px;
  max-width: 760px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0 0 24px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.6);
  animation: pulse 2s infinite;
}

.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(2.3rem, 8vw, 4.3rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 800;
}
.hero h1 span {
  display: block;
  font-size: 0.36em;
  letter-spacing: -0.01em;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 14px;
}

.hero-sub {
  margin: 0 0 32px;
  max-width: 560px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-stats {
  display: flex;
  gap: 34px;
  margin-top: 46px;
  flex-wrap: wrap;
}
.hero-stats div { display: flex; flex-direction: column; gap: 4px; }
.hero-stats strong { font-size: 1.15rem; letter-spacing: -0.01em; }
.hero-stats span { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.feature-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 20px;
}
.feature-card {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s;
}
.feature-card:hover {
  transform: translateY(-3px) scale(1.015);
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.feature-card h3 { margin: 14px 0 6px; font-size: 1rem; }
.feature-card p { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }

.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-2);
  border: 1px solid rgba(255, 45, 63, 0.24);
}
.feature-icon svg { width: 22px; height: 22px; }

.landing-foot {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-top: 40px;
  color: var(--muted);
  font-size: 0.76rem;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------
   Modals
   --------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.18s ease both;
}
.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(28, 28, 33, 0.96), rgba(15, 15, 18, 0.98));
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  animation: slideUp 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.modal-card.small { width: min(360px, 100%); }
.modal-close { position: absolute; top: 12px; right: 12px; }

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand h2 { margin: 0; font-size: 1.18rem; letter-spacing: -0.01em; }

.tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  padding: 9px;
  border: none;
  background: transparent;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.18s, color 0.18s;
}
.tab.active { background: var(--surface-3); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.01em; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus {
  border-color: rgba(255, 45, 63, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 45, 63, 0.12);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: #ff8a92;
  font-size: 0.82rem;
  line-height: 1.4;
}
.auth-hint { margin: 16px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; text-align: center; }

.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
#confirmText { margin: 8px 0 0; font-size: 0.9rem; line-height: 1.5; }

/* ---------------------------------------------------------
   App shell
   --------------------------------------------------------- */
.app {
  display: flex;
  min-height: 100dvh;
  animation: fadeIn 0.25s ease both;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 60;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: calc(18px + var(--safe-top)) 14px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(20, 20, 24, 0.98), rgba(11, 11, 13, 0.99));
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.sidebar.open { transform: translateX(0); box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5); }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 18px;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.91rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.18s, color 0.18s;
}
.nav-item svg { width: 20px; height: 20px; opacity: 0.85; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: #ffd7da;
  box-shadow: inset 0 0 0 1px rgba(255, 45, 63, 0.22);
}
.nav-item.active svg { color: var(--accent-2); opacity: 1; }
.nav-item span { flex: 1; }

.nav-badge {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-group { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.nav-label {
  margin: 0 0 6px;
  padding: 0 13px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.sidebar-foot { padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.me-mini {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 14px;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 0.18s;
}
.me-mini:hover { background: var(--surface); }
.me-mini-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.me-mini-text strong { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-mini-text small { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease both;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 11, 0.82);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex: none;
  z-index: 20;
}
.topbar-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 7px; padding-right: 6px; }
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.25s, box-shadow 0.25s;
}
.conn-dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.14); }
.conn-dot.connecting { background: var(--amber); animation: pulse 1.4s infinite; }
.conn-text { font-size: 0.72rem; color: var(--muted); }

.views { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.view { display: none; padding: 18px 16px calc(24px + var(--safe-bottom)); animation: fadeUp 0.22s ease both; }
.view.active { display: block; }
#view-messages.active {
  display: block;
  height: 100%;
  padding: 0;
  animation: none;
}

/* ---------------------------------------------------------
   Panels / home
   --------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.panel + .panel { margin-top: 14px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 1rem; letter-spacing: -0.01em; }
.panel-head.sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 0 12px;
  margin: 0;
  background: linear-gradient(180deg, rgba(18, 18, 22, 0.98), rgba(18, 18, 22, 0.75));
  backdrop-filter: blur(8px);
}

.home-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }

.mini-list { display: flex; flex-direction: column; gap: 2px; }
.mini-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 13px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.16s;
}
.mini-item:hover { background: var(--surface-2); }
.mini-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-item-text strong { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item-text small { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.mini-time { font-size: 0.68rem; color: var(--muted); }
.mini-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.online-dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.16); }

.empty-inline { color: var(--muted); font-size: 0.84rem; padding: 16px 10px; text-align: center; }

.quick-cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 16px; }
.quick-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: transform 0.2s ease, border-color 0.2s, background 0.2s;
}
.quick-card:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-2); }
.quick-card .feature-icon { width: 42px; height: 42px; }
.quick-card strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
.quick-card small { color: var(--muted); font-size: 0.76rem; }

/* ---------------------------------------------------------
   Chat layout
   --------------------------------------------------------- */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
  min-height: 0;
}

.chat-list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
}
.chat-list-panel .panel-head { padding: 18px 16px 8px; margin: 0; }
.chat-list-panel .panel-head h2 { font-size: 1.02rem; }

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 16px 12px;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
}
.search-box svg { width: 17px; height: 17px; color: var(--muted); }
.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.86rem;
}
.search-box.compact { margin: 0; padding: 7px 12px; max-width: 220px; }

.user-list { display: flex; flex-direction: column; padding: 0 8px 14px; gap: 1px; }
.user-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 13px;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.16s;
}
.user-row:hover { background: var(--surface-2); }
.user-row.active { background: var(--accent-soft); }
.user-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-row-text strong { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row-text small { font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-panel { display: none; flex-direction: column; min-height: 0; background: rgba(0, 0, 0, 0.12); }
.chat-layout.chatting .chat-list-panel { display: none; }
.chat-layout.chatting .chat-panel { display: flex; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 40px 24px;
  color: var(--muted);
}
.empty-state .feature-icon { width: 58px; height: 58px; border-radius: 18px; margin-bottom: 6px; }
.empty-state h3 { margin: 0; color: var(--text); font-size: 1.05rem; }
.empty-state p { margin: 0; font-size: 0.85rem; max-width: 280px; line-height: 1.5; }

.chat-active { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.75);
  backdrop-filter: blur(10px);
  flex: none;
}
.chat-peer { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-peer-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-peer-text strong { font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-text small { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-text small.online { color: var(--green); }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg {
  display: flex;
  max-width: 82%;
  animation: msgIn 0.18s ease both;
}
.msg.out { align-self: flex-end; }
.msg.in { align-self: flex-start; }

.msg-bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.out .msg-bubble {
  background: linear-gradient(135deg, #e32334, #b51626);
  border-color: transparent;
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg.in .msg-bubble { border-bottom-left-radius: 5px; }

.msg-text { margin: 0; white-space: pre-wrap; }
.msg-text a { color: inherit; text-decoration: underline; }

.msg-photo {
  display: block;
  max-width: 100%;
  width: 230px;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
  cursor: zoom-in;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.3);
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 4px;
  font-size: 0.63rem;
  opacity: 0.75;
}
.msg-meta svg { width: 13px; height: 13px; }
.msg-status.seen { color: #9be9ff; opacity: 1; }
.msg-deleted { font-style: italic; opacity: 0.7; }

.msg-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: #1c1c22;
  color: var(--text-dim);
  display: none;
  align-items: center;
  justify-content: center;
}
.msg-delete svg { width: 13px; height: 13px; }
.msg.out:hover .msg-delete { display: inline-flex; }
.msg-delete:hover { color: #ff8a92; border-color: rgba(255, 45, 63, 0.5); }

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 18px 6px;
  font-size: 0.74rem;
  color: var(--muted);
  flex: none;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: typing 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

.emoji-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.9);
  max-height: 130px;
  overflow-y: auto;
  flex: none;
}
.emoji-bar button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.15s;
}
.emoji-bar button:hover { background: var(--surface-2); }

.composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px calc(9px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.9);
  backdrop-filter: blur(10px);
  flex: none;
}
.composer-input {
  flex: 1;
  min-width: 0;
  padding: 11px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.32);
  outline: none;
  font-size: 0.9rem;
  transition: border-color 0.18s;
}
.composer-input:focus { border-color: rgba(255, 45, 63, 0.5); }

/* ---------------------------------------------------------
   Calls
   --------------------------------------------------------- */
.call-list { display: flex; flex-direction: column; gap: 2px; }
.call-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 13px;
  transition: background 0.16s;
}
.call-item:hover { background: var(--surface-2); }
.call-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.call-item-text strong { font-size: 0.89rem; }
.call-item-text small { font-size: 0.74rem; color: var(--muted); }
.call-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.call-tag { font-size: 0.68rem; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); }
.call-tag.missed { background: rgba(255, 45, 63, 0.16); color: #ff8a92; }
.call-tag.completed { background: rgba(61, 220, 151, 0.14); color: #7cf0c4; }
.call-direction { display: inline-flex; color: var(--muted); }
.call-direction svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------
   Profile / settings
   --------------------------------------------------------- */
.profile-panel { max-width: 620px; }
.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.profile-head h2 { margin: 0 0 4px; font-size: 1.35rem; }
.profile-avatar-wrap { position: relative; }
.avatar-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 3px solid #111114;
  transition: transform 0.15s;
}
.avatar-edit:hover { transform: scale(1.08); }
.avatar-edit svg { width: 15px; height: 15px; }

.profile-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.profile-form .btn { align-self: flex-start; }

.profile-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.profile-meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  padding: 8px 0;
}
.profile-meta span { color: var(--muted); }
.profile-meta strong { font-weight: 600; }

.settings-panel { max-width: 680px; }
.settings-panel h2 { margin: 0 0 8px; font-size: 1.15rem; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.setting-row strong { font-size: 0.9rem; }
.setting-row small { color: var(--muted); font-size: 0.77rem; line-height: 1.4; }
.danger-row strong { color: #ff8a92; }

.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.2s;
  pointer-events: none;
}
.slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(19px); }

/* ---------------------------------------------------------
   Call overlays
   --------------------------------------------------------- */
.call-popup, .call-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 5, 6, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: fadeIn 0.2s ease both;
}
.call-popup-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 34px 26px 28px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(30, 30, 36, 0.97), rgba(14, 14, 17, 0.99));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.call-ripple {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.call-ripple::before,
.call-ripple::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 45, 63, 0.4);
  animation: ripple 2.4s infinite ease-out;
}
.call-ripple::after { animation-delay: 1.2s; }
.call-ripple.large::before, .call-ripple.large::after { inset: -22px; }

.call-kicker { margin: 0 0 4px; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.call-popup-card h2 { margin: 4px 0 4px; font-size: 1.4rem; }
.call-popup-actions { display: flex; justify-content: center; gap: 34px; margin-top: 26px; }

.call-screen { background: radial-gradient(700px 500px at 50% 0%, rgba(255, 45, 63, 0.16), transparent 60%), rgba(6, 6, 8, 0.96); }
.call-screen-inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.call-screen-inner h2 { margin: 18px 0 2px; font-size: 1.5rem; }
.call-status { margin: 0; color: var(--muted); font-size: 0.86rem; }
.call-timer { margin: 10px 0 0; font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: 0.06em; color: var(--text-dim); }
.call-controls { display: flex; gap: 26px; margin-top: 44px; }

.call-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s, filter 0.2s;
}
.call-btn:hover { transform: scale(1.06); background: var(--surface-3); }
.call-btn:active { transform: scale(0.95); }
.call-btn svg { width: 26px; height: 26px; }
.call-btn.accept { background: linear-gradient(135deg, #2fbf7f, #1e9a63); border-color: transparent; color: #fff; }
.call-btn.reject { background: linear-gradient(135deg, var(--accent), #c11a29); border-color: transparent; color: #fff; }
.call-btn.muted { background: #fff; color: #111; }
.call-btn.muted svg { color: #111; }

#remoteAudio { display: none; }

/* ---------------------------------------------------------
   Lightbox / toasts
   --------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.9);
  animation: fadeIn 0.18s ease both;
}
.lightbox img {
  max-width: 100%;
  max-height: 88dvh;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: var(--shadow);
}
.lightbox-close { position: absolute; top: 16px; right: 16px; background: rgba(255, 255, 255, 0.08); }

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(420px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(28, 28, 34, 0.96);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.83rem;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
  max-width: 100%;
  text-align: center;
}
.toast.error { border-color: rgba(255, 45, 63, 0.5); color: #ffb0b6; }
.toast.success { border-color: rgba(61, 220, 151, 0.4); color: #a9f5d6; }

/* ---------------------------------------------------------
   Animations
   --------------------------------------------------------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(61, 220, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}
@keyframes ripple {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------
   Responsive — tablet / desktop
   --------------------------------------------------------- */
@media (min-width: 640px) {
  .feature-cards { grid-template-columns: repeat(3, 1fr); }
  .quick-cards { grid-template-columns: repeat(3, 1fr); }
  .profile-meta { grid-template-columns: repeat(3, 1fr); }
  .home-grid { grid-template-columns: 1.15fr 1fr; }
  .view { padding: 22px 24px calc(28px + var(--safe-bottom)); }
}

@media (min-width: 900px) {
  .only-mobile { display: none !important; }
  .menu-btn, #menuBtn { display: none; }

  .sidebar {
    position: sticky;
    top: 0;
    transform: none;
    width: var(--sidebar-w);
    flex: none;
    height: 100dvh;
  }
  .scrim { display: none !important; }

  .chat-layout { grid-template-columns: 320px 1fr; }
  .chat-layout .chat-list-panel { display: flex; }
  .chat-layout .chat-panel { display: flex; }
  .chat-layout.chatting .chat-list-panel { display: flex; }

  .messages { padding: 22px 26px 12px; }
  .msg { max-width: 68%; }
  .composer { padding: 12px 22px; }

  .hero { padding: 60px 0 40px; }
  .landing { padding-left: 40px; padding-right: 40px; }
}

@media (min-width: 1180px) {
  .chat-layout { grid-template-columns: 360px 1fr; }
}

/* =========================================================
   SevenChat theme layer
   Black canvas + white cards + red accent.
   Card containers redefine the palette locally so every
   nested control keeps readable contrast automatically.
   ========================================================= */
.panel,
.feature-card,
.quick-card,
.modal-card,
.call-popup-card {
  --text: #101014;
  --text-dim: #34343b;
  --muted: #6b7280;
  --border: rgba(15, 15, 20, 0.10);
  --border-strong: rgba(15, 15, 20, 0.18);
  --surface: #ffffff;
  --surface-2: #f4f4f7;
  --surface-3: #e9e9ee;
  --accent-soft: rgba(255, 45, 63, 0.10);
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

.panel .field input,
.modal-card .field input {
  background: #f5f5f8;
  border-color: rgba(15, 15, 20, 0.14);
  color: var(--text);
}
.panel .field input:focus,
.modal-card .field input:focus {
  border-color: rgba(255, 45, 63, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 45, 63, 0.12);
}

.modal-card .tabs { background: #f1f1f5; }
.modal-card .tab.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.modal-card .form-error,
.panel .form-error { color: #d91f30; }
.modal-card .btn.danger,
.panel .btn.danger {
  color: #b51626;
  background: rgba(255, 45, 63, 0.10);
  border-color: rgba(255, 45, 63, 0.28);
}
.settings-panel .slider { background: #e2e2e8; }
.settings-panel .switch input:checked + .slider { background: var(--accent); }

.profile-note {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

/* Topbar notification bell */
.topbar-bell { position: relative; color: var(--text-dim); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* Notifications modal */
.notifications-card {
  width: min(520px, 100%);
  max-height: min(82dvh, 640px);
  display: flex;
  flex-direction: column;
}
.notifications-card h2 { margin: 0 0 14px; font-size: 1.15rem; }
.notification-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -6px;
  padding: 0 6px;
}
.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 9px;
  border-radius: 13px;
  border-bottom: 1px solid var(--border);
}
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background: var(--accent-soft); }
.notification-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.notification-icon svg { width: 17px; height: 17px; }
.notification-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notification-text strong { font-size: 0.86rem; }
.notification-text small { font-size: 0.76rem; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.notification-time { font-size: 0.66rem; color: var(--muted); flex: none; padding-top: 2px; }

.panel .call-tag.missed { color: #b51626; }
.panel .call-tag.completed { color: #1e9a63; }
.panel .btn.ghost:hover,
.modal-card .btn.ghost:hover { background: #f4f4f7; }
.panel .icon-btn:hover,
.modal-card .icon-btn:hover { background: #f4f4f7; }
