/* =====================================================================
   App shell layout
   ===================================================================== */

.app {
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 0;
  height: 100dvh;
  height: 100vh;
  background: var(--bg-app);
  transition: grid-template-columns var(--t-slow) var(--ease-out);
}

.shell.info-open {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--info-w);
}

/* =====================================================================
   Sidebar
   ===================================================================== */
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border);
  position: relative;
  z-index: 2;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--head-h);
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.search-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 var(--sp-3);
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.search-box:focus-within {
  background: var(--bg-surface);
  border-color: var(--brand-400);
}
.search-box svg { flex: none; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font-size: var(--fs-md);
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input::-webkit-search-cancel-button { display: none; }

.clear-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text-muted);
}
.clear-btn:hover { color: var(--text); }

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-bottom: 82px;
}

.fab {
  position: absolute;
  inset-block-end: var(--sp-5);
  inset-inline-end: var(--sp-5);
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bubble-out-solid);
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--bubble-out-solid) 42%, transparent);
  z-index: var(--z-fab);
  transition: transform var(--t-base) var(--ease-spring), box-shadow var(--t-base);
}
.fab:hover {
  transform: scale(1.06) rotate(90deg);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bubble-out-solid) 55%, transparent);
}
.fab:active { transform: scale(.96); }

/* =====================================================================
   Chat panel
   ===================================================================== */
.chat-panel {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  background-image:
    radial-gradient(circle at 18% 22%, var(--chat-pattern) 0, transparent 42%),
    radial-gradient(circle at 82% 78%, var(--chat-pattern) 0, transparent 46%);
}

.chat-placeholder {
  flex: 1;
  display: grid;
  place-items: center;
  padding: var(--sp-8);
  text-align: center;
  color: var(--text-muted);
}
.placeholder-inner { max-width: 340px; animation: slideUp var(--t-slow) var(--ease-out); }
.placeholder-art { color: var(--brand-400); opacity: .55; margin: 0 auto var(--sp-5); width: fit-content; }
.chat-placeholder h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: var(--sp-2);
}
.chat-placeholder p { font-size: var(--fs-md); line-height: var(--lh-normal); }

.chat-active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---- header ---- */
.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--head-h);
  padding: 0 var(--sp-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-sticky);
}

.back-btn { display: none; }

.chat-identity {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-md);
  text-align: start;
  transition: background var(--t-fast);
}
.chat-identity:hover { background: var(--bg-hover); }

.identity-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.identity-name {
  font-weight: 600;
  font-size: var(--fs-lg);
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.identity-sub.is-online { color: var(--brand-500); font-weight: 500; }
.identity-sub.is-typing { color: var(--success); font-weight: 500; }

.chat-head-actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }

/* ---- in-chat search ---- */
.chat-search-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  animation: slideUp var(--t-base) var(--ease-out);
}
.chat-search-bar input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 var(--sp-3);
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-size: var(--fs-md);
}
.chat-search-bar input:focus { border-color: var(--brand-400); background: var(--bg-surface); }
.chat-search-bar input::-webkit-search-cancel-button { display: none; }
.search-count {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}

/* ---- pinned banner ---- */
.pinned-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  animation: slideUp var(--t-base) var(--ease-out);
}
.pinned-icon { color: var(--brand-500); display: grid; place-items: center; flex: none; }
.pinned-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding-inline-start: var(--sp-2);
  border-inline-start: 2.5px solid var(--brand-500);
  text-align: start;
}
.pinned-label { font-size: var(--fs-xs); font-weight: 600; color: var(--brand-500); }
.pinned-text {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ---- message scroller ---- */
.message-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: var(--sp-4) var(--sp-4) var(--sp-2);
  display: flex;
  flex-direction: column;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: auto;
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
}

.load-more { display: grid; place-items: center; padding: var(--sp-4); order: -1; color: var(--text-muted); }

.scroll-bottom {
  position: absolute;
  inset-inline-end: var(--sp-5);
  inset-block-end: calc(var(--composer-min-h) + var(--sp-5));
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: var(--z-fab);
  animation: popIn var(--t-base) var(--ease-spring);
}
.scroll-bottom:hover { color: var(--brand-500); transform: translateY(-2px); }
.scroll-bottom .badge-dot {
  position: absolute;
  inset-block-start: -5px;
  inset-inline-end: -3px;
}

/* ---- typing strip ---- */
.typing-strip {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-5) var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  animation: fadeIn var(--t-fast);
}

.typing-dots { display: inline-flex; gap: 3px; align-items: flex-end; height: 12px; }
.typing-dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--brand-500);
  animation: typingBounce 1.3s var(--ease-inout) infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .16s; }
.typing-dots i:nth-child(3) { animation-delay: .32s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* =====================================================================
   Info panel
   ===================================================================== */
.info-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-inline-start: 1px solid var(--border);
  overflow: hidden;
}

.info-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: var(--head-h);
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.info-head h2 { flex: 1; font-size: var(--fs-lg); font-weight: 600; color: var(--text-strong); }

.info-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* =====================================================================
   Scrim (mobile drawers / modals)
   ===================================================================== */
.scrim {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-scrim);
  animation: fadeIn var(--t-base) var(--ease-out);
  backdrop-filter: blur(2px);
}

/* =====================================================================
   Drag & drop overlay
   ===================================================================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--brand-600) 22%, var(--bg-overlay));
  backdrop-filter: blur(3px);
  animation: fadeIn var(--t-fast);
  pointer-events: none;
}
.drop-inner {
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8) 56px;
  border: 2.5px dashed rgba(255, 255, 255, .8);
  border-radius: var(--r-xl);
  color: #fff;
  font-size: var(--fs-lg);
  font-weight: 600;
}
