:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #eef2f7;
  --border: #dde3ea;
  --text: #17191c;
  --muted: #6f7782;
  --accent: #1f2937;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  --sidebar-w: 300px;
  --composer-offset: 210px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 16px/1.5 Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; }
body { min-height: 100vh; overflow-x: hidden; }
button, textarea, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 14px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(250,252,255,0.96), rgba(246,248,251,0.92));
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.5);
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(246,249,252,0.88));
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.07);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.sidebar-logo,
.topbar-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f6f8fb);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.sidebar-title,
.topbar-title { font-size: 16px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.sidebar-tagline,
.topbar-status { margin-top: 2px; font-size: 12px; color: var(--muted); }
.sidebar-actions,
.topbar-left { display: flex; align-items: center; gap: 8px; }
.sidebar-section {
  min-height: 0;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(248,250,253,0.82));
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}
.sidebar-section-grow { flex: 1 1 auto; }
.sidebar-search {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  color: var(--text);
  padding: 11px 13px;
  outline: none;
}
.sidebar-section-title { padding: 0 6px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.sidebar-list { display: flex; flex-direction: column; gap: 6px; }
.sidebar-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(255,255,255,0.58), rgba(248,250,253,0.48));
  border-radius: 18px;
  padding: 12px 13px;
  color: var(--text);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
  position: relative;
  overflow: hidden;
}
.sidebar-item:hover,
.sidebar-item.active {
  background: linear-gradient(180deg, #ffffff, #f9fbff);
  border-color: var(--border);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}
.sidebar-item:hover { transform: translateY(-1px); }
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #111827, #475569);
}
.sidebar-item-title { font-size: 13px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-snippet { margin-top: 5px; font-size: 12px; color: var(--text); opacity: .76; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sidebar-item-meta { margin-top: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-hit { background: rgba(250, 204, 21, 0.24); color: inherit; border-radius: 5px; padding: 0 2px; }
.sidebar-item-row { display: flex; align-items: flex-start; gap: 8px; }
.sidebar-item-copy { min-width: 0; flex: 1 1 auto; }
.sidebar-item-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .18s ease; }
.sidebar-item:hover .sidebar-item-actions,
.sidebar-item.active .sidebar-item-actions { opacity: 1; }
.sidebar-item-action {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255,255,255,0.72);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sidebar-item-action:hover { color: var(--text); background: rgba(255,255,255,0.95); }
.sidebar-item-action .icon-svg { width: 14px; height: 14px; }
.sidebar-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(248,250,253,0.5));
}

.main-shell { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar.compact {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 56px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(243,245,248,0.82);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mobile-only { display: none; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f6f8fb);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { background: linear-gradient(180deg, #ffffff, #edf2f8); transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08); }
.icon-btn:active { transform: translateY(0); }
.icon-svg {
  width: 18px;
  height: 18px;
  display: inline-block;
  background-color: currentColor;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
  mask-size: contain;
  -webkit-mask-size: contain;
}
.icon-svg[data-icon="menu"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="compose"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="logout"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="send"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 2 11 13'/%3E%3Cpath d='M22 2 15 22l-4-9-9-4Z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 2 11 13'/%3E%3Cpath d='M22 2 15 22l-4-9-9-4Z'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="star"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='m12 17.27 6.18 3.73-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='m12 17.27 6.18 3.73-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="close"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="trash"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='m19 6-1 14H6L5 6'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M8 6V4h8v2'/%3E%3Cpath d='m19 6-1 14H6L5 6'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="spark"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8Z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 3 1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8Z'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="briefcase"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='18' height='12' rx='2'/%3E%3Cpath d='M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='7' width='18' height='12' rx='2'/%3E%3Cpath d='M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="chart"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19h16'/%3E%3Cpath d='M7 16V9'/%3E%3Cpath d='M12 16V5'/%3E%3Cpath d='M17 16v-7'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19h16'/%3E%3Cpath d='M7 16V9'/%3E%3Cpath d='M12 16V5'/%3E%3Cpath d='M17 16v-7'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="shield"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 5 6v6c0 5 3.5 8 7 9 3.5-1 7-4 7-9V6z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 5 6v6c0 5 3.5 8 7 9 3.5-1 7-4 7-9V6z'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="compass"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m15.5 8.5-3.2 7.2-3.8-3.8z'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m15.5 8.5-3.2 7.2-3.8-3.8z'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="sliders"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 21v-7'/%3E%3Cpath d='M4 10V3'/%3E%3Cpath d='M12 21v-9'/%3E%3Cpath d='M12 8V3'/%3E%3Cpath d='M20 21v-4'/%3E%3Cpath d='M20 13V3'/%3E%3Cpath d='M2 14h4'/%3E%3Cpath d='M10 8h4'/%3E%3Cpath d='M18 13h4'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 21v-7'/%3E%3Cpath d='M4 10V3'/%3E%3Cpath d='M12 21v-9'/%3E%3Cpath d='M12 8V3'/%3E%3Cpath d='M20 21v-4'/%3E%3Cpath d='M20 13V3'/%3E%3Cpath d='M2 14h4'/%3E%3Cpath d='M10 8h4'/%3E%3Cpath d='M18 13h4'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="house"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="globe"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18'/%3E%3Cpath d='M12 3a15 15 0 0 1 0 18'/%3E%3Cpath d='M12 3a15 15 0 0 0 0 18'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18'/%3E%3Cpath d='M12 3a15 15 0 0 1 0 18'/%3E%3Cpath d='M12 3a15 15 0 0 0 0 18'/%3E%3C/svg%3E"); }
.icon-svg[data-icon="users"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); }
.icon-send { width: 16px; height: 16px; }

.messages {
  flex: 1;
  padding: 18px 24px calc(var(--composer-offset) + 24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}
.message { display: flex; flex-direction: column; gap: 6px; max-width: 900px; }
.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }
.message-role { font-size: 12px; color: var(--muted); padding: 0 4px; }
.message-bubble {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(251,252,254,0.98));
  box-shadow: var(--shadow);
}
.message.user .message-bubble { background: linear-gradient(180deg, #f4f7fb, #edf2f8); }
.message-text { word-break: break-word; font-size: 15px; line-height: 1.62; }
.message-text p { margin: 0; }
.message-text p + p,
.message-text p + ul,
.message-text ul + p,
.message-text ul + ul { margin-top: 10px; }
.message-text ul { margin: 0; padding-left: 20px; }
.message-text li + li { margin-top: 6px; }
.meta-block { margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-soft); color: var(--muted); border: 1px solid var(--border); }
.attachments { margin-top: 12px; display: grid; gap: 12px; }
.attachment-group { display: grid; gap: 8px; }
.attachment-group-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding-left: 2px; }
.followups-wrap {
  margin-top: 14px;
  padding-top: 2px;
}
.followups-title {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.followups { display: flex; flex-wrap: wrap; gap: 8px; }
.followup-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f7faff);
  color: var(--text);
  padding: 9px 13px;
  max-width: 100%;
  text-align: left;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.followup-chip:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #ffffff, #edf4fd);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}
.followup-chip:active { transform: translateY(0); }
.attachment-card { border: 1px solid var(--border); border-radius: 16px; padding: 12px; background: linear-gradient(180deg, #fbfcfe, #f6f9fc); }
.attachment-badge-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.attachment-badge { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: #e9eef6; color: #475569; text-transform: uppercase; letter-spacing: .06em; }
.attachment-smart-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.attachment-smart-chip { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: #475569; letter-spacing: .02em; }
.attachment-smart-chip.primary { background: #edf6ff; color: #285ea8; border-color: #cfe0f6; }
.attachment-smart-chip.followup { background: #f5f7fa; color: #5b6471; }
.attachment-smart-chip.backup { background: #f8f3ff; color: #7052a8; border-color: #e1d7f3; }
.attachment-smart-chip.proof { background: #eefbf3; color: #1f7a45; border-color: #cfead8; }
.attachment-smart-chip.objection { background: #fff4ea; color: #9a5a10; border-color: #f0d8bd; }
.attachment-smart-chip.visual { background: #eef6ff; color: #365d96; border-color: #d3e2f7; }
.attachment-smart-chip.deck { background: #f4f0ff; color: #6752a6; border-color: #ddd6f7; }
.attachment-note { margin-top: 6px; font-size: 12px; color: var(--text); opacity: .82; }
.attachment-card.image-card { padding: 10px; }
.attachment-preview { width: 100%; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #fff; margin-bottom: 10px; padding: 0; }
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment-preview.pdf-preview img { object-fit: contain; background: #f8fafc; }
.attachment-card a {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.attachment-name { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.attachment-meta { margin-top: 4px; font-size: 12px; color: var(--muted); word-break: break-word; overflow-wrap: anywhere; }
.attachment-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.attachment-open { border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--text); padding: 8px 12px; text-decoration: none; display: inline-flex; align-items: center; min-width: 0; max-width: 100%; }
.message-footer { margin-top: 10px; display: flex; justify-content: flex-end; }
.favorite-btn { width: 32px; height: 32px; }
.favorite-btn.active { background: #111827; color: #fff; border-color: #111827; }

.composer {
  position: fixed;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(243,245,248,0), rgba(243,245,248,0.88) 36%, rgba(243,245,248,1));
}
.composer-inner {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 10px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,252,255,0.98));
  box-shadow: var(--shadow);
  min-width: 0;
}
.composer-toolbar { display: flex; gap: 10px; grid-column: 1 / -1; flex-wrap: wrap; padding: 2px 2px 0; }
.scenario-chips { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; align-items: center; }
.scenario-chip {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f6f9fc);
  color: var(--text);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.scenario-chip:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08); }
.scenario-chip .icon-svg { width: 15px; height: 15px; }
.scenario-chip.active {
  background: linear-gradient(180deg, #111827, #1f2937);
  color: #fff;
  border-color: #111827;
}
.composer-select-wrap { display: grid; gap: 5px; min-width: 170px; }
.composer-select-wide { min-width: 240px; }
.composer-select-wrap span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.composer-select-wrap select {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}
.composer-switch-wrap { display: grid; gap: 5px; min-width: 186px; }
.composer-switch-wrap span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.visibility-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}
.visibility-option {
  width: 40px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.visibility-option .icon-svg { width: 15px; height: 15px; }
.visibility-option.active {
  background: linear-gradient(180deg, #111827, #1f2937);
  color: #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}
textarea { resize: none; min-height: 56px; max-height: 180px; padding: 14px 16px; border-radius: 16px; border: 1px solid transparent; background: transparent; color: var(--text); outline: none; }
textarea::placeholder,
input::placeholder { color: #9ca3af; }
.send-btn,
.login-form button { border: none; border-radius: 16px; min-width: 52px; padding: 0 16px; background: var(--accent); color: #fff; font-weight: 600; }
.typing .message-bubble { border-style: dashed; }

.auth-overlay { position: fixed; inset: 0; background: rgba(243,245,248,0.84); backdrop-filter: blur(10px); display: grid; place-items: center; z-index: 20; padding: 24px; }
.auth-card { width: min(100%, 420px); background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(248,250,253,0.98)); border: 1px solid var(--border); border-radius: 28px; padding: 28px; box-shadow: var(--shadow); text-align: center; }
.auth-logo { width: 120px; height: 120px; object-fit: contain; margin: 0 auto 18px; }
.auth-card h2 { margin: 0 0 10px; font-size: 28px; letter-spacing: -0.03em; }
.auth-tagline { margin: 0; color: var(--muted); }
.login-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 22px; }
.login-form.users-mode { grid-template-columns: 1fr; }
.login-form input { min-width: 0; border-radius: 18px; border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); padding: 15px 16px; outline: none; }
.login-error { margin-top: 12px; color: #c43d3d; }

.admin-modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; }
.admin-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.48); backdrop-filter: blur(4px); }
.admin-card { position: relative; width: min(100%, 920px); max-height: 88vh; overflow: auto; border-radius: 24px; border: 1px solid var(--border); background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,250,253,0.98)); box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18); padding: 18px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.admin-title { font-size: 20px; font-weight: 700; }
.admin-subtitle { font-size: 12px; color: var(--muted); }
.admin-user-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; margin-bottom: 14px; }
.admin-user-form input { min-width: 0; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-soft); padding: 12px 14px; }
.admin-user-form button { border: none; border-radius: 14px; background: var(--accent); color: #fff; padding: 0 16px; font-weight: 600; }
.admin-users-list { display: grid; gap: 10px; }
.admin-user-card { border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(180deg, #fff, #f8fafc); padding: 14px; }
.admin-user-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-user-name { font-weight: 700; }
.admin-user-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.admin-user-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.admin-stat { font-size: 11px; padding: 4px 8px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); border: 1px solid var(--border); }
.admin-user-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.admin-action { border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--text); padding: 8px 12px; }
.admin-action.danger { color: #9a3412; }

.media-preview { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; }
.media-preview-backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.66); backdrop-filter: blur(6px); }
.media-preview-card { position: relative; max-width: min(92vw, 1200px); max-height: 88vh; padding: 14px; border-radius: 24px; background: rgba(255,255,255,0.97); box-shadow: 0 20px 80px rgba(16, 24, 40, 0.18); }
.media-preview-image { display: block; max-width: 100%; max-height: calc(88vh - 28px); border-radius: 18px; }
.media-preview-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 1px solid rgba(255,255,255,0.7); background: rgba(17,24,39,0.72); color: #fff; border-radius: 999px; }

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 320px);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform .22s ease, box-shadow .22s ease;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 19; background: rgba(17, 24, 39, 0.24); backdrop-filter: blur(2px); opacity: 1; transition: opacity .2s ease; }
  .mobile-only { display: inline-flex; }
  .sidebar-item-actions { opacity: 1; }
  .messages { padding: 14px 14px 110px; }
  .messages { padding-bottom: calc(var(--composer-offset) + 18px + env(safe-area-inset-bottom)); }
  .composer { left: 0; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .topbar.compact { min-height: 50px; padding: 7px 10px; }
  .topbar-logo { width: 30px; height: 30px; }
  .topbar-title { font-size: 15px; }
  .topbar-status { font-size: 11px; }
}

@media (max-width: 640px) {
  .login-form,
  .composer-inner { grid-template-columns: 1fr; }
  .admin-user-form { grid-template-columns: 1fr; }
  .composer-select-wrap { min-width: 0; }
  .composer-select-wide { min-width: 0; }
  .composer-switch-wrap { min-width: 0; }
  .scenario-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .send-btn,
  .login-form button { min-height: 48px; }
  .message-bubble { padding: 14px 15px; border-radius: 18px; }
  .message-text { font-size: 14px; }
  .attachment-actions { gap: 6px; }
  .attachment-open { font-size: 13px; padding: 7px 10px; }
  .followup-chip { font-size: 13px; padding: 8px 10px; }
}

@media (hover: none) {
  .sidebar-item-actions { opacity: 1; }
}
